documentation.d.ts 3.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static readonly Now: number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. /**
  483. * Returns client's state
  484. */
  485. readonly readyState: number;
  486. /**
  487. * Returns client's status
  488. */
  489. readonly status: number;
  490. /**
  491. * Returns client's status as a text
  492. */
  493. readonly statusText: string;
  494. /**
  495. * Returns client's response
  496. */
  497. readonly response: any;
  498. /**
  499. * Returns client's response url
  500. */
  501. readonly responseURL: string;
  502. /**
  503. * Returns client's response as text
  504. */
  505. readonly responseText: string;
  506. /**
  507. * Gets or sets the expected response type
  508. */
  509. responseType: XMLHttpRequestResponseType;
  510. /** @hidden */
  511. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  512. /** @hidden */
  513. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  514. /**
  515. * Cancels any network activity
  516. */
  517. abort(): void;
  518. /**
  519. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  520. * @param body defines an optional request body
  521. */
  522. send(body?: Document | BodyInit | null): void;
  523. /**
  524. * Sets the request method, request URL
  525. * @param method defines the method to use (GET, POST, etc..)
  526. * @param url defines the url to connect with
  527. */
  528. open(method: string, url: string): void;
  529. /**
  530. * Sets the value of a request header.
  531. * @param name The name of the header whose value is to be set
  532. * @param value The value to set as the body of the header
  533. */
  534. setRequestHeader(name: string, value: string): void;
  535. /**
  536. * Get the string containing the text of a particular header's value.
  537. * @param name The name of the header
  538. * @returns The string containing the text of the given header name
  539. */
  540. getResponseHeader(name: string): Nullable<string>;
  541. }
  542. }
  543. declare module BABYLON {
  544. /**
  545. * File request interface
  546. */
  547. export interface IFileRequest {
  548. /**
  549. * Raised when the request is complete (success or error).
  550. */
  551. onCompleteObservable: Observable<IFileRequest>;
  552. /**
  553. * Aborts the request for a file.
  554. */
  555. abort: () => void;
  556. }
  557. }
  558. declare module BABYLON {
  559. /**
  560. * Define options used to create a render target texture
  561. */
  562. export class RenderTargetCreationOptions {
  563. /**
  564. * Specifies is mipmaps must be generated
  565. */
  566. generateMipMaps?: boolean;
  567. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  568. generateDepthBuffer?: boolean;
  569. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  570. generateStencilBuffer?: boolean;
  571. /** Defines texture type (int by default) */
  572. type?: number;
  573. /** Defines sampling mode (trilinear by default) */
  574. samplingMode?: number;
  575. /** Defines format (RGBA by default) */
  576. format?: number;
  577. }
  578. }
  579. declare module BABYLON {
  580. /**
  581. * @hidden
  582. **/
  583. export class _TimeToken {
  584. _startTimeQuery: Nullable<WebGLQuery>;
  585. _endTimeQuery: Nullable<WebGLQuery>;
  586. _timeElapsedQuery: Nullable<WebGLQuery>;
  587. _timeElapsedQueryEnded: boolean;
  588. }
  589. }
  590. declare module BABYLON {
  591. /** Defines the cross module used constants to avoid circular dependncies */
  592. export class Constants {
  593. /** Defines that alpha blending is disabled */
  594. static readonly ALPHA_DISABLE: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  596. static readonly ALPHA_ADD: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  598. static readonly ALPHA_COMBINE: number;
  599. /** Defines that alpha blending is DEST - SRC * DEST */
  600. static readonly ALPHA_SUBTRACT: number;
  601. /** Defines that alpha blending is SRC * DEST */
  602. static readonly ALPHA_MULTIPLY: number;
  603. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  604. static readonly ALPHA_MAXIMIZED: number;
  605. /** Defines that alpha blending is SRC + DEST */
  606. static readonly ALPHA_ONEONE: number;
  607. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  608. static readonly ALPHA_PREMULTIPLIED: number;
  609. /**
  610. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  611. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  612. */
  613. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  614. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  615. static readonly ALPHA_INTERPOLATE: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  618. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_SCREENMODE: number;
  621. /**
  622. * Defines that alpha blending is SRC + DST
  623. * Alpha will be set to SRC ALPHA + DST ALPHA
  624. */
  625. static readonly ALPHA_ONEONE_ONEONE: number;
  626. /**
  627. * Defines that alpha blending is SRC * DST ALPHA + DST
  628. * Alpha will be set to 0
  629. */
  630. static readonly ALPHA_ALPHATOCOLOR: number;
  631. /**
  632. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  633. */
  634. static readonly ALPHA_REVERSEONEMINUS: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  637. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  638. */
  639. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  640. /**
  641. * Defines that alpha blending is SRC + DST
  642. * Alpha will be set to SRC ALPHA
  643. */
  644. static readonly ALPHA_ONEONE_ONEZERO: number;
  645. /**
  646. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  647. * Alpha will be set to DST ALPHA
  648. */
  649. static readonly ALPHA_EXCLUSION: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** 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 */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** 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 */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** 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 */
  686. static readonly GEQUAL: number;
  687. /** 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 */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = nearest */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * 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.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module BABYLON {
  1044. /**
  1045. * This represents the required contract to create a new type of texture loader.
  1046. */
  1047. export interface IInternalTextureLoader {
  1048. /**
  1049. * Defines wether the loader supports cascade loading the different faces.
  1050. */
  1051. supportCascades: boolean;
  1052. /**
  1053. * This returns if the loader support the current file information.
  1054. * @param extension defines the file extension of the file being loaded
  1055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1056. * @param fallback defines the fallback internal texture if any
  1057. * @param isBase64 defines whether the texture is encoded as a base64
  1058. * @param isBuffer defines whether the texture data are stored as a buffer
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1062. /**
  1063. * Transform the url before loading if required.
  1064. * @param rootUrl the url of the texture
  1065. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1066. * @returns the transformed texture
  1067. */
  1068. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1069. /**
  1070. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1071. * @param rootUrl the url of the texture
  1072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1073. * @returns the fallback texture
  1074. */
  1075. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1076. /**
  1077. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param createPolynomials will be true if polynomials have been requested
  1081. * @param onLoad defines the callback to trigger once the texture is ready
  1082. * @param onError defines the callback to trigger in case of error
  1083. */
  1084. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1085. /**
  1086. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param callback defines the method to call once ready to upload
  1090. */
  1091. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1092. }
  1093. }
  1094. declare module BABYLON {
  1095. /**
  1096. * Class used to store and describe the pipeline context associated with an effect
  1097. */
  1098. export interface IPipelineContext {
  1099. /**
  1100. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1101. */
  1102. isAsync: boolean;
  1103. /**
  1104. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1105. */
  1106. isReady: boolean;
  1107. /** @hidden */
  1108. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1109. }
  1110. }
  1111. declare module BABYLON {
  1112. /**
  1113. * Class used to store gfx data (like WebGLBuffer)
  1114. */
  1115. export class DataBuffer {
  1116. /**
  1117. * Gets or sets the number of objects referencing this buffer
  1118. */
  1119. references: number;
  1120. /** Gets or sets the size of the underlying buffer */
  1121. capacity: number;
  1122. /**
  1123. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1124. */
  1125. is32Bits: boolean;
  1126. /**
  1127. * Gets the underlying buffer
  1128. */
  1129. readonly underlyingResource: any;
  1130. }
  1131. }
  1132. declare module BABYLON {
  1133. /** @hidden */
  1134. export interface IShaderProcessor {
  1135. attributeProcessor?: (attribute: string) => string;
  1136. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1137. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1138. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1139. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1140. lineProcessor?: (line: string, isFragment: boolean) => string;
  1141. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1142. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1143. }
  1144. }
  1145. declare module BABYLON {
  1146. /** @hidden */
  1147. export interface ProcessingOptions {
  1148. defines: string[];
  1149. indexParameters: any;
  1150. isFragment: boolean;
  1151. shouldUseHighPrecisionShader: boolean;
  1152. supportsUniformBuffers: boolean;
  1153. shadersRepository: string;
  1154. includesShadersStore: {
  1155. [key: string]: string;
  1156. };
  1157. processor?: IShaderProcessor;
  1158. version: string;
  1159. platformName: string;
  1160. lookForClosingBracketForUniformBuffer?: boolean;
  1161. }
  1162. }
  1163. declare module BABYLON {
  1164. /** @hidden */
  1165. export class ShaderCodeNode {
  1166. line: string;
  1167. children: ShaderCodeNode[];
  1168. additionalDefineKey?: string;
  1169. additionalDefineValue?: string;
  1170. isValid(preprocessors: {
  1171. [key: string]: string;
  1172. }): boolean;
  1173. process(preprocessors: {
  1174. [key: string]: string;
  1175. }, options: ProcessingOptions): string;
  1176. }
  1177. }
  1178. declare module BABYLON {
  1179. /** @hidden */
  1180. export class ShaderCodeCursor {
  1181. private _lines;
  1182. lineIndex: number;
  1183. readonly currentLine: string;
  1184. readonly canRead: boolean;
  1185. lines: string[];
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1191. process(preprocessors: {
  1192. [key: string]: string;
  1193. }, options: ProcessingOptions): string;
  1194. }
  1195. }
  1196. declare module BABYLON {
  1197. /** @hidden */
  1198. export class ShaderDefineExpression {
  1199. isTrue(preprocessors: {
  1200. [key: string]: string;
  1201. }): boolean;
  1202. }
  1203. }
  1204. declare module BABYLON {
  1205. /** @hidden */
  1206. export class ShaderCodeTestNode extends ShaderCodeNode {
  1207. testExpression: ShaderDefineExpression;
  1208. isValid(preprocessors: {
  1209. [key: string]: string;
  1210. }): boolean;
  1211. }
  1212. }
  1213. declare module BABYLON {
  1214. /** @hidden */
  1215. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1216. define: string;
  1217. not: boolean;
  1218. constructor(define: string, not?: boolean);
  1219. isTrue(preprocessors: {
  1220. [key: string]: string;
  1221. }): boolean;
  1222. }
  1223. }
  1224. declare module BABYLON {
  1225. /** @hidden */
  1226. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1227. leftOperand: ShaderDefineExpression;
  1228. rightOperand: ShaderDefineExpression;
  1229. isTrue(preprocessors: {
  1230. [key: string]: string;
  1231. }): boolean;
  1232. }
  1233. }
  1234. declare module BABYLON {
  1235. /** @hidden */
  1236. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module BABYLON {
  1245. /** @hidden */
  1246. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. operand: string;
  1249. testValue: string;
  1250. constructor(define: string, operand: string, testValue: string);
  1251. isTrue(preprocessors: {
  1252. [key: string]: string;
  1253. }): boolean;
  1254. }
  1255. }
  1256. declare module BABYLON {
  1257. /**
  1258. * Class used to enable access to offline support
  1259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1260. */
  1261. export interface IOfflineProvider {
  1262. /**
  1263. * Gets a boolean indicating if scene must be saved in the database
  1264. */
  1265. enableSceneOffline: boolean;
  1266. /**
  1267. * Gets a boolean indicating if textures must be saved in the database
  1268. */
  1269. enableTexturesOffline: boolean;
  1270. /**
  1271. * Open the offline support and make it available
  1272. * @param successCallback defines the callback to call on success
  1273. * @param errorCallback defines the callback to call on error
  1274. */
  1275. open(successCallback: () => void, errorCallback: () => void): void;
  1276. /**
  1277. * Loads an image from the offline support
  1278. * @param url defines the url to load from
  1279. * @param image defines the target DOM image
  1280. */
  1281. loadImage(url: string, image: HTMLImageElement): void;
  1282. /**
  1283. * Loads a file from offline support
  1284. * @param url defines the URL to load from
  1285. * @param sceneLoaded defines a callback to call on success
  1286. * @param progressCallBack defines a callback to call when progress changed
  1287. * @param errorCallback defines a callback to call on error
  1288. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1289. */
  1290. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /**
  1295. * Class used to help managing file picking and drag'n'drop
  1296. * File Storage
  1297. */
  1298. export class FilesInputStore {
  1299. /**
  1300. * List of files ready to be loaded
  1301. */
  1302. static FilesToLoad: {
  1303. [key: string]: File;
  1304. };
  1305. }
  1306. }
  1307. declare module BABYLON {
  1308. /**
  1309. * Class used to define a retry strategy when error happens while loading assets
  1310. */
  1311. export class RetryStrategy {
  1312. /**
  1313. * Function used to defines an exponential back off strategy
  1314. * @param maxRetries defines the maximum number of retries (3 by default)
  1315. * @param baseInterval defines the interval between retries
  1316. * @returns the strategy function to use
  1317. */
  1318. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1319. }
  1320. }
  1321. declare module BABYLON {
  1322. /**
  1323. * @ignore
  1324. * Application error to support additional information when loading a file
  1325. */
  1326. export abstract class BaseError extends Error {
  1327. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1328. }
  1329. }
  1330. declare module BABYLON {
  1331. /** @ignore */
  1332. export class LoadFileError extends BaseError {
  1333. request?: WebRequest;
  1334. file?: File;
  1335. /**
  1336. * Creates a new LoadFileError
  1337. * @param message defines the message of the error
  1338. * @param request defines the optional web request
  1339. * @param file defines the optional file
  1340. */
  1341. constructor(message: string, object?: WebRequest | File);
  1342. }
  1343. /** @ignore */
  1344. export class RequestFileError extends BaseError {
  1345. request: WebRequest;
  1346. /**
  1347. * Creates a new LoadFileError
  1348. * @param message defines the message of the error
  1349. * @param request defines the optional web request
  1350. */
  1351. constructor(message: string, request: WebRequest);
  1352. }
  1353. /** @ignore */
  1354. export class ReadFileError extends BaseError {
  1355. file: File;
  1356. /**
  1357. * Creates a new ReadFileError
  1358. * @param message defines the message of the error
  1359. * @param file defines the optional file
  1360. */
  1361. constructor(message: string, file: File);
  1362. }
  1363. /**
  1364. * @hidden
  1365. */
  1366. export class FileTools {
  1367. /**
  1368. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1369. */
  1370. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1371. /**
  1372. * Gets or sets the base URL to use to load assets
  1373. */
  1374. static BaseUrl: string;
  1375. /**
  1376. * Default behaviour for cors in the application.
  1377. * It can be a string if the expected behavior is identical in the entire app.
  1378. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1379. */
  1380. static CorsBehavior: string | ((url: string | string[]) => string);
  1381. /**
  1382. * Gets or sets a function used to pre-process url before using them to load assets
  1383. */
  1384. static PreprocessUrl: (url: string) => string;
  1385. /**
  1386. * Removes unwanted characters from an url
  1387. * @param url defines the url to clean
  1388. * @returns the cleaned url
  1389. */
  1390. private static _CleanUrl;
  1391. /**
  1392. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1393. * @param url define the url we are trying
  1394. * @param element define the dom element where to configure the cors policy
  1395. */
  1396. static SetCorsBehavior(url: string | string[], element: {
  1397. crossOrigin: string | null;
  1398. }): void;
  1399. /**
  1400. * Loads an image as an HTMLImageElement.
  1401. * @param input url string, ArrayBuffer, or Blob to load
  1402. * @param onLoad callback called when the image successfully loads
  1403. * @param onError callback called when the image fails to load
  1404. * @param offlineProvider offline provider for caching
  1405. * @param mimeType optional mime type
  1406. * @returns the HTMLImageElement of the loaded image
  1407. */
  1408. 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>;
  1409. /**
  1410. * Reads a file from a File object
  1411. * @param file defines the file to load
  1412. * @param onSuccess defines the callback to call when data is loaded
  1413. * @param onProgress defines the callback to call during loading process
  1414. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1415. * @param onError defines the callback to call when an error occurs
  1416. * @returns a file request object
  1417. */
  1418. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1419. /**
  1420. * Loads a file from a url
  1421. * @param url url to load
  1422. * @param onSuccess callback called when the file successfully loads
  1423. * @param onProgress callback called while file is loading (if the server supports this mode)
  1424. * @param offlineProvider defines the offline provider for caching
  1425. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1426. * @param onError callback called when the file fails to load
  1427. * @returns a file request object
  1428. */
  1429. 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;
  1430. /**
  1431. * Loads a file
  1432. * @param url url to load
  1433. * @param onSuccess callback called when the file successfully loads
  1434. * @param onProgress callback called while file is loading (if the server supports this mode)
  1435. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1436. * @param onError callback called when the file fails to load
  1437. * @param onOpened callback called when the web request is opened
  1438. * @returns a file request object
  1439. */
  1440. 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;
  1441. /**
  1442. * Checks if the loaded document was accessed via `file:`-Protocol.
  1443. * @returns boolean
  1444. */
  1445. static IsFileURL(): boolean;
  1446. }
  1447. }
  1448. declare module BABYLON {
  1449. /** @hidden */
  1450. export class ShaderProcessor {
  1451. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1452. private static _ProcessPrecision;
  1453. private static _ExtractOperation;
  1454. private static _BuildSubExpression;
  1455. private static _BuildExpression;
  1456. private static _MoveCursorWithinIf;
  1457. private static _MoveCursor;
  1458. private static _EvaluatePreProcessors;
  1459. private static _PreparePreProcessors;
  1460. private static _ProcessShaderConversion;
  1461. private static _ProcessIncludes;
  1462. }
  1463. }
  1464. declare module BABYLON {
  1465. /**
  1466. * @hidden
  1467. */
  1468. export interface IColor4Like {
  1469. r: float;
  1470. g: float;
  1471. b: float;
  1472. a: float;
  1473. }
  1474. /**
  1475. * @hidden
  1476. */
  1477. export interface IColor3Like {
  1478. r: float;
  1479. g: float;
  1480. b: float;
  1481. }
  1482. /**
  1483. * @hidden
  1484. */
  1485. export interface IVector4Like {
  1486. x: float;
  1487. y: float;
  1488. z: float;
  1489. w: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IVector3Like {
  1495. x: float;
  1496. y: float;
  1497. z: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IVector2Like {
  1503. x: float;
  1504. y: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IMatrixLike {
  1510. toArray(): DeepImmutable<Float32Array>;
  1511. updateFlag: int;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IViewportLike {
  1517. x: float;
  1518. y: float;
  1519. width: float;
  1520. height: float;
  1521. }
  1522. /**
  1523. * @hidden
  1524. */
  1525. export interface IPlaneLike {
  1526. normal: IVector3Like;
  1527. d: float;
  1528. normalize(): void;
  1529. }
  1530. }
  1531. declare module BABYLON {
  1532. /**
  1533. * Interface used to define common properties for effect fallbacks
  1534. */
  1535. export interface IEffectFallbacks {
  1536. /**
  1537. * Removes the defines that should be removed when falling back.
  1538. * @param currentDefines defines the current define statements for the shader.
  1539. * @param effect defines the current effect we try to compile
  1540. * @returns The resulting defines with defines of the current rank removed.
  1541. */
  1542. reduce(currentDefines: string, effect: Effect): string;
  1543. /**
  1544. * Removes the fallback from the bound mesh.
  1545. */
  1546. unBindMesh(): void;
  1547. /**
  1548. * Checks to see if more fallbacks are still availible.
  1549. */
  1550. hasMoreFallbacks: boolean;
  1551. }
  1552. }
  1553. declare module BABYLON {
  1554. /**
  1555. * Class used to evalaute queries containing `and` and `or` operators
  1556. */
  1557. export class AndOrNotEvaluator {
  1558. /**
  1559. * Evaluate a query
  1560. * @param query defines the query to evaluate
  1561. * @param evaluateCallback defines the callback used to filter result
  1562. * @returns true if the query matches
  1563. */
  1564. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1565. private static _HandleParenthesisContent;
  1566. private static _SimplifyNegation;
  1567. }
  1568. }
  1569. declare module BABYLON {
  1570. /**
  1571. * Class used to store custom tags
  1572. */
  1573. export class Tags {
  1574. /**
  1575. * Adds support for tags on the given object
  1576. * @param obj defines the object to use
  1577. */
  1578. static EnableFor(obj: any): void;
  1579. /**
  1580. * Removes tags support
  1581. * @param obj defines the object to use
  1582. */
  1583. static DisableFor(obj: any): void;
  1584. /**
  1585. * Gets a boolean indicating if the given object has tags
  1586. * @param obj defines the object to use
  1587. * @returns a boolean
  1588. */
  1589. static HasTags(obj: any): boolean;
  1590. /**
  1591. * Gets the tags available on a given object
  1592. * @param obj defines the object to use
  1593. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1594. * @returns the tags
  1595. */
  1596. static GetTags(obj: any, asString?: boolean): any;
  1597. /**
  1598. * Adds tags to an object
  1599. * @param obj defines the object to use
  1600. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1601. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1602. */
  1603. static AddTagsTo(obj: any, tagsString: string): void;
  1604. /**
  1605. * @hidden
  1606. */
  1607. static _AddTagTo(obj: any, tag: string): void;
  1608. /**
  1609. * Removes specific tags from a specific object
  1610. * @param obj defines the object to use
  1611. * @param tagsString defines the tags to remove
  1612. */
  1613. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1614. /**
  1615. * @hidden
  1616. */
  1617. static _RemoveTagFrom(obj: any, tag: string): void;
  1618. /**
  1619. * Defines if tags hosted on an object match a given query
  1620. * @param obj defines the object to use
  1621. * @param tagsQuery defines the tag query
  1622. * @returns a boolean
  1623. */
  1624. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1625. }
  1626. }
  1627. declare module BABYLON {
  1628. /**
  1629. * Scalar computation library
  1630. */
  1631. export class Scalar {
  1632. /**
  1633. * Two pi constants convenient for computation.
  1634. */
  1635. static TwoPi: number;
  1636. /**
  1637. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. * @param a number
  1639. * @param b number
  1640. * @param epsilon (default = 1.401298E-45)
  1641. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1642. */
  1643. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1644. /**
  1645. * Returns a string : the upper case translation of the number i to hexadecimal.
  1646. * @param i number
  1647. * @returns the upper case translation of the number i to hexadecimal.
  1648. */
  1649. static ToHex(i: number): string;
  1650. /**
  1651. * Returns -1 if value is negative and +1 is value is positive.
  1652. * @param value the value
  1653. * @returns the value itself if it's equal to zero.
  1654. */
  1655. static Sign(value: number): number;
  1656. /**
  1657. * Returns the value itself if it's between min and max.
  1658. * Returns min if the value is lower than min.
  1659. * Returns max if the value is greater than max.
  1660. * @param value the value to clmap
  1661. * @param min the min value to clamp to (default: 0)
  1662. * @param max the max value to clamp to (default: 1)
  1663. * @returns the clamped value
  1664. */
  1665. static Clamp(value: number, min?: number, max?: number): number;
  1666. /**
  1667. * the log2 of value.
  1668. * @param value the value to compute log2 of
  1669. * @returns the log2 of value.
  1670. */
  1671. static Log2(value: number): number;
  1672. /**
  1673. * Loops the value, so that it is never larger than length and never smaller than 0.
  1674. *
  1675. * This is similar to the modulo operator but it works with floating point numbers.
  1676. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1677. * With t = 5 and length = 2.5, the result would be 0.0.
  1678. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1679. * @param value the value
  1680. * @param length the length
  1681. * @returns the looped value
  1682. */
  1683. static Repeat(value: number, length: number): number;
  1684. /**
  1685. * Normalize the value between 0.0 and 1.0 using min and max values
  1686. * @param value value to normalize
  1687. * @param min max to normalize between
  1688. * @param max min to normalize between
  1689. * @returns the normalized value
  1690. */
  1691. static Normalize(value: number, min: number, max: number): number;
  1692. /**
  1693. * Denormalize the value from 0.0 and 1.0 using min and max values
  1694. * @param normalized value to denormalize
  1695. * @param min max to denormalize between
  1696. * @param max min to denormalize between
  1697. * @returns the denormalized value
  1698. */
  1699. static Denormalize(normalized: number, min: number, max: number): number;
  1700. /**
  1701. * Calculates the shortest difference between two given angles given in degrees.
  1702. * @param current current angle in degrees
  1703. * @param target target angle in degrees
  1704. * @returns the delta
  1705. */
  1706. static DeltaAngle(current: number, target: number): number;
  1707. /**
  1708. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1709. * @param tx value
  1710. * @param length length
  1711. * @returns The returned value will move back and forth between 0 and length
  1712. */
  1713. static PingPong(tx: number, length: number): number;
  1714. /**
  1715. * Interpolates between min and max with smoothing at the limits.
  1716. *
  1717. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1718. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1719. * @param from from
  1720. * @param to to
  1721. * @param tx value
  1722. * @returns the smooth stepped value
  1723. */
  1724. static SmoothStep(from: number, to: number, tx: number): number;
  1725. /**
  1726. * Moves a value current towards target.
  1727. *
  1728. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1729. * Negative values of maxDelta pushes the value away from target.
  1730. * @param current current value
  1731. * @param target target value
  1732. * @param maxDelta max distance to move
  1733. * @returns resulting value
  1734. */
  1735. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1736. /**
  1737. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1738. *
  1739. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1740. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1741. * @param current current value
  1742. * @param target target value
  1743. * @param maxDelta max distance to move
  1744. * @returns resulting angle
  1745. */
  1746. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1747. /**
  1748. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1749. * @param start start value
  1750. * @param end target value
  1751. * @param amount amount to lerp between
  1752. * @returns the lerped value
  1753. */
  1754. static Lerp(start: number, end: number, amount: number): number;
  1755. /**
  1756. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1757. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1758. * @param start start value
  1759. * @param end target value
  1760. * @param amount amount to lerp between
  1761. * @returns the lerped value
  1762. */
  1763. static LerpAngle(start: number, end: number, amount: number): number;
  1764. /**
  1765. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1766. * @param a start value
  1767. * @param b target value
  1768. * @param value value between a and b
  1769. * @returns the inverseLerp value
  1770. */
  1771. static InverseLerp(a: number, b: number, value: number): number;
  1772. /**
  1773. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1774. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1775. * @param value1 spline value
  1776. * @param tangent1 spline value
  1777. * @param value2 spline value
  1778. * @param tangent2 spline value
  1779. * @param amount input value
  1780. * @returns hermite result
  1781. */
  1782. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1783. /**
  1784. * Returns a random float number between and min and max values
  1785. * @param min min value of random
  1786. * @param max max value of random
  1787. * @returns random value
  1788. */
  1789. static RandomRange(min: number, max: number): number;
  1790. /**
  1791. * This function returns percentage of a number in a given range.
  1792. *
  1793. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1794. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1795. * @param number to convert to percentage
  1796. * @param min min range
  1797. * @param max max range
  1798. * @returns the percentage
  1799. */
  1800. static RangeToPercent(number: number, min: number, max: number): number;
  1801. /**
  1802. * This function returns number that corresponds to the percentage in a given range.
  1803. *
  1804. * PercentToRange(0.34,0,100) will return 34.
  1805. * @param percent to convert to number
  1806. * @param min min range
  1807. * @param max max range
  1808. * @returns the number
  1809. */
  1810. static PercentToRange(percent: number, min: number, max: number): number;
  1811. /**
  1812. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1813. * @param angle The angle to normalize in radian.
  1814. * @return The converted angle.
  1815. */
  1816. static NormalizeRadians(angle: number): number;
  1817. }
  1818. }
  1819. declare module BABYLON {
  1820. /**
  1821. * Constant used to convert a value to gamma space
  1822. * @ignorenaming
  1823. */
  1824. export const ToGammaSpace: number;
  1825. /**
  1826. * Constant used to convert a value to linear space
  1827. * @ignorenaming
  1828. */
  1829. export const ToLinearSpace = 2.2;
  1830. /**
  1831. * Constant used to define the minimal number value in Babylon.js
  1832. * @ignorenaming
  1833. */
  1834. let Epsilon: number;
  1835. }
  1836. declare module BABYLON {
  1837. /**
  1838. * Class used to represent a viewport on screen
  1839. */
  1840. export class Viewport {
  1841. /** viewport left coordinate */
  1842. x: number;
  1843. /** viewport top coordinate */
  1844. y: number;
  1845. /**viewport width */
  1846. width: number;
  1847. /** viewport height */
  1848. height: number;
  1849. /**
  1850. * Creates a Viewport object located at (x, y) and sized (width, height)
  1851. * @param x defines viewport left coordinate
  1852. * @param y defines viewport top coordinate
  1853. * @param width defines the viewport width
  1854. * @param height defines the viewport height
  1855. */
  1856. constructor(
  1857. /** viewport left coordinate */
  1858. x: number,
  1859. /** viewport top coordinate */
  1860. y: number,
  1861. /**viewport width */
  1862. width: number,
  1863. /** viewport height */
  1864. height: number);
  1865. /**
  1866. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1867. * @param renderWidth defines the rendering width
  1868. * @param renderHeight defines the rendering height
  1869. * @returns a new Viewport
  1870. */
  1871. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1872. /**
  1873. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1874. * @param renderWidth defines the rendering width
  1875. * @param renderHeight defines the rendering height
  1876. * @param ref defines the target viewport
  1877. * @returns the current viewport
  1878. */
  1879. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1880. /**
  1881. * Returns a new Viewport copied from the current one
  1882. * @returns a new Viewport
  1883. */
  1884. clone(): Viewport;
  1885. }
  1886. }
  1887. declare module BABYLON {
  1888. /**
  1889. * Class containing a set of static utilities functions for arrays.
  1890. */
  1891. export class ArrayTools {
  1892. /**
  1893. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1894. * @param size the number of element to construct and put in the array
  1895. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1896. * @returns a new array filled with new objects
  1897. */
  1898. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class representing a vector containing 2 coordinates
  1904. */
  1905. export class Vector2 {
  1906. /** defines the first coordinate */
  1907. x: number;
  1908. /** defines the second coordinate */
  1909. y: number;
  1910. /**
  1911. * Creates a new Vector2 from the given x and y coordinates
  1912. * @param x defines the first coordinate
  1913. * @param y defines the second coordinate
  1914. */
  1915. constructor(
  1916. /** defines the first coordinate */
  1917. x?: number,
  1918. /** defines the second coordinate */
  1919. y?: number);
  1920. /**
  1921. * Gets a string with the Vector2 coordinates
  1922. * @returns a string with the Vector2 coordinates
  1923. */
  1924. toString(): string;
  1925. /**
  1926. * Gets class name
  1927. * @returns the string "Vector2"
  1928. */
  1929. getClassName(): string;
  1930. /**
  1931. * Gets current vector hash code
  1932. * @returns the Vector2 hash code as a number
  1933. */
  1934. getHashCode(): number;
  1935. /**
  1936. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1937. * @param array defines the source array
  1938. * @param index defines the offset in source array
  1939. * @returns the current Vector2
  1940. */
  1941. toArray(array: FloatArray, index?: number): Vector2;
  1942. /**
  1943. * Copy the current vector to an array
  1944. * @returns a new array with 2 elements: the Vector2 coordinates.
  1945. */
  1946. asArray(): number[];
  1947. /**
  1948. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1949. * @param source defines the source Vector2
  1950. * @returns the current updated Vector2
  1951. */
  1952. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1953. /**
  1954. * Sets the Vector2 coordinates with the given floats
  1955. * @param x defines the first coordinate
  1956. * @param y defines the second coordinate
  1957. * @returns the current updated Vector2
  1958. */
  1959. copyFromFloats(x: number, y: number): Vector2;
  1960. /**
  1961. * Sets the Vector2 coordinates with the given floats
  1962. * @param x defines the first coordinate
  1963. * @param y defines the second coordinate
  1964. * @returns the current updated Vector2
  1965. */
  1966. set(x: number, y: number): Vector2;
  1967. /**
  1968. * Add another vector with the current one
  1969. * @param otherVector defines the other vector
  1970. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1971. */
  1972. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1973. /**
  1974. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1975. * @param otherVector defines the other vector
  1976. * @param result defines the target vector
  1977. * @returns the unmodified current Vector2
  1978. */
  1979. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1980. /**
  1981. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1982. * @param otherVector defines the other vector
  1983. * @returns the current updated Vector2
  1984. */
  1985. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1988. * @param otherVector defines the other vector
  1989. * @returns a new Vector2
  1990. */
  1991. addVector3(otherVector: Vector3): Vector2;
  1992. /**
  1993. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2
  1996. */
  1997. subtract(otherVector: Vector2): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Multiplies in place the current Vector2 coordinates by the given ones
  2013. * @param otherVector defines the other vector
  2014. * @returns the current updated Vector2
  2015. */
  2016. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2017. /**
  2018. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2023. /**
  2024. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2032. * @param x defines the first coordinate
  2033. * @param y defines the second coordinate
  2034. * @returns a new Vector2
  2035. */
  2036. multiplyByFloats(x: number, y: number): Vector2;
  2037. /**
  2038. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @returns a new Vector2
  2041. */
  2042. divide(otherVector: Vector2): Vector2;
  2043. /**
  2044. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2045. * @param otherVector defines the other vector
  2046. * @param result defines the target vector
  2047. * @returns the unmodified current Vector2
  2048. */
  2049. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2050. /**
  2051. * Divides the current Vector2 coordinates by the given ones
  2052. * @param otherVector defines the other vector
  2053. * @returns the current updated Vector2
  2054. */
  2055. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2056. /**
  2057. * Gets a new Vector2 with current Vector2 negated coordinates
  2058. * @returns a new Vector2
  2059. */
  2060. negate(): Vector2;
  2061. /**
  2062. * Multiply the Vector2 coordinates by scale
  2063. * @param scale defines the scaling factor
  2064. * @returns the current updated Vector2
  2065. */
  2066. scaleInPlace(scale: number): Vector2;
  2067. /**
  2068. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2069. * @param scale defines the scaling factor
  2070. * @returns a new Vector2
  2071. */
  2072. scale(scale: number): Vector2;
  2073. /**
  2074. * Scale the current Vector2 values by a factor to a given Vector2
  2075. * @param scale defines the scale factor
  2076. * @param result defines the Vector2 object where to store the result
  2077. * @returns the unmodified current Vector2
  2078. */
  2079. scaleToRef(scale: number, result: Vector2): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Gets a boolean if two vectors are equals
  2089. * @param otherVector defines the other vector
  2090. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2091. */
  2092. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2093. /**
  2094. * Gets a boolean if two vectors are equals (using an epsilon value)
  2095. * @param otherVector defines the other vector
  2096. * @param epsilon defines the minimal distance to consider equality
  2097. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2098. */
  2099. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. floor(): Vector2;
  2105. /**
  2106. * Gets a new Vector2 from current Vector2 floored values
  2107. * @returns a new Vector2
  2108. */
  2109. fract(): Vector2;
  2110. /**
  2111. * Gets the length of the vector
  2112. * @returns the vector length (float)
  2113. */
  2114. length(): number;
  2115. /**
  2116. * Gets the vector squared length
  2117. * @returns the vector squared length (float)
  2118. */
  2119. lengthSquared(): number;
  2120. /**
  2121. * Normalize the vector
  2122. * @returns the current updated Vector2
  2123. */
  2124. normalize(): Vector2;
  2125. /**
  2126. * Gets a new Vector2 copied from the Vector2
  2127. * @returns a new Vector2
  2128. */
  2129. clone(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(0, 0)
  2132. * @returns a new Vector2
  2133. */
  2134. static Zero(): Vector2;
  2135. /**
  2136. * Gets a new Vector2(1, 1)
  2137. * @returns a new Vector2
  2138. */
  2139. static One(): Vector2;
  2140. /**
  2141. * Gets a new Vector2 set from the given index element of the given array
  2142. * @param array defines the data source
  2143. * @param offset defines the offset in the data source
  2144. * @returns a new Vector2
  2145. */
  2146. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2147. /**
  2148. * Sets "result" from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @param result defines the target vector
  2152. */
  2153. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2154. /**
  2155. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2156. * @param value1 defines 1st point of control
  2157. * @param value2 defines 2nd point of control
  2158. * @param value3 defines 3rd point of control
  2159. * @param value4 defines 4th point of control
  2160. * @param amount defines the interpolation factor
  2161. * @returns a new Vector2
  2162. */
  2163. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2164. /**
  2165. * 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".
  2166. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2167. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2168. * @param value defines the value to clamp
  2169. * @param min defines the lower limit
  2170. * @param max defines the upper limit
  2171. * @returns a new Vector2
  2172. */
  2173. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2176. * @param value1 defines the 1st control point
  2177. * @param tangent1 defines the outgoing tangent
  2178. * @param value2 defines the 2nd control point
  2179. * @param tangent2 defines the incoming tangent
  2180. * @param amount defines the interpolation factor
  2181. * @returns a new Vector2
  2182. */
  2183. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2184. /**
  2185. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2186. * @param start defines the start vector
  2187. * @param end defines the end vector
  2188. * @param amount defines the interpolation factor
  2189. * @returns a new Vector2
  2190. */
  2191. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2192. /**
  2193. * Gets the dot product of the vector "left" and the vector "right"
  2194. * @param left defines first vector
  2195. * @param right defines second vector
  2196. * @returns the dot product (float)
  2197. */
  2198. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2199. /**
  2200. * Returns a new Vector2 equal to the normalized given vector
  2201. * @param vector defines the vector to normalize
  2202. * @returns a new Vector2
  2203. */
  2204. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2207. * @param left defines 1st vector
  2208. * @param right defines 2nd vector
  2209. * @returns a new Vector2
  2210. */
  2211. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2221. * @param vector defines the vector to transform
  2222. * @param transformation defines the matrix to apply
  2223. * @returns a new Vector2
  2224. */
  2225. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2226. /**
  2227. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @param result defines the target vector
  2231. */
  2232. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2233. /**
  2234. * Determines if a given vector is included in a triangle
  2235. * @param p defines the vector to test
  2236. * @param p0 defines 1st triangle point
  2237. * @param p1 defines 2nd triangle point
  2238. * @param p2 defines 3rd triangle point
  2239. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2240. */
  2241. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2242. /**
  2243. * Gets the distance between the vectors "value1" and "value2"
  2244. * @param value1 defines first vector
  2245. * @param value2 defines second vector
  2246. * @returns the distance between vectors
  2247. */
  2248. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2249. /**
  2250. * Returns the squared distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the squared distance between vectors
  2254. */
  2255. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns a new Vector2
  2261. */
  2262. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2263. /**
  2264. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2265. * @param p defines the middle point
  2266. * @param segA defines one point of the segment
  2267. * @param segB defines the other point of the segment
  2268. * @returns the shortest distance
  2269. */
  2270. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2271. }
  2272. /**
  2273. * Class used to store (x,y,z) vector representation
  2274. * A Vector3 is the main object used in 3D geometry
  2275. * It can represent etiher the coordinates of a point the space, either a direction
  2276. * Reminder: js uses a left handed forward facing system
  2277. */
  2278. export class Vector3 {
  2279. /**
  2280. * Defines the first coordinates (on X axis)
  2281. */
  2282. x: number;
  2283. /**
  2284. * Defines the second coordinates (on Y axis)
  2285. */
  2286. y: number;
  2287. /**
  2288. * Defines the third coordinates (on Z axis)
  2289. */
  2290. z: number;
  2291. private static _UpReadOnly;
  2292. private static _ZeroReadOnly;
  2293. /**
  2294. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2295. * @param x defines the first coordinates (on X axis)
  2296. * @param y defines the second coordinates (on Y axis)
  2297. * @param z defines the third coordinates (on Z axis)
  2298. */
  2299. constructor(
  2300. /**
  2301. * Defines the first coordinates (on X axis)
  2302. */
  2303. x?: number,
  2304. /**
  2305. * Defines the second coordinates (on Y axis)
  2306. */
  2307. y?: number,
  2308. /**
  2309. * Defines the third coordinates (on Z axis)
  2310. */
  2311. z?: number);
  2312. /**
  2313. * Creates a string representation of the Vector3
  2314. * @returns a string with the Vector3 coordinates.
  2315. */
  2316. toString(): string;
  2317. /**
  2318. * Gets the class name
  2319. * @returns the string "Vector3"
  2320. */
  2321. getClassName(): string;
  2322. /**
  2323. * Creates the Vector3 hash code
  2324. * @returns a number which tends to be unique between Vector3 instances
  2325. */
  2326. getHashCode(): number;
  2327. /**
  2328. * Creates an array containing three elements : the coordinates of the Vector3
  2329. * @returns a new array of numbers
  2330. */
  2331. asArray(): number[];
  2332. /**
  2333. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2334. * @param array defines the destination array
  2335. * @param index defines the offset in the destination array
  2336. * @returns the current Vector3
  2337. */
  2338. toArray(array: FloatArray, index?: number): Vector3;
  2339. /**
  2340. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2341. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2342. */
  2343. toQuaternion(): Quaternion;
  2344. /**
  2345. * Adds the given vector to the current Vector3
  2346. * @param otherVector defines the second operand
  2347. * @returns the current updated Vector3
  2348. */
  2349. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2350. /**
  2351. * Adds the given coordinates to the current Vector3
  2352. * @param x defines the x coordinate of the operand
  2353. * @param y defines the y coordinate of the operand
  2354. * @param z defines the z coordinate of the operand
  2355. * @returns the current updated Vector3
  2356. */
  2357. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2358. /**
  2359. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2360. * @param otherVector defines the second operand
  2361. * @returns the resulting Vector3
  2362. */
  2363. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2366. * @param otherVector defines the second operand
  2367. * @param result defines the Vector3 object where to store the result
  2368. * @returns the current Vector3
  2369. */
  2370. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2371. /**
  2372. * Subtract the given vector from the current Vector3
  2373. * @param otherVector defines the second operand
  2374. * @returns the current updated Vector3
  2375. */
  2376. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2377. /**
  2378. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2379. * @param otherVector defines the second operand
  2380. * @returns the resulting Vector3
  2381. */
  2382. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2383. /**
  2384. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2385. * @param otherVector defines the second operand
  2386. * @param result defines the Vector3 object where to store the result
  2387. * @returns the current Vector3
  2388. */
  2389. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2390. /**
  2391. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the resulting Vector3
  2396. */
  2397. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @param result defines the Vector3 object where to store the result
  2404. * @returns the current Vector3
  2405. */
  2406. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2407. /**
  2408. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2409. * @returns a new Vector3
  2410. */
  2411. negate(): Vector3;
  2412. /**
  2413. * Multiplies the Vector3 coordinates by the float "scale"
  2414. * @param scale defines the multiplier factor
  2415. * @returns the current updated Vector3
  2416. */
  2417. scaleInPlace(scale: number): Vector3;
  2418. /**
  2419. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2420. * @param scale defines the multiplier factor
  2421. * @returns a new Vector3
  2422. */
  2423. scale(scale: number): Vector3;
  2424. /**
  2425. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2426. * @param scale defines the multiplier factor
  2427. * @param result defines the Vector3 object where to store the result
  2428. * @returns the current Vector3
  2429. */
  2430. scaleToRef(scale: number, result: Vector3): Vector3;
  2431. /**
  2432. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2433. * @param scale defines the scale factor
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the unmodified current Vector3
  2436. */
  2437. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2438. /**
  2439. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2440. * @param otherVector defines the second operand
  2441. * @returns true if both vectors are equals
  2442. */
  2443. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2444. /**
  2445. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2446. * @param otherVector defines the second operand
  2447. * @param epsilon defines the minimal distance to define values as equals
  2448. * @returns true if both vectors are distant less than epsilon
  2449. */
  2450. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2451. /**
  2452. * Returns true if the current Vector3 coordinates equals the given floats
  2453. * @param x defines the x coordinate of the operand
  2454. * @param y defines the y coordinate of the operand
  2455. * @param z defines the z coordinate of the operand
  2456. * @returns true if both vectors are equals
  2457. */
  2458. equalsToFloats(x: number, y: number, z: number): boolean;
  2459. /**
  2460. * Multiplies the current Vector3 coordinates by the given ones
  2461. * @param otherVector defines the second operand
  2462. * @returns the current updated Vector3
  2463. */
  2464. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2465. /**
  2466. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2467. * @param otherVector defines the second operand
  2468. * @returns the new Vector3
  2469. */
  2470. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2471. /**
  2472. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2473. * @param otherVector defines the second operand
  2474. * @param result defines the Vector3 object where to store the result
  2475. * @returns the current Vector3
  2476. */
  2477. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2478. /**
  2479. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2480. * @param x defines the x coordinate of the operand
  2481. * @param y defines the y coordinate of the operand
  2482. * @param z defines the z coordinate of the operand
  2483. * @returns the new Vector3
  2484. */
  2485. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2486. /**
  2487. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2488. * @param otherVector defines the second operand
  2489. * @returns the new Vector3
  2490. */
  2491. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2494. * @param otherVector defines the second operand
  2495. * @param result defines the Vector3 object where to store the result
  2496. * @returns the current Vector3
  2497. */
  2498. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2499. /**
  2500. * Divides the current Vector3 coordinates by the given ones.
  2501. * @param otherVector defines the second operand
  2502. * @returns the current updated Vector3
  2503. */
  2504. divideInPlace(otherVector: Vector3): Vector3;
  2505. /**
  2506. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2507. * @param other defines the second operand
  2508. * @returns the current updated Vector3
  2509. */
  2510. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2513. * @param other defines the second operand
  2514. * @returns the current updated Vector3
  2515. */
  2516. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2519. * @param x defines the x coordinate of the operand
  2520. * @param y defines the y coordinate of the operand
  2521. * @param z defines the z coordinate of the operand
  2522. * @returns the current updated Vector3
  2523. */
  2524. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2525. /**
  2526. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2527. * @param x defines the x coordinate of the operand
  2528. * @param y defines the y coordinate of the operand
  2529. * @param z defines the z coordinate of the operand
  2530. * @returns the current updated Vector3
  2531. */
  2532. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2533. /**
  2534. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2535. * Check if is non uniform within a certain amount of decimal places to account for this
  2536. * @param epsilon the amount the values can differ
  2537. * @returns if the the vector is non uniform to a certain number of decimal places
  2538. */
  2539. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2540. /**
  2541. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2542. */
  2543. readonly isNonUniform: boolean;
  2544. /**
  2545. * Gets a new Vector3 from current Vector3 floored values
  2546. * @returns a new Vector3
  2547. */
  2548. floor(): Vector3;
  2549. /**
  2550. * Gets a new Vector3 from current Vector3 floored values
  2551. * @returns a new Vector3
  2552. */
  2553. fract(): Vector3;
  2554. /**
  2555. * Gets the length of the Vector3
  2556. * @returns the length of the Vector3
  2557. */
  2558. length(): number;
  2559. /**
  2560. * Gets the squared length of the Vector3
  2561. * @returns squared length of the Vector3
  2562. */
  2563. lengthSquared(): number;
  2564. /**
  2565. * Normalize the current Vector3.
  2566. * Please note that this is an in place operation.
  2567. * @returns the current updated Vector3
  2568. */
  2569. normalize(): Vector3;
  2570. /**
  2571. * Reorders the x y z properties of the vector in place
  2572. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2573. * @returns the current updated vector
  2574. */
  2575. reorderInPlace(order: string): this;
  2576. /**
  2577. * Rotates the vector around 0,0,0 by a quaternion
  2578. * @param quaternion the rotation quaternion
  2579. * @param result vector to store the result
  2580. * @returns the resulting vector
  2581. */
  2582. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2583. /**
  2584. * Rotates a vector around a given point
  2585. * @param quaternion the rotation quaternion
  2586. * @param point the point to rotate around
  2587. * @param result vector to store the result
  2588. * @returns the resulting vector
  2589. */
  2590. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2591. /**
  2592. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2593. * The cross product is then orthogonal to both current and "other"
  2594. * @param other defines the right operand
  2595. * @returns the cross product
  2596. */
  2597. cross(other: Vector3): Vector3;
  2598. /**
  2599. * Normalize the current Vector3 with the given input length.
  2600. * Please note that this is an in place operation.
  2601. * @param len the length of the vector
  2602. * @returns the current updated Vector3
  2603. */
  2604. normalizeFromLength(len: number): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 to a new vector
  2607. * @returns the new Vector3
  2608. */
  2609. normalizeToNew(): Vector3;
  2610. /**
  2611. * Normalize the current Vector3 to the reference
  2612. * @param reference define the Vector3 to update
  2613. * @returns the updated Vector3
  2614. */
  2615. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2616. /**
  2617. * Creates a new Vector3 copied from the current Vector3
  2618. * @returns the new Vector3
  2619. */
  2620. clone(): Vector3;
  2621. /**
  2622. * Copies the given vector coordinates to the current Vector3 ones
  2623. * @param source defines the source Vector3
  2624. * @returns the current updated Vector3
  2625. */
  2626. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2627. /**
  2628. * Copies the given floats to the current Vector3 coordinates
  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 current updated Vector3
  2633. */
  2634. copyFromFloats(x: number, y: number, z: number): Vector3;
  2635. /**
  2636. * Copies the given floats to the current Vector3 coordinates
  2637. * @param x defines the x coordinate of the operand
  2638. * @param y defines the y coordinate of the operand
  2639. * @param z defines the z coordinate of the operand
  2640. * @returns the current updated Vector3
  2641. */
  2642. set(x: number, y: number, z: number): Vector3;
  2643. /**
  2644. * Copies the given float to the current Vector3 coordinates
  2645. * @param v defines the x, y and z coordinates of the operand
  2646. * @returns the current updated Vector3
  2647. */
  2648. setAll(v: number): Vector3;
  2649. /**
  2650. * Get the clip factor between two vectors
  2651. * @param vector0 defines the first operand
  2652. * @param vector1 defines the second operand
  2653. * @param axis defines the axis to use
  2654. * @param size defines the size along the axis
  2655. * @returns the clip factor
  2656. */
  2657. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2658. /**
  2659. * Get angle between two vectors
  2660. * @param vector0 angle between vector0 and vector1
  2661. * @param vector1 angle between vector0 and vector1
  2662. * @param normal direction of the normal
  2663. * @return the angle between vector0 and vector1
  2664. */
  2665. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2666. /**
  2667. * Returns a new Vector3 set from the index "offset" of the given array
  2668. * @param array defines the source array
  2669. * @param offset defines the offset in the source array
  2670. * @returns the new Vector3
  2671. */
  2672. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2673. /**
  2674. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2675. * @param array defines the source array
  2676. * @param offset defines the offset in the source array
  2677. * @returns the new Vector3
  2678. * @deprecated Please use FromArray instead.
  2679. */
  2680. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2681. /**
  2682. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2683. * @param array defines the source array
  2684. * @param offset defines the offset in the source array
  2685. * @param result defines the Vector3 where to store the result
  2686. */
  2687. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2688. /**
  2689. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2690. * @param array defines the source array
  2691. * @param offset defines the offset in the source array
  2692. * @param result defines the Vector3 where to store the result
  2693. * @deprecated Please use FromArrayToRef instead.
  2694. */
  2695. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2696. /**
  2697. * Sets the given vector "result" with the given floats.
  2698. * @param x defines the x coordinate of the source
  2699. * @param y defines the y coordinate of the source
  2700. * @param z defines the z coordinate of the source
  2701. * @param result defines the Vector3 where to store the result
  2702. */
  2703. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2704. /**
  2705. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2706. * @returns a new empty Vector3
  2707. */
  2708. static Zero(): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2711. * @returns a new unit Vector3
  2712. */
  2713. static One(): Vector3;
  2714. /**
  2715. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2716. * @returns a new up Vector3
  2717. */
  2718. static Up(): Vector3;
  2719. /**
  2720. * Gets a up Vector3 that must not be updated
  2721. */
  2722. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2723. /**
  2724. * Gets a zero Vector3 that must not be updated
  2725. */
  2726. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2727. /**
  2728. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2729. * @returns a new down Vector3
  2730. */
  2731. static Down(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2734. * @returns a new forward Vector3
  2735. */
  2736. static Forward(): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2739. * @returns a new forward Vector3
  2740. */
  2741. static Backward(): Vector3;
  2742. /**
  2743. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2744. * @returns a new right Vector3
  2745. */
  2746. static Right(): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2749. * @returns a new left Vector3
  2750. */
  2751. static Left(): Vector3;
  2752. /**
  2753. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2754. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2755. * @param vector defines the Vector3 to transform
  2756. * @param transformation defines the transformation matrix
  2757. * @returns the transformed Vector3
  2758. */
  2759. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2760. /**
  2761. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2762. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2763. * @param vector defines the Vector3 to transform
  2764. * @param transformation defines the transformation matrix
  2765. * @param result defines the Vector3 where to store the result
  2766. */
  2767. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2768. /**
  2769. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2770. * This method computes tranformed coordinates only, not transformed direction vectors
  2771. * @param x define the x coordinate of the source vector
  2772. * @param y define the y coordinate of the source vector
  2773. * @param z define the z coordinate of the source vector
  2774. * @param transformation defines the transformation matrix
  2775. * @param result defines the Vector3 where to store the result
  2776. */
  2777. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2778. /**
  2779. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2780. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @returns the new Vector3
  2784. */
  2785. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2786. /**
  2787. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2788. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2789. * @param vector defines the Vector3 to transform
  2790. * @param transformation defines the transformation matrix
  2791. * @param result defines the Vector3 where to store the result
  2792. */
  2793. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2794. /**
  2795. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2796. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2797. * @param x define the x coordinate of the source vector
  2798. * @param y define the y coordinate of the source vector
  2799. * @param z define the z coordinate of the source vector
  2800. * @param transformation defines the transformation matrix
  2801. * @param result defines the Vector3 where to store the result
  2802. */
  2803. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2804. /**
  2805. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2806. * @param value1 defines the first control point
  2807. * @param value2 defines the second control point
  2808. * @param value3 defines the third control point
  2809. * @param value4 defines the fourth control point
  2810. * @param amount defines the amount on the spline to use
  2811. * @returns the new Vector3
  2812. */
  2813. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2814. /**
  2815. * 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"
  2816. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2817. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2818. * @param value defines the current value
  2819. * @param min defines the lower range value
  2820. * @param max defines the upper range value
  2821. * @returns the new Vector3
  2822. */
  2823. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2824. /**
  2825. * 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"
  2826. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2827. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2828. * @param value defines the current value
  2829. * @param min defines the lower range value
  2830. * @param max defines the upper range value
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2834. /**
  2835. * Checks if a given vector is inside a specific range
  2836. * @param v defines the vector to test
  2837. * @param min defines the minimum range
  2838. * @param max defines the maximum range
  2839. */
  2840. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2841. /**
  2842. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2843. * @param value1 defines the first control point
  2844. * @param tangent1 defines the first tangent vector
  2845. * @param value2 defines the second control point
  2846. * @param tangent2 defines the second tangent vector
  2847. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2848. * @returns the new Vector3
  2849. */
  2850. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2851. /**
  2852. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2853. * @param start defines the start value
  2854. * @param end defines the end value
  2855. * @param amount max defines amount between both (between 0 and 1)
  2856. * @returns the new Vector3
  2857. */
  2858. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2859. /**
  2860. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2861. * @param start defines the start value
  2862. * @param end defines the end value
  2863. * @param amount max defines amount between both (between 0 and 1)
  2864. * @param result defines the Vector3 where to store the result
  2865. */
  2866. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2867. /**
  2868. * Returns the dot product (float) between the vectors "left" and "right"
  2869. * @param left defines the left operand
  2870. * @param right defines the right operand
  2871. * @returns the dot product
  2872. */
  2873. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2874. /**
  2875. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2876. * The cross product is then orthogonal to both "left" and "right"
  2877. * @param left defines the left operand
  2878. * @param right defines the right operand
  2879. * @returns the cross product
  2880. */
  2881. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * Sets the given vector "result" with the cross product of "left" and "right"
  2884. * The cross product is then orthogonal to both "left" and "right"
  2885. * @param left defines the left operand
  2886. * @param right defines the right operand
  2887. * @param result defines the Vector3 where to store the result
  2888. */
  2889. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2890. /**
  2891. * Returns a new Vector3 as the normalization of the given vector
  2892. * @param vector defines the Vector3 to normalize
  2893. * @returns the new Vector3
  2894. */
  2895. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2896. /**
  2897. * Sets the given vector "result" with the normalization of the given first vector
  2898. * @param vector defines the Vector3 to normalize
  2899. * @param result defines the Vector3 where to store the result
  2900. */
  2901. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2902. /**
  2903. * Project a Vector3 onto screen space
  2904. * @param vector defines the Vector3 to project
  2905. * @param world defines the world matrix to use
  2906. * @param transform defines the transform (view x projection) matrix to use
  2907. * @param viewport defines the screen viewport to use
  2908. * @returns the new Vector3
  2909. */
  2910. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2911. /** @hidden */
  2912. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2913. /**
  2914. * Unproject from screen space to object space
  2915. * @param source defines the screen space Vector3 to use
  2916. * @param viewportWidth defines the current width of the viewport
  2917. * @param viewportHeight defines the current height of the viewport
  2918. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2919. * @param transform defines the transform (view x projection) matrix to use
  2920. * @returns the new Vector3
  2921. */
  2922. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2923. /**
  2924. * Unproject from screen space to object space
  2925. * @param source defines the screen space Vector3 to use
  2926. * @param viewportWidth defines the current width of the viewport
  2927. * @param viewportHeight defines the current height of the viewport
  2928. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2929. * @param view defines the view matrix to use
  2930. * @param projection defines the projection matrix to use
  2931. * @returns the new Vector3
  2932. */
  2933. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2934. /**
  2935. * Unproject from screen space to object space
  2936. * @param source defines the screen space Vector3 to use
  2937. * @param viewportWidth defines the current width of the viewport
  2938. * @param viewportHeight defines the current height of the viewport
  2939. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2940. * @param view defines the view matrix to use
  2941. * @param projection defines the projection matrix to use
  2942. * @param result defines the Vector3 where to store the result
  2943. */
  2944. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param sourceX defines the screen space x coordinate to use
  2948. * @param sourceY defines the screen space y coordinate to use
  2949. * @param sourceZ defines the screen space z coordinate to use
  2950. * @param viewportWidth defines the current width of the viewport
  2951. * @param viewportHeight defines the current height of the viewport
  2952. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2953. * @param view defines the view matrix to use
  2954. * @param projection defines the projection matrix to use
  2955. * @param result defines the Vector3 where to store the result
  2956. */
  2957. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2958. /**
  2959. * Gets the minimal coordinate values between two Vector3
  2960. * @param left defines the first operand
  2961. * @param right defines the second operand
  2962. * @returns the new Vector3
  2963. */
  2964. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2965. /**
  2966. * Gets the maximal coordinate values between two Vector3
  2967. * @param left defines the first operand
  2968. * @param right defines the second operand
  2969. * @returns the new Vector3
  2970. */
  2971. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2972. /**
  2973. * Returns the distance between the vectors "value1" and "value2"
  2974. * @param value1 defines the first operand
  2975. * @param value2 defines the second operand
  2976. * @returns the distance
  2977. */
  2978. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2979. /**
  2980. * Returns the squared distance between the vectors "value1" and "value2"
  2981. * @param value1 defines the first operand
  2982. * @param value2 defines the second operand
  2983. * @returns the squared distance
  2984. */
  2985. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2986. /**
  2987. * Returns a new Vector3 located at the center between "value1" and "value2"
  2988. * @param value1 defines the first operand
  2989. * @param value2 defines the second operand
  2990. * @returns the new Vector3
  2991. */
  2992. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2993. /**
  2994. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2995. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2996. * to something in order to rotate it from its local system to the given target system
  2997. * Note: axis1, axis2 and axis3 are normalized during this operation
  2998. * @param axis1 defines the first axis
  2999. * @param axis2 defines the second axis
  3000. * @param axis3 defines the third axis
  3001. * @returns a new Vector3
  3002. */
  3003. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3004. /**
  3005. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3006. * @param axis1 defines the first axis
  3007. * @param axis2 defines the second axis
  3008. * @param axis3 defines the third axis
  3009. * @param ref defines the Vector3 where to store the result
  3010. */
  3011. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3012. }
  3013. /**
  3014. * Vector4 class created for EulerAngle class conversion to Quaternion
  3015. */
  3016. export class Vector4 {
  3017. /** x value of the vector */
  3018. x: number;
  3019. /** y value of the vector */
  3020. y: number;
  3021. /** z value of the vector */
  3022. z: number;
  3023. /** w value of the vector */
  3024. w: number;
  3025. /**
  3026. * Creates a Vector4 object from the given floats.
  3027. * @param x x value of the vector
  3028. * @param y y value of the vector
  3029. * @param z z value of the vector
  3030. * @param w w value of the vector
  3031. */
  3032. constructor(
  3033. /** x value of the vector */
  3034. x: number,
  3035. /** y value of the vector */
  3036. y: number,
  3037. /** z value of the vector */
  3038. z: number,
  3039. /** w value of the vector */
  3040. w: number);
  3041. /**
  3042. * Returns the string with the Vector4 coordinates.
  3043. * @returns a string containing all the vector values
  3044. */
  3045. toString(): string;
  3046. /**
  3047. * Returns the string "Vector4".
  3048. * @returns "Vector4"
  3049. */
  3050. getClassName(): string;
  3051. /**
  3052. * Returns the Vector4 hash code.
  3053. * @returns a unique hash code
  3054. */
  3055. getHashCode(): number;
  3056. /**
  3057. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3058. * @returns the resulting array
  3059. */
  3060. asArray(): number[];
  3061. /**
  3062. * Populates the given array from the given index with the Vector4 coordinates.
  3063. * @param array array to populate
  3064. * @param index index of the array to start at (default: 0)
  3065. * @returns the Vector4.
  3066. */
  3067. toArray(array: FloatArray, index?: number): Vector4;
  3068. /**
  3069. * Adds the given vector to the current Vector4.
  3070. * @param otherVector the vector to add
  3071. * @returns the updated Vector4.
  3072. */
  3073. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3074. /**
  3075. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3076. * @param otherVector the vector to add
  3077. * @returns the resulting vector
  3078. */
  3079. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3080. /**
  3081. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3082. * @param otherVector the vector to add
  3083. * @param result the vector to store the result
  3084. * @returns the current Vector4.
  3085. */
  3086. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3087. /**
  3088. * Subtract in place the given vector from the current Vector4.
  3089. * @param otherVector the vector to subtract
  3090. * @returns the updated Vector4.
  3091. */
  3092. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3093. /**
  3094. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the new vector with the result
  3097. */
  3098. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3101. * @param otherVector the vector to subtract
  3102. * @param result the vector to store the result
  3103. * @returns the current Vector4.
  3104. */
  3105. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3106. /**
  3107. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3108. */
  3109. /**
  3110. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3111. * @param x value to subtract
  3112. * @param y value to subtract
  3113. * @param z value to subtract
  3114. * @param w value to subtract
  3115. * @returns new vector containing the result
  3116. */
  3117. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3118. /**
  3119. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3120. * @param x value to subtract
  3121. * @param y value to subtract
  3122. * @param z value to subtract
  3123. * @param w value to subtract
  3124. * @param result the vector to store the result in
  3125. * @returns the current Vector4.
  3126. */
  3127. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3128. /**
  3129. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3130. * @returns a new vector with the negated values
  3131. */
  3132. negate(): Vector4;
  3133. /**
  3134. * Multiplies the current Vector4 coordinates by scale (float).
  3135. * @param scale the number to scale with
  3136. * @returns the updated Vector4.
  3137. */
  3138. scaleInPlace(scale: number): Vector4;
  3139. /**
  3140. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3141. * @param scale the number to scale with
  3142. * @returns a new vector with the result
  3143. */
  3144. scale(scale: number): Vector4;
  3145. /**
  3146. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3147. * @param scale the number to scale with
  3148. * @param result a vector to store the result in
  3149. * @returns the current Vector4.
  3150. */
  3151. scaleToRef(scale: number, result: Vector4): Vector4;
  3152. /**
  3153. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3154. * @param scale defines the scale factor
  3155. * @param result defines the Vector4 object where to store the result
  3156. * @returns the unmodified current Vector4
  3157. */
  3158. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3159. /**
  3160. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3161. * @param otherVector the vector to compare against
  3162. * @returns true if they are equal
  3163. */
  3164. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3165. /**
  3166. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3167. * @param otherVector vector to compare against
  3168. * @param epsilon (Default: very small number)
  3169. * @returns true if they are equal
  3170. */
  3171. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3172. /**
  3173. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3174. * @param x x value to compare against
  3175. * @param y y value to compare against
  3176. * @param z z value to compare against
  3177. * @param w w value to compare against
  3178. * @returns true if equal
  3179. */
  3180. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3181. /**
  3182. * Multiplies in place the current Vector4 by the given one.
  3183. * @param otherVector vector to multiple with
  3184. * @returns the updated Vector4.
  3185. */
  3186. multiplyInPlace(otherVector: Vector4): Vector4;
  3187. /**
  3188. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3189. * @param otherVector vector to multiple with
  3190. * @returns resulting new vector
  3191. */
  3192. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3193. /**
  3194. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3195. * @param otherVector vector to multiple with
  3196. * @param result vector to store the result
  3197. * @returns the current Vector4.
  3198. */
  3199. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3200. /**
  3201. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3202. * @param x x value multiply with
  3203. * @param y y value multiply with
  3204. * @param z z value multiply with
  3205. * @param w w value multiply with
  3206. * @returns resulting new vector
  3207. */
  3208. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3209. /**
  3210. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3211. * @param otherVector vector to devide with
  3212. * @returns resulting new vector
  3213. */
  3214. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3215. /**
  3216. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3217. * @param otherVector vector to devide with
  3218. * @param result vector to store the result
  3219. * @returns the current Vector4.
  3220. */
  3221. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3222. /**
  3223. * Divides the current Vector3 coordinates by the given ones.
  3224. * @param otherVector vector to devide with
  3225. * @returns the updated Vector3.
  3226. */
  3227. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3228. /**
  3229. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3230. * @param other defines the second operand
  3231. * @returns the current updated Vector4
  3232. */
  3233. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3234. /**
  3235. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3236. * @param other defines the second operand
  3237. * @returns the current updated Vector4
  3238. */
  3239. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Gets a new Vector4 from current Vector4 floored values
  3242. * @returns a new Vector4
  3243. */
  3244. floor(): Vector4;
  3245. /**
  3246. * Gets a new Vector4 from current Vector3 floored values
  3247. * @returns a new Vector4
  3248. */
  3249. fract(): Vector4;
  3250. /**
  3251. * Returns the Vector4 length (float).
  3252. * @returns the length
  3253. */
  3254. length(): number;
  3255. /**
  3256. * Returns the Vector4 squared length (float).
  3257. * @returns the length squared
  3258. */
  3259. lengthSquared(): number;
  3260. /**
  3261. * Normalizes in place the Vector4.
  3262. * @returns the updated Vector4.
  3263. */
  3264. normalize(): Vector4;
  3265. /**
  3266. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3267. * @returns this converted to a new vector3
  3268. */
  3269. toVector3(): Vector3;
  3270. /**
  3271. * Returns a new Vector4 copied from the current one.
  3272. * @returns the new cloned vector
  3273. */
  3274. clone(): Vector4;
  3275. /**
  3276. * Updates the current Vector4 with the given one coordinates.
  3277. * @param source the source vector to copy from
  3278. * @returns the updated Vector4.
  3279. */
  3280. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the current Vector4 coordinates with the given floats.
  3283. * @param x float to copy from
  3284. * @param y float to copy from
  3285. * @param z float to copy from
  3286. * @param w float to copy from
  3287. * @returns the updated Vector4.
  3288. */
  3289. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3290. /**
  3291. * Updates the current Vector4 coordinates with the given floats.
  3292. * @param x float to set from
  3293. * @param y float to set from
  3294. * @param z float to set from
  3295. * @param w float to set from
  3296. * @returns the updated Vector4.
  3297. */
  3298. set(x: number, y: number, z: number, w: number): Vector4;
  3299. /**
  3300. * Copies the given float to the current Vector3 coordinates
  3301. * @param v defines the x, y, z and w coordinates of the operand
  3302. * @returns the current updated Vector3
  3303. */
  3304. setAll(v: number): Vector4;
  3305. /**
  3306. * Returns a new Vector4 set from the starting index of the given array.
  3307. * @param array the array to pull values from
  3308. * @param offset the offset into the array to start at
  3309. * @returns the new vector
  3310. */
  3311. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3312. /**
  3313. * Updates the given vector "result" from the starting index of the given array.
  3314. * @param array the array to pull values from
  3315. * @param offset the offset into the array to start at
  3316. * @param result the vector to store the result in
  3317. */
  3318. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3319. /**
  3320. * Updates the given vector "result" from the starting index of the given Float32Array.
  3321. * @param array the array to pull values from
  3322. * @param offset the offset into the array to start at
  3323. * @param result the vector to store the result in
  3324. */
  3325. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3326. /**
  3327. * Updates the given vector "result" coordinates from the given floats.
  3328. * @param x float to set from
  3329. * @param y float to set from
  3330. * @param z float to set from
  3331. * @param w float to set from
  3332. * @param result the vector to the floats in
  3333. */
  3334. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3335. /**
  3336. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3337. * @returns the new vector
  3338. */
  3339. static Zero(): Vector4;
  3340. /**
  3341. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3342. * @returns the new vector
  3343. */
  3344. static One(): Vector4;
  3345. /**
  3346. * Returns a new normalized Vector4 from the given one.
  3347. * @param vector the vector to normalize
  3348. * @returns the vector
  3349. */
  3350. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3351. /**
  3352. * Updates the given vector "result" from the normalization of the given one.
  3353. * @param vector the vector to normalize
  3354. * @param result the vector to store the result in
  3355. */
  3356. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3357. /**
  3358. * Returns a vector with the minimum values from the left and right vectors
  3359. * @param left left vector to minimize
  3360. * @param right right vector to minimize
  3361. * @returns a new vector with the minimum of the left and right vector values
  3362. */
  3363. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3364. /**
  3365. * Returns a vector with the maximum values from the left and right vectors
  3366. * @param left left vector to maximize
  3367. * @param right right vector to maximize
  3368. * @returns a new vector with the maximum of the left and right vector values
  3369. */
  3370. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3371. /**
  3372. * Returns the distance (float) between the vectors "value1" and "value2".
  3373. * @param value1 value to calulate the distance between
  3374. * @param value2 value to calulate the distance between
  3375. * @return the distance between the two vectors
  3376. */
  3377. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3378. /**
  3379. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3380. * @param value1 value to calulate the distance between
  3381. * @param value2 value to calulate the distance between
  3382. * @return the distance between the two vectors squared
  3383. */
  3384. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3385. /**
  3386. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3387. * @param value1 value to calulate the center between
  3388. * @param value2 value to calulate the center between
  3389. * @return the center between the two vectors
  3390. */
  3391. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3392. /**
  3393. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3394. * This methods computes transformed normalized direction vectors only.
  3395. * @param vector the vector to transform
  3396. * @param transformation the transformation matrix to apply
  3397. * @returns the new vector
  3398. */
  3399. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3400. /**
  3401. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3402. * This methods computes transformed normalized direction vectors only.
  3403. * @param vector the vector to transform
  3404. * @param transformation the transformation matrix to apply
  3405. * @param result the vector to store the result in
  3406. */
  3407. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3408. /**
  3409. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3410. * This methods computes transformed normalized direction vectors only.
  3411. * @param x value to transform
  3412. * @param y value to transform
  3413. * @param z value to transform
  3414. * @param w value to transform
  3415. * @param transformation the transformation matrix to apply
  3416. * @param result the vector to store the results in
  3417. */
  3418. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3419. /**
  3420. * Creates a new Vector4 from a Vector3
  3421. * @param source defines the source data
  3422. * @param w defines the 4th component (default is 0)
  3423. * @returns a new Vector4
  3424. */
  3425. static FromVector3(source: Vector3, w?: number): Vector4;
  3426. }
  3427. /**
  3428. * Class used to store quaternion data
  3429. * @see https://en.wikipedia.org/wiki/Quaternion
  3430. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3431. */
  3432. export class Quaternion {
  3433. /** defines the first component (0 by default) */
  3434. x: number;
  3435. /** defines the second component (0 by default) */
  3436. y: number;
  3437. /** defines the third component (0 by default) */
  3438. z: number;
  3439. /** defines the fourth component (1.0 by default) */
  3440. w: number;
  3441. /**
  3442. * Creates a new Quaternion from the given floats
  3443. * @param x defines the first component (0 by default)
  3444. * @param y defines the second component (0 by default)
  3445. * @param z defines the third component (0 by default)
  3446. * @param w defines the fourth component (1.0 by default)
  3447. */
  3448. constructor(
  3449. /** defines the first component (0 by default) */
  3450. x?: number,
  3451. /** defines the second component (0 by default) */
  3452. y?: number,
  3453. /** defines the third component (0 by default) */
  3454. z?: number,
  3455. /** defines the fourth component (1.0 by default) */
  3456. w?: number);
  3457. /**
  3458. * Gets a string representation for the current quaternion
  3459. * @returns a string with the Quaternion coordinates
  3460. */
  3461. toString(): string;
  3462. /**
  3463. * Gets the class name of the quaternion
  3464. * @returns the string "Quaternion"
  3465. */
  3466. getClassName(): string;
  3467. /**
  3468. * Gets a hash code for this quaternion
  3469. * @returns the quaternion hash code
  3470. */
  3471. getHashCode(): number;
  3472. /**
  3473. * Copy the quaternion to an array
  3474. * @returns a new array populated with 4 elements from the quaternion coordinates
  3475. */
  3476. asArray(): number[];
  3477. /**
  3478. * Check if two quaternions are equals
  3479. * @param otherQuaternion defines the second operand
  3480. * @return true if the current quaternion and the given one coordinates are strictly equals
  3481. */
  3482. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3483. /**
  3484. * Clone the current quaternion
  3485. * @returns a new quaternion copied from the current one
  3486. */
  3487. clone(): Quaternion;
  3488. /**
  3489. * Copy a quaternion to the current one
  3490. * @param other defines the other quaternion
  3491. * @returns the updated current quaternion
  3492. */
  3493. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3494. /**
  3495. * Updates the current quaternion with the given float coordinates
  3496. * @param x defines the x coordinate
  3497. * @param y defines the y coordinate
  3498. * @param z defines the z coordinate
  3499. * @param w defines the w coordinate
  3500. * @returns the updated current quaternion
  3501. */
  3502. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3503. /**
  3504. * Updates the current quaternion from the given float coordinates
  3505. * @param x defines the x coordinate
  3506. * @param y defines the y coordinate
  3507. * @param z defines the z coordinate
  3508. * @param w defines the w coordinate
  3509. * @returns the updated current quaternion
  3510. */
  3511. set(x: number, y: number, z: number, w: number): Quaternion;
  3512. /**
  3513. * Adds two quaternions
  3514. * @param other defines the second operand
  3515. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3516. */
  3517. add(other: DeepImmutable<Quaternion>): Quaternion;
  3518. /**
  3519. * Add a quaternion to the current one
  3520. * @param other defines the quaternion to add
  3521. * @returns the current quaternion
  3522. */
  3523. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3524. /**
  3525. * Subtract two quaternions
  3526. * @param other defines the second operand
  3527. * @returns a new quaternion as the subtraction result of the given one from the current one
  3528. */
  3529. subtract(other: Quaternion): Quaternion;
  3530. /**
  3531. * Multiplies the current quaternion by a scale factor
  3532. * @param value defines the scale factor
  3533. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3534. */
  3535. scale(value: number): Quaternion;
  3536. /**
  3537. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Quaternion object where to store the result
  3540. * @returns the unmodified current quaternion
  3541. */
  3542. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3543. /**
  3544. * Multiplies in place the current quaternion by a scale factor
  3545. * @param value defines the scale factor
  3546. * @returns the current modified quaternion
  3547. */
  3548. scaleInPlace(value: number): Quaternion;
  3549. /**
  3550. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3551. * @param scale defines the scale factor
  3552. * @param result defines the Quaternion object where to store the result
  3553. * @returns the unmodified current quaternion
  3554. */
  3555. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3556. /**
  3557. * Multiplies two quaternions
  3558. * @param q1 defines the second operand
  3559. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3560. */
  3561. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3562. /**
  3563. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3564. * @param q1 defines the second operand
  3565. * @param result defines the target quaternion
  3566. * @returns the current quaternion
  3567. */
  3568. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3569. /**
  3570. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3571. * @param q1 defines the second operand
  3572. * @returns the currentupdated quaternion
  3573. */
  3574. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3575. /**
  3576. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3577. * @param ref defines the target quaternion
  3578. * @returns the current quaternion
  3579. */
  3580. conjugateToRef(ref: Quaternion): Quaternion;
  3581. /**
  3582. * Conjugates in place (1-q) the current quaternion
  3583. * @returns the current updated quaternion
  3584. */
  3585. conjugateInPlace(): Quaternion;
  3586. /**
  3587. * Conjugates in place (1-q) the current quaternion
  3588. * @returns a new quaternion
  3589. */
  3590. conjugate(): Quaternion;
  3591. /**
  3592. * Gets length of current quaternion
  3593. * @returns the quaternion length (float)
  3594. */
  3595. length(): number;
  3596. /**
  3597. * Normalize in place the current quaternion
  3598. * @returns the current updated quaternion
  3599. */
  3600. normalize(): Quaternion;
  3601. /**
  3602. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3603. * @param order is a reserved parameter and is ignore for now
  3604. * @returns a new Vector3 containing the Euler angles
  3605. */
  3606. toEulerAngles(order?: string): Vector3;
  3607. /**
  3608. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3609. * @param result defines the vector which will be filled with the Euler angles
  3610. * @param order is a reserved parameter and is ignore for now
  3611. * @returns the current unchanged quaternion
  3612. */
  3613. toEulerAnglesToRef(result: Vector3): Quaternion;
  3614. /**
  3615. * Updates the given rotation matrix with the current quaternion values
  3616. * @param result defines the target matrix
  3617. * @returns the current unchanged quaternion
  3618. */
  3619. toRotationMatrix(result: Matrix): Quaternion;
  3620. /**
  3621. * Updates the current quaternion from the given rotation matrix values
  3622. * @param matrix defines the source matrix
  3623. * @returns the current updated quaternion
  3624. */
  3625. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3626. /**
  3627. * Creates a new quaternion from a rotation matrix
  3628. * @param matrix defines the source matrix
  3629. * @returns a new quaternion created from the given rotation matrix values
  3630. */
  3631. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3632. /**
  3633. * Updates the given quaternion with the given rotation matrix values
  3634. * @param matrix defines the source matrix
  3635. * @param result defines the target quaternion
  3636. */
  3637. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3638. /**
  3639. * Returns the dot product (float) between the quaternions "left" and "right"
  3640. * @param left defines the left operand
  3641. * @param right defines the right operand
  3642. * @returns the dot product
  3643. */
  3644. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3645. /**
  3646. * Checks if the two quaternions are close to each other
  3647. * @param quat0 defines the first quaternion to check
  3648. * @param quat1 defines the second quaternion to check
  3649. * @returns true if the two quaternions are close to each other
  3650. */
  3651. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3652. /**
  3653. * Creates an empty quaternion
  3654. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3655. */
  3656. static Zero(): Quaternion;
  3657. /**
  3658. * Inverse a given quaternion
  3659. * @param q defines the source quaternion
  3660. * @returns a new quaternion as the inverted current quaternion
  3661. */
  3662. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3663. /**
  3664. * Inverse a given quaternion
  3665. * @param q defines the source quaternion
  3666. * @param result the quaternion the result will be stored in
  3667. * @returns the result quaternion
  3668. */
  3669. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3670. /**
  3671. * Creates an identity quaternion
  3672. * @returns the identity quaternion
  3673. */
  3674. static Identity(): Quaternion;
  3675. /**
  3676. * Gets a boolean indicating if the given quaternion is identity
  3677. * @param quaternion defines the quaternion to check
  3678. * @returns true if the quaternion is identity
  3679. */
  3680. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3681. /**
  3682. * Creates a quaternion from a rotation around an axis
  3683. * @param axis defines the axis to use
  3684. * @param angle defines the angle to use
  3685. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3686. */
  3687. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3688. /**
  3689. * Creates a rotation around an axis and stores it into the given quaternion
  3690. * @param axis defines the axis to use
  3691. * @param angle defines the angle to use
  3692. * @param result defines the target quaternion
  3693. * @returns the target quaternion
  3694. */
  3695. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3696. /**
  3697. * Creates a new quaternion from data stored into an array
  3698. * @param array defines the data source
  3699. * @param offset defines the offset in the source array where the data starts
  3700. * @returns a new quaternion
  3701. */
  3702. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3703. /**
  3704. * Create a quaternion from Euler rotation angles
  3705. * @param x Pitch
  3706. * @param y Yaw
  3707. * @param z Roll
  3708. * @returns the new Quaternion
  3709. */
  3710. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3711. /**
  3712. * Updates a quaternion from Euler rotation angles
  3713. * @param x Pitch
  3714. * @param y Yaw
  3715. * @param z Roll
  3716. * @param result the quaternion to store the result
  3717. * @returns the updated quaternion
  3718. */
  3719. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Create a quaternion from Euler rotation vector
  3722. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3723. * @returns the new Quaternion
  3724. */
  3725. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3726. /**
  3727. * Updates a quaternion from Euler rotation vector
  3728. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3729. * @param result the quaternion to store the result
  3730. * @returns the updated quaternion
  3731. */
  3732. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3733. /**
  3734. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3735. * @param yaw defines the rotation around Y axis
  3736. * @param pitch defines the rotation around X axis
  3737. * @param roll defines the rotation around Z axis
  3738. * @returns the new quaternion
  3739. */
  3740. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3741. /**
  3742. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3743. * @param yaw defines the rotation around Y axis
  3744. * @param pitch defines the rotation around X axis
  3745. * @param roll defines the rotation around Z axis
  3746. * @param result defines the target quaternion
  3747. */
  3748. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3749. /**
  3750. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3751. * @param alpha defines the rotation around first axis
  3752. * @param beta defines the rotation around second axis
  3753. * @param gamma defines the rotation around third axis
  3754. * @returns the new quaternion
  3755. */
  3756. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3757. /**
  3758. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3759. * @param alpha defines the rotation around first axis
  3760. * @param beta defines the rotation around second axis
  3761. * @param gamma defines the rotation around third axis
  3762. * @param result defines the target quaternion
  3763. */
  3764. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3765. /**
  3766. * 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)
  3767. * @param axis1 defines the first axis
  3768. * @param axis2 defines the second axis
  3769. * @param axis3 defines the third axis
  3770. * @returns the new quaternion
  3771. */
  3772. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3773. /**
  3774. * 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
  3775. * @param axis1 defines the first axis
  3776. * @param axis2 defines the second axis
  3777. * @param axis3 defines the third axis
  3778. * @param ref defines the target quaternion
  3779. */
  3780. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3781. /**
  3782. * Interpolates between two quaternions
  3783. * @param left defines first quaternion
  3784. * @param right defines second quaternion
  3785. * @param amount defines the gradient to use
  3786. * @returns the new interpolated quaternion
  3787. */
  3788. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3789. /**
  3790. * Interpolates between two quaternions and stores it into a target quaternion
  3791. * @param left defines first quaternion
  3792. * @param right defines second quaternion
  3793. * @param amount defines the gradient to use
  3794. * @param result defines the target quaternion
  3795. */
  3796. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3797. /**
  3798. * Interpolate between two quaternions using Hermite interpolation
  3799. * @param value1 defines first quaternion
  3800. * @param tangent1 defines the incoming tangent
  3801. * @param value2 defines second quaternion
  3802. * @param tangent2 defines the outgoing tangent
  3803. * @param amount defines the target quaternion
  3804. * @returns the new interpolated quaternion
  3805. */
  3806. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3807. }
  3808. /**
  3809. * Class used to store matrix data (4x4)
  3810. */
  3811. export class Matrix {
  3812. private static _updateFlagSeed;
  3813. private static _identityReadOnly;
  3814. private _isIdentity;
  3815. private _isIdentityDirty;
  3816. private _isIdentity3x2;
  3817. private _isIdentity3x2Dirty;
  3818. /**
  3819. * Gets the update flag of the matrix which is an unique number for the matrix.
  3820. * It will be incremented every time the matrix data change.
  3821. * You can use it to speed the comparison between two versions of the same matrix.
  3822. */
  3823. updateFlag: number;
  3824. private readonly _m;
  3825. /**
  3826. * Gets the internal data of the matrix
  3827. */
  3828. readonly m: DeepImmutable<Float32Array>;
  3829. /** @hidden */
  3830. _markAsUpdated(): void;
  3831. /** @hidden */
  3832. private _updateIdentityStatus;
  3833. /**
  3834. * Creates an empty matrix (filled with zeros)
  3835. */
  3836. constructor();
  3837. /**
  3838. * Check if the current matrix is identity
  3839. * @returns true is the matrix is the identity matrix
  3840. */
  3841. isIdentity(): boolean;
  3842. /**
  3843. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3844. * @returns true is the matrix is the identity matrix
  3845. */
  3846. isIdentityAs3x2(): boolean;
  3847. /**
  3848. * Gets the determinant of the matrix
  3849. * @returns the matrix determinant
  3850. */
  3851. determinant(): number;
  3852. /**
  3853. * Returns the matrix as a Float32Array
  3854. * @returns the matrix underlying array
  3855. */
  3856. toArray(): DeepImmutable<Float32Array>;
  3857. /**
  3858. * Returns the matrix as a Float32Array
  3859. * @returns the matrix underlying array.
  3860. */
  3861. asArray(): DeepImmutable<Float32Array>;
  3862. /**
  3863. * Inverts the current matrix in place
  3864. * @returns the current inverted matrix
  3865. */
  3866. invert(): Matrix;
  3867. /**
  3868. * Sets all the matrix elements to zero
  3869. * @returns the current matrix
  3870. */
  3871. reset(): Matrix;
  3872. /**
  3873. * Adds the current matrix with a second one
  3874. * @param other defines the matrix to add
  3875. * @returns a new matrix as the addition of the current matrix and the given one
  3876. */
  3877. add(other: DeepImmutable<Matrix>): Matrix;
  3878. /**
  3879. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3880. * @param other defines the matrix to add
  3881. * @param result defines the target matrix
  3882. * @returns the current matrix
  3883. */
  3884. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3885. /**
  3886. * Adds in place the given matrix to the current matrix
  3887. * @param other defines the second operand
  3888. * @returns the current updated matrix
  3889. */
  3890. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3891. /**
  3892. * Sets the given matrix to the current inverted Matrix
  3893. * @param other defines the target matrix
  3894. * @returns the unmodified current matrix
  3895. */
  3896. invertToRef(other: Matrix): Matrix;
  3897. /**
  3898. * add a value at the specified position in the current Matrix
  3899. * @param index the index of the value within the matrix. between 0 and 15.
  3900. * @param value the value to be added
  3901. * @returns the current updated matrix
  3902. */
  3903. addAtIndex(index: number, value: number): Matrix;
  3904. /**
  3905. * mutiply the specified position in the current Matrix by a value
  3906. * @param index the index of the value within the matrix. between 0 and 15.
  3907. * @param value the value to be added
  3908. * @returns the current updated matrix
  3909. */
  3910. multiplyAtIndex(index: number, value: number): Matrix;
  3911. /**
  3912. * Inserts the translation vector (using 3 floats) in the current matrix
  3913. * @param x defines the 1st component of the translation
  3914. * @param y defines the 2nd component of the translation
  3915. * @param z defines the 3rd component of the translation
  3916. * @returns the current updated matrix
  3917. */
  3918. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3919. /**
  3920. * Adds the translation vector (using 3 floats) in the current matrix
  3921. * @param x defines the 1st component of the translation
  3922. * @param y defines the 2nd component of the translation
  3923. * @param z defines the 3rd component of the translation
  3924. * @returns the current updated matrix
  3925. */
  3926. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3927. /**
  3928. * Inserts the translation vector in the current matrix
  3929. * @param vector3 defines the translation to insert
  3930. * @returns the current updated matrix
  3931. */
  3932. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3933. /**
  3934. * Gets the translation value of the current matrix
  3935. * @returns a new Vector3 as the extracted translation from the matrix
  3936. */
  3937. getTranslation(): Vector3;
  3938. /**
  3939. * Fill a Vector3 with the extracted translation from the matrix
  3940. * @param result defines the Vector3 where to store the translation
  3941. * @returns the current matrix
  3942. */
  3943. getTranslationToRef(result: Vector3): Matrix;
  3944. /**
  3945. * Remove rotation and scaling part from the matrix
  3946. * @returns the updated matrix
  3947. */
  3948. removeRotationAndScaling(): Matrix;
  3949. /**
  3950. * Multiply two matrices
  3951. * @param other defines the second operand
  3952. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3953. */
  3954. multiply(other: DeepImmutable<Matrix>): Matrix;
  3955. /**
  3956. * Copy the current matrix from the given one
  3957. * @param other defines the source matrix
  3958. * @returns the current updated matrix
  3959. */
  3960. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3961. /**
  3962. * Populates the given array from the starting index with the current matrix values
  3963. * @param array defines the target array
  3964. * @param offset defines the offset in the target array where to start storing values
  3965. * @returns the current matrix
  3966. */
  3967. copyToArray(array: Float32Array, offset?: number): Matrix;
  3968. /**
  3969. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3970. * @param other defines the second operand
  3971. * @param result defines the matrix where to store the multiplication
  3972. * @returns the current matrix
  3973. */
  3974. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3975. /**
  3976. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3977. * @param other defines the second operand
  3978. * @param result defines the array where to store the multiplication
  3979. * @param offset defines the offset in the target array where to start storing values
  3980. * @returns the current matrix
  3981. */
  3982. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3983. /**
  3984. * Check equality between this matrix and a second one
  3985. * @param value defines the second matrix to compare
  3986. * @returns true is the current matrix and the given one values are strictly equal
  3987. */
  3988. equals(value: DeepImmutable<Matrix>): boolean;
  3989. /**
  3990. * Clone the current matrix
  3991. * @returns a new matrix from the current matrix
  3992. */
  3993. clone(): Matrix;
  3994. /**
  3995. * Returns the name of the current matrix class
  3996. * @returns the string "Matrix"
  3997. */
  3998. getClassName(): string;
  3999. /**
  4000. * Gets the hash code of the current matrix
  4001. * @returns the hash code
  4002. */
  4003. getHashCode(): number;
  4004. /**
  4005. * Decomposes the current Matrix into a translation, rotation and scaling components
  4006. * @param scale defines the scale vector3 given as a reference to update
  4007. * @param rotation defines the rotation quaternion given as a reference to update
  4008. * @param translation defines the translation vector3 given as a reference to update
  4009. * @returns true if operation was successful
  4010. */
  4011. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4012. /**
  4013. * Gets specific row of the matrix
  4014. * @param index defines the number of the row to get
  4015. * @returns the index-th row of the current matrix as a new Vector4
  4016. */
  4017. getRow(index: number): Nullable<Vector4>;
  4018. /**
  4019. * Sets the index-th row of the current matrix to the vector4 values
  4020. * @param index defines the number of the row to set
  4021. * @param row defines the target vector4
  4022. * @returns the updated current matrix
  4023. */
  4024. setRow(index: number, row: Vector4): Matrix;
  4025. /**
  4026. * Compute the transpose of the matrix
  4027. * @returns the new transposed matrix
  4028. */
  4029. transpose(): Matrix;
  4030. /**
  4031. * Compute the transpose of the matrix and store it in a given matrix
  4032. * @param result defines the target matrix
  4033. * @returns the current matrix
  4034. */
  4035. transposeToRef(result: Matrix): Matrix;
  4036. /**
  4037. * Sets the index-th row of the current matrix with the given 4 x float values
  4038. * @param index defines the row index
  4039. * @param x defines the x component to set
  4040. * @param y defines the y component to set
  4041. * @param z defines the z component to set
  4042. * @param w defines the w component to set
  4043. * @returns the updated current matrix
  4044. */
  4045. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4046. /**
  4047. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4048. * @param scale defines the scale factor
  4049. * @returns a new matrix
  4050. */
  4051. scale(scale: number): Matrix;
  4052. /**
  4053. * Scale the current matrix values by a factor to a given result matrix
  4054. * @param scale defines the scale factor
  4055. * @param result defines the matrix to store the result
  4056. * @returns the current matrix
  4057. */
  4058. scaleToRef(scale: number, result: Matrix): Matrix;
  4059. /**
  4060. * Scale the current matrix values by a factor and add the result to a given matrix
  4061. * @param scale defines the scale factor
  4062. * @param result defines the Matrix to store the result
  4063. * @returns the current matrix
  4064. */
  4065. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4066. /**
  4067. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4068. * @param ref matrix to store the result
  4069. */
  4070. toNormalMatrix(ref: Matrix): void;
  4071. /**
  4072. * Gets only rotation part of the current matrix
  4073. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4074. */
  4075. getRotationMatrix(): Matrix;
  4076. /**
  4077. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4078. * @param result defines the target matrix to store data to
  4079. * @returns the current matrix
  4080. */
  4081. getRotationMatrixToRef(result: Matrix): Matrix;
  4082. /**
  4083. * Toggles model matrix from being right handed to left handed in place and vice versa
  4084. */
  4085. toggleModelMatrixHandInPlace(): void;
  4086. /**
  4087. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4088. */
  4089. toggleProjectionMatrixHandInPlace(): void;
  4090. /**
  4091. * Creates a matrix from an array
  4092. * @param array defines the source array
  4093. * @param offset defines an offset in the source array
  4094. * @returns a new Matrix set from the starting index of the given array
  4095. */
  4096. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4097. /**
  4098. * Copy the content of an array into a given matrix
  4099. * @param array defines the source array
  4100. * @param offset defines an offset in the source array
  4101. * @param result defines the target matrix
  4102. */
  4103. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4104. /**
  4105. * Stores an array into a matrix after having multiplied each component by a given factor
  4106. * @param array defines the source array
  4107. * @param offset defines the offset in the source array
  4108. * @param scale defines the scaling factor
  4109. * @param result defines the target matrix
  4110. */
  4111. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4112. /**
  4113. * Gets an identity matrix that must not be updated
  4114. */
  4115. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4116. /**
  4117. * Stores a list of values (16) inside a given matrix
  4118. * @param initialM11 defines 1st value of 1st row
  4119. * @param initialM12 defines 2nd value of 1st row
  4120. * @param initialM13 defines 3rd value of 1st row
  4121. * @param initialM14 defines 4th value of 1st row
  4122. * @param initialM21 defines 1st value of 2nd row
  4123. * @param initialM22 defines 2nd value of 2nd row
  4124. * @param initialM23 defines 3rd value of 2nd row
  4125. * @param initialM24 defines 4th value of 2nd row
  4126. * @param initialM31 defines 1st value of 3rd row
  4127. * @param initialM32 defines 2nd value of 3rd row
  4128. * @param initialM33 defines 3rd value of 3rd row
  4129. * @param initialM34 defines 4th value of 3rd row
  4130. * @param initialM41 defines 1st value of 4th row
  4131. * @param initialM42 defines 2nd value of 4th row
  4132. * @param initialM43 defines 3rd value of 4th row
  4133. * @param initialM44 defines 4th value of 4th row
  4134. * @param result defines the target matrix
  4135. */
  4136. 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;
  4137. /**
  4138. * Creates new matrix from a list of values (16)
  4139. * @param initialM11 defines 1st value of 1st row
  4140. * @param initialM12 defines 2nd value of 1st row
  4141. * @param initialM13 defines 3rd value of 1st row
  4142. * @param initialM14 defines 4th value of 1st row
  4143. * @param initialM21 defines 1st value of 2nd row
  4144. * @param initialM22 defines 2nd value of 2nd row
  4145. * @param initialM23 defines 3rd value of 2nd row
  4146. * @param initialM24 defines 4th value of 2nd row
  4147. * @param initialM31 defines 1st value of 3rd row
  4148. * @param initialM32 defines 2nd value of 3rd row
  4149. * @param initialM33 defines 3rd value of 3rd row
  4150. * @param initialM34 defines 4th value of 3rd row
  4151. * @param initialM41 defines 1st value of 4th row
  4152. * @param initialM42 defines 2nd value of 4th row
  4153. * @param initialM43 defines 3rd value of 4th row
  4154. * @param initialM44 defines 4th value of 4th row
  4155. * @returns the new matrix
  4156. */
  4157. 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;
  4158. /**
  4159. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4160. * @param scale defines the scale vector3
  4161. * @param rotation defines the rotation quaternion
  4162. * @param translation defines the translation vector3
  4163. * @returns a new matrix
  4164. */
  4165. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4166. /**
  4167. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4168. * @param scale defines the scale vector3
  4169. * @param rotation defines the rotation quaternion
  4170. * @param translation defines the translation vector3
  4171. * @param result defines the target matrix
  4172. */
  4173. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4174. /**
  4175. * Creates a new identity matrix
  4176. * @returns a new identity matrix
  4177. */
  4178. static Identity(): Matrix;
  4179. /**
  4180. * Creates a new identity matrix and stores the result in a given matrix
  4181. * @param result defines the target matrix
  4182. */
  4183. static IdentityToRef(result: Matrix): void;
  4184. /**
  4185. * Creates a new zero matrix
  4186. * @returns a new zero matrix
  4187. */
  4188. static Zero(): Matrix;
  4189. /**
  4190. * Creates a new rotation matrix for "angle" radians around the X axis
  4191. * @param angle defines the angle (in radians) to use
  4192. * @return the new matrix
  4193. */
  4194. static RotationX(angle: number): Matrix;
  4195. /**
  4196. * Creates a new matrix as the invert of a given matrix
  4197. * @param source defines the source matrix
  4198. * @returns the new matrix
  4199. */
  4200. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4203. * @param angle defines the angle (in radians) to use
  4204. * @param result defines the target matrix
  4205. */
  4206. static RotationXToRef(angle: number, result: Matrix): void;
  4207. /**
  4208. * Creates a new rotation matrix for "angle" radians around the Y axis
  4209. * @param angle defines the angle (in radians) to use
  4210. * @return the new matrix
  4211. */
  4212. static RotationY(angle: number): Matrix;
  4213. /**
  4214. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4215. * @param angle defines the angle (in radians) to use
  4216. * @param result defines the target matrix
  4217. */
  4218. static RotationYToRef(angle: number, result: Matrix): void;
  4219. /**
  4220. * Creates a new rotation matrix for "angle" radians around the Z axis
  4221. * @param angle defines the angle (in radians) to use
  4222. * @return the new matrix
  4223. */
  4224. static RotationZ(angle: number): Matrix;
  4225. /**
  4226. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4227. * @param angle defines the angle (in radians) to use
  4228. * @param result defines the target matrix
  4229. */
  4230. static RotationZToRef(angle: number, result: Matrix): void;
  4231. /**
  4232. * Creates a new rotation matrix for "angle" radians around the given axis
  4233. * @param axis defines the axis to use
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4240. * @param axis defines the axis to use
  4241. * @param angle defines the angle (in radians) to use
  4242. * @param result defines the target matrix
  4243. */
  4244. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4245. /**
  4246. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4247. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4248. * @param from defines the vector to align
  4249. * @param to defines the vector to align to
  4250. * @param result defines the target matrix
  4251. */
  4252. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4253. /**
  4254. * Creates a rotation matrix
  4255. * @param yaw defines the yaw angle in radians (Y axis)
  4256. * @param pitch defines the pitch angle in radians (X axis)
  4257. * @param roll defines the roll angle in radians (X axis)
  4258. * @returns the new rotation matrix
  4259. */
  4260. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4261. /**
  4262. * Creates a rotation matrix and stores it in a given matrix
  4263. * @param yaw defines the yaw angle in radians (Y axis)
  4264. * @param pitch defines the pitch angle in radians (X axis)
  4265. * @param roll defines the roll angle in radians (X axis)
  4266. * @param result defines the target matrix
  4267. */
  4268. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4269. /**
  4270. * Creates a scaling matrix
  4271. * @param x defines the scale factor on X axis
  4272. * @param y defines the scale factor on Y axis
  4273. * @param z defines the scale factor on Z axis
  4274. * @returns the new matrix
  4275. */
  4276. static Scaling(x: number, y: number, z: number): Matrix;
  4277. /**
  4278. * Creates a scaling matrix and stores it in a given matrix
  4279. * @param x defines the scale factor on X axis
  4280. * @param y defines the scale factor on Y axis
  4281. * @param z defines the scale factor on Z axis
  4282. * @param result defines the target matrix
  4283. */
  4284. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4285. /**
  4286. * Creates a translation matrix
  4287. * @param x defines the translation on X axis
  4288. * @param y defines the translation on Y axis
  4289. * @param z defines the translationon Z axis
  4290. * @returns the new matrix
  4291. */
  4292. static Translation(x: number, y: number, z: number): Matrix;
  4293. /**
  4294. * Creates a translation matrix and stores it in a given matrix
  4295. * @param x defines the translation on X axis
  4296. * @param y defines the translation on Y axis
  4297. * @param z defines the translationon Z axis
  4298. * @param result defines the target matrix
  4299. */
  4300. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4301. /**
  4302. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4303. * @param startValue defines the start value
  4304. * @param endValue defines the end value
  4305. * @param gradient defines the gradient factor
  4306. * @returns the new matrix
  4307. */
  4308. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4309. /**
  4310. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4311. * @param startValue defines the start value
  4312. * @param endValue defines the end value
  4313. * @param gradient defines the gradient factor
  4314. * @param result defines the Matrix object where to store data
  4315. */
  4316. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4317. /**
  4318. * Builds a new matrix whose values are computed by:
  4319. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4320. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4321. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4322. * @param startValue defines the first matrix
  4323. * @param endValue defines the second matrix
  4324. * @param gradient defines the gradient between the two matrices
  4325. * @returns the new matrix
  4326. */
  4327. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4328. /**
  4329. * Update a matrix to values which are computed by:
  4330. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4331. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4332. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4333. * @param startValue defines the first matrix
  4334. * @param endValue defines the second matrix
  4335. * @param gradient defines the gradient between the two matrices
  4336. * @param result defines the target matrix
  4337. */
  4338. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4339. /**
  4340. * 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"
  4341. * This function works in left handed mode
  4342. * @param eye defines the final position of the entity
  4343. * @param target defines where the entity should look at
  4344. * @param up defines the up vector for the entity
  4345. * @returns the new matrix
  4346. */
  4347. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4348. /**
  4349. * 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".
  4350. * This function works in left handed mode
  4351. * @param eye defines the final position of the entity
  4352. * @param target defines where the entity should look at
  4353. * @param up defines the up vector for the entity
  4354. * @param result defines the target matrix
  4355. */
  4356. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4357. /**
  4358. * 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"
  4359. * This function works in right handed mode
  4360. * @param eye defines the final position of the entity
  4361. * @param target defines where the entity should look at
  4362. * @param up defines the up vector for the entity
  4363. * @returns the new matrix
  4364. */
  4365. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4366. /**
  4367. * 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".
  4368. * This function works in right handed mode
  4369. * @param eye defines the final position of the entity
  4370. * @param target defines where the entity should look at
  4371. * @param up defines the up vector for the entity
  4372. * @param result defines the target matrix
  4373. */
  4374. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4375. /**
  4376. * Create a left-handed orthographic projection matrix
  4377. * @param width defines the viewport width
  4378. * @param height defines the viewport height
  4379. * @param znear defines the near clip plane
  4380. * @param zfar defines the far clip plane
  4381. * @returns a new matrix as a left-handed orthographic projection matrix
  4382. */
  4383. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4384. /**
  4385. * Store a left-handed orthographic projection to a given matrix
  4386. * @param width defines the viewport width
  4387. * @param height defines the viewport height
  4388. * @param znear defines the near clip plane
  4389. * @param zfar defines the far clip plane
  4390. * @param result defines the target matrix
  4391. */
  4392. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4393. /**
  4394. * Create a left-handed orthographic projection matrix
  4395. * @param left defines the viewport left coordinate
  4396. * @param right defines the viewport right coordinate
  4397. * @param bottom defines the viewport bottom coordinate
  4398. * @param top defines the viewport top coordinate
  4399. * @param znear defines the near clip plane
  4400. * @param zfar defines the far clip plane
  4401. * @returns a new matrix as a left-handed orthographic projection matrix
  4402. */
  4403. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4404. /**
  4405. * Stores a left-handed orthographic projection into a given matrix
  4406. * @param left defines the viewport left coordinate
  4407. * @param right defines the viewport right coordinate
  4408. * @param bottom defines the viewport bottom coordinate
  4409. * @param top defines the viewport top coordinate
  4410. * @param znear defines the near clip plane
  4411. * @param zfar defines the far clip plane
  4412. * @param result defines the target matrix
  4413. */
  4414. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4415. /**
  4416. * Creates a right-handed orthographic projection matrix
  4417. * @param left defines the viewport left coordinate
  4418. * @param right defines the viewport right coordinate
  4419. * @param bottom defines the viewport bottom coordinate
  4420. * @param top defines the viewport top coordinate
  4421. * @param znear defines the near clip plane
  4422. * @param zfar defines the far clip plane
  4423. * @returns a new matrix as a right-handed orthographic projection matrix
  4424. */
  4425. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4426. /**
  4427. * Stores a right-handed orthographic projection into a given matrix
  4428. * @param left defines the viewport left coordinate
  4429. * @param right defines the viewport right coordinate
  4430. * @param bottom defines the viewport bottom coordinate
  4431. * @param top defines the viewport top coordinate
  4432. * @param znear defines the near clip plane
  4433. * @param zfar defines the far clip plane
  4434. * @param result defines the target matrix
  4435. */
  4436. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4437. /**
  4438. * Creates a left-handed perspective projection matrix
  4439. * @param width defines the viewport width
  4440. * @param height defines the viewport height
  4441. * @param znear defines the near clip plane
  4442. * @param zfar defines the far clip plane
  4443. * @returns a new matrix as a left-handed perspective projection matrix
  4444. */
  4445. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4446. /**
  4447. * Creates a left-handed perspective projection matrix
  4448. * @param fov defines the horizontal field of view
  4449. * @param aspect defines the aspect ratio
  4450. * @param znear defines the near clip plane
  4451. * @param zfar defines the far clip plane
  4452. * @returns a new matrix as a left-handed perspective projection matrix
  4453. */
  4454. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4455. /**
  4456. * Stores a left-handed perspective projection into a given matrix
  4457. * @param fov defines the horizontal field of view
  4458. * @param aspect defines the aspect ratio
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @param result defines the target matrix
  4462. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4463. */
  4464. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4465. /**
  4466. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4467. * @param fov defines the horizontal field of view
  4468. * @param aspect defines the aspect ratio
  4469. * @param znear defines the near clip plane
  4470. * @param zfar not used as infinity is used as far clip
  4471. * @param result defines the target matrix
  4472. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4473. */
  4474. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4475. /**
  4476. * Creates a right-handed perspective projection matrix
  4477. * @param fov defines the horizontal field of view
  4478. * @param aspect defines the aspect ratio
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a right-handed perspective projection matrix
  4482. */
  4483. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a right-handed perspective projection into a given matrix
  4486. * @param fov defines the horizontal field of view
  4487. * @param aspect defines the aspect ratio
  4488. * @param znear defines the near clip plane
  4489. * @param zfar defines the far clip plane
  4490. * @param result defines the target matrix
  4491. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4492. */
  4493. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4494. /**
  4495. * Stores a right-handed perspective projection into a given matrix
  4496. * @param fov defines the horizontal field of view
  4497. * @param aspect defines the aspect ratio
  4498. * @param znear defines the near clip plane
  4499. * @param zfar not used as infinity is used as far clip
  4500. * @param result defines the target matrix
  4501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4502. */
  4503. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4504. /**
  4505. * Stores a perspective projection for WebVR info a given matrix
  4506. * @param fov defines the field of view
  4507. * @param znear defines the near clip plane
  4508. * @param zfar defines the far clip plane
  4509. * @param result defines the target matrix
  4510. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4511. */
  4512. static PerspectiveFovWebVRToRef(fov: {
  4513. upDegrees: number;
  4514. downDegrees: number;
  4515. leftDegrees: number;
  4516. rightDegrees: number;
  4517. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4518. /**
  4519. * Computes a complete transformation matrix
  4520. * @param viewport defines the viewport to use
  4521. * @param world defines the world matrix
  4522. * @param view defines the view matrix
  4523. * @param projection defines the projection matrix
  4524. * @param zmin defines the near clip plane
  4525. * @param zmax defines the far clip plane
  4526. * @returns the transformation matrix
  4527. */
  4528. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4529. /**
  4530. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4531. * @param matrix defines the matrix to use
  4532. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4533. */
  4534. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4535. /**
  4536. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4537. * @param matrix defines the matrix to use
  4538. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4539. */
  4540. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4541. /**
  4542. * Compute the transpose of a given matrix
  4543. * @param matrix defines the matrix to transpose
  4544. * @returns the new matrix
  4545. */
  4546. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4547. /**
  4548. * Compute the transpose of a matrix and store it in a target matrix
  4549. * @param matrix defines the matrix to transpose
  4550. * @param result defines the target matrix
  4551. */
  4552. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4553. /**
  4554. * Computes a reflection matrix from a plane
  4555. * @param plane defines the reflection plane
  4556. * @returns a new matrix
  4557. */
  4558. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4559. /**
  4560. * Computes a reflection matrix from a plane
  4561. * @param plane defines the reflection plane
  4562. * @param result defines the target matrix
  4563. */
  4564. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4565. /**
  4566. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4567. * @param xaxis defines the value of the 1st axis
  4568. * @param yaxis defines the value of the 2nd axis
  4569. * @param zaxis defines the value of the 3rd axis
  4570. * @param result defines the target matrix
  4571. */
  4572. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4573. /**
  4574. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4575. * @param quat defines the quaternion to use
  4576. * @param result defines the target matrix
  4577. */
  4578. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4579. }
  4580. /**
  4581. * @hidden
  4582. */
  4583. export class TmpVectors {
  4584. static Vector2: Vector2[];
  4585. static Vector3: Vector3[];
  4586. static Vector4: Vector4[];
  4587. static Quaternion: Quaternion[];
  4588. static Matrix: Matrix[];
  4589. }
  4590. }
  4591. declare module BABYLON {
  4592. /**
  4593. * Defines potential orientation for back face culling
  4594. */
  4595. export enum Orientation {
  4596. /**
  4597. * Clockwise
  4598. */
  4599. CW = 0,
  4600. /** Counter clockwise */
  4601. CCW = 1
  4602. }
  4603. /** Class used to represent a Bezier curve */
  4604. export class BezierCurve {
  4605. /**
  4606. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4607. * @param t defines the time
  4608. * @param x1 defines the left coordinate on X axis
  4609. * @param y1 defines the left coordinate on Y axis
  4610. * @param x2 defines the right coordinate on X axis
  4611. * @param y2 defines the right coordinate on Y axis
  4612. * @returns the interpolated value
  4613. */
  4614. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4615. }
  4616. /**
  4617. * Defines angle representation
  4618. */
  4619. export class Angle {
  4620. private _radians;
  4621. /**
  4622. * Creates an Angle object of "radians" radians (float).
  4623. * @param radians the angle in radians
  4624. */
  4625. constructor(radians: number);
  4626. /**
  4627. * Get value in degrees
  4628. * @returns the Angle value in degrees (float)
  4629. */
  4630. degrees(): number;
  4631. /**
  4632. * Get value in radians
  4633. * @returns the Angle value in radians (float)
  4634. */
  4635. radians(): number;
  4636. /**
  4637. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4638. * @param a defines first vector
  4639. * @param b defines second vector
  4640. * @returns a new Angle
  4641. */
  4642. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4643. /**
  4644. * Gets a new Angle object from the given float in radians
  4645. * @param radians defines the angle value in radians
  4646. * @returns a new Angle
  4647. */
  4648. static FromRadians(radians: number): Angle;
  4649. /**
  4650. * Gets a new Angle object from the given float in degrees
  4651. * @param degrees defines the angle value in degrees
  4652. * @returns a new Angle
  4653. */
  4654. static FromDegrees(degrees: number): Angle;
  4655. }
  4656. /**
  4657. * This represents an arc in a 2d space.
  4658. */
  4659. export class Arc2 {
  4660. /** Defines the start point of the arc */
  4661. startPoint: Vector2;
  4662. /** Defines the mid point of the arc */
  4663. midPoint: Vector2;
  4664. /** Defines the end point of the arc */
  4665. endPoint: Vector2;
  4666. /**
  4667. * Defines the center point of the arc.
  4668. */
  4669. centerPoint: Vector2;
  4670. /**
  4671. * Defines the radius of the arc.
  4672. */
  4673. radius: number;
  4674. /**
  4675. * Defines the angle of the arc (from mid point to end point).
  4676. */
  4677. angle: Angle;
  4678. /**
  4679. * Defines the start angle of the arc (from start point to middle point).
  4680. */
  4681. startAngle: Angle;
  4682. /**
  4683. * Defines the orientation of the arc (clock wise/counter clock wise).
  4684. */
  4685. orientation: Orientation;
  4686. /**
  4687. * Creates an Arc object from the three given points : start, middle and end.
  4688. * @param startPoint Defines the start point of the arc
  4689. * @param midPoint Defines the midlle point of the arc
  4690. * @param endPoint Defines the end point of the arc
  4691. */
  4692. constructor(
  4693. /** Defines the start point of the arc */
  4694. startPoint: Vector2,
  4695. /** Defines the mid point of the arc */
  4696. midPoint: Vector2,
  4697. /** Defines the end point of the arc */
  4698. endPoint: Vector2);
  4699. }
  4700. /**
  4701. * Represents a 2D path made up of multiple 2D points
  4702. */
  4703. export class Path2 {
  4704. private _points;
  4705. private _length;
  4706. /**
  4707. * If the path start and end point are the same
  4708. */
  4709. closed: boolean;
  4710. /**
  4711. * Creates a Path2 object from the starting 2D coordinates x and y.
  4712. * @param x the starting points x value
  4713. * @param y the starting points y value
  4714. */
  4715. constructor(x: number, y: number);
  4716. /**
  4717. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4718. * @param x the added points x value
  4719. * @param y the added points y value
  4720. * @returns the updated Path2.
  4721. */
  4722. addLineTo(x: number, y: number): Path2;
  4723. /**
  4724. * 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.
  4725. * @param midX middle point x value
  4726. * @param midY middle point y value
  4727. * @param endX end point x value
  4728. * @param endY end point y value
  4729. * @param numberOfSegments (default: 36)
  4730. * @returns the updated Path2.
  4731. */
  4732. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4733. /**
  4734. * Closes the Path2.
  4735. * @returns the Path2.
  4736. */
  4737. close(): Path2;
  4738. /**
  4739. * Gets the sum of the distance between each sequential point in the path
  4740. * @returns the Path2 total length (float).
  4741. */
  4742. length(): number;
  4743. /**
  4744. * Gets the points which construct the path
  4745. * @returns the Path2 internal array of points.
  4746. */
  4747. getPoints(): Vector2[];
  4748. /**
  4749. * Retreives the point at the distance aways from the starting point
  4750. * @param normalizedLengthPosition the length along the path to retreive the point from
  4751. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4752. */
  4753. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4754. /**
  4755. * Creates a new path starting from an x and y position
  4756. * @param x starting x value
  4757. * @param y starting y value
  4758. * @returns a new Path2 starting at the coordinates (x, y).
  4759. */
  4760. static StartingAt(x: number, y: number): Path2;
  4761. }
  4762. /**
  4763. * Represents a 3D path made up of multiple 3D points
  4764. */
  4765. export class Path3D {
  4766. /**
  4767. * an array of Vector3, the curve axis of the Path3D
  4768. */
  4769. path: Vector3[];
  4770. private _curve;
  4771. private _distances;
  4772. private _tangents;
  4773. private _normals;
  4774. private _binormals;
  4775. private _raw;
  4776. private _alignTangentsWithPath;
  4777. private readonly _pointAtData;
  4778. /**
  4779. * new Path3D(path, normal, raw)
  4780. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4781. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4782. * @param path an array of Vector3, the curve axis of the Path3D
  4783. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4784. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4785. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4786. */
  4787. constructor(
  4788. /**
  4789. * an array of Vector3, the curve axis of the Path3D
  4790. */
  4791. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4792. /**
  4793. * Returns the Path3D array of successive Vector3 designing its curve.
  4794. * @returns the Path3D array of successive Vector3 designing its curve.
  4795. */
  4796. getCurve(): Vector3[];
  4797. /**
  4798. * Returns the Path3D array of successive Vector3 designing its curve.
  4799. * @returns the Path3D array of successive Vector3 designing its curve.
  4800. */
  4801. getPoints(): Vector3[];
  4802. /**
  4803. * @returns the computed length (float) of the path.
  4804. */
  4805. length(): number;
  4806. /**
  4807. * Returns an array populated with tangent vectors on each Path3D curve point.
  4808. * @returns an array populated with tangent vectors on each Path3D curve point.
  4809. */
  4810. getTangents(): Vector3[];
  4811. /**
  4812. * Returns an array populated with normal vectors on each Path3D curve point.
  4813. * @returns an array populated with normal vectors on each Path3D curve point.
  4814. */
  4815. getNormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with binormal vectors on each Path3D curve point.
  4818. * @returns an array populated with binormal vectors on each Path3D curve point.
  4819. */
  4820. getBinormals(): Vector3[];
  4821. /**
  4822. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4823. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4824. */
  4825. getDistances(): number[];
  4826. /**
  4827. * Returns an interpolated point along this path
  4828. * @param position the position of the point along this path, from 0.0 to 1.0
  4829. * @returns a new Vector3 as the point
  4830. */
  4831. getPointAt(position: number): Vector3;
  4832. /**
  4833. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4834. * @param position the position of the point along this path, from 0.0 to 1.0
  4835. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4836. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4837. */
  4838. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4839. /**
  4840. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4841. * @param position the position of the point along this path, from 0.0 to 1.0
  4842. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4843. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4844. */
  4845. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4846. /**
  4847. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4848. * @param position the position of the point along this path, from 0.0 to 1.0
  4849. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4850. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4851. */
  4852. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4853. /**
  4854. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4857. */
  4858. getDistanceAt(position: number): number;
  4859. /**
  4860. * Returns the array index of the previous point of an interpolated point along this path
  4861. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4862. * @returns the array index
  4863. */
  4864. getPreviousPointIndexAt(position: number): number;
  4865. /**
  4866. * 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)
  4867. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4868. * @returns the sub position
  4869. */
  4870. getSubPositionAt(position: number): number;
  4871. /**
  4872. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4873. * @param target the vector of which to get the closest position to
  4874. * @returns the position of the closest virtual point on this path to the target vector
  4875. */
  4876. getClosestPositionTo(target: Vector3): number;
  4877. /**
  4878. * Returns a sub path (slice) of this path
  4879. * @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
  4880. * @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
  4881. * @returns a sub path (slice) of this path
  4882. */
  4883. slice(start?: number, end?: number): Path3D;
  4884. /**
  4885. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4886. * @param path path which all values are copied into the curves points
  4887. * @param firstNormal which should be projected onto the curve
  4888. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4889. * @returns the same object updated.
  4890. */
  4891. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4892. private _compute;
  4893. private _getFirstNonNullVector;
  4894. private _getLastNonNullVector;
  4895. private _normalVector;
  4896. /**
  4897. * Updates the point at data for an interpolated point along this curve
  4898. * @param position the position of the point along this curve, from 0.0 to 1.0
  4899. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4900. * @returns the (updated) point at data
  4901. */
  4902. private _updatePointAtData;
  4903. /**
  4904. * Updates the point at data from the specified parameters
  4905. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4906. * @param point the interpolated point
  4907. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4908. */
  4909. private _setPointAtData;
  4910. /**
  4911. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4912. */
  4913. private _updateInterpolationMatrix;
  4914. }
  4915. /**
  4916. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4917. * A Curve3 is designed from a series of successive Vector3.
  4918. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4919. */
  4920. export class Curve3 {
  4921. private _points;
  4922. private _length;
  4923. /**
  4924. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4925. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4926. * @param v1 (Vector3) the control point
  4927. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4928. * @param nbPoints (integer) the wanted number of points in the curve
  4929. * @returns the created Curve3
  4930. */
  4931. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4932. /**
  4933. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4934. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4935. * @param v1 (Vector3) the first control point
  4936. * @param v2 (Vector3) the second control point
  4937. * @param v3 (Vector3) the end point of the Cubic Bezier
  4938. * @param nbPoints (integer) the wanted number of points in the curve
  4939. * @returns the created Curve3
  4940. */
  4941. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4942. /**
  4943. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4944. * @param p1 (Vector3) the origin point of the Hermite Spline
  4945. * @param t1 (Vector3) the tangent vector at the origin point
  4946. * @param p2 (Vector3) the end point of the Hermite Spline
  4947. * @param t2 (Vector3) the tangent vector at the end point
  4948. * @param nbPoints (integer) the wanted number of points in the curve
  4949. * @returns the created Curve3
  4950. */
  4951. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4952. /**
  4953. * Returns a Curve3 object along a CatmullRom Spline curve :
  4954. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4955. * @param nbPoints (integer) the wanted number of points between each curve control points
  4956. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4957. * @returns the created Curve3
  4958. */
  4959. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4960. /**
  4961. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4962. * A Curve3 is designed from a series of successive Vector3.
  4963. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4964. * @param points points which make up the curve
  4965. */
  4966. constructor(points: Vector3[]);
  4967. /**
  4968. * @returns the Curve3 stored array of successive Vector3
  4969. */
  4970. getPoints(): Vector3[];
  4971. /**
  4972. * @returns the computed length (float) of the curve.
  4973. */
  4974. length(): number;
  4975. /**
  4976. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4977. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4978. * curveA and curveB keep unchanged.
  4979. * @param curve the curve to continue from this curve
  4980. * @returns the newly constructed curve
  4981. */
  4982. continue(curve: DeepImmutable<Curve3>): Curve3;
  4983. private _computeLength;
  4984. }
  4985. }
  4986. declare module BABYLON {
  4987. /**
  4988. * This represents the main contract an easing function should follow.
  4989. * Easing functions are used throughout the animation system.
  4990. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4991. */
  4992. export interface IEasingFunction {
  4993. /**
  4994. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4995. * of the easing function.
  4996. * The link below provides some of the most common examples of easing functions.
  4997. * @see https://easings.net/
  4998. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4999. * @returns the corresponding value on the curve defined by the easing function
  5000. */
  5001. ease(gradient: number): number;
  5002. }
  5003. /**
  5004. * Base class used for every default easing function.
  5005. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5006. */
  5007. export class EasingFunction implements IEasingFunction {
  5008. /**
  5009. * Interpolation follows the mathematical formula associated with the easing function.
  5010. */
  5011. static readonly EASINGMODE_EASEIN: number;
  5012. /**
  5013. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5014. */
  5015. static readonly EASINGMODE_EASEOUT: number;
  5016. /**
  5017. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5018. */
  5019. static readonly EASINGMODE_EASEINOUT: number;
  5020. private _easingMode;
  5021. /**
  5022. * Sets the easing mode of the current function.
  5023. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5024. */
  5025. setEasingMode(easingMode: number): void;
  5026. /**
  5027. * Gets the current easing mode.
  5028. * @returns the easing mode
  5029. */
  5030. getEasingMode(): number;
  5031. /**
  5032. * @hidden
  5033. */
  5034. easeInCore(gradient: number): number;
  5035. /**
  5036. * Given an input gradient between 0 and 1, this returns the corresponding value
  5037. * of the easing function.
  5038. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5039. * @returns the corresponding value on the curve defined by the easing function
  5040. */
  5041. ease(gradient: number): number;
  5042. }
  5043. /**
  5044. * Easing function with a circle shape (see link below).
  5045. * @see https://easings.net/#easeInCirc
  5046. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5047. */
  5048. export class CircleEase extends EasingFunction implements IEasingFunction {
  5049. /** @hidden */
  5050. easeInCore(gradient: number): number;
  5051. }
  5052. /**
  5053. * Easing function with a ease back shape (see link below).
  5054. * @see https://easings.net/#easeInBack
  5055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5056. */
  5057. export class BackEase extends EasingFunction implements IEasingFunction {
  5058. /** Defines the amplitude of the function */
  5059. amplitude: number;
  5060. /**
  5061. * Instantiates a back ease easing
  5062. * @see https://easings.net/#easeInBack
  5063. * @param amplitude Defines the amplitude of the function
  5064. */
  5065. constructor(
  5066. /** Defines the amplitude of the function */
  5067. amplitude?: number);
  5068. /** @hidden */
  5069. easeInCore(gradient: number): number;
  5070. }
  5071. /**
  5072. * Easing function with a bouncing shape (see link below).
  5073. * @see https://easings.net/#easeInBounce
  5074. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5075. */
  5076. export class BounceEase extends EasingFunction implements IEasingFunction {
  5077. /** Defines the number of bounces */
  5078. bounces: number;
  5079. /** Defines the amplitude of the bounce */
  5080. bounciness: number;
  5081. /**
  5082. * Instantiates a bounce easing
  5083. * @see https://easings.net/#easeInBounce
  5084. * @param bounces Defines the number of bounces
  5085. * @param bounciness Defines the amplitude of the bounce
  5086. */
  5087. constructor(
  5088. /** Defines the number of bounces */
  5089. bounces?: number,
  5090. /** Defines the amplitude of the bounce */
  5091. bounciness?: number);
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a power of 3 shape (see link below).
  5097. * @see https://easings.net/#easeInCubic
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class CubicEase extends EasingFunction implements IEasingFunction {
  5101. /** @hidden */
  5102. easeInCore(gradient: number): number;
  5103. }
  5104. /**
  5105. * Easing function with an elastic shape (see link below).
  5106. * @see https://easings.net/#easeInElastic
  5107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5108. */
  5109. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5110. /** Defines the number of oscillations*/
  5111. oscillations: number;
  5112. /** Defines the amplitude of the oscillations*/
  5113. springiness: number;
  5114. /**
  5115. * Instantiates an elastic easing function
  5116. * @see https://easings.net/#easeInElastic
  5117. * @param oscillations Defines the number of oscillations
  5118. * @param springiness Defines the amplitude of the oscillations
  5119. */
  5120. constructor(
  5121. /** Defines the number of oscillations*/
  5122. oscillations?: number,
  5123. /** Defines the amplitude of the oscillations*/
  5124. springiness?: number);
  5125. /** @hidden */
  5126. easeInCore(gradient: number): number;
  5127. }
  5128. /**
  5129. * Easing function with an exponential shape (see link below).
  5130. * @see https://easings.net/#easeInExpo
  5131. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5132. */
  5133. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5134. /** Defines the exponent of the function */
  5135. exponent: number;
  5136. /**
  5137. * Instantiates an exponential easing function
  5138. * @see https://easings.net/#easeInExpo
  5139. * @param exponent Defines the exponent of the function
  5140. */
  5141. constructor(
  5142. /** Defines the exponent of the function */
  5143. exponent?: number);
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with a power shape (see link below).
  5149. * @see https://easings.net/#easeInQuad
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class PowerEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the power of the function */
  5154. power: number;
  5155. /**
  5156. * Instantiates an power base easing function
  5157. * @see https://easings.net/#easeInQuad
  5158. * @param power Defines the power of the function
  5159. */
  5160. constructor(
  5161. /** Defines the power of the function */
  5162. power?: number);
  5163. /** @hidden */
  5164. easeInCore(gradient: number): number;
  5165. }
  5166. /**
  5167. * Easing function with a power of 2 shape (see link below).
  5168. * @see https://easings.net/#easeInQuad
  5169. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5170. */
  5171. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5172. /** @hidden */
  5173. easeInCore(gradient: number): number;
  5174. }
  5175. /**
  5176. * Easing function with a power of 4 shape (see link below).
  5177. * @see https://easings.net/#easeInQuart
  5178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5179. */
  5180. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5181. /** @hidden */
  5182. easeInCore(gradient: number): number;
  5183. }
  5184. /**
  5185. * Easing function with a power of 5 shape (see link below).
  5186. * @see https://easings.net/#easeInQuint
  5187. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5188. */
  5189. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a sin shape (see link below).
  5195. * @see https://easings.net/#easeInSine
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class SineEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a bezier shape (see link below).
  5204. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5208. /** Defines the x component of the start tangent in the bezier curve */
  5209. x1: number;
  5210. /** Defines the y component of the start tangent in the bezier curve */
  5211. y1: number;
  5212. /** Defines the x component of the end tangent in the bezier curve */
  5213. x2: number;
  5214. /** Defines the y component of the end tangent in the bezier curve */
  5215. y2: number;
  5216. /**
  5217. * Instantiates a bezier function
  5218. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5219. * @param x1 Defines the x component of the start tangent in the bezier curve
  5220. * @param y1 Defines the y component of the start tangent in the bezier curve
  5221. * @param x2 Defines the x component of the end tangent in the bezier curve
  5222. * @param y2 Defines the y component of the end tangent in the bezier curve
  5223. */
  5224. constructor(
  5225. /** Defines the x component of the start tangent in the bezier curve */
  5226. x1?: number,
  5227. /** Defines the y component of the start tangent in the bezier curve */
  5228. y1?: number,
  5229. /** Defines the x component of the end tangent in the bezier curve */
  5230. x2?: number,
  5231. /** Defines the y component of the end tangent in the bezier curve */
  5232. y2?: number);
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. }
  5237. declare module BABYLON {
  5238. /**
  5239. * Class used to hold a RBG color
  5240. */
  5241. export class Color3 {
  5242. /**
  5243. * Defines the red component (between 0 and 1, default is 0)
  5244. */
  5245. r: number;
  5246. /**
  5247. * Defines the green component (between 0 and 1, default is 0)
  5248. */
  5249. g: number;
  5250. /**
  5251. * Defines the blue component (between 0 and 1, default is 0)
  5252. */
  5253. b: number;
  5254. /**
  5255. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5256. * @param r defines the red component (between 0 and 1, default is 0)
  5257. * @param g defines the green component (between 0 and 1, default is 0)
  5258. * @param b defines the blue component (between 0 and 1, default is 0)
  5259. */
  5260. constructor(
  5261. /**
  5262. * Defines the red component (between 0 and 1, default is 0)
  5263. */
  5264. r?: number,
  5265. /**
  5266. * Defines the green component (between 0 and 1, default is 0)
  5267. */
  5268. g?: number,
  5269. /**
  5270. * Defines the blue component (between 0 and 1, default is 0)
  5271. */
  5272. b?: number);
  5273. /**
  5274. * Creates a string with the Color3 current values
  5275. * @returns the string representation of the Color3 object
  5276. */
  5277. toString(): string;
  5278. /**
  5279. * Returns the string "Color3"
  5280. * @returns "Color3"
  5281. */
  5282. getClassName(): string;
  5283. /**
  5284. * Compute the Color3 hash code
  5285. * @returns an unique number that can be used to hash Color3 objects
  5286. */
  5287. getHashCode(): number;
  5288. /**
  5289. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5290. * @param array defines the array where to store the r,g,b components
  5291. * @param index defines an optional index in the target array to define where to start storing values
  5292. * @returns the current Color3 object
  5293. */
  5294. toArray(array: FloatArray, index?: number): Color3;
  5295. /**
  5296. * Returns a new Color4 object from the current Color3 and the given alpha
  5297. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5298. * @returns a new Color4 object
  5299. */
  5300. toColor4(alpha?: number): Color4;
  5301. /**
  5302. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5303. * @returns the new array
  5304. */
  5305. asArray(): number[];
  5306. /**
  5307. * Returns the luminance value
  5308. * @returns a float value
  5309. */
  5310. toLuminance(): number;
  5311. /**
  5312. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5313. * @param otherColor defines the second operand
  5314. * @returns the new Color3 object
  5315. */
  5316. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5317. /**
  5318. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5319. * @param otherColor defines the second operand
  5320. * @param result defines the Color3 object where to store the result
  5321. * @returns the current Color3
  5322. */
  5323. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5324. /**
  5325. * Determines equality between Color3 objects
  5326. * @param otherColor defines the second operand
  5327. * @returns true if the rgb values are equal to the given ones
  5328. */
  5329. equals(otherColor: DeepImmutable<Color3>): boolean;
  5330. /**
  5331. * Determines equality between the current Color3 object and a set of r,b,g values
  5332. * @param r defines the red component to check
  5333. * @param g defines the green component to check
  5334. * @param b defines the blue component to check
  5335. * @returns true if the rgb values are equal to the given ones
  5336. */
  5337. equalsFloats(r: number, g: number, b: number): boolean;
  5338. /**
  5339. * Multiplies in place each rgb value by scale
  5340. * @param scale defines the scaling factor
  5341. * @returns the updated Color3
  5342. */
  5343. scale(scale: number): Color3;
  5344. /**
  5345. * Multiplies the rgb values by scale and stores the result into "result"
  5346. * @param scale defines the scaling factor
  5347. * @param result defines the Color3 object where to store the result
  5348. * @returns the unmodified current Color3
  5349. */
  5350. scaleToRef(scale: number, result: Color3): Color3;
  5351. /**
  5352. * Scale the current Color3 values by a factor and add the result to a given Color3
  5353. * @param scale defines the scale factor
  5354. * @param result defines color to store the result into
  5355. * @returns the unmodified current Color3
  5356. */
  5357. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5358. /**
  5359. * Clamps the rgb values by the min and max values and stores the result into "result"
  5360. * @param min defines minimum clamping value (default is 0)
  5361. * @param max defines maximum clamping value (default is 1)
  5362. * @param result defines color to store the result into
  5363. * @returns the original Color3
  5364. */
  5365. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5366. /**
  5367. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5368. * @param otherColor defines the second operand
  5369. * @returns the new Color3
  5370. */
  5371. add(otherColor: DeepImmutable<Color3>): Color3;
  5372. /**
  5373. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5374. * @param otherColor defines the second operand
  5375. * @param result defines Color3 object to store the result into
  5376. * @returns the unmodified current Color3
  5377. */
  5378. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5379. /**
  5380. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5381. * @param otherColor defines the second operand
  5382. * @returns the new Color3
  5383. */
  5384. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5385. /**
  5386. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5387. * @param otherColor defines the second operand
  5388. * @param result defines Color3 object to store the result into
  5389. * @returns the unmodified current Color3
  5390. */
  5391. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5392. /**
  5393. * Copy the current object
  5394. * @returns a new Color3 copied the current one
  5395. */
  5396. clone(): Color3;
  5397. /**
  5398. * Copies the rgb values from the source in the current Color3
  5399. * @param source defines the source Color3 object
  5400. * @returns the updated Color3 object
  5401. */
  5402. copyFrom(source: DeepImmutable<Color3>): Color3;
  5403. /**
  5404. * Updates the Color3 rgb values from the given floats
  5405. * @param r defines the red component to read from
  5406. * @param g defines the green component to read from
  5407. * @param b defines the blue component to read from
  5408. * @returns the current Color3 object
  5409. */
  5410. copyFromFloats(r: number, g: number, b: number): Color3;
  5411. /**
  5412. * Updates the Color3 rgb values from the given floats
  5413. * @param r defines the red component to read from
  5414. * @param g defines the green component to read from
  5415. * @param b defines the blue component to read from
  5416. * @returns the current Color3 object
  5417. */
  5418. set(r: number, g: number, b: number): Color3;
  5419. /**
  5420. * Compute the Color3 hexadecimal code as a string
  5421. * @returns a string containing the hexadecimal representation of the Color3 object
  5422. */
  5423. toHexString(): string;
  5424. /**
  5425. * Computes a new Color3 converted from the current one to linear space
  5426. * @returns a new Color3 object
  5427. */
  5428. toLinearSpace(): Color3;
  5429. /**
  5430. * Converts current color in rgb space to HSV values
  5431. * @returns a new color3 representing the HSV values
  5432. */
  5433. toHSV(): Color3;
  5434. /**
  5435. * Converts current color in rgb space to HSV values
  5436. * @param result defines the Color3 where to store the HSV values
  5437. */
  5438. toHSVToRef(result: Color3): void;
  5439. /**
  5440. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5441. * @param convertedColor defines the Color3 object where to store the linear space version
  5442. * @returns the unmodified Color3
  5443. */
  5444. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5445. /**
  5446. * Computes a new Color3 converted from the current one to gamma space
  5447. * @returns a new Color3 object
  5448. */
  5449. toGammaSpace(): Color3;
  5450. /**
  5451. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5452. * @param convertedColor defines the Color3 object where to store the gamma space version
  5453. * @returns the unmodified Color3
  5454. */
  5455. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5456. private static _BlackReadOnly;
  5457. /**
  5458. * Convert Hue, saturation and value to a Color3 (RGB)
  5459. * @param hue defines the hue
  5460. * @param saturation defines the saturation
  5461. * @param value defines the value
  5462. * @param result defines the Color3 where to store the RGB values
  5463. */
  5464. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5465. /**
  5466. * Creates a new Color3 from the string containing valid hexadecimal values
  5467. * @param hex defines a string containing valid hexadecimal values
  5468. * @returns a new Color3 object
  5469. */
  5470. static FromHexString(hex: string): Color3;
  5471. /**
  5472. * Creates a new Color3 from the starting index of the given array
  5473. * @param array defines the source array
  5474. * @param offset defines an offset in the source array
  5475. * @returns a new Color3 object
  5476. */
  5477. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5478. /**
  5479. * Creates a new Color3 from integer values (< 256)
  5480. * @param r defines the red component to read from (value between 0 and 255)
  5481. * @param g defines the green component to read from (value between 0 and 255)
  5482. * @param b defines the blue component to read from (value between 0 and 255)
  5483. * @returns a new Color3 object
  5484. */
  5485. static FromInts(r: number, g: number, b: number): Color3;
  5486. /**
  5487. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5488. * @param start defines the start Color3 value
  5489. * @param end defines the end Color3 value
  5490. * @param amount defines the gradient value between start and end
  5491. * @returns a new Color3 object
  5492. */
  5493. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5494. /**
  5495. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5496. * @param left defines the start value
  5497. * @param right defines the end value
  5498. * @param amount defines the gradient factor
  5499. * @param result defines the Color3 object where to store the result
  5500. */
  5501. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5502. /**
  5503. * Returns a Color3 value containing a red color
  5504. * @returns a new Color3 object
  5505. */
  5506. static Red(): Color3;
  5507. /**
  5508. * Returns a Color3 value containing a green color
  5509. * @returns a new Color3 object
  5510. */
  5511. static Green(): Color3;
  5512. /**
  5513. * Returns a Color3 value containing a blue color
  5514. * @returns a new Color3 object
  5515. */
  5516. static Blue(): Color3;
  5517. /**
  5518. * Returns a Color3 value containing a black color
  5519. * @returns a new Color3 object
  5520. */
  5521. static Black(): Color3;
  5522. /**
  5523. * Gets a Color3 value containing a black color that must not be updated
  5524. */
  5525. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5526. /**
  5527. * Returns a Color3 value containing a white color
  5528. * @returns a new Color3 object
  5529. */
  5530. static White(): Color3;
  5531. /**
  5532. * Returns a Color3 value containing a purple color
  5533. * @returns a new Color3 object
  5534. */
  5535. static Purple(): Color3;
  5536. /**
  5537. * Returns a Color3 value containing a magenta color
  5538. * @returns a new Color3 object
  5539. */
  5540. static Magenta(): Color3;
  5541. /**
  5542. * Returns a Color3 value containing a yellow color
  5543. * @returns a new Color3 object
  5544. */
  5545. static Yellow(): Color3;
  5546. /**
  5547. * Returns a Color3 value containing a gray color
  5548. * @returns a new Color3 object
  5549. */
  5550. static Gray(): Color3;
  5551. /**
  5552. * Returns a Color3 value containing a teal color
  5553. * @returns a new Color3 object
  5554. */
  5555. static Teal(): Color3;
  5556. /**
  5557. * Returns a Color3 value containing a random color
  5558. * @returns a new Color3 object
  5559. */
  5560. static Random(): Color3;
  5561. }
  5562. /**
  5563. * Class used to hold a RBGA color
  5564. */
  5565. export class Color4 {
  5566. /**
  5567. * Defines the red component (between 0 and 1, default is 0)
  5568. */
  5569. r: number;
  5570. /**
  5571. * Defines the green component (between 0 and 1, default is 0)
  5572. */
  5573. g: number;
  5574. /**
  5575. * Defines the blue component (between 0 and 1, default is 0)
  5576. */
  5577. b: number;
  5578. /**
  5579. * Defines the alpha component (between 0 and 1, default is 1)
  5580. */
  5581. a: number;
  5582. /**
  5583. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5584. * @param r defines the red component (between 0 and 1, default is 0)
  5585. * @param g defines the green component (between 0 and 1, default is 0)
  5586. * @param b defines the blue component (between 0 and 1, default is 0)
  5587. * @param a defines the alpha component (between 0 and 1, default is 1)
  5588. */
  5589. constructor(
  5590. /**
  5591. * Defines the red component (between 0 and 1, default is 0)
  5592. */
  5593. r?: number,
  5594. /**
  5595. * Defines the green component (between 0 and 1, default is 0)
  5596. */
  5597. g?: number,
  5598. /**
  5599. * Defines the blue component (between 0 and 1, default is 0)
  5600. */
  5601. b?: number,
  5602. /**
  5603. * Defines the alpha component (between 0 and 1, default is 1)
  5604. */
  5605. a?: number);
  5606. /**
  5607. * Adds in place the given Color4 values to the current Color4 object
  5608. * @param right defines the second operand
  5609. * @returns the current updated Color4 object
  5610. */
  5611. addInPlace(right: DeepImmutable<Color4>): Color4;
  5612. /**
  5613. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5614. * @returns the new array
  5615. */
  5616. asArray(): number[];
  5617. /**
  5618. * Stores from the starting index in the given array the Color4 successive values
  5619. * @param array defines the array where to store the r,g,b components
  5620. * @param index defines an optional index in the target array to define where to start storing values
  5621. * @returns the current Color4 object
  5622. */
  5623. toArray(array: number[], index?: number): Color4;
  5624. /**
  5625. * Determines equality between Color4 objects
  5626. * @param otherColor defines the second operand
  5627. * @returns true if the rgba values are equal to the given ones
  5628. */
  5629. equals(otherColor: DeepImmutable<Color4>): boolean;
  5630. /**
  5631. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5632. * @param right defines the second operand
  5633. * @returns a new Color4 object
  5634. */
  5635. add(right: DeepImmutable<Color4>): Color4;
  5636. /**
  5637. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5638. * @param right defines the second operand
  5639. * @returns a new Color4 object
  5640. */
  5641. subtract(right: DeepImmutable<Color4>): Color4;
  5642. /**
  5643. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5644. * @param right defines the second operand
  5645. * @param result defines the Color4 object where to store the result
  5646. * @returns the current Color4 object
  5647. */
  5648. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5649. /**
  5650. * Creates a new Color4 with the current Color4 values multiplied by scale
  5651. * @param scale defines the scaling factor to apply
  5652. * @returns a new Color4 object
  5653. */
  5654. scale(scale: number): Color4;
  5655. /**
  5656. * Multiplies the current Color4 values by scale and stores the result in "result"
  5657. * @param scale defines the scaling factor to apply
  5658. * @param result defines the Color4 object where to store the result
  5659. * @returns the current unmodified Color4
  5660. */
  5661. scaleToRef(scale: number, result: Color4): Color4;
  5662. /**
  5663. * Scale the current Color4 values by a factor and add the result to a given Color4
  5664. * @param scale defines the scale factor
  5665. * @param result defines the Color4 object where to store the result
  5666. * @returns the unmodified current Color4
  5667. */
  5668. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5669. /**
  5670. * Clamps the rgb values by the min and max values and stores the result into "result"
  5671. * @param min defines minimum clamping value (default is 0)
  5672. * @param max defines maximum clamping value (default is 1)
  5673. * @param result defines color to store the result into.
  5674. * @returns the cuurent Color4
  5675. */
  5676. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5677. /**
  5678. * Multipy an Color4 value by another and return a new Color4 object
  5679. * @param color defines the Color4 value to multiply by
  5680. * @returns a new Color4 object
  5681. */
  5682. multiply(color: Color4): Color4;
  5683. /**
  5684. * Multipy a Color4 value by another and push the result in a reference value
  5685. * @param color defines the Color4 value to multiply by
  5686. * @param result defines the Color4 to fill the result in
  5687. * @returns the result Color4
  5688. */
  5689. multiplyToRef(color: Color4, result: Color4): Color4;
  5690. /**
  5691. * Creates a string with the Color4 current values
  5692. * @returns the string representation of the Color4 object
  5693. */
  5694. toString(): string;
  5695. /**
  5696. * Returns the string "Color4"
  5697. * @returns "Color4"
  5698. */
  5699. getClassName(): string;
  5700. /**
  5701. * Compute the Color4 hash code
  5702. * @returns an unique number that can be used to hash Color4 objects
  5703. */
  5704. getHashCode(): number;
  5705. /**
  5706. * Creates a new Color4 copied from the current one
  5707. * @returns a new Color4 object
  5708. */
  5709. clone(): Color4;
  5710. /**
  5711. * Copies the given Color4 values into the current one
  5712. * @param source defines the source Color4 object
  5713. * @returns the current updated Color4 object
  5714. */
  5715. copyFrom(source: Color4): Color4;
  5716. /**
  5717. * Copies the given float values into the current one
  5718. * @param r defines the red component to read from
  5719. * @param g defines the green component to read from
  5720. * @param b defines the blue component to read from
  5721. * @param a defines the alpha component to read from
  5722. * @returns the current updated Color4 object
  5723. */
  5724. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Copies the given float values into the current one
  5727. * @param r defines the red component to read from
  5728. * @param g defines the green component to read from
  5729. * @param b defines the blue component to read from
  5730. * @param a defines the alpha component to read from
  5731. * @returns the current updated Color4 object
  5732. */
  5733. set(r: number, g: number, b: number, a: number): Color4;
  5734. /**
  5735. * Compute the Color4 hexadecimal code as a string
  5736. * @returns a string containing the hexadecimal representation of the Color4 object
  5737. */
  5738. toHexString(): string;
  5739. /**
  5740. * Computes a new Color4 converted from the current one to linear space
  5741. * @returns a new Color4 object
  5742. */
  5743. toLinearSpace(): Color4;
  5744. /**
  5745. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5746. * @param convertedColor defines the Color4 object where to store the linear space version
  5747. * @returns the unmodified Color4
  5748. */
  5749. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5750. /**
  5751. * Computes a new Color4 converted from the current one to gamma space
  5752. * @returns a new Color4 object
  5753. */
  5754. toGammaSpace(): Color4;
  5755. /**
  5756. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5757. * @param convertedColor defines the Color4 object where to store the gamma space version
  5758. * @returns the unmodified Color4
  5759. */
  5760. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5761. /**
  5762. * Creates a new Color4 from the string containing valid hexadecimal values
  5763. * @param hex defines a string containing valid hexadecimal values
  5764. * @returns a new Color4 object
  5765. */
  5766. static FromHexString(hex: string): Color4;
  5767. /**
  5768. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5769. * @param left defines the start value
  5770. * @param right defines the end value
  5771. * @param amount defines the gradient factor
  5772. * @returns a new Color4 object
  5773. */
  5774. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5775. /**
  5776. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5777. * @param left defines the start value
  5778. * @param right defines the end value
  5779. * @param amount defines the gradient factor
  5780. * @param result defines the Color4 object where to store data
  5781. */
  5782. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5783. /**
  5784. * Creates a new Color4 from a Color3 and an alpha value
  5785. * @param color3 defines the source Color3 to read from
  5786. * @param alpha defines the alpha component (1.0 by default)
  5787. * @returns a new Color4 object
  5788. */
  5789. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5790. /**
  5791. * Creates a new Color4 from the starting index element of the given array
  5792. * @param array defines the source array to read from
  5793. * @param offset defines the offset in the source array
  5794. * @returns a new Color4 object
  5795. */
  5796. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5797. /**
  5798. * Creates a new Color3 from integer values (< 256)
  5799. * @param r defines the red component to read from (value between 0 and 255)
  5800. * @param g defines the green component to read from (value between 0 and 255)
  5801. * @param b defines the blue component to read from (value between 0 and 255)
  5802. * @param a defines the alpha component to read from (value between 0 and 255)
  5803. * @returns a new Color3 object
  5804. */
  5805. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5806. /**
  5807. * Check the content of a given array and convert it to an array containing RGBA data
  5808. * If the original array was already containing count * 4 values then it is returned directly
  5809. * @param colors defines the array to check
  5810. * @param count defines the number of RGBA data to expect
  5811. * @returns an array containing count * 4 values (RGBA)
  5812. */
  5813. static CheckColors4(colors: number[], count: number): number[];
  5814. }
  5815. /**
  5816. * @hidden
  5817. */
  5818. export class TmpColors {
  5819. static Color3: Color3[];
  5820. static Color4: Color4[];
  5821. }
  5822. }
  5823. declare module BABYLON {
  5824. /**
  5825. * Defines an interface which represents an animation key frame
  5826. */
  5827. export interface IAnimationKey {
  5828. /**
  5829. * Frame of the key frame
  5830. */
  5831. frame: number;
  5832. /**
  5833. * Value at the specifies key frame
  5834. */
  5835. value: any;
  5836. /**
  5837. * The input tangent for the cubic hermite spline
  5838. */
  5839. inTangent?: any;
  5840. /**
  5841. * The output tangent for the cubic hermite spline
  5842. */
  5843. outTangent?: any;
  5844. /**
  5845. * The animation interpolation type
  5846. */
  5847. interpolation?: AnimationKeyInterpolation;
  5848. }
  5849. /**
  5850. * Enum for the animation key frame interpolation type
  5851. */
  5852. export enum AnimationKeyInterpolation {
  5853. /**
  5854. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5855. */
  5856. STEP = 1
  5857. }
  5858. }
  5859. declare module BABYLON {
  5860. /**
  5861. * Represents the range of an animation
  5862. */
  5863. export class AnimationRange {
  5864. /**The name of the animation range**/
  5865. name: string;
  5866. /**The starting frame of the animation */
  5867. from: number;
  5868. /**The ending frame of the animation*/
  5869. to: number;
  5870. /**
  5871. * Initializes the range of an animation
  5872. * @param name The name of the animation range
  5873. * @param from The starting frame of the animation
  5874. * @param to The ending frame of the animation
  5875. */
  5876. constructor(
  5877. /**The name of the animation range**/
  5878. name: string,
  5879. /**The starting frame of the animation */
  5880. from: number,
  5881. /**The ending frame of the animation*/
  5882. to: number);
  5883. /**
  5884. * Makes a copy of the animation range
  5885. * @returns A copy of the animation range
  5886. */
  5887. clone(): AnimationRange;
  5888. }
  5889. }
  5890. declare module BABYLON {
  5891. /**
  5892. * Composed of a frame, and an action function
  5893. */
  5894. export class AnimationEvent {
  5895. /** The frame for which the event is triggered **/
  5896. frame: number;
  5897. /** The event to perform when triggered **/
  5898. action: (currentFrame: number) => void;
  5899. /** Specifies if the event should be triggered only once**/
  5900. onlyOnce?: boolean | undefined;
  5901. /**
  5902. * Specifies if the animation event is done
  5903. */
  5904. isDone: boolean;
  5905. /**
  5906. * Initializes the animation event
  5907. * @param frame The frame for which the event is triggered
  5908. * @param action The event to perform when triggered
  5909. * @param onlyOnce Specifies if the event should be triggered only once
  5910. */
  5911. constructor(
  5912. /** The frame for which the event is triggered **/
  5913. frame: number,
  5914. /** The event to perform when triggered **/
  5915. action: (currentFrame: number) => void,
  5916. /** Specifies if the event should be triggered only once**/
  5917. onlyOnce?: boolean | undefined);
  5918. /** @hidden */
  5919. _clone(): AnimationEvent;
  5920. }
  5921. }
  5922. declare module BABYLON {
  5923. /**
  5924. * Interface used to define a behavior
  5925. */
  5926. export interface Behavior<T> {
  5927. /** gets or sets behavior's name */
  5928. name: string;
  5929. /**
  5930. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5931. */
  5932. init(): void;
  5933. /**
  5934. * Called when the behavior is attached to a target
  5935. * @param target defines the target where the behavior is attached to
  5936. */
  5937. attach(target: T): void;
  5938. /**
  5939. * Called when the behavior is detached from its target
  5940. */
  5941. detach(): void;
  5942. }
  5943. /**
  5944. * Interface implemented by classes supporting behaviors
  5945. */
  5946. export interface IBehaviorAware<T> {
  5947. /**
  5948. * Attach a behavior
  5949. * @param behavior defines the behavior to attach
  5950. * @returns the current host
  5951. */
  5952. addBehavior(behavior: Behavior<T>): T;
  5953. /**
  5954. * Remove a behavior from the current object
  5955. * @param behavior defines the behavior to detach
  5956. * @returns the current host
  5957. */
  5958. removeBehavior(behavior: Behavior<T>): T;
  5959. /**
  5960. * Gets a behavior using its name to search
  5961. * @param name defines the name to search
  5962. * @returns the behavior or null if not found
  5963. */
  5964. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5965. }
  5966. }
  5967. declare module BABYLON {
  5968. /**
  5969. * Defines an array and its length.
  5970. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5971. */
  5972. export interface ISmartArrayLike<T> {
  5973. /**
  5974. * The data of the array.
  5975. */
  5976. data: Array<T>;
  5977. /**
  5978. * The active length of the array.
  5979. */
  5980. length: number;
  5981. }
  5982. /**
  5983. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5984. */
  5985. export class SmartArray<T> implements ISmartArrayLike<T> {
  5986. /**
  5987. * The full set of data from the array.
  5988. */
  5989. data: Array<T>;
  5990. /**
  5991. * The active length of the array.
  5992. */
  5993. length: number;
  5994. protected _id: number;
  5995. /**
  5996. * Instantiates a Smart Array.
  5997. * @param capacity defines the default capacity of the array.
  5998. */
  5999. constructor(capacity: number);
  6000. /**
  6001. * Pushes a value at the end of the active data.
  6002. * @param value defines the object to push in the array.
  6003. */
  6004. push(value: T): void;
  6005. /**
  6006. * Iterates over the active data and apply the lambda to them.
  6007. * @param func defines the action to apply on each value.
  6008. */
  6009. forEach(func: (content: T) => void): void;
  6010. /**
  6011. * Sorts the full sets of data.
  6012. * @param compareFn defines the comparison function to apply.
  6013. */
  6014. sort(compareFn: (a: T, b: T) => number): void;
  6015. /**
  6016. * Resets the active data to an empty array.
  6017. */
  6018. reset(): void;
  6019. /**
  6020. * Releases all the data from the array as well as the array.
  6021. */
  6022. dispose(): void;
  6023. /**
  6024. * Concats the active data with a given array.
  6025. * @param array defines the data to concatenate with.
  6026. */
  6027. concat(array: any): void;
  6028. /**
  6029. * Returns the position of a value in the active data.
  6030. * @param value defines the value to find the index for
  6031. * @returns the index if found in the active data otherwise -1
  6032. */
  6033. indexOf(value: T): number;
  6034. /**
  6035. * Returns whether an element is part of the active data.
  6036. * @param value defines the value to look for
  6037. * @returns true if found in the active data otherwise false
  6038. */
  6039. contains(value: T): boolean;
  6040. private static _GlobalId;
  6041. }
  6042. /**
  6043. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6044. * The data in this array can only be present once
  6045. */
  6046. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6047. private _duplicateId;
  6048. /**
  6049. * Pushes a value at the end of the active data.
  6050. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6051. * @param value defines the object to push in the array.
  6052. */
  6053. push(value: T): void;
  6054. /**
  6055. * Pushes a value at the end of the active data.
  6056. * If the data is already present, it won t be added again
  6057. * @param value defines the object to push in the array.
  6058. * @returns true if added false if it was already present
  6059. */
  6060. pushNoDuplicate(value: T): boolean;
  6061. /**
  6062. * Resets the active data to an empty array.
  6063. */
  6064. reset(): void;
  6065. /**
  6066. * Concats the active data with a given array.
  6067. * This ensures no dupplicate will be present in the result.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concatWithNoDuplicate(array: any): void;
  6071. }
  6072. }
  6073. declare module BABYLON {
  6074. /**
  6075. * @ignore
  6076. * This is a list of all the different input types that are available in the application.
  6077. * Fo instance: ArcRotateCameraGamepadInput...
  6078. */
  6079. export var CameraInputTypes: {};
  6080. /**
  6081. * This is the contract to implement in order to create a new input class.
  6082. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6083. */
  6084. export interface ICameraInput<TCamera extends Camera> {
  6085. /**
  6086. * Defines the camera the input is attached to.
  6087. */
  6088. camera: Nullable<TCamera>;
  6089. /**
  6090. * Gets the class name of the current intput.
  6091. * @returns the class name
  6092. */
  6093. getClassName(): string;
  6094. /**
  6095. * Get the friendly name associated with the input class.
  6096. * @returns the input friendly name
  6097. */
  6098. getSimpleName(): string;
  6099. /**
  6100. * Attach the input controls to a specific dom element to get the input from.
  6101. * @param element Defines the element the controls should be listened from
  6102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6103. */
  6104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6105. /**
  6106. * Detach the current controls from the specified dom element.
  6107. * @param element Defines the element to stop listening the inputs from
  6108. */
  6109. detachControl(element: Nullable<HTMLElement>): void;
  6110. /**
  6111. * Update the current camera state depending on the inputs that have been used this frame.
  6112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6113. */
  6114. checkInputs?: () => void;
  6115. }
  6116. /**
  6117. * Represents a map of input types to input instance or input index to input instance.
  6118. */
  6119. export interface CameraInputsMap<TCamera extends Camera> {
  6120. /**
  6121. * Accessor to the input by input type.
  6122. */
  6123. [name: string]: ICameraInput<TCamera>;
  6124. /**
  6125. * Accessor to the input by input index.
  6126. */
  6127. [idx: number]: ICameraInput<TCamera>;
  6128. }
  6129. /**
  6130. * This represents the input manager used within a camera.
  6131. * It helps dealing with all the different kind of input attached to a camera.
  6132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6133. */
  6134. export class CameraInputsManager<TCamera extends Camera> {
  6135. /**
  6136. * Defines the list of inputs attahed to the camera.
  6137. */
  6138. attached: CameraInputsMap<TCamera>;
  6139. /**
  6140. * Defines the dom element the camera is collecting inputs from.
  6141. * This is null if the controls have not been attached.
  6142. */
  6143. attachedElement: Nullable<HTMLElement>;
  6144. /**
  6145. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. noPreventDefault: boolean;
  6148. /**
  6149. * Defined the camera the input manager belongs to.
  6150. */
  6151. camera: TCamera;
  6152. /**
  6153. * Update the current camera state depending on the inputs that have been used this frame.
  6154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6155. */
  6156. checkInputs: () => void;
  6157. /**
  6158. * Instantiate a new Camera Input Manager.
  6159. * @param camera Defines the camera the input manager blongs to
  6160. */
  6161. constructor(camera: TCamera);
  6162. /**
  6163. * Add an input method to a camera
  6164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6165. * @param input camera input method
  6166. */
  6167. add(input: ICameraInput<TCamera>): void;
  6168. /**
  6169. * Remove a specific input method from a camera
  6170. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6171. * @param inputToRemove camera input method
  6172. */
  6173. remove(inputToRemove: ICameraInput<TCamera>): void;
  6174. /**
  6175. * Remove a specific input type from a camera
  6176. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6177. * @param inputType the type of the input to remove
  6178. */
  6179. removeByType(inputType: string): void;
  6180. private _addCheckInputs;
  6181. /**
  6182. * Attach the input controls to the currently attached dom element to listen the events from.
  6183. * @param input Defines the input to attach
  6184. */
  6185. attachInput(input: ICameraInput<TCamera>): void;
  6186. /**
  6187. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6188. * @param element Defines the dom element to collect the events from
  6189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6190. */
  6191. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6192. /**
  6193. * Detach the current manager inputs controls from a specific dom element.
  6194. * @param element Defines the dom element to collect the events from
  6195. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6196. */
  6197. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6198. /**
  6199. * Rebuild the dynamic inputCheck function from the current list of
  6200. * defined inputs in the manager.
  6201. */
  6202. rebuildInputCheck(): void;
  6203. /**
  6204. * Remove all attached input methods from a camera
  6205. */
  6206. clear(): void;
  6207. /**
  6208. * Serialize the current input manager attached to a camera.
  6209. * This ensures than once parsed,
  6210. * the input associated to the camera will be identical to the current ones
  6211. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6212. */
  6213. serialize(serializedCamera: any): void;
  6214. /**
  6215. * Parses an input manager serialized JSON to restore the previous list of inputs
  6216. * and states associated to a camera.
  6217. * @param parsedCamera Defines the JSON to parse
  6218. */
  6219. parse(parsedCamera: any): void;
  6220. }
  6221. }
  6222. declare module BABYLON {
  6223. /**
  6224. * Class used to store data that will be store in GPU memory
  6225. */
  6226. export class Buffer {
  6227. private _engine;
  6228. private _buffer;
  6229. /** @hidden */
  6230. _data: Nullable<DataArray>;
  6231. private _updatable;
  6232. private _instanced;
  6233. private _divisor;
  6234. /**
  6235. * Gets the byte stride.
  6236. */
  6237. readonly byteStride: number;
  6238. /**
  6239. * Constructor
  6240. * @param engine the engine
  6241. * @param data the data to use for this buffer
  6242. * @param updatable whether the data is updatable
  6243. * @param stride the stride (optional)
  6244. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6245. * @param instanced whether the buffer is instanced (optional)
  6246. * @param useBytes set to true if the stride in in bytes (optional)
  6247. * @param divisor sets an optional divisor for instances (1 by default)
  6248. */
  6249. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6250. /**
  6251. * Create a new VertexBuffer based on the current buffer
  6252. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6253. * @param offset defines offset in the buffer (0 by default)
  6254. * @param size defines the size in floats of attributes (position is 3 for instance)
  6255. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6256. * @param instanced defines if the vertex buffer contains indexed data
  6257. * @param useBytes defines if the offset and stride are in bytes *
  6258. * @param divisor sets an optional divisor for instances (1 by default)
  6259. * @returns the new vertex buffer
  6260. */
  6261. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6262. /**
  6263. * Gets a boolean indicating if the Buffer is updatable?
  6264. * @returns true if the buffer is updatable
  6265. */
  6266. isUpdatable(): boolean;
  6267. /**
  6268. * Gets current buffer's data
  6269. * @returns a DataArray or null
  6270. */
  6271. getData(): Nullable<DataArray>;
  6272. /**
  6273. * Gets underlying native buffer
  6274. * @returns underlying native buffer
  6275. */
  6276. getBuffer(): Nullable<DataBuffer>;
  6277. /**
  6278. * Gets the stride in float32 units (i.e. byte stride / 4).
  6279. * May not be an integer if the byte stride is not divisible by 4.
  6280. * @returns the stride in float32 units
  6281. * @deprecated Please use byteStride instead.
  6282. */
  6283. getStrideSize(): number;
  6284. /**
  6285. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6286. * @param data defines the data to store
  6287. */
  6288. create(data?: Nullable<DataArray>): void;
  6289. /** @hidden */
  6290. _rebuild(): void;
  6291. /**
  6292. * Update current buffer data
  6293. * @param data defines the data to store
  6294. */
  6295. update(data: DataArray): void;
  6296. /**
  6297. * Updates the data directly.
  6298. * @param data the new data
  6299. * @param offset the new offset
  6300. * @param vertexCount the vertex count (optional)
  6301. * @param useBytes set to true if the offset is in bytes
  6302. */
  6303. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6304. /**
  6305. * Release all resources
  6306. */
  6307. dispose(): void;
  6308. }
  6309. /**
  6310. * Specialized buffer used to store vertex data
  6311. */
  6312. export class VertexBuffer {
  6313. /** @hidden */
  6314. _buffer: Buffer;
  6315. private _kind;
  6316. private _size;
  6317. private _ownsBuffer;
  6318. private _instanced;
  6319. private _instanceDivisor;
  6320. /**
  6321. * The byte type.
  6322. */
  6323. static readonly BYTE: number;
  6324. /**
  6325. * The unsigned byte type.
  6326. */
  6327. static readonly UNSIGNED_BYTE: number;
  6328. /**
  6329. * The short type.
  6330. */
  6331. static readonly SHORT: number;
  6332. /**
  6333. * The unsigned short type.
  6334. */
  6335. static readonly UNSIGNED_SHORT: number;
  6336. /**
  6337. * The integer type.
  6338. */
  6339. static readonly INT: number;
  6340. /**
  6341. * The unsigned integer type.
  6342. */
  6343. static readonly UNSIGNED_INT: number;
  6344. /**
  6345. * The float type.
  6346. */
  6347. static readonly FLOAT: number;
  6348. /**
  6349. * Gets or sets the instance divisor when in instanced mode
  6350. */
  6351. instanceDivisor: number;
  6352. /**
  6353. * Gets the byte stride.
  6354. */
  6355. readonly byteStride: number;
  6356. /**
  6357. * Gets the byte offset.
  6358. */
  6359. readonly byteOffset: number;
  6360. /**
  6361. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6362. */
  6363. readonly normalized: boolean;
  6364. /**
  6365. * Gets the data type of each component in the array.
  6366. */
  6367. readonly type: number;
  6368. /**
  6369. * Constructor
  6370. * @param engine the engine
  6371. * @param data the data to use for this vertex buffer
  6372. * @param kind the vertex buffer kind
  6373. * @param updatable whether the data is updatable
  6374. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6375. * @param stride the stride (optional)
  6376. * @param instanced whether the buffer is instanced (optional)
  6377. * @param offset the offset of the data (optional)
  6378. * @param size the number of components (optional)
  6379. * @param type the type of the component (optional)
  6380. * @param normalized whether the data contains normalized data (optional)
  6381. * @param useBytes set to true if stride and offset are in bytes (optional)
  6382. * @param divisor defines the instance divisor to use (1 by default)
  6383. */
  6384. 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);
  6385. /** @hidden */
  6386. _rebuild(): void;
  6387. /**
  6388. * Returns the kind of the VertexBuffer (string)
  6389. * @returns a string
  6390. */
  6391. getKind(): string;
  6392. /**
  6393. * Gets a boolean indicating if the VertexBuffer is updatable?
  6394. * @returns true if the buffer is updatable
  6395. */
  6396. isUpdatable(): boolean;
  6397. /**
  6398. * Gets current buffer's data
  6399. * @returns a DataArray or null
  6400. */
  6401. getData(): Nullable<DataArray>;
  6402. /**
  6403. * Gets underlying native buffer
  6404. * @returns underlying native buffer
  6405. */
  6406. getBuffer(): Nullable<DataBuffer>;
  6407. /**
  6408. * Gets the stride in float32 units (i.e. byte stride / 4).
  6409. * May not be an integer if the byte stride is not divisible by 4.
  6410. * @returns the stride in float32 units
  6411. * @deprecated Please use byteStride instead.
  6412. */
  6413. getStrideSize(): number;
  6414. /**
  6415. * Returns the offset as a multiple of the type byte length.
  6416. * @returns the offset in bytes
  6417. * @deprecated Please use byteOffset instead.
  6418. */
  6419. getOffset(): number;
  6420. /**
  6421. * Returns the number of components per vertex attribute (integer)
  6422. * @returns the size in float
  6423. */
  6424. getSize(): number;
  6425. /**
  6426. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6427. * @returns true if this buffer is instanced
  6428. */
  6429. getIsInstanced(): boolean;
  6430. /**
  6431. * Returns the instancing divisor, zero for non-instanced (integer).
  6432. * @returns a number
  6433. */
  6434. getInstanceDivisor(): number;
  6435. /**
  6436. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6437. * @param data defines the data to store
  6438. */
  6439. create(data?: DataArray): void;
  6440. /**
  6441. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6442. * This function will create a new buffer if the current one is not updatable
  6443. * @param data defines the data to store
  6444. */
  6445. update(data: DataArray): void;
  6446. /**
  6447. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6448. * Returns the directly updated WebGLBuffer.
  6449. * @param data the new data
  6450. * @param offset the new offset
  6451. * @param useBytes set to true if the offset is in bytes
  6452. */
  6453. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6454. /**
  6455. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6456. */
  6457. dispose(): void;
  6458. /**
  6459. * Enumerates each value of this vertex buffer as numbers.
  6460. * @param count the number of values to enumerate
  6461. * @param callback the callback function called for each value
  6462. */
  6463. forEach(count: number, callback: (value: number, index: number) => void): void;
  6464. /**
  6465. * Positions
  6466. */
  6467. static readonly PositionKind: string;
  6468. /**
  6469. * Normals
  6470. */
  6471. static readonly NormalKind: string;
  6472. /**
  6473. * Tangents
  6474. */
  6475. static readonly TangentKind: string;
  6476. /**
  6477. * Texture coordinates
  6478. */
  6479. static readonly UVKind: string;
  6480. /**
  6481. * Texture coordinates 2
  6482. */
  6483. static readonly UV2Kind: string;
  6484. /**
  6485. * Texture coordinates 3
  6486. */
  6487. static readonly UV3Kind: string;
  6488. /**
  6489. * Texture coordinates 4
  6490. */
  6491. static readonly UV4Kind: string;
  6492. /**
  6493. * Texture coordinates 5
  6494. */
  6495. static readonly UV5Kind: string;
  6496. /**
  6497. * Texture coordinates 6
  6498. */
  6499. static readonly UV6Kind: string;
  6500. /**
  6501. * Colors
  6502. */
  6503. static readonly ColorKind: string;
  6504. /**
  6505. * Matrix indices (for bones)
  6506. */
  6507. static readonly MatricesIndicesKind: string;
  6508. /**
  6509. * Matrix weights (for bones)
  6510. */
  6511. static readonly MatricesWeightsKind: string;
  6512. /**
  6513. * Additional matrix indices (for bones)
  6514. */
  6515. static readonly MatricesIndicesExtraKind: string;
  6516. /**
  6517. * Additional matrix weights (for bones)
  6518. */
  6519. static readonly MatricesWeightsExtraKind: string;
  6520. /**
  6521. * Deduces the stride given a kind.
  6522. * @param kind The kind string to deduce
  6523. * @returns The deduced stride
  6524. */
  6525. static DeduceStride(kind: string): number;
  6526. /**
  6527. * Gets the byte length of the given type.
  6528. * @param type the type
  6529. * @returns the number of bytes
  6530. */
  6531. static GetTypeByteLength(type: number): number;
  6532. /**
  6533. * Enumerates each value of the given parameters as numbers.
  6534. * @param data the data to enumerate
  6535. * @param byteOffset the byte offset of the data
  6536. * @param byteStride the byte stride of the data
  6537. * @param componentCount the number of components per element
  6538. * @param componentType the type of the component
  6539. * @param count the number of values to enumerate
  6540. * @param normalized whether the data is normalized
  6541. * @param callback the callback function called for each value
  6542. */
  6543. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6544. private static _GetFloatValue;
  6545. }
  6546. }
  6547. declare module BABYLON {
  6548. /**
  6549. * @hidden
  6550. */
  6551. export class IntersectionInfo {
  6552. bu: Nullable<number>;
  6553. bv: Nullable<number>;
  6554. distance: number;
  6555. faceId: number;
  6556. subMeshId: number;
  6557. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6558. }
  6559. }
  6560. declare module BABYLON {
  6561. /**
  6562. * Represens a plane by the equation ax + by + cz + d = 0
  6563. */
  6564. export class Plane {
  6565. private static _TmpMatrix;
  6566. /**
  6567. * Normal of the plane (a,b,c)
  6568. */
  6569. normal: Vector3;
  6570. /**
  6571. * d component of the plane
  6572. */
  6573. d: number;
  6574. /**
  6575. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6576. * @param a a component of the plane
  6577. * @param b b component of the plane
  6578. * @param c c component of the plane
  6579. * @param d d component of the plane
  6580. */
  6581. constructor(a: number, b: number, c: number, d: number);
  6582. /**
  6583. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6584. */
  6585. asArray(): number[];
  6586. /**
  6587. * @returns a new plane copied from the current Plane.
  6588. */
  6589. clone(): Plane;
  6590. /**
  6591. * @returns the string "Plane".
  6592. */
  6593. getClassName(): string;
  6594. /**
  6595. * @returns the Plane hash code.
  6596. */
  6597. getHashCode(): number;
  6598. /**
  6599. * Normalize the current Plane in place.
  6600. * @returns the updated Plane.
  6601. */
  6602. normalize(): Plane;
  6603. /**
  6604. * Applies a transformation the plane and returns the result
  6605. * @param transformation the transformation matrix to be applied to the plane
  6606. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6607. */
  6608. transform(transformation: DeepImmutable<Matrix>): Plane;
  6609. /**
  6610. * Calcualtte the dot product between the point and the plane normal
  6611. * @param point point to calculate the dot product with
  6612. * @returns the dot product (float) of the point coordinates and the plane normal.
  6613. */
  6614. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6615. /**
  6616. * Updates the current Plane from the plane defined by the three given points.
  6617. * @param point1 one of the points used to contruct the plane
  6618. * @param point2 one of the points used to contruct the plane
  6619. * @param point3 one of the points used to contruct the plane
  6620. * @returns the updated Plane.
  6621. */
  6622. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6623. /**
  6624. * Checks if the plane is facing a given direction
  6625. * @param direction the direction to check if the plane is facing
  6626. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6627. * @returns True is the vector "direction" is the same side than the plane normal.
  6628. */
  6629. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6630. /**
  6631. * Calculates the distance to a point
  6632. * @param point point to calculate distance to
  6633. * @returns the signed distance (float) from the given point to the Plane.
  6634. */
  6635. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6636. /**
  6637. * Creates a plane from an array
  6638. * @param array the array to create a plane from
  6639. * @returns a new Plane from the given array.
  6640. */
  6641. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6642. /**
  6643. * Creates a plane from three points
  6644. * @param point1 point used to create the plane
  6645. * @param point2 point used to create the plane
  6646. * @param point3 point used to create the plane
  6647. * @returns a new Plane defined by the three given points.
  6648. */
  6649. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6650. /**
  6651. * Creates a plane from an origin point and a normal
  6652. * @param origin origin of the plane to be constructed
  6653. * @param normal normal of the plane to be constructed
  6654. * @returns a new Plane the normal vector to this plane at the given origin point.
  6655. * Note : the vector "normal" is updated because normalized.
  6656. */
  6657. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6658. /**
  6659. * Calculates the distance from a plane and a point
  6660. * @param origin origin of the plane to be constructed
  6661. * @param normal normal of the plane to be constructed
  6662. * @param point point to calculate distance to
  6663. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6664. */
  6665. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6666. }
  6667. }
  6668. declare module BABYLON {
  6669. /**
  6670. * Class used to store bounding sphere information
  6671. */
  6672. export class BoundingSphere {
  6673. /**
  6674. * Gets the center of the bounding sphere in local space
  6675. */
  6676. readonly center: Vector3;
  6677. /**
  6678. * Radius of the bounding sphere in local space
  6679. */
  6680. radius: number;
  6681. /**
  6682. * Gets the center of the bounding sphere in world space
  6683. */
  6684. readonly centerWorld: Vector3;
  6685. /**
  6686. * Radius of the bounding sphere in world space
  6687. */
  6688. radiusWorld: number;
  6689. /**
  6690. * Gets the minimum vector in local space
  6691. */
  6692. readonly minimum: Vector3;
  6693. /**
  6694. * Gets the maximum vector in local space
  6695. */
  6696. readonly maximum: Vector3;
  6697. private _worldMatrix;
  6698. private static readonly TmpVector3;
  6699. /**
  6700. * Creates a new bounding sphere
  6701. * @param min defines the minimum vector (in local space)
  6702. * @param max defines the maximum vector (in local space)
  6703. * @param worldMatrix defines the new world matrix
  6704. */
  6705. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6706. /**
  6707. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6708. * @param min defines the new minimum vector (in local space)
  6709. * @param max defines the new maximum vector (in local space)
  6710. * @param worldMatrix defines the new world matrix
  6711. */
  6712. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6713. /**
  6714. * Scale the current bounding sphere by applying a scale factor
  6715. * @param factor defines the scale factor to apply
  6716. * @returns the current bounding box
  6717. */
  6718. scale(factor: number): BoundingSphere;
  6719. /**
  6720. * Gets the world matrix of the bounding box
  6721. * @returns a matrix
  6722. */
  6723. getWorldMatrix(): DeepImmutable<Matrix>;
  6724. /** @hidden */
  6725. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6726. /**
  6727. * Tests if the bounding sphere is intersecting the frustum planes
  6728. * @param frustumPlanes defines the frustum planes to test
  6729. * @returns true if there is an intersection
  6730. */
  6731. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6732. /**
  6733. * Tests if the bounding sphere center is in between the frustum planes.
  6734. * Used for optimistic fast inclusion.
  6735. * @param frustumPlanes defines the frustum planes to test
  6736. * @returns true if the sphere center is in between the frustum planes
  6737. */
  6738. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6739. /**
  6740. * Tests if a point is inside the bounding sphere
  6741. * @param point defines the point to test
  6742. * @returns true if the point is inside the bounding sphere
  6743. */
  6744. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6745. /**
  6746. * Checks if two sphere intersct
  6747. * @param sphere0 sphere 0
  6748. * @param sphere1 sphere 1
  6749. * @returns true if the speres intersect
  6750. */
  6751. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6752. }
  6753. }
  6754. declare module BABYLON {
  6755. /**
  6756. * Class used to store bounding box information
  6757. */
  6758. export class BoundingBox implements ICullable {
  6759. /**
  6760. * Gets the 8 vectors representing the bounding box in local space
  6761. */
  6762. readonly vectors: Vector3[];
  6763. /**
  6764. * Gets the center of the bounding box in local space
  6765. */
  6766. readonly center: Vector3;
  6767. /**
  6768. * Gets the center of the bounding box in world space
  6769. */
  6770. readonly centerWorld: Vector3;
  6771. /**
  6772. * Gets the extend size in local space
  6773. */
  6774. readonly extendSize: Vector3;
  6775. /**
  6776. * Gets the extend size in world space
  6777. */
  6778. readonly extendSizeWorld: Vector3;
  6779. /**
  6780. * Gets the OBB (object bounding box) directions
  6781. */
  6782. readonly directions: Vector3[];
  6783. /**
  6784. * Gets the 8 vectors representing the bounding box in world space
  6785. */
  6786. readonly vectorsWorld: Vector3[];
  6787. /**
  6788. * Gets the minimum vector in world space
  6789. */
  6790. readonly minimumWorld: Vector3;
  6791. /**
  6792. * Gets the maximum vector in world space
  6793. */
  6794. readonly maximumWorld: Vector3;
  6795. /**
  6796. * Gets the minimum vector in local space
  6797. */
  6798. readonly minimum: Vector3;
  6799. /**
  6800. * Gets the maximum vector in local space
  6801. */
  6802. readonly maximum: Vector3;
  6803. private _worldMatrix;
  6804. private static readonly TmpVector3;
  6805. /**
  6806. * @hidden
  6807. */
  6808. _tag: number;
  6809. /**
  6810. * Creates a new bounding box
  6811. * @param min defines the minimum vector (in local space)
  6812. * @param max defines the maximum vector (in local space)
  6813. * @param worldMatrix defines the new world matrix
  6814. */
  6815. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6816. /**
  6817. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6818. * @param min defines the new minimum vector (in local space)
  6819. * @param max defines the new maximum vector (in local space)
  6820. * @param worldMatrix defines the new world matrix
  6821. */
  6822. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6823. /**
  6824. * Scale the current bounding box by applying a scale factor
  6825. * @param factor defines the scale factor to apply
  6826. * @returns the current bounding box
  6827. */
  6828. scale(factor: number): BoundingBox;
  6829. /**
  6830. * Gets the world matrix of the bounding box
  6831. * @returns a matrix
  6832. */
  6833. getWorldMatrix(): DeepImmutable<Matrix>;
  6834. /** @hidden */
  6835. _update(world: DeepImmutable<Matrix>): void;
  6836. /**
  6837. * Tests if the bounding box is intersecting the frustum planes
  6838. * @param frustumPlanes defines the frustum planes to test
  6839. * @returns true if there is an intersection
  6840. */
  6841. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6842. /**
  6843. * Tests if the bounding box is entirely inside the frustum planes
  6844. * @param frustumPlanes defines the frustum planes to test
  6845. * @returns true if there is an inclusion
  6846. */
  6847. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6848. /**
  6849. * Tests if a point is inside the bounding box
  6850. * @param point defines the point to test
  6851. * @returns true if the point is inside the bounding box
  6852. */
  6853. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6854. /**
  6855. * Tests if the bounding box intersects with a bounding sphere
  6856. * @param sphere defines the sphere to test
  6857. * @returns true if there is an intersection
  6858. */
  6859. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6860. /**
  6861. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6862. * @param min defines the min vector to use
  6863. * @param max defines the max vector to use
  6864. * @returns true if there is an intersection
  6865. */
  6866. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6867. /**
  6868. * Tests if two bounding boxes are intersections
  6869. * @param box0 defines the first box to test
  6870. * @param box1 defines the second box to test
  6871. * @returns true if there is an intersection
  6872. */
  6873. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6874. /**
  6875. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6876. * @param minPoint defines the minimum vector of the bounding box
  6877. * @param maxPoint defines the maximum vector of the bounding box
  6878. * @param sphereCenter defines the sphere center
  6879. * @param sphereRadius defines the sphere radius
  6880. * @returns true if there is an intersection
  6881. */
  6882. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6883. /**
  6884. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6885. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6886. * @param frustumPlanes defines the frustum planes to test
  6887. * @return true if there is an inclusion
  6888. */
  6889. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6890. /**
  6891. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6892. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @return true if there is an intersection
  6895. */
  6896. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. }
  6898. }
  6899. declare module BABYLON {
  6900. /** @hidden */
  6901. export class Collider {
  6902. /** Define if a collision was found */
  6903. collisionFound: boolean;
  6904. /**
  6905. * Define last intersection point in local space
  6906. */
  6907. intersectionPoint: Vector3;
  6908. /**
  6909. * Define last collided mesh
  6910. */
  6911. collidedMesh: Nullable<AbstractMesh>;
  6912. private _collisionPoint;
  6913. private _planeIntersectionPoint;
  6914. private _tempVector;
  6915. private _tempVector2;
  6916. private _tempVector3;
  6917. private _tempVector4;
  6918. private _edge;
  6919. private _baseToVertex;
  6920. private _destinationPoint;
  6921. private _slidePlaneNormal;
  6922. private _displacementVector;
  6923. /** @hidden */
  6924. _radius: Vector3;
  6925. /** @hidden */
  6926. _retry: number;
  6927. private _velocity;
  6928. private _basePoint;
  6929. private _epsilon;
  6930. /** @hidden */
  6931. _velocityWorldLength: number;
  6932. /** @hidden */
  6933. _basePointWorld: Vector3;
  6934. private _velocityWorld;
  6935. private _normalizedVelocity;
  6936. /** @hidden */
  6937. _initialVelocity: Vector3;
  6938. /** @hidden */
  6939. _initialPosition: Vector3;
  6940. private _nearestDistance;
  6941. private _collisionMask;
  6942. collisionMask: number;
  6943. /**
  6944. * Gets the plane normal used to compute the sliding response (in local space)
  6945. */
  6946. readonly slidePlaneNormal: Vector3;
  6947. /** @hidden */
  6948. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6949. /** @hidden */
  6950. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6951. /** @hidden */
  6952. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6953. /** @hidden */
  6954. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6955. /** @hidden */
  6956. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6957. /** @hidden */
  6958. _getResponse(pos: Vector3, vel: Vector3): void;
  6959. }
  6960. }
  6961. declare module BABYLON {
  6962. /**
  6963. * Interface for cullable objects
  6964. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6965. */
  6966. export interface ICullable {
  6967. /**
  6968. * Checks if the object or part of the object is in the frustum
  6969. * @param frustumPlanes Camera near/planes
  6970. * @returns true if the object is in frustum otherwise false
  6971. */
  6972. isInFrustum(frustumPlanes: Plane[]): boolean;
  6973. /**
  6974. * Checks if a cullable object (mesh...) is in the camera frustum
  6975. * Unlike isInFrustum this cheks the full bounding box
  6976. * @param frustumPlanes Camera near/planes
  6977. * @returns true if the object is in frustum otherwise false
  6978. */
  6979. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6980. }
  6981. /**
  6982. * Info for a bounding data of a mesh
  6983. */
  6984. export class BoundingInfo implements ICullable {
  6985. /**
  6986. * Bounding box for the mesh
  6987. */
  6988. readonly boundingBox: BoundingBox;
  6989. /**
  6990. * Bounding sphere for the mesh
  6991. */
  6992. readonly boundingSphere: BoundingSphere;
  6993. private _isLocked;
  6994. private static readonly TmpVector3;
  6995. /**
  6996. * Constructs bounding info
  6997. * @param minimum min vector of the bounding box/sphere
  6998. * @param maximum max vector of the bounding box/sphere
  6999. * @param worldMatrix defines the new world matrix
  7000. */
  7001. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7002. /**
  7003. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7004. * @param min defines the new minimum vector (in local space)
  7005. * @param max defines the new maximum vector (in local space)
  7006. * @param worldMatrix defines the new world matrix
  7007. */
  7008. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7009. /**
  7010. * min vector of the bounding box/sphere
  7011. */
  7012. readonly minimum: Vector3;
  7013. /**
  7014. * max vector of the bounding box/sphere
  7015. */
  7016. readonly maximum: Vector3;
  7017. /**
  7018. * If the info is locked and won't be updated to avoid perf overhead
  7019. */
  7020. isLocked: boolean;
  7021. /**
  7022. * Updates the bounding sphere and box
  7023. * @param world world matrix to be used to update
  7024. */
  7025. update(world: DeepImmutable<Matrix>): void;
  7026. /**
  7027. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7028. * @param center New center of the bounding info
  7029. * @param extend New extend of the bounding info
  7030. * @returns the current bounding info
  7031. */
  7032. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7033. /**
  7034. * Scale the current bounding info by applying a scale factor
  7035. * @param factor defines the scale factor to apply
  7036. * @returns the current bounding info
  7037. */
  7038. scale(factor: number): BoundingInfo;
  7039. /**
  7040. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7041. * @param frustumPlanes defines the frustum to test
  7042. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7043. * @returns true if the bounding info is in the frustum planes
  7044. */
  7045. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7046. /**
  7047. * Gets the world distance between the min and max points of the bounding box
  7048. */
  7049. readonly diagonalLength: number;
  7050. /**
  7051. * Checks if a cullable object (mesh...) is in the camera frustum
  7052. * Unlike isInFrustum this cheks the full bounding box
  7053. * @param frustumPlanes Camera near/planes
  7054. * @returns true if the object is in frustum otherwise false
  7055. */
  7056. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /** @hidden */
  7058. _checkCollision(collider: Collider): boolean;
  7059. /**
  7060. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7061. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7062. * @param point the point to check intersection with
  7063. * @returns if the point intersects
  7064. */
  7065. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7068. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7069. * @param boundingInfo the bounding info to check intersection with
  7070. * @param precise if the intersection should be done using OBB
  7071. * @returns if the bounding info intersects
  7072. */
  7073. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7074. }
  7075. }
  7076. declare module BABYLON {
  7077. /**
  7078. * Extracts minimum and maximum values from a list of indexed positions
  7079. * @param positions defines the positions to use
  7080. * @param indices defines the indices to the positions
  7081. * @param indexStart defines the start index
  7082. * @param indexCount defines the end index
  7083. * @param bias defines bias value to add to the result
  7084. * @return minimum and maximum values
  7085. */
  7086. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7087. minimum: Vector3;
  7088. maximum: Vector3;
  7089. };
  7090. /**
  7091. * Extracts minimum and maximum values from a list of positions
  7092. * @param positions defines the positions to use
  7093. * @param start defines the start index in the positions array
  7094. * @param count defines the number of positions to handle
  7095. * @param bias defines bias value to add to the result
  7096. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7097. * @return minimum and maximum values
  7098. */
  7099. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7100. minimum: Vector3;
  7101. maximum: Vector3;
  7102. };
  7103. }
  7104. declare module BABYLON {
  7105. /** @hidden */
  7106. export class WebGLDataBuffer extends DataBuffer {
  7107. private _buffer;
  7108. constructor(resource: WebGLBuffer);
  7109. readonly underlyingResource: any;
  7110. }
  7111. }
  7112. declare module BABYLON {
  7113. /** @hidden */
  7114. export class WebGLPipelineContext implements IPipelineContext {
  7115. engine: ThinEngine;
  7116. program: Nullable<WebGLProgram>;
  7117. context?: WebGLRenderingContext;
  7118. vertexShader?: WebGLShader;
  7119. fragmentShader?: WebGLShader;
  7120. isParallelCompiled: boolean;
  7121. onCompiled?: () => void;
  7122. transformFeedback?: WebGLTransformFeedback | null;
  7123. readonly isAsync: boolean;
  7124. readonly isReady: boolean;
  7125. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7126. }
  7127. }
  7128. declare module BABYLON {
  7129. interface ThinEngine {
  7130. /**
  7131. * Create an uniform buffer
  7132. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7133. * @param elements defines the content of the uniform buffer
  7134. * @returns the webGL uniform buffer
  7135. */
  7136. createUniformBuffer(elements: FloatArray): DataBuffer;
  7137. /**
  7138. * Create a dynamic uniform buffer
  7139. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7140. * @param elements defines the content of the uniform buffer
  7141. * @returns the webGL uniform buffer
  7142. */
  7143. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7144. /**
  7145. * Update an existing uniform buffer
  7146. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7147. * @param uniformBuffer defines the target uniform buffer
  7148. * @param elements defines the content to update
  7149. * @param offset defines the offset in the uniform buffer where update should start
  7150. * @param count defines the size of the data to update
  7151. */
  7152. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7153. /**
  7154. * Bind an uniform buffer to the current webGL context
  7155. * @param buffer defines the buffer to bind
  7156. */
  7157. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7158. /**
  7159. * Bind a buffer to the current webGL context at a given location
  7160. * @param buffer defines the buffer to bind
  7161. * @param location defines the index where to bind the buffer
  7162. */
  7163. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7164. /**
  7165. * Bind a specific block at a given index in a specific shader program
  7166. * @param pipelineContext defines the pipeline context to use
  7167. * @param blockName defines the block name
  7168. * @param index defines the index where to bind the block
  7169. */
  7170. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7171. }
  7172. }
  7173. declare module BABYLON {
  7174. /**
  7175. * Uniform buffer objects.
  7176. *
  7177. * Handles blocks of uniform on the GPU.
  7178. *
  7179. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7180. *
  7181. * For more information, please refer to :
  7182. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7183. */
  7184. export class UniformBuffer {
  7185. private _engine;
  7186. private _buffer;
  7187. private _data;
  7188. private _bufferData;
  7189. private _dynamic?;
  7190. private _uniformLocations;
  7191. private _uniformSizes;
  7192. private _uniformLocationPointer;
  7193. private _needSync;
  7194. private _noUBO;
  7195. private _currentEffect;
  7196. /** @hidden */
  7197. _alreadyBound: boolean;
  7198. private static _MAX_UNIFORM_SIZE;
  7199. private static _tempBuffer;
  7200. /**
  7201. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7206. /**
  7207. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7212. /**
  7213. * Lambda to Update a single float in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateFloat: (name: string, x: number) => void;
  7218. /**
  7219. * Lambda to Update a vec2 of float in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update a vec3 of float in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7230. /**
  7231. * Lambda to Update a vec4 of float in a uniform buffer.
  7232. * This is dynamic to allow compat with webgl 1 and 2.
  7233. * You will need to pass the name of the uniform as well as the value.
  7234. */
  7235. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7236. /**
  7237. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7238. * This is dynamic to allow compat with webgl 1 and 2.
  7239. * You will need to pass the name of the uniform as well as the value.
  7240. */
  7241. updateMatrix: (name: string, mat: Matrix) => void;
  7242. /**
  7243. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7244. * This is dynamic to allow compat with webgl 1 and 2.
  7245. * You will need to pass the name of the uniform as well as the value.
  7246. */
  7247. updateVector3: (name: string, vector: Vector3) => void;
  7248. /**
  7249. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7250. * This is dynamic to allow compat with webgl 1 and 2.
  7251. * You will need to pass the name of the uniform as well as the value.
  7252. */
  7253. updateVector4: (name: string, vector: Vector4) => void;
  7254. /**
  7255. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7256. * This is dynamic to allow compat with webgl 1 and 2.
  7257. * You will need to pass the name of the uniform as well as the value.
  7258. */
  7259. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7260. /**
  7261. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7262. * This is dynamic to allow compat with webgl 1 and 2.
  7263. * You will need to pass the name of the uniform as well as the value.
  7264. */
  7265. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7266. /**
  7267. * Instantiates a new Uniform buffer objects.
  7268. *
  7269. * Handles blocks of uniform on the GPU.
  7270. *
  7271. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7272. *
  7273. * For more information, please refer to :
  7274. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7275. * @param engine Define the engine the buffer is associated with
  7276. * @param data Define the data contained in the buffer
  7277. * @param dynamic Define if the buffer is updatable
  7278. */
  7279. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7280. /**
  7281. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7282. * or just falling back on setUniformXXX calls.
  7283. */
  7284. readonly useUbo: boolean;
  7285. /**
  7286. * Indicates if the WebGL underlying uniform buffer is in sync
  7287. * with the javascript cache data.
  7288. */
  7289. readonly isSync: boolean;
  7290. /**
  7291. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7292. * Also, a dynamic UniformBuffer will disable cache verification and always
  7293. * update the underlying WebGL uniform buffer to the GPU.
  7294. * @returns if Dynamic, otherwise false
  7295. */
  7296. isDynamic(): boolean;
  7297. /**
  7298. * The data cache on JS side.
  7299. * @returns the underlying data as a float array
  7300. */
  7301. getData(): Float32Array;
  7302. /**
  7303. * The underlying WebGL Uniform buffer.
  7304. * @returns the webgl buffer
  7305. */
  7306. getBuffer(): Nullable<DataBuffer>;
  7307. /**
  7308. * std140 layout specifies how to align data within an UBO structure.
  7309. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7310. * for specs.
  7311. */
  7312. private _fillAlignment;
  7313. /**
  7314. * Adds an uniform in the buffer.
  7315. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7316. * for the layout to be correct !
  7317. * @param name Name of the uniform, as used in the uniform block in the shader.
  7318. * @param size Data size, or data directly.
  7319. */
  7320. addUniform(name: string, size: number | number[]): void;
  7321. /**
  7322. * Adds a Matrix 4x4 to the uniform buffer.
  7323. * @param name Name of the uniform, as used in the uniform block in the shader.
  7324. * @param mat A 4x4 matrix.
  7325. */
  7326. addMatrix(name: string, mat: Matrix): void;
  7327. /**
  7328. * Adds a vec2 to the uniform buffer.
  7329. * @param name Name of the uniform, as used in the uniform block in the shader.
  7330. * @param x Define the x component value of the vec2
  7331. * @param y Define the y component value of the vec2
  7332. */
  7333. addFloat2(name: string, x: number, y: number): void;
  7334. /**
  7335. * Adds a vec3 to the uniform buffer.
  7336. * @param name Name of the uniform, as used in the uniform block in the shader.
  7337. * @param x Define the x component value of the vec3
  7338. * @param y Define the y component value of the vec3
  7339. * @param z Define the z component value of the vec3
  7340. */
  7341. addFloat3(name: string, x: number, y: number, z: number): void;
  7342. /**
  7343. * Adds a vec3 to the uniform buffer.
  7344. * @param name Name of the uniform, as used in the uniform block in the shader.
  7345. * @param color Define the vec3 from a Color
  7346. */
  7347. addColor3(name: string, color: Color3): void;
  7348. /**
  7349. * Adds a vec4 to the uniform buffer.
  7350. * @param name Name of the uniform, as used in the uniform block in the shader.
  7351. * @param color Define the rgb components from a Color
  7352. * @param alpha Define the a component of the vec4
  7353. */
  7354. addColor4(name: string, color: Color3, alpha: number): void;
  7355. /**
  7356. * Adds a vec3 to the uniform buffer.
  7357. * @param name Name of the uniform, as used in the uniform block in the shader.
  7358. * @param vector Define the vec3 components from a Vector
  7359. */
  7360. addVector3(name: string, vector: Vector3): void;
  7361. /**
  7362. * Adds a Matrix 3x3 to the uniform buffer.
  7363. * @param name Name of the uniform, as used in the uniform block in the shader.
  7364. */
  7365. addMatrix3x3(name: string): void;
  7366. /**
  7367. * Adds a Matrix 2x2 to the uniform buffer.
  7368. * @param name Name of the uniform, as used in the uniform block in the shader.
  7369. */
  7370. addMatrix2x2(name: string): void;
  7371. /**
  7372. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7373. */
  7374. create(): void;
  7375. /** @hidden */
  7376. _rebuild(): void;
  7377. /**
  7378. * Updates the WebGL Uniform Buffer on the GPU.
  7379. * If the `dynamic` flag is set to true, no cache comparison is done.
  7380. * Otherwise, the buffer will be updated only if the cache differs.
  7381. */
  7382. update(): void;
  7383. /**
  7384. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7385. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7386. * @param data Define the flattened data
  7387. * @param size Define the size of the data.
  7388. */
  7389. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7390. private _valueCache;
  7391. private _cacheMatrix;
  7392. private _updateMatrix3x3ForUniform;
  7393. private _updateMatrix3x3ForEffect;
  7394. private _updateMatrix2x2ForEffect;
  7395. private _updateMatrix2x2ForUniform;
  7396. private _updateFloatForEffect;
  7397. private _updateFloatForUniform;
  7398. private _updateFloat2ForEffect;
  7399. private _updateFloat2ForUniform;
  7400. private _updateFloat3ForEffect;
  7401. private _updateFloat3ForUniform;
  7402. private _updateFloat4ForEffect;
  7403. private _updateFloat4ForUniform;
  7404. private _updateMatrixForEffect;
  7405. private _updateMatrixForUniform;
  7406. private _updateVector3ForEffect;
  7407. private _updateVector3ForUniform;
  7408. private _updateVector4ForEffect;
  7409. private _updateVector4ForUniform;
  7410. private _updateColor3ForEffect;
  7411. private _updateColor3ForUniform;
  7412. private _updateColor4ForEffect;
  7413. private _updateColor4ForUniform;
  7414. /**
  7415. * Sets a sampler uniform on the effect.
  7416. * @param name Define the name of the sampler.
  7417. * @param texture Define the texture to set in the sampler
  7418. */
  7419. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7420. /**
  7421. * Directly updates the value of the uniform in the cache AND on the GPU.
  7422. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7423. * @param data Define the flattened data
  7424. */
  7425. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7426. /**
  7427. * Binds this uniform buffer to an effect.
  7428. * @param effect Define the effect to bind the buffer to
  7429. * @param name Name of the uniform block in the shader.
  7430. */
  7431. bindToEffect(effect: Effect, name: string): void;
  7432. /**
  7433. * Disposes the uniform buffer.
  7434. */
  7435. dispose(): void;
  7436. }
  7437. }
  7438. declare module BABYLON {
  7439. /**
  7440. * Enum that determines the text-wrapping mode to use.
  7441. */
  7442. export enum InspectableType {
  7443. /**
  7444. * Checkbox for booleans
  7445. */
  7446. Checkbox = 0,
  7447. /**
  7448. * Sliders for numbers
  7449. */
  7450. Slider = 1,
  7451. /**
  7452. * Vector3
  7453. */
  7454. Vector3 = 2,
  7455. /**
  7456. * Quaternions
  7457. */
  7458. Quaternion = 3,
  7459. /**
  7460. * Color3
  7461. */
  7462. Color3 = 4,
  7463. /**
  7464. * String
  7465. */
  7466. String = 5
  7467. }
  7468. /**
  7469. * Interface used to define custom inspectable properties.
  7470. * This interface is used by the inspector to display custom property grids
  7471. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7472. */
  7473. export interface IInspectable {
  7474. /**
  7475. * Gets the label to display
  7476. */
  7477. label: string;
  7478. /**
  7479. * Gets the name of the property to edit
  7480. */
  7481. propertyName: string;
  7482. /**
  7483. * Gets the type of the editor to use
  7484. */
  7485. type: InspectableType;
  7486. /**
  7487. * Gets the minimum value of the property when using in "slider" mode
  7488. */
  7489. min?: number;
  7490. /**
  7491. * Gets the maximum value of the property when using in "slider" mode
  7492. */
  7493. max?: number;
  7494. /**
  7495. * Gets the setp to use when using in "slider" mode
  7496. */
  7497. step?: number;
  7498. }
  7499. }
  7500. declare module BABYLON {
  7501. /**
  7502. * Class used to provide helper for timing
  7503. */
  7504. export class TimingTools {
  7505. /**
  7506. * Polyfill for setImmediate
  7507. * @param action defines the action to execute after the current execution block
  7508. */
  7509. static SetImmediate(action: () => void): void;
  7510. }
  7511. }
  7512. declare module BABYLON {
  7513. /**
  7514. * Class used to enable instatition of objects by class name
  7515. */
  7516. export class InstantiationTools {
  7517. /**
  7518. * Use this object to register external classes like custom textures or material
  7519. * to allow the laoders to instantiate them
  7520. */
  7521. static RegisteredExternalClasses: {
  7522. [key: string]: Object;
  7523. };
  7524. /**
  7525. * Tries to instantiate a new object from a given class name
  7526. * @param className defines the class name to instantiate
  7527. * @returns the new object or null if the system was not able to do the instantiation
  7528. */
  7529. static Instantiate(className: string): any;
  7530. }
  7531. }
  7532. declare module BABYLON {
  7533. /**
  7534. * Define options used to create a depth texture
  7535. */
  7536. export class DepthTextureCreationOptions {
  7537. /** Specifies whether or not a stencil should be allocated in the texture */
  7538. generateStencil?: boolean;
  7539. /** Specifies whether or not bilinear filtering is enable on the texture */
  7540. bilinearFiltering?: boolean;
  7541. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7542. comparisonFunction?: number;
  7543. /** Specifies if the created texture is a cube texture */
  7544. isCube?: boolean;
  7545. }
  7546. }
  7547. declare module BABYLON {
  7548. interface ThinEngine {
  7549. /**
  7550. * Creates a depth stencil cube texture.
  7551. * This is only available in WebGL 2.
  7552. * @param size The size of face edge in the cube texture.
  7553. * @param options The options defining the cube texture.
  7554. * @returns The cube texture
  7555. */
  7556. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7557. /**
  7558. * Creates a cube texture
  7559. * @param rootUrl defines the url where the files to load is located
  7560. * @param scene defines the current scene
  7561. * @param files defines the list of files to load (1 per face)
  7562. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7563. * @param onLoad defines an optional callback raised when the texture is loaded
  7564. * @param onError defines an optional callback raised if there is an issue to load the texture
  7565. * @param format defines the format of the data
  7566. * @param forcedExtension defines the extension to use to pick the right loader
  7567. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7568. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7569. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7570. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7571. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7572. * @returns the cube texture as an InternalTexture
  7573. */
  7574. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7575. /**
  7576. * Creates a cube texture
  7577. * @param rootUrl defines the url where the files to load is located
  7578. * @param scene defines the current scene
  7579. * @param files defines the list of files to load (1 per face)
  7580. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7581. * @param onLoad defines an optional callback raised when the texture is loaded
  7582. * @param onError defines an optional callback raised if there is an issue to load the texture
  7583. * @param format defines the format of the data
  7584. * @param forcedExtension defines the extension to use to pick the right loader
  7585. * @returns the cube texture as an InternalTexture
  7586. */
  7587. 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;
  7588. /**
  7589. * Creates a cube texture
  7590. * @param rootUrl defines the url where the files to load is located
  7591. * @param scene defines the current scene
  7592. * @param files defines the list of files to load (1 per face)
  7593. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7594. * @param onLoad defines an optional callback raised when the texture is loaded
  7595. * @param onError defines an optional callback raised if there is an issue to load the texture
  7596. * @param format defines the format of the data
  7597. * @param forcedExtension defines the extension to use to pick the right loader
  7598. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7599. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7600. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7601. * @returns the cube texture as an InternalTexture
  7602. */
  7603. 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;
  7604. /** @hidden */
  7605. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7606. /** @hidden */
  7607. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7608. /** @hidden */
  7609. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7610. /** @hidden */
  7611. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7612. /**
  7613. * @hidden
  7614. */
  7615. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Class for creating a cube texture
  7621. */
  7622. export class CubeTexture extends BaseTexture {
  7623. private _delayedOnLoad;
  7624. /**
  7625. * The url of the texture
  7626. */
  7627. url: string;
  7628. /**
  7629. * Gets or sets the center of the bounding box associated with the cube texture.
  7630. * It must define where the camera used to render the texture was set
  7631. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7632. */
  7633. boundingBoxPosition: Vector3;
  7634. private _boundingBoxSize;
  7635. /**
  7636. * Gets or sets the size of the bounding box associated with the cube texture
  7637. * When defined, the cubemap will switch to local mode
  7638. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7639. * @example https://www.babylonjs-playground.com/#RNASML
  7640. */
  7641. /**
  7642. * Returns the bounding box size
  7643. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7644. */
  7645. boundingBoxSize: Vector3;
  7646. protected _rotationY: number;
  7647. /**
  7648. * Sets texture matrix rotation angle around Y axis in radians.
  7649. */
  7650. /**
  7651. * Gets texture matrix rotation angle around Y axis radians.
  7652. */
  7653. rotationY: number;
  7654. /**
  7655. * Are mip maps generated for this texture or not.
  7656. */
  7657. readonly noMipmap: boolean;
  7658. private _noMipmap;
  7659. private _files;
  7660. protected _forcedExtension: Nullable<string>;
  7661. private _extensions;
  7662. private _textureMatrix;
  7663. private _format;
  7664. private _createPolynomials;
  7665. /** @hidden */
  7666. _prefiltered: boolean;
  7667. /**
  7668. * Creates a cube texture from an array of image urls
  7669. * @param files defines an array of image urls
  7670. * @param scene defines the hosting scene
  7671. * @param noMipmap specifies if mip maps are not used
  7672. * @returns a cube texture
  7673. */
  7674. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7675. /**
  7676. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7677. * @param url defines the url of the prefiltered texture
  7678. * @param scene defines the scene the texture is attached to
  7679. * @param forcedExtension defines the extension of the file if different from the url
  7680. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7681. * @return the prefiltered texture
  7682. */
  7683. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7684. /**
  7685. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7686. * as prefiltered data.
  7687. * @param rootUrl defines the url of the texture or the root name of the six images
  7688. * @param scene defines the scene the texture is attached to
  7689. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7690. * @param noMipmap defines if mipmaps should be created or not
  7691. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7692. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7693. * @param onError defines a callback triggered in case of error during load
  7694. * @param format defines the internal format to use for the texture once loaded
  7695. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7696. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7697. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7698. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7699. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7700. * @return the cube texture
  7701. */
  7702. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7703. /**
  7704. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7705. */
  7706. readonly isPrefiltered: boolean;
  7707. /**
  7708. * Get the current class name of the texture useful for serialization or dynamic coding.
  7709. * @returns "CubeTexture"
  7710. */
  7711. getClassName(): string;
  7712. /**
  7713. * Update the url (and optional buffer) of this texture if url was null during construction.
  7714. * @param url the url of the texture
  7715. * @param forcedExtension defines the extension to use
  7716. * @param onLoad callback called when the texture is loaded (defaults to null)
  7717. */
  7718. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7719. /**
  7720. * Delays loading of the cube texture
  7721. * @param forcedExtension defines the extension to use
  7722. */
  7723. delayLoad(forcedExtension?: string): void;
  7724. /**
  7725. * Returns the reflection texture matrix
  7726. * @returns the reflection texture matrix
  7727. */
  7728. getReflectionTextureMatrix(): Matrix;
  7729. /**
  7730. * Sets the reflection texture matrix
  7731. * @param value Reflection texture matrix
  7732. */
  7733. setReflectionTextureMatrix(value: Matrix): void;
  7734. /**
  7735. * Parses text to create a cube texture
  7736. * @param parsedTexture define the serialized text to read from
  7737. * @param scene defines the hosting scene
  7738. * @param rootUrl defines the root url of the cube texture
  7739. * @returns a cube texture
  7740. */
  7741. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7742. /**
  7743. * Makes a clone, or deep copy, of the cube texture
  7744. * @returns a new cube texture
  7745. */
  7746. clone(): CubeTexture;
  7747. }
  7748. }
  7749. declare module BABYLON {
  7750. /**
  7751. * Manages the defines for the Material
  7752. */
  7753. export class MaterialDefines {
  7754. /** @hidden */
  7755. protected _keys: string[];
  7756. private _isDirty;
  7757. /** @hidden */
  7758. _renderId: number;
  7759. /** @hidden */
  7760. _areLightsDirty: boolean;
  7761. /** @hidden */
  7762. _areLightsDisposed: boolean;
  7763. /** @hidden */
  7764. _areAttributesDirty: boolean;
  7765. /** @hidden */
  7766. _areTexturesDirty: boolean;
  7767. /** @hidden */
  7768. _areFresnelDirty: boolean;
  7769. /** @hidden */
  7770. _areMiscDirty: boolean;
  7771. /** @hidden */
  7772. _areImageProcessingDirty: boolean;
  7773. /** @hidden */
  7774. _normals: boolean;
  7775. /** @hidden */
  7776. _uvs: boolean;
  7777. /** @hidden */
  7778. _needNormals: boolean;
  7779. /** @hidden */
  7780. _needUVs: boolean;
  7781. [id: string]: any;
  7782. /**
  7783. * Specifies if the material needs to be re-calculated
  7784. */
  7785. readonly isDirty: boolean;
  7786. /**
  7787. * Marks the material to indicate that it has been re-calculated
  7788. */
  7789. markAsProcessed(): void;
  7790. /**
  7791. * Marks the material to indicate that it needs to be re-calculated
  7792. */
  7793. markAsUnprocessed(): void;
  7794. /**
  7795. * Marks the material to indicate all of its defines need to be re-calculated
  7796. */
  7797. markAllAsDirty(): void;
  7798. /**
  7799. * Marks the material to indicate that image processing needs to be re-calculated
  7800. */
  7801. markAsImageProcessingDirty(): void;
  7802. /**
  7803. * Marks the material to indicate the lights need to be re-calculated
  7804. * @param disposed Defines whether the light is dirty due to dispose or not
  7805. */
  7806. markAsLightDirty(disposed?: boolean): void;
  7807. /**
  7808. * Marks the attribute state as changed
  7809. */
  7810. markAsAttributesDirty(): void;
  7811. /**
  7812. * Marks the texture state as changed
  7813. */
  7814. markAsTexturesDirty(): void;
  7815. /**
  7816. * Marks the fresnel state as changed
  7817. */
  7818. markAsFresnelDirty(): void;
  7819. /**
  7820. * Marks the misc state as changed
  7821. */
  7822. markAsMiscDirty(): void;
  7823. /**
  7824. * Rebuilds the material defines
  7825. */
  7826. rebuild(): void;
  7827. /**
  7828. * Specifies if two material defines are equal
  7829. * @param other - A material define instance to compare to
  7830. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7831. */
  7832. isEqual(other: MaterialDefines): boolean;
  7833. /**
  7834. * Clones this instance's defines to another instance
  7835. * @param other - material defines to clone values to
  7836. */
  7837. cloneTo(other: MaterialDefines): void;
  7838. /**
  7839. * Resets the material define values
  7840. */
  7841. reset(): void;
  7842. /**
  7843. * Converts the material define values to a string
  7844. * @returns - String of material define information
  7845. */
  7846. toString(): string;
  7847. }
  7848. }
  7849. declare module BABYLON {
  7850. /**
  7851. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7852. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7853. * 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;
  7854. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7855. */
  7856. export class ColorCurves {
  7857. private _dirty;
  7858. private _tempColor;
  7859. private _globalCurve;
  7860. private _highlightsCurve;
  7861. private _midtonesCurve;
  7862. private _shadowsCurve;
  7863. private _positiveCurve;
  7864. private _negativeCurve;
  7865. private _globalHue;
  7866. private _globalDensity;
  7867. private _globalSaturation;
  7868. private _globalExposure;
  7869. /**
  7870. * Gets the global Hue value.
  7871. * 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).
  7872. */
  7873. /**
  7874. * Sets the global Hue value.
  7875. * 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).
  7876. */
  7877. globalHue: number;
  7878. /**
  7879. * Gets the global Density value.
  7880. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7881. * Values less than zero provide a filter of opposite hue.
  7882. */
  7883. /**
  7884. * Sets the global Density value.
  7885. * 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.
  7886. * Values less than zero provide a filter of opposite hue.
  7887. */
  7888. globalDensity: number;
  7889. /**
  7890. * Gets the global Saturation value.
  7891. * 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.
  7892. */
  7893. /**
  7894. * Sets the global Saturation value.
  7895. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7896. */
  7897. globalSaturation: number;
  7898. /**
  7899. * Gets the global Exposure value.
  7900. * 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.
  7901. */
  7902. /**
  7903. * Sets the global Exposure value.
  7904. * 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.
  7905. */
  7906. globalExposure: number;
  7907. private _highlightsHue;
  7908. private _highlightsDensity;
  7909. private _highlightsSaturation;
  7910. private _highlightsExposure;
  7911. /**
  7912. * Gets the highlights Hue value.
  7913. * 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).
  7914. */
  7915. /**
  7916. * Sets the highlights Hue value.
  7917. * 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).
  7918. */
  7919. highlightsHue: number;
  7920. /**
  7921. * Gets the highlights Density value.
  7922. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7923. * Values less than zero provide a filter of opposite hue.
  7924. */
  7925. /**
  7926. * Sets the highlights Density value.
  7927. * 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.
  7928. * Values less than zero provide a filter of opposite hue.
  7929. */
  7930. highlightsDensity: number;
  7931. /**
  7932. * Gets the highlights Saturation value.
  7933. * 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.
  7934. */
  7935. /**
  7936. * Sets the highlights Saturation value.
  7937. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7938. */
  7939. highlightsSaturation: number;
  7940. /**
  7941. * Gets the highlights Exposure value.
  7942. * 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.
  7943. */
  7944. /**
  7945. * Sets the highlights Exposure value.
  7946. * 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.
  7947. */
  7948. highlightsExposure: number;
  7949. private _midtonesHue;
  7950. private _midtonesDensity;
  7951. private _midtonesSaturation;
  7952. private _midtonesExposure;
  7953. /**
  7954. * Gets the midtones Hue value.
  7955. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7956. */
  7957. /**
  7958. * Sets the midtones Hue value.
  7959. * 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).
  7960. */
  7961. midtonesHue: number;
  7962. /**
  7963. * Gets the midtones Density value.
  7964. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7965. * Values less than zero provide a filter of opposite hue.
  7966. */
  7967. /**
  7968. * Sets the midtones Density value.
  7969. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7970. * Values less than zero provide a filter of opposite hue.
  7971. */
  7972. midtonesDensity: number;
  7973. /**
  7974. * Gets the midtones Saturation value.
  7975. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7976. */
  7977. /**
  7978. * Sets the midtones 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. midtonesSaturation: number;
  7982. /**
  7983. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  7985. */
  7986. /**
  7987. * Sets the midtones Exposure value.
  7988. * 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.
  7989. */
  7990. midtonesExposure: number;
  7991. private _shadowsHue;
  7992. private _shadowsDensity;
  7993. private _shadowsSaturation;
  7994. private _shadowsExposure;
  7995. /**
  7996. * Gets the shadows Hue value.
  7997. * 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).
  7998. */
  7999. /**
  8000. * Sets the shadows Hue value.
  8001. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8002. */
  8003. shadowsHue: number;
  8004. /**
  8005. * Gets the shadows Density value.
  8006. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8007. * Values less than zero provide a filter of opposite hue.
  8008. */
  8009. /**
  8010. * Sets the shadows Density value.
  8011. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. shadowsDensity: number;
  8015. /**
  8016. * Gets the shadows Saturation value.
  8017. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8018. */
  8019. /**
  8020. * Sets the shadows Saturation value.
  8021. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8022. */
  8023. shadowsSaturation: number;
  8024. /**
  8025. * Gets the shadows Exposure value.
  8026. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8027. */
  8028. /**
  8029. * Sets the shadows Exposure 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 exposure and negative values decrease exposure.
  8031. */
  8032. shadowsExposure: number;
  8033. /**
  8034. * Returns the class name
  8035. * @returns The class name
  8036. */
  8037. getClassName(): string;
  8038. /**
  8039. * Binds the color curves to the shader.
  8040. * @param colorCurves The color curve to bind
  8041. * @param effect The effect to bind to
  8042. * @param positiveUniform The positive uniform shader parameter
  8043. * @param neutralUniform The neutral uniform shader parameter
  8044. * @param negativeUniform The negative uniform shader parameter
  8045. */
  8046. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8047. /**
  8048. * Prepare the list of uniforms associated with the ColorCurves effects.
  8049. * @param uniformsList The list of uniforms used in the effect
  8050. */
  8051. static PrepareUniforms(uniformsList: string[]): void;
  8052. /**
  8053. * Returns color grading data based on a hue, density, saturation and exposure value.
  8054. * @param filterHue The hue of the color filter.
  8055. * @param filterDensity The density of the color filter.
  8056. * @param saturation The saturation.
  8057. * @param exposure The exposure.
  8058. * @param result The result data container.
  8059. */
  8060. private getColorGradingDataToRef;
  8061. /**
  8062. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8063. * @param value The input slider value in range [-100,100].
  8064. * @returns Adjusted value.
  8065. */
  8066. private static applyColorGradingSliderNonlinear;
  8067. /**
  8068. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8069. * @param hue The hue (H) input.
  8070. * @param saturation The saturation (S) input.
  8071. * @param brightness The brightness (B) input.
  8072. * @result An RGBA color represented as Vector4.
  8073. */
  8074. private static fromHSBToRef;
  8075. /**
  8076. * Returns a value clamped between min and max
  8077. * @param value The value to clamp
  8078. * @param min The minimum of value
  8079. * @param max The maximum of value
  8080. * @returns The clamped value.
  8081. */
  8082. private static clamp;
  8083. /**
  8084. * Clones the current color curve instance.
  8085. * @return The cloned curves
  8086. */
  8087. clone(): ColorCurves;
  8088. /**
  8089. * Serializes the current color curve instance to a json representation.
  8090. * @return a JSON representation
  8091. */
  8092. serialize(): any;
  8093. /**
  8094. * Parses the color curve from a json representation.
  8095. * @param source the JSON source to parse
  8096. * @return The parsed curves
  8097. */
  8098. static Parse(source: any): ColorCurves;
  8099. }
  8100. }
  8101. declare module BABYLON {
  8102. /**
  8103. * Interface to follow in your material defines to integrate easily the
  8104. * Image proccessing functions.
  8105. * @hidden
  8106. */
  8107. export interface IImageProcessingConfigurationDefines {
  8108. IMAGEPROCESSING: boolean;
  8109. VIGNETTE: boolean;
  8110. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8111. VIGNETTEBLENDMODEOPAQUE: boolean;
  8112. TONEMAPPING: boolean;
  8113. TONEMAPPING_ACES: boolean;
  8114. CONTRAST: boolean;
  8115. EXPOSURE: boolean;
  8116. COLORCURVES: boolean;
  8117. COLORGRADING: boolean;
  8118. COLORGRADING3D: boolean;
  8119. SAMPLER3DGREENDEPTH: boolean;
  8120. SAMPLER3DBGRMAP: boolean;
  8121. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8122. }
  8123. /**
  8124. * @hidden
  8125. */
  8126. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8127. IMAGEPROCESSING: boolean;
  8128. VIGNETTE: boolean;
  8129. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8130. VIGNETTEBLENDMODEOPAQUE: boolean;
  8131. TONEMAPPING: boolean;
  8132. TONEMAPPING_ACES: boolean;
  8133. CONTRAST: boolean;
  8134. COLORCURVES: boolean;
  8135. COLORGRADING: boolean;
  8136. COLORGRADING3D: boolean;
  8137. SAMPLER3DGREENDEPTH: boolean;
  8138. SAMPLER3DBGRMAP: boolean;
  8139. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8140. EXPOSURE: boolean;
  8141. constructor();
  8142. }
  8143. /**
  8144. * This groups together the common properties used for image processing either in direct forward pass
  8145. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8146. * or not.
  8147. */
  8148. export class ImageProcessingConfiguration {
  8149. /**
  8150. * Default tone mapping applied in BabylonJS.
  8151. */
  8152. static readonly TONEMAPPING_STANDARD: number;
  8153. /**
  8154. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8155. * to other engines rendering to increase portability.
  8156. */
  8157. static readonly TONEMAPPING_ACES: number;
  8158. /**
  8159. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8160. */
  8161. colorCurves: Nullable<ColorCurves>;
  8162. private _colorCurvesEnabled;
  8163. /**
  8164. * Gets wether the color curves effect is enabled.
  8165. */
  8166. /**
  8167. * Sets wether the color curves effect is enabled.
  8168. */
  8169. colorCurvesEnabled: boolean;
  8170. private _colorGradingTexture;
  8171. /**
  8172. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8173. */
  8174. /**
  8175. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8176. */
  8177. colorGradingTexture: Nullable<BaseTexture>;
  8178. private _colorGradingEnabled;
  8179. /**
  8180. * Gets wether the color grading effect is enabled.
  8181. */
  8182. /**
  8183. * Sets wether the color grading effect is enabled.
  8184. */
  8185. colorGradingEnabled: boolean;
  8186. private _colorGradingWithGreenDepth;
  8187. /**
  8188. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8189. */
  8190. /**
  8191. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8192. */
  8193. colorGradingWithGreenDepth: boolean;
  8194. private _colorGradingBGR;
  8195. /**
  8196. * Gets wether the color grading texture contains BGR values.
  8197. */
  8198. /**
  8199. * Sets wether the color grading texture contains BGR values.
  8200. */
  8201. colorGradingBGR: boolean;
  8202. /** @hidden */
  8203. _exposure: number;
  8204. /**
  8205. * Gets the Exposure used in the effect.
  8206. */
  8207. /**
  8208. * Sets the Exposure used in the effect.
  8209. */
  8210. exposure: number;
  8211. private _toneMappingEnabled;
  8212. /**
  8213. * Gets wether the tone mapping effect is enabled.
  8214. */
  8215. /**
  8216. * Sets wether the tone mapping effect is enabled.
  8217. */
  8218. toneMappingEnabled: boolean;
  8219. private _toneMappingType;
  8220. /**
  8221. * Gets the type of tone mapping effect.
  8222. */
  8223. /**
  8224. * Sets the type of tone mapping effect used in BabylonJS.
  8225. */
  8226. toneMappingType: number;
  8227. protected _contrast: number;
  8228. /**
  8229. * Gets the contrast used in the effect.
  8230. */
  8231. /**
  8232. * Sets the contrast used in the effect.
  8233. */
  8234. contrast: number;
  8235. /**
  8236. * Vignette stretch size.
  8237. */
  8238. vignetteStretch: number;
  8239. /**
  8240. * Vignette centre X Offset.
  8241. */
  8242. vignetteCentreX: number;
  8243. /**
  8244. * Vignette centre Y Offset.
  8245. */
  8246. vignetteCentreY: number;
  8247. /**
  8248. * Vignette weight or intensity of the vignette effect.
  8249. */
  8250. vignetteWeight: number;
  8251. /**
  8252. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8253. * if vignetteEnabled is set to true.
  8254. */
  8255. vignetteColor: Color4;
  8256. /**
  8257. * Camera field of view used by the Vignette effect.
  8258. */
  8259. vignetteCameraFov: number;
  8260. private _vignetteBlendMode;
  8261. /**
  8262. * Gets the vignette blend mode allowing different kind of effect.
  8263. */
  8264. /**
  8265. * Sets the vignette blend mode allowing different kind of effect.
  8266. */
  8267. vignetteBlendMode: number;
  8268. private _vignetteEnabled;
  8269. /**
  8270. * Gets wether the vignette effect is enabled.
  8271. */
  8272. /**
  8273. * Sets wether the vignette effect is enabled.
  8274. */
  8275. vignetteEnabled: boolean;
  8276. private _applyByPostProcess;
  8277. /**
  8278. * Gets wether the image processing is applied through a post process or not.
  8279. */
  8280. /**
  8281. * Sets wether the image processing is applied through a post process or not.
  8282. */
  8283. applyByPostProcess: boolean;
  8284. private _isEnabled;
  8285. /**
  8286. * Gets wether the image processing is enabled or not.
  8287. */
  8288. /**
  8289. * Sets wether the image processing is enabled or not.
  8290. */
  8291. isEnabled: boolean;
  8292. /**
  8293. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8294. */
  8295. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8296. /**
  8297. * Method called each time the image processing information changes requires to recompile the effect.
  8298. */
  8299. protected _updateParameters(): void;
  8300. /**
  8301. * Gets the current class name.
  8302. * @return "ImageProcessingConfiguration"
  8303. */
  8304. getClassName(): string;
  8305. /**
  8306. * Prepare the list of uniforms associated with the Image Processing effects.
  8307. * @param uniforms The list of uniforms used in the effect
  8308. * @param defines the list of defines currently in use
  8309. */
  8310. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8311. /**
  8312. * Prepare the list of samplers associated with the Image Processing effects.
  8313. * @param samplersList The list of uniforms used in the effect
  8314. * @param defines the list of defines currently in use
  8315. */
  8316. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8317. /**
  8318. * Prepare the list of defines associated to the shader.
  8319. * @param defines the list of defines to complete
  8320. * @param forPostProcess Define if we are currently in post process mode or not
  8321. */
  8322. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8323. /**
  8324. * Returns true if all the image processing information are ready.
  8325. * @returns True if ready, otherwise, false
  8326. */
  8327. isReady(): boolean;
  8328. /**
  8329. * Binds the image processing to the shader.
  8330. * @param effect The effect to bind to
  8331. * @param overrideAspectRatio Override the aspect ratio of the effect
  8332. */
  8333. bind(effect: Effect, overrideAspectRatio?: number): void;
  8334. /**
  8335. * Clones the current image processing instance.
  8336. * @return The cloned image processing
  8337. */
  8338. clone(): ImageProcessingConfiguration;
  8339. /**
  8340. * Serializes the current image processing instance to a json representation.
  8341. * @return a JSON representation
  8342. */
  8343. serialize(): any;
  8344. /**
  8345. * Parses the image processing from a json representation.
  8346. * @param source the JSON source to parse
  8347. * @return The parsed image processing
  8348. */
  8349. static Parse(source: any): ImageProcessingConfiguration;
  8350. private static _VIGNETTEMODE_MULTIPLY;
  8351. private static _VIGNETTEMODE_OPAQUE;
  8352. /**
  8353. * Used to apply the vignette as a mix with the pixel color.
  8354. */
  8355. static readonly VIGNETTEMODE_MULTIPLY: number;
  8356. /**
  8357. * Used to apply the vignette as a replacement of the pixel color.
  8358. */
  8359. static readonly VIGNETTEMODE_OPAQUE: number;
  8360. }
  8361. }
  8362. declare module BABYLON {
  8363. /** @hidden */
  8364. export var postprocessVertexShader: {
  8365. name: string;
  8366. shader: string;
  8367. };
  8368. }
  8369. declare module BABYLON {
  8370. interface ThinEngine {
  8371. /**
  8372. * Creates a new render target texture
  8373. * @param size defines the size of the texture
  8374. * @param options defines the options used to create the texture
  8375. * @returns a new render target texture stored in an InternalTexture
  8376. */
  8377. createRenderTargetTexture(size: number | {
  8378. width: number;
  8379. height: number;
  8380. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8381. /**
  8382. * Creates a depth stencil texture.
  8383. * This is only available in WebGL 2 or with the depth texture extension available.
  8384. * @param size The size of face edge in the texture.
  8385. * @param options The options defining the texture.
  8386. * @returns The texture
  8387. */
  8388. createDepthStencilTexture(size: number | {
  8389. width: number;
  8390. height: number;
  8391. }, options: DepthTextureCreationOptions): InternalTexture;
  8392. /** @hidden */
  8393. _createDepthStencilTexture(size: number | {
  8394. width: number;
  8395. height: number;
  8396. }, options: DepthTextureCreationOptions): InternalTexture;
  8397. }
  8398. }
  8399. declare module BABYLON {
  8400. /** Defines supported spaces */
  8401. export enum Space {
  8402. /** Local (object) space */
  8403. LOCAL = 0,
  8404. /** World space */
  8405. WORLD = 1,
  8406. /** Bone space */
  8407. BONE = 2
  8408. }
  8409. /** Defines the 3 main axes */
  8410. export class Axis {
  8411. /** X axis */
  8412. static X: Vector3;
  8413. /** Y axis */
  8414. static Y: Vector3;
  8415. /** Z axis */
  8416. static Z: Vector3;
  8417. }
  8418. }
  8419. declare module BABYLON {
  8420. /**
  8421. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8422. * This is the base of the follow, arc rotate cameras and Free camera
  8423. * @see http://doc.babylonjs.com/features/cameras
  8424. */
  8425. export class TargetCamera extends Camera {
  8426. private static _RigCamTransformMatrix;
  8427. private static _TargetTransformMatrix;
  8428. private static _TargetFocalPoint;
  8429. /**
  8430. * Define the current direction the camera is moving to
  8431. */
  8432. cameraDirection: Vector3;
  8433. /**
  8434. * Define the current rotation the camera is rotating to
  8435. */
  8436. cameraRotation: Vector2;
  8437. /**
  8438. * When set, the up vector of the camera will be updated by the rotation of the camera
  8439. */
  8440. updateUpVectorFromRotation: boolean;
  8441. private _tmpQuaternion;
  8442. /**
  8443. * Define the current rotation of the camera
  8444. */
  8445. rotation: Vector3;
  8446. /**
  8447. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8448. */
  8449. rotationQuaternion: Quaternion;
  8450. /**
  8451. * Define the current speed of the camera
  8452. */
  8453. speed: number;
  8454. /**
  8455. * Add constraint to the camera to prevent it to move freely in all directions and
  8456. * around all axis.
  8457. */
  8458. noRotationConstraint: boolean;
  8459. /**
  8460. * Define the current target of the camera as an object or a position.
  8461. */
  8462. lockedTarget: any;
  8463. /** @hidden */
  8464. _currentTarget: Vector3;
  8465. /** @hidden */
  8466. _initialFocalDistance: number;
  8467. /** @hidden */
  8468. _viewMatrix: Matrix;
  8469. /** @hidden */
  8470. _camMatrix: Matrix;
  8471. /** @hidden */
  8472. _cameraTransformMatrix: Matrix;
  8473. /** @hidden */
  8474. _cameraRotationMatrix: Matrix;
  8475. /** @hidden */
  8476. _referencePoint: Vector3;
  8477. /** @hidden */
  8478. _transformedReferencePoint: Vector3;
  8479. protected _globalCurrentTarget: Vector3;
  8480. protected _globalCurrentUpVector: Vector3;
  8481. /** @hidden */
  8482. _reset: () => void;
  8483. private _defaultUp;
  8484. /**
  8485. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8486. * This is the base of the follow, arc rotate cameras and Free camera
  8487. * @see http://doc.babylonjs.com/features/cameras
  8488. * @param name Defines the name of the camera in the scene
  8489. * @param position Defines the start position of the camera in the scene
  8490. * @param scene Defines the scene the camera belongs to
  8491. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8492. */
  8493. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8494. /**
  8495. * Gets the position in front of the camera at a given distance.
  8496. * @param distance The distance from the camera we want the position to be
  8497. * @returns the position
  8498. */
  8499. getFrontPosition(distance: number): Vector3;
  8500. /** @hidden */
  8501. _getLockedTargetPosition(): Nullable<Vector3>;
  8502. private _storedPosition;
  8503. private _storedRotation;
  8504. private _storedRotationQuaternion;
  8505. /**
  8506. * Store current camera state of the camera (fov, position, rotation, etc..)
  8507. * @returns the camera
  8508. */
  8509. storeState(): Camera;
  8510. /**
  8511. * Restored camera state. You must call storeState() first
  8512. * @returns whether it was successful or not
  8513. * @hidden
  8514. */
  8515. _restoreStateValues(): boolean;
  8516. /** @hidden */
  8517. _initCache(): void;
  8518. /** @hidden */
  8519. _updateCache(ignoreParentClass?: boolean): void;
  8520. /** @hidden */
  8521. _isSynchronizedViewMatrix(): boolean;
  8522. /** @hidden */
  8523. _computeLocalCameraSpeed(): number;
  8524. /**
  8525. * Defines the target the camera should look at.
  8526. * @param target Defines the new target as a Vector or a mesh
  8527. */
  8528. setTarget(target: Vector3): void;
  8529. /**
  8530. * Return the current target position of the camera. This value is expressed in local space.
  8531. * @returns the target position
  8532. */
  8533. getTarget(): Vector3;
  8534. /** @hidden */
  8535. _decideIfNeedsToMove(): boolean;
  8536. /** @hidden */
  8537. _updatePosition(): void;
  8538. /** @hidden */
  8539. _checkInputs(): void;
  8540. protected _updateCameraRotationMatrix(): void;
  8541. /**
  8542. * 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)
  8543. * @returns the current camera
  8544. */
  8545. private _rotateUpVectorWithCameraRotationMatrix;
  8546. private _cachedRotationZ;
  8547. private _cachedQuaternionRotationZ;
  8548. /** @hidden */
  8549. _getViewMatrix(): Matrix;
  8550. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8551. /**
  8552. * @hidden
  8553. */
  8554. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8555. /**
  8556. * @hidden
  8557. */
  8558. _updateRigCameras(): void;
  8559. private _getRigCamPositionAndTarget;
  8560. /**
  8561. * Gets the current object class name.
  8562. * @return the class name
  8563. */
  8564. getClassName(): string;
  8565. }
  8566. }
  8567. declare module BABYLON {
  8568. /**
  8569. * Gather the list of keyboard event types as constants.
  8570. */
  8571. export class KeyboardEventTypes {
  8572. /**
  8573. * The keydown event is fired when a key becomes active (pressed).
  8574. */
  8575. static readonly KEYDOWN: number;
  8576. /**
  8577. * The keyup event is fired when a key has been released.
  8578. */
  8579. static readonly KEYUP: number;
  8580. }
  8581. /**
  8582. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8583. */
  8584. export class KeyboardInfo {
  8585. /**
  8586. * Defines the type of event (KeyboardEventTypes)
  8587. */
  8588. type: number;
  8589. /**
  8590. * Defines the related dom event
  8591. */
  8592. event: KeyboardEvent;
  8593. /**
  8594. * Instantiates a new keyboard info.
  8595. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8596. * @param type Defines the type of event (KeyboardEventTypes)
  8597. * @param event Defines the related dom event
  8598. */
  8599. constructor(
  8600. /**
  8601. * Defines the type of event (KeyboardEventTypes)
  8602. */
  8603. type: number,
  8604. /**
  8605. * Defines the related dom event
  8606. */
  8607. event: KeyboardEvent);
  8608. }
  8609. /**
  8610. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8611. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8612. */
  8613. export class KeyboardInfoPre extends KeyboardInfo {
  8614. /**
  8615. * Defines the type of event (KeyboardEventTypes)
  8616. */
  8617. type: number;
  8618. /**
  8619. * Defines the related dom event
  8620. */
  8621. event: KeyboardEvent;
  8622. /**
  8623. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8624. */
  8625. skipOnPointerObservable: boolean;
  8626. /**
  8627. * Instantiates a new keyboard pre info.
  8628. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8629. * @param type Defines the type of event (KeyboardEventTypes)
  8630. * @param event Defines the related dom event
  8631. */
  8632. constructor(
  8633. /**
  8634. * Defines the type of event (KeyboardEventTypes)
  8635. */
  8636. type: number,
  8637. /**
  8638. * Defines the related dom event
  8639. */
  8640. event: KeyboardEvent);
  8641. }
  8642. }
  8643. declare module BABYLON {
  8644. /**
  8645. * Manage the keyboard inputs to control the movement of a free camera.
  8646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8647. */
  8648. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8649. /**
  8650. * Defines the camera the input is attached to.
  8651. */
  8652. camera: FreeCamera;
  8653. /**
  8654. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8655. */
  8656. keysUp: number[];
  8657. /**
  8658. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8659. */
  8660. keysDown: number[];
  8661. /**
  8662. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8663. */
  8664. keysLeft: number[];
  8665. /**
  8666. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8667. */
  8668. keysRight: number[];
  8669. private _keys;
  8670. private _onCanvasBlurObserver;
  8671. private _onKeyboardObserver;
  8672. private _engine;
  8673. private _scene;
  8674. /**
  8675. * Attach the input controls to a specific dom element to get the input from.
  8676. * @param element Defines the element the controls should be listened from
  8677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8678. */
  8679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8680. /**
  8681. * Detach the current controls from the specified dom element.
  8682. * @param element Defines the element to stop listening the inputs from
  8683. */
  8684. detachControl(element: Nullable<HTMLElement>): void;
  8685. /**
  8686. * Update the current camera state depending on the inputs that have been used this frame.
  8687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8688. */
  8689. checkInputs(): void;
  8690. /**
  8691. * Gets the class name of the current intput.
  8692. * @returns the class name
  8693. */
  8694. getClassName(): string;
  8695. /** @hidden */
  8696. _onLostFocus(): void;
  8697. /**
  8698. * Get the friendly name associated with the input class.
  8699. * @returns the input friendly name
  8700. */
  8701. getSimpleName(): string;
  8702. }
  8703. }
  8704. declare module BABYLON {
  8705. /**
  8706. * Interface describing all the common properties and methods a shadow light needs to implement.
  8707. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8708. * as well as binding the different shadow properties to the effects.
  8709. */
  8710. export interface IShadowLight extends Light {
  8711. /**
  8712. * The light id in the scene (used in scene.findLighById for instance)
  8713. */
  8714. id: string;
  8715. /**
  8716. * The position the shdow will be casted from.
  8717. */
  8718. position: Vector3;
  8719. /**
  8720. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8721. */
  8722. direction: Vector3;
  8723. /**
  8724. * The transformed position. Position of the light in world space taking parenting in account.
  8725. */
  8726. transformedPosition: Vector3;
  8727. /**
  8728. * The transformed direction. Direction of the light in world space taking parenting in account.
  8729. */
  8730. transformedDirection: Vector3;
  8731. /**
  8732. * The friendly name of the light in the scene.
  8733. */
  8734. name: string;
  8735. /**
  8736. * Defines the shadow projection clipping minimum z value.
  8737. */
  8738. shadowMinZ: number;
  8739. /**
  8740. * Defines the shadow projection clipping maximum z value.
  8741. */
  8742. shadowMaxZ: number;
  8743. /**
  8744. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8745. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8746. */
  8747. computeTransformedInformation(): boolean;
  8748. /**
  8749. * Gets the scene the light belongs to.
  8750. * @returns The scene
  8751. */
  8752. getScene(): Scene;
  8753. /**
  8754. * Callback defining a custom Projection Matrix Builder.
  8755. * This can be used to override the default projection matrix computation.
  8756. */
  8757. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8758. /**
  8759. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8760. * @param matrix The materix to updated with the projection information
  8761. * @param viewMatrix The transform matrix of the light
  8762. * @param renderList The list of mesh to render in the map
  8763. * @returns The current light
  8764. */
  8765. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8766. /**
  8767. * Gets the current depth scale used in ESM.
  8768. * @returns The scale
  8769. */
  8770. getDepthScale(): number;
  8771. /**
  8772. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8773. * @returns true if a cube texture needs to be use
  8774. */
  8775. needCube(): boolean;
  8776. /**
  8777. * Detects if the projection matrix requires to be recomputed this frame.
  8778. * @returns true if it requires to be recomputed otherwise, false.
  8779. */
  8780. needProjectionMatrixCompute(): boolean;
  8781. /**
  8782. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8783. */
  8784. forceProjectionMatrixCompute(): void;
  8785. /**
  8786. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8787. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8788. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8789. */
  8790. getShadowDirection(faceIndex?: number): Vector3;
  8791. /**
  8792. * Gets the minZ used for shadow according to both the scene and the light.
  8793. * @param activeCamera The camera we are returning the min for
  8794. * @returns the depth min z
  8795. */
  8796. getDepthMinZ(activeCamera: Camera): number;
  8797. /**
  8798. * Gets the maxZ used for shadow according to both the scene and the light.
  8799. * @param activeCamera The camera we are returning the max for
  8800. * @returns the depth max z
  8801. */
  8802. getDepthMaxZ(activeCamera: Camera): number;
  8803. }
  8804. /**
  8805. * Base implementation IShadowLight
  8806. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8807. */
  8808. export abstract class ShadowLight extends Light implements IShadowLight {
  8809. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8810. protected _position: Vector3;
  8811. protected _setPosition(value: Vector3): void;
  8812. /**
  8813. * Sets the position the shadow will be casted from. Also use as the light position for both
  8814. * point and spot lights.
  8815. */
  8816. /**
  8817. * Sets the position the shadow will be casted from. Also use as the light position for both
  8818. * point and spot lights.
  8819. */
  8820. position: Vector3;
  8821. protected _direction: Vector3;
  8822. protected _setDirection(value: Vector3): void;
  8823. /**
  8824. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8825. * Also use as the light direction on spot and directional lights.
  8826. */
  8827. /**
  8828. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8829. * Also use as the light direction on spot and directional lights.
  8830. */
  8831. direction: Vector3;
  8832. private _shadowMinZ;
  8833. /**
  8834. * Gets the shadow projection clipping minimum z value.
  8835. */
  8836. /**
  8837. * Sets the shadow projection clipping minimum z value.
  8838. */
  8839. shadowMinZ: number;
  8840. private _shadowMaxZ;
  8841. /**
  8842. * Sets the shadow projection clipping maximum z value.
  8843. */
  8844. /**
  8845. * Gets the shadow projection clipping maximum z value.
  8846. */
  8847. shadowMaxZ: number;
  8848. /**
  8849. * Callback defining a custom Projection Matrix Builder.
  8850. * This can be used to override the default projection matrix computation.
  8851. */
  8852. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8853. /**
  8854. * The transformed position. Position of the light in world space taking parenting in account.
  8855. */
  8856. transformedPosition: Vector3;
  8857. /**
  8858. * The transformed direction. Direction of the light in world space taking parenting in account.
  8859. */
  8860. transformedDirection: Vector3;
  8861. private _needProjectionMatrixCompute;
  8862. /**
  8863. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8864. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8865. */
  8866. computeTransformedInformation(): boolean;
  8867. /**
  8868. * Return the depth scale used for the shadow map.
  8869. * @returns the depth scale.
  8870. */
  8871. getDepthScale(): number;
  8872. /**
  8873. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8874. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8875. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8876. */
  8877. getShadowDirection(faceIndex?: number): Vector3;
  8878. /**
  8879. * Returns the ShadowLight absolute position in the World.
  8880. * @returns the position vector in world space
  8881. */
  8882. getAbsolutePosition(): Vector3;
  8883. /**
  8884. * Sets the ShadowLight direction toward the passed target.
  8885. * @param target The point to target in local space
  8886. * @returns the updated ShadowLight direction
  8887. */
  8888. setDirectionToTarget(target: Vector3): Vector3;
  8889. /**
  8890. * Returns the light rotation in euler definition.
  8891. * @returns the x y z rotation in local space.
  8892. */
  8893. getRotation(): Vector3;
  8894. /**
  8895. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8896. * @returns true if a cube texture needs to be use
  8897. */
  8898. needCube(): boolean;
  8899. /**
  8900. * Detects if the projection matrix requires to be recomputed this frame.
  8901. * @returns true if it requires to be recomputed otherwise, false.
  8902. */
  8903. needProjectionMatrixCompute(): boolean;
  8904. /**
  8905. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8906. */
  8907. forceProjectionMatrixCompute(): void;
  8908. /** @hidden */
  8909. _initCache(): void;
  8910. /** @hidden */
  8911. _isSynchronized(): boolean;
  8912. /**
  8913. * Computes the world matrix of the node
  8914. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8915. * @returns the world matrix
  8916. */
  8917. computeWorldMatrix(force?: boolean): Matrix;
  8918. /**
  8919. * Gets the minZ used for shadow according to both the scene and the light.
  8920. * @param activeCamera The camera we are returning the min for
  8921. * @returns the depth min z
  8922. */
  8923. getDepthMinZ(activeCamera: Camera): number;
  8924. /**
  8925. * Gets the maxZ used for shadow according to both the scene and the light.
  8926. * @param activeCamera The camera we are returning the max for
  8927. * @returns the depth max z
  8928. */
  8929. getDepthMaxZ(activeCamera: Camera): number;
  8930. /**
  8931. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8932. * @param matrix The materix to updated with the projection information
  8933. * @param viewMatrix The transform matrix of the light
  8934. * @param renderList The list of mesh to render in the map
  8935. * @returns The current light
  8936. */
  8937. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8938. }
  8939. }
  8940. declare module BABYLON {
  8941. /**
  8942. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8943. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8944. */
  8945. export class EffectFallbacks implements IEffectFallbacks {
  8946. private _defines;
  8947. private _currentRank;
  8948. private _maxRank;
  8949. private _mesh;
  8950. /**
  8951. * Removes the fallback from the bound mesh.
  8952. */
  8953. unBindMesh(): void;
  8954. /**
  8955. * Adds a fallback on the specified property.
  8956. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8957. * @param define The name of the define in the shader
  8958. */
  8959. addFallback(rank: number, define: string): void;
  8960. /**
  8961. * Sets the mesh to use CPU skinning when needing to fallback.
  8962. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8963. * @param mesh The mesh to use the fallbacks.
  8964. */
  8965. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8966. /**
  8967. * Checks to see if more fallbacks are still availible.
  8968. */
  8969. readonly hasMoreFallbacks: boolean;
  8970. /**
  8971. * Removes the defines that should be removed when falling back.
  8972. * @param currentDefines defines the current define statements for the shader.
  8973. * @param effect defines the current effect we try to compile
  8974. * @returns The resulting defines with defines of the current rank removed.
  8975. */
  8976. reduce(currentDefines: string, effect: Effect): string;
  8977. }
  8978. }
  8979. declare module BABYLON {
  8980. /**
  8981. * "Static Class" containing the most commonly used helper while dealing with material for
  8982. * rendering purpose.
  8983. *
  8984. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8985. *
  8986. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8987. */
  8988. export class MaterialHelper {
  8989. /**
  8990. * Bind the current view position to an effect.
  8991. * @param effect The effect to be bound
  8992. * @param scene The scene the eyes position is used from
  8993. */
  8994. static BindEyePosition(effect: Effect, scene: Scene): void;
  8995. /**
  8996. * Helps preparing the defines values about the UVs in used in the effect.
  8997. * UVs are shared as much as we can accross channels in the shaders.
  8998. * @param texture The texture we are preparing the UVs for
  8999. * @param defines The defines to update
  9000. * @param key The channel key "diffuse", "specular"... used in the shader
  9001. */
  9002. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9003. /**
  9004. * Binds a texture matrix value to its corrsponding uniform
  9005. * @param texture The texture to bind the matrix for
  9006. * @param uniformBuffer The uniform buffer receivin the data
  9007. * @param key The channel key "diffuse", "specular"... used in the shader
  9008. */
  9009. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9010. /**
  9011. * Gets the current status of the fog (should it be enabled?)
  9012. * @param mesh defines the mesh to evaluate for fog support
  9013. * @param scene defines the hosting scene
  9014. * @returns true if fog must be enabled
  9015. */
  9016. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9017. /**
  9018. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9019. * @param mesh defines the current mesh
  9020. * @param scene defines the current scene
  9021. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9022. * @param pointsCloud defines if point cloud rendering has to be turned on
  9023. * @param fogEnabled defines if fog has to be turned on
  9024. * @param alphaTest defines if alpha testing has to be turned on
  9025. * @param defines defines the current list of defines
  9026. */
  9027. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9028. /**
  9029. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9030. * @param scene defines the current scene
  9031. * @param engine defines the current engine
  9032. * @param defines specifies the list of active defines
  9033. * @param useInstances defines if instances have to be turned on
  9034. * @param useClipPlane defines if clip plane have to be turned on
  9035. */
  9036. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9037. /**
  9038. * Prepares the defines for bones
  9039. * @param mesh The mesh containing the geometry data we will draw
  9040. * @param defines The defines to update
  9041. */
  9042. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9043. /**
  9044. * Prepares the defines for morph targets
  9045. * @param mesh The mesh containing the geometry data we will draw
  9046. * @param defines The defines to update
  9047. */
  9048. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9049. /**
  9050. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9051. * @param mesh The mesh containing the geometry data we will draw
  9052. * @param defines The defines to update
  9053. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9054. * @param useBones Precise whether bones should be used or not (override mesh info)
  9055. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9056. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9057. * @returns false if defines are considered not dirty and have not been checked
  9058. */
  9059. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9060. /**
  9061. * Prepares the defines related to multiview
  9062. * @param scene The scene we are intending to draw
  9063. * @param defines The defines to update
  9064. */
  9065. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9066. /**
  9067. * Prepares the defines related to the light information passed in parameter
  9068. * @param scene The scene we are intending to draw
  9069. * @param mesh The mesh the effect is compiling for
  9070. * @param light The light the effect is compiling for
  9071. * @param lightIndex The index of the light
  9072. * @param defines The defines to update
  9073. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9074. * @param state Defines the current state regarding what is needed (normals, etc...)
  9075. */
  9076. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9077. needNormals: boolean;
  9078. needRebuild: boolean;
  9079. shadowEnabled: boolean;
  9080. specularEnabled: boolean;
  9081. lightmapMode: boolean;
  9082. }): void;
  9083. /**
  9084. * Prepares the defines related to the light information passed in parameter
  9085. * @param scene The scene we are intending to draw
  9086. * @param mesh The mesh the effect is compiling for
  9087. * @param defines The defines to update
  9088. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9089. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9090. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9091. * @returns true if normals will be required for the rest of the effect
  9092. */
  9093. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9094. /**
  9095. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9096. * @param lightIndex defines the light index
  9097. * @param uniformsList The uniform list
  9098. * @param samplersList The sampler list
  9099. * @param projectedLightTexture defines if projected texture must be used
  9100. * @param uniformBuffersList defines an optional list of uniform buffers
  9101. */
  9102. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9103. /**
  9104. * Prepares the uniforms and samplers list to be used in the effect
  9105. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9106. * @param samplersList The sampler list
  9107. * @param defines The defines helping in the list generation
  9108. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9109. */
  9110. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9111. /**
  9112. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9113. * @param defines The defines to update while falling back
  9114. * @param fallbacks The authorized effect fallbacks
  9115. * @param maxSimultaneousLights The maximum number of lights allowed
  9116. * @param rank the current rank of the Effect
  9117. * @returns The newly affected rank
  9118. */
  9119. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9120. private static _TmpMorphInfluencers;
  9121. /**
  9122. * Prepares the list of attributes required for morph targets according to the effect defines.
  9123. * @param attribs The current list of supported attribs
  9124. * @param mesh The mesh to prepare the morph targets attributes for
  9125. * @param influencers The number of influencers
  9126. */
  9127. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9128. /**
  9129. * Prepares the list of attributes required for morph targets according to the effect defines.
  9130. * @param attribs The current list of supported attribs
  9131. * @param mesh The mesh to prepare the morph targets attributes for
  9132. * @param defines The current Defines of the effect
  9133. */
  9134. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9135. /**
  9136. * Prepares the list of attributes required for bones according to the effect defines.
  9137. * @param attribs The current list of supported attribs
  9138. * @param mesh The mesh to prepare the bones attributes for
  9139. * @param defines The current Defines of the effect
  9140. * @param fallbacks The current efffect fallback strategy
  9141. */
  9142. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9143. /**
  9144. * Check and prepare the list of attributes required for instances according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param defines The current MaterialDefines of the effect
  9147. */
  9148. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9149. /**
  9150. * Add the list of attributes required for instances to the attribs array.
  9151. * @param attribs The current list of supported attribs
  9152. */
  9153. static PushAttributesForInstances(attribs: string[]): void;
  9154. /**
  9155. * Binds the light information to the effect.
  9156. * @param light The light containing the generator
  9157. * @param effect The effect we are binding the data to
  9158. * @param lightIndex The light index in the effect used to render
  9159. */
  9160. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9161. /**
  9162. * Binds the lights information from the scene to the effect for the given mesh.
  9163. * @param light Light to bind
  9164. * @param lightIndex Light index
  9165. * @param scene The scene where the light belongs to
  9166. * @param effect The effect we are binding the data to
  9167. * @param useSpecular Defines if specular is supported
  9168. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9169. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9170. */
  9171. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9172. /**
  9173. * Binds the lights information from the scene to the effect for the given mesh.
  9174. * @param scene The scene the lights belongs to
  9175. * @param mesh The mesh we are binding the information to render
  9176. * @param effect The effect we are binding the data to
  9177. * @param defines The generated defines for the effect
  9178. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9179. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9180. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9181. */
  9182. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9183. private static _tempFogColor;
  9184. /**
  9185. * Binds the fog information from the scene to the effect for the given mesh.
  9186. * @param scene The scene the lights belongs to
  9187. * @param mesh The mesh we are binding the information to render
  9188. * @param effect The effect we are binding the data to
  9189. * @param linearSpace Defines if the fog effect is applied in linear space
  9190. */
  9191. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9192. /**
  9193. * Binds the bones information from the mesh to the effect.
  9194. * @param mesh The mesh we are binding the information to render
  9195. * @param effect The effect we are binding the data to
  9196. */
  9197. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9198. /**
  9199. * Binds the morph targets information from the mesh to the effect.
  9200. * @param abstractMesh The mesh we are binding the information to render
  9201. * @param effect The effect we are binding the data to
  9202. */
  9203. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9204. /**
  9205. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9206. * @param defines The generated defines used in the effect
  9207. * @param effect The effect we are binding the data to
  9208. * @param scene The scene we are willing to render with logarithmic scale for
  9209. */
  9210. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9211. /**
  9212. * Binds the clip plane information from the scene to the effect.
  9213. * @param scene The scene the clip plane information are extracted from
  9214. * @param effect The effect we are binding the data to
  9215. */
  9216. static BindClipPlane(effect: Effect, scene: Scene): void;
  9217. }
  9218. }
  9219. declare module BABYLON {
  9220. /** @hidden */
  9221. export var packingFunctions: {
  9222. name: string;
  9223. shader: string;
  9224. };
  9225. }
  9226. declare module BABYLON {
  9227. /** @hidden */
  9228. export var shadowMapPixelShader: {
  9229. name: string;
  9230. shader: string;
  9231. };
  9232. }
  9233. declare module BABYLON {
  9234. /** @hidden */
  9235. export var bonesDeclaration: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module BABYLON {
  9241. /** @hidden */
  9242. export var morphTargetsVertexGlobalDeclaration: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module BABYLON {
  9248. /** @hidden */
  9249. export var morphTargetsVertexDeclaration: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module BABYLON {
  9255. /** @hidden */
  9256. export var instancesDeclaration: {
  9257. name: string;
  9258. shader: string;
  9259. };
  9260. }
  9261. declare module BABYLON {
  9262. /** @hidden */
  9263. export var helperFunctions: {
  9264. name: string;
  9265. shader: string;
  9266. };
  9267. }
  9268. declare module BABYLON {
  9269. /** @hidden */
  9270. export var morphTargetsVertex: {
  9271. name: string;
  9272. shader: string;
  9273. };
  9274. }
  9275. declare module BABYLON {
  9276. /** @hidden */
  9277. export var instancesVertex: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module BABYLON {
  9283. /** @hidden */
  9284. export var bonesVertex: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module BABYLON {
  9290. /** @hidden */
  9291. export var shadowMapVertexShader: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module BABYLON {
  9297. /** @hidden */
  9298. export var depthBoxBlurPixelShader: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /**
  9305. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9306. */
  9307. export interface ICustomShaderOptions {
  9308. /**
  9309. * Gets or sets the custom shader name to use
  9310. */
  9311. shaderName: string;
  9312. /**
  9313. * The list of attribute names used in the shader
  9314. */
  9315. attributes?: string[];
  9316. /**
  9317. * The list of unifrom names used in the shader
  9318. */
  9319. uniforms?: string[];
  9320. /**
  9321. * The list of sampler names used in the shader
  9322. */
  9323. samplers?: string[];
  9324. /**
  9325. * The list of defines used in the shader
  9326. */
  9327. defines?: string[];
  9328. }
  9329. /**
  9330. * Interface to implement to create a shadow generator compatible with BJS.
  9331. */
  9332. export interface IShadowGenerator {
  9333. /**
  9334. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9335. * @returns The render target texture if present otherwise, null
  9336. */
  9337. getShadowMap(): Nullable<RenderTargetTexture>;
  9338. /**
  9339. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9340. * @returns The render target texture if the shadow map is present otherwise, null
  9341. */
  9342. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9343. /**
  9344. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9345. * @param subMesh The submesh we want to render in the shadow map
  9346. * @param useInstances Defines wether will draw in the map using instances
  9347. * @returns true if ready otherwise, false
  9348. */
  9349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9350. /**
  9351. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9352. * @param defines Defines of the material we want to update
  9353. * @param lightIndex Index of the light in the enabled light list of the material
  9354. */
  9355. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9356. /**
  9357. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9358. * defined in the generator but impacting the effect).
  9359. * It implies the unifroms available on the materials are the standard BJS ones.
  9360. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9361. * @param effect The effect we are binfing the information for
  9362. */
  9363. bindShadowLight(lightIndex: string, effect: Effect): void;
  9364. /**
  9365. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9366. * (eq to shadow prjection matrix * light transform matrix)
  9367. * @returns The transform matrix used to create the shadow map
  9368. */
  9369. getTransformMatrix(): Matrix;
  9370. /**
  9371. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9372. * Cube and 2D textures for instance.
  9373. */
  9374. recreateShadowMap(): void;
  9375. /**
  9376. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9377. * @param onCompiled Callback triggered at the and of the effects compilation
  9378. * @param options Sets of optional options forcing the compilation with different modes
  9379. */
  9380. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9381. useInstances: boolean;
  9382. }>): void;
  9383. /**
  9384. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9385. * @param options Sets of optional options forcing the compilation with different modes
  9386. * @returns A promise that resolves when the compilation completes
  9387. */
  9388. forceCompilationAsync(options?: Partial<{
  9389. useInstances: boolean;
  9390. }>): Promise<void>;
  9391. /**
  9392. * Serializes the shadow generator setup to a json object.
  9393. * @returns The serialized JSON object
  9394. */
  9395. serialize(): any;
  9396. /**
  9397. * Disposes the Shadow map and related Textures and effects.
  9398. */
  9399. dispose(): void;
  9400. }
  9401. /**
  9402. * Default implementation IShadowGenerator.
  9403. * This is the main object responsible of generating shadows in the framework.
  9404. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9405. */
  9406. export class ShadowGenerator implements IShadowGenerator {
  9407. /**
  9408. * Shadow generator mode None: no filtering applied.
  9409. */
  9410. static readonly FILTER_NONE: number;
  9411. /**
  9412. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9413. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9414. */
  9415. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9416. /**
  9417. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9418. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9419. */
  9420. static readonly FILTER_POISSONSAMPLING: number;
  9421. /**
  9422. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9423. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9424. */
  9425. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9426. /**
  9427. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9428. * edge artifacts on steep falloff.
  9429. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9430. */
  9431. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9432. /**
  9433. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9434. * edge artifacts on steep falloff.
  9435. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9436. */
  9437. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9438. /**
  9439. * Shadow generator mode PCF: Percentage Closer Filtering
  9440. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9441. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9442. */
  9443. static readonly FILTER_PCF: number;
  9444. /**
  9445. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9446. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9447. * Contact Hardening
  9448. */
  9449. static readonly FILTER_PCSS: number;
  9450. /**
  9451. * Reserved for PCF and PCSS
  9452. * Highest Quality.
  9453. *
  9454. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9455. *
  9456. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9457. */
  9458. static readonly QUALITY_HIGH: number;
  9459. /**
  9460. * Reserved for PCF and PCSS
  9461. * Good tradeoff for quality/perf cross devices
  9462. *
  9463. * Execute PCF on a 3*3 kernel.
  9464. *
  9465. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9466. */
  9467. static readonly QUALITY_MEDIUM: number;
  9468. /**
  9469. * Reserved for PCF and PCSS
  9470. * The lowest quality but the fastest.
  9471. *
  9472. * Execute PCF on a 1*1 kernel.
  9473. *
  9474. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9475. */
  9476. static readonly QUALITY_LOW: number;
  9477. /** Gets or sets the custom shader name to use */
  9478. customShaderOptions: ICustomShaderOptions;
  9479. /**
  9480. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9481. */
  9482. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9483. /**
  9484. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9485. */
  9486. onAfterShadowMapRenderObservable: Observable<Effect>;
  9487. /**
  9488. * Observable triggered before a mesh is rendered in the shadow map.
  9489. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9490. */
  9491. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9492. /**
  9493. * Observable triggered after a mesh is rendered in the shadow map.
  9494. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9495. */
  9496. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9497. private _bias;
  9498. /**
  9499. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9500. */
  9501. /**
  9502. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9503. */
  9504. bias: number;
  9505. private _normalBias;
  9506. /**
  9507. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9508. */
  9509. /**
  9510. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9511. */
  9512. normalBias: number;
  9513. private _blurBoxOffset;
  9514. /**
  9515. * Gets the blur box offset: offset applied during the blur pass.
  9516. * Only useful if useKernelBlur = false
  9517. */
  9518. /**
  9519. * Sets the blur box offset: offset applied during the blur pass.
  9520. * Only useful if useKernelBlur = false
  9521. */
  9522. blurBoxOffset: number;
  9523. private _blurScale;
  9524. /**
  9525. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9526. * 2 means half of the size.
  9527. */
  9528. /**
  9529. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9530. * 2 means half of the size.
  9531. */
  9532. blurScale: number;
  9533. private _blurKernel;
  9534. /**
  9535. * Gets the blur kernel: kernel size of the blur pass.
  9536. * Only useful if useKernelBlur = true
  9537. */
  9538. /**
  9539. * Sets the blur kernel: kernel size of the blur pass.
  9540. * Only useful if useKernelBlur = true
  9541. */
  9542. blurKernel: number;
  9543. private _useKernelBlur;
  9544. /**
  9545. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9546. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9547. */
  9548. /**
  9549. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9550. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9551. */
  9552. useKernelBlur: boolean;
  9553. private _depthScale;
  9554. /**
  9555. * Gets the depth scale used in ESM mode.
  9556. */
  9557. /**
  9558. * Sets the depth scale used in ESM mode.
  9559. * This can override the scale stored on the light.
  9560. */
  9561. depthScale: number;
  9562. private _filter;
  9563. /**
  9564. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9565. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9566. */
  9567. /**
  9568. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9569. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9570. */
  9571. filter: number;
  9572. /**
  9573. * Gets if the current filter is set to Poisson Sampling.
  9574. */
  9575. /**
  9576. * Sets the current filter to Poisson Sampling.
  9577. */
  9578. usePoissonSampling: boolean;
  9579. /**
  9580. * Gets if the current filter is set to ESM.
  9581. */
  9582. /**
  9583. * Sets the current filter is to ESM.
  9584. */
  9585. useExponentialShadowMap: boolean;
  9586. /**
  9587. * Gets if the current filter is set to filtered ESM.
  9588. */
  9589. /**
  9590. * Gets if the current filter is set to filtered ESM.
  9591. */
  9592. useBlurExponentialShadowMap: boolean;
  9593. /**
  9594. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9595. * exponential to prevent steep falloff artifacts).
  9596. */
  9597. /**
  9598. * Sets the current filter to "close ESM" (using the inverse of the
  9599. * exponential to prevent steep falloff artifacts).
  9600. */
  9601. useCloseExponentialShadowMap: boolean;
  9602. /**
  9603. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9604. * exponential to prevent steep falloff artifacts).
  9605. */
  9606. /**
  9607. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9608. * exponential to prevent steep falloff artifacts).
  9609. */
  9610. useBlurCloseExponentialShadowMap: boolean;
  9611. /**
  9612. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9613. */
  9614. /**
  9615. * Sets the current filter to "PCF" (percentage closer filtering).
  9616. */
  9617. usePercentageCloserFiltering: boolean;
  9618. private _filteringQuality;
  9619. /**
  9620. * Gets the PCF or PCSS Quality.
  9621. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9622. */
  9623. /**
  9624. * Sets the PCF or PCSS Quality.
  9625. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9626. */
  9627. filteringQuality: number;
  9628. /**
  9629. * Gets if the current filter is set to "PCSS" (contact hardening).
  9630. */
  9631. /**
  9632. * Sets the current filter to "PCSS" (contact hardening).
  9633. */
  9634. useContactHardeningShadow: boolean;
  9635. private _contactHardeningLightSizeUVRatio;
  9636. /**
  9637. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9638. * Using a ratio helps keeping shape stability independently of the map size.
  9639. *
  9640. * It does not account for the light projection as it was having too much
  9641. * instability during the light setup or during light position changes.
  9642. *
  9643. * Only valid if useContactHardeningShadow is true.
  9644. */
  9645. /**
  9646. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9647. * Using a ratio helps keeping shape stability independently of the map size.
  9648. *
  9649. * It does not account for the light projection as it was having too much
  9650. * instability during the light setup or during light position changes.
  9651. *
  9652. * Only valid if useContactHardeningShadow is true.
  9653. */
  9654. contactHardeningLightSizeUVRatio: number;
  9655. private _darkness;
  9656. /** Gets or sets the actual darkness of a shadow */
  9657. darkness: number;
  9658. /**
  9659. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9660. * 0 means strongest and 1 would means no shadow.
  9661. * @returns the darkness.
  9662. */
  9663. getDarkness(): number;
  9664. /**
  9665. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9666. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9667. * @returns the shadow generator allowing fluent coding.
  9668. */
  9669. setDarkness(darkness: number): ShadowGenerator;
  9670. private _transparencyShadow;
  9671. /** Gets or sets the ability to have transparent shadow */
  9672. transparencyShadow: boolean;
  9673. /**
  9674. * Sets the ability to have transparent shadow (boolean).
  9675. * @param transparent True if transparent else False
  9676. * @returns the shadow generator allowing fluent coding
  9677. */
  9678. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9679. private _shadowMap;
  9680. private _shadowMap2;
  9681. /**
  9682. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9683. * @returns The render target texture if present otherwise, null
  9684. */
  9685. getShadowMap(): Nullable<RenderTargetTexture>;
  9686. /**
  9687. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9688. * @returns The render target texture if the shadow map is present otherwise, null
  9689. */
  9690. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9691. /**
  9692. * Gets the class name of that object
  9693. * @returns "ShadowGenerator"
  9694. */
  9695. getClassName(): string;
  9696. /**
  9697. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9698. * @param mesh Mesh to add
  9699. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9700. * @returns the Shadow Generator itself
  9701. */
  9702. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9703. /**
  9704. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9705. * @param mesh Mesh to remove
  9706. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9707. * @returns the Shadow Generator itself
  9708. */
  9709. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9710. /**
  9711. * Controls the extent to which the shadows fade out at the edge of the frustum
  9712. * Used only by directionals and spots
  9713. */
  9714. frustumEdgeFalloff: number;
  9715. private _light;
  9716. /**
  9717. * Returns the associated light object.
  9718. * @returns the light generating the shadow
  9719. */
  9720. getLight(): IShadowLight;
  9721. /**
  9722. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9723. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9724. * It might on the other hand introduce peter panning.
  9725. */
  9726. forceBackFacesOnly: boolean;
  9727. private _scene;
  9728. private _lightDirection;
  9729. private _effect;
  9730. private _viewMatrix;
  9731. private _projectionMatrix;
  9732. private _transformMatrix;
  9733. private _cachedPosition;
  9734. private _cachedDirection;
  9735. private _cachedDefines;
  9736. private _currentRenderID;
  9737. private _boxBlurPostprocess;
  9738. private _kernelBlurXPostprocess;
  9739. private _kernelBlurYPostprocess;
  9740. private _blurPostProcesses;
  9741. private _mapSize;
  9742. private _currentFaceIndex;
  9743. private _currentFaceIndexCache;
  9744. private _textureType;
  9745. private _defaultTextureMatrix;
  9746. private _storedUniqueId;
  9747. /** @hidden */
  9748. static _SceneComponentInitialization: (scene: Scene) => void;
  9749. /**
  9750. * Creates a ShadowGenerator object.
  9751. * A ShadowGenerator is the required tool to use the shadows.
  9752. * Each light casting shadows needs to use its own ShadowGenerator.
  9753. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9754. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9755. * @param light The light object generating the shadows.
  9756. * @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.
  9757. */
  9758. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9759. private _initializeGenerator;
  9760. private _initializeShadowMap;
  9761. private _initializeBlurRTTAndPostProcesses;
  9762. private _renderForShadowMap;
  9763. private _renderSubMeshForShadowMap;
  9764. private _applyFilterValues;
  9765. /**
  9766. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9767. * @param onCompiled Callback triggered at the and of the effects compilation
  9768. * @param options Sets of optional options forcing the compilation with different modes
  9769. */
  9770. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9771. useInstances: boolean;
  9772. }>): void;
  9773. /**
  9774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9775. * @param options Sets of optional options forcing the compilation with different modes
  9776. * @returns A promise that resolves when the compilation completes
  9777. */
  9778. forceCompilationAsync(options?: Partial<{
  9779. useInstances: boolean;
  9780. }>): Promise<void>;
  9781. /**
  9782. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9783. * @param subMesh The submesh we want to render in the shadow map
  9784. * @param useInstances Defines wether will draw in the map using instances
  9785. * @returns true if ready otherwise, false
  9786. */
  9787. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9788. /**
  9789. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9790. * @param defines Defines of the material we want to update
  9791. * @param lightIndex Index of the light in the enabled light list of the material
  9792. */
  9793. prepareDefines(defines: any, lightIndex: number): void;
  9794. /**
  9795. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9796. * defined in the generator but impacting the effect).
  9797. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9798. * @param effect The effect we are binfing the information for
  9799. */
  9800. bindShadowLight(lightIndex: string, effect: Effect): void;
  9801. /**
  9802. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9803. * (eq to shadow prjection matrix * light transform matrix)
  9804. * @returns The transform matrix used to create the shadow map
  9805. */
  9806. getTransformMatrix(): Matrix;
  9807. /**
  9808. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9809. * Cube and 2D textures for instance.
  9810. */
  9811. recreateShadowMap(): void;
  9812. private _disposeBlurPostProcesses;
  9813. private _disposeRTTandPostProcesses;
  9814. /**
  9815. * Disposes the ShadowGenerator.
  9816. * Returns nothing.
  9817. */
  9818. dispose(): void;
  9819. /**
  9820. * Serializes the shadow generator setup to a json object.
  9821. * @returns The serialized JSON object
  9822. */
  9823. serialize(): any;
  9824. /**
  9825. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9826. * @param parsedShadowGenerator The JSON object to parse
  9827. * @param scene The scene to create the shadow map for
  9828. * @returns The parsed shadow generator
  9829. */
  9830. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9831. }
  9832. }
  9833. declare module BABYLON {
  9834. /**
  9835. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9836. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9837. * 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.
  9838. */
  9839. export abstract class Light extends Node {
  9840. /**
  9841. * Falloff Default: light is falling off following the material specification:
  9842. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9843. */
  9844. static readonly FALLOFF_DEFAULT: number;
  9845. /**
  9846. * Falloff Physical: light is falling off following the inverse squared distance law.
  9847. */
  9848. static readonly FALLOFF_PHYSICAL: number;
  9849. /**
  9850. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9851. * to enhance interoperability with other engines.
  9852. */
  9853. static readonly FALLOFF_GLTF: number;
  9854. /**
  9855. * Falloff Standard: light is falling off like in the standard material
  9856. * to enhance interoperability with other materials.
  9857. */
  9858. static readonly FALLOFF_STANDARD: number;
  9859. /**
  9860. * If every light affecting the material is in this lightmapMode,
  9861. * material.lightmapTexture adds or multiplies
  9862. * (depends on material.useLightmapAsShadowmap)
  9863. * after every other light calculations.
  9864. */
  9865. static readonly LIGHTMAP_DEFAULT: number;
  9866. /**
  9867. * material.lightmapTexture as only diffuse lighting from this light
  9868. * adds only specular lighting from this light
  9869. * adds dynamic shadows
  9870. */
  9871. static readonly LIGHTMAP_SPECULAR: number;
  9872. /**
  9873. * material.lightmapTexture as only lighting
  9874. * no light calculation from this light
  9875. * only adds dynamic shadows from this light
  9876. */
  9877. static readonly LIGHTMAP_SHADOWSONLY: number;
  9878. /**
  9879. * Each light type uses the default quantity according to its type:
  9880. * point/spot lights use luminous intensity
  9881. * directional lights use illuminance
  9882. */
  9883. static readonly INTENSITYMODE_AUTOMATIC: number;
  9884. /**
  9885. * lumen (lm)
  9886. */
  9887. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9888. /**
  9889. * candela (lm/sr)
  9890. */
  9891. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9892. /**
  9893. * lux (lm/m^2)
  9894. */
  9895. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9896. /**
  9897. * nit (cd/m^2)
  9898. */
  9899. static readonly INTENSITYMODE_LUMINANCE: number;
  9900. /**
  9901. * Light type const id of the point light.
  9902. */
  9903. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9904. /**
  9905. * Light type const id of the directional light.
  9906. */
  9907. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9908. /**
  9909. * Light type const id of the spot light.
  9910. */
  9911. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9912. /**
  9913. * Light type const id of the hemispheric light.
  9914. */
  9915. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9916. /**
  9917. * Diffuse gives the basic color to an object.
  9918. */
  9919. diffuse: Color3;
  9920. /**
  9921. * Specular produces a highlight color on an object.
  9922. * Note: This is note affecting PBR materials.
  9923. */
  9924. specular: Color3;
  9925. /**
  9926. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9927. * falling off base on range or angle.
  9928. * This can be set to any values in Light.FALLOFF_x.
  9929. *
  9930. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9931. * other types of materials.
  9932. */
  9933. falloffType: number;
  9934. /**
  9935. * Strength of the light.
  9936. * Note: By default it is define in the framework own unit.
  9937. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9938. */
  9939. intensity: number;
  9940. private _range;
  9941. protected _inverseSquaredRange: number;
  9942. /**
  9943. * Defines how far from the source the light is impacting in scene units.
  9944. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9945. */
  9946. /**
  9947. * Defines how far from the source the light is impacting in scene units.
  9948. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9949. */
  9950. range: number;
  9951. /**
  9952. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9953. * of light.
  9954. */
  9955. private _photometricScale;
  9956. private _intensityMode;
  9957. /**
  9958. * Gets the photometric scale used to interpret the intensity.
  9959. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9960. */
  9961. /**
  9962. * Sets the photometric scale used to interpret the intensity.
  9963. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9964. */
  9965. intensityMode: number;
  9966. private _radius;
  9967. /**
  9968. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9969. */
  9970. /**
  9971. * sets the light radius used by PBR Materials to simulate soft area lights.
  9972. */
  9973. radius: number;
  9974. private _renderPriority;
  9975. /**
  9976. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9977. * exceeding the number allowed of the materials.
  9978. */
  9979. renderPriority: number;
  9980. private _shadowEnabled;
  9981. /**
  9982. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9983. * the current shadow generator.
  9984. */
  9985. /**
  9986. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9987. * the current shadow generator.
  9988. */
  9989. shadowEnabled: boolean;
  9990. private _includedOnlyMeshes;
  9991. /**
  9992. * Gets the only meshes impacted by this light.
  9993. */
  9994. /**
  9995. * Sets the only meshes impacted by this light.
  9996. */
  9997. includedOnlyMeshes: AbstractMesh[];
  9998. private _excludedMeshes;
  9999. /**
  10000. * Gets the meshes not impacted by this light.
  10001. */
  10002. /**
  10003. * Sets the meshes not impacted by this light.
  10004. */
  10005. excludedMeshes: AbstractMesh[];
  10006. private _excludeWithLayerMask;
  10007. /**
  10008. * Gets the layer id use to find what meshes are not impacted by the light.
  10009. * Inactive if 0
  10010. */
  10011. /**
  10012. * Sets the layer id use to find what meshes are not impacted by the light.
  10013. * Inactive if 0
  10014. */
  10015. excludeWithLayerMask: number;
  10016. private _includeOnlyWithLayerMask;
  10017. /**
  10018. * Gets the layer id use to find what meshes are impacted by the light.
  10019. * Inactive if 0
  10020. */
  10021. /**
  10022. * Sets the layer id use to find what meshes are impacted by the light.
  10023. * Inactive if 0
  10024. */
  10025. includeOnlyWithLayerMask: number;
  10026. private _lightmapMode;
  10027. /**
  10028. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10029. */
  10030. /**
  10031. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10032. */
  10033. lightmapMode: number;
  10034. /**
  10035. * Shadow generator associted to the light.
  10036. * @hidden Internal use only.
  10037. */
  10038. _shadowGenerator: Nullable<IShadowGenerator>;
  10039. /**
  10040. * @hidden Internal use only.
  10041. */
  10042. _excludedMeshesIds: string[];
  10043. /**
  10044. * @hidden Internal use only.
  10045. */
  10046. _includedOnlyMeshesIds: string[];
  10047. /**
  10048. * The current light unifom buffer.
  10049. * @hidden Internal use only.
  10050. */
  10051. _uniformBuffer: UniformBuffer;
  10052. /** @hidden */
  10053. _renderId: number;
  10054. /**
  10055. * Creates a Light object in the scene.
  10056. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10057. * @param name The firendly name of the light
  10058. * @param scene The scene the light belongs too
  10059. */
  10060. constructor(name: string, scene: Scene);
  10061. protected abstract _buildUniformLayout(): void;
  10062. /**
  10063. * Sets the passed Effect "effect" with the Light information.
  10064. * @param effect The effect to update
  10065. * @param lightIndex The index of the light in the effect to update
  10066. * @returns The light
  10067. */
  10068. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10069. /**
  10070. * Sets the passed Effect "effect" with the Light textures.
  10071. * @param effect The effect to update
  10072. * @param lightIndex The index of the light in the effect to update
  10073. * @returns The light
  10074. */
  10075. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10076. /**
  10077. * Binds the lights information from the scene to the effect for the given mesh.
  10078. * @param lightIndex Light index
  10079. * @param scene The scene where the light belongs to
  10080. * @param effect The effect we are binding the data to
  10081. * @param useSpecular Defines if specular is supported
  10082. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10083. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10084. */
  10085. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10086. /**
  10087. * Sets the passed Effect "effect" with the Light information.
  10088. * @param effect The effect to update
  10089. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10090. * @returns The light
  10091. */
  10092. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10093. /**
  10094. * Returns the string "Light".
  10095. * @returns the class name
  10096. */
  10097. getClassName(): string;
  10098. /** @hidden */
  10099. readonly _isLight: boolean;
  10100. /**
  10101. * Converts the light information to a readable string for debug purpose.
  10102. * @param fullDetails Supports for multiple levels of logging within scene loading
  10103. * @returns the human readable light info
  10104. */
  10105. toString(fullDetails?: boolean): string;
  10106. /** @hidden */
  10107. protected _syncParentEnabledState(): void;
  10108. /**
  10109. * Set the enabled state of this node.
  10110. * @param value - the new enabled state
  10111. */
  10112. setEnabled(value: boolean): void;
  10113. /**
  10114. * Returns the Light associated shadow generator if any.
  10115. * @return the associated shadow generator.
  10116. */
  10117. getShadowGenerator(): Nullable<IShadowGenerator>;
  10118. /**
  10119. * Returns a Vector3, the absolute light position in the World.
  10120. * @returns the world space position of the light
  10121. */
  10122. getAbsolutePosition(): Vector3;
  10123. /**
  10124. * Specifies if the light will affect the passed mesh.
  10125. * @param mesh The mesh to test against the light
  10126. * @return true the mesh is affected otherwise, false.
  10127. */
  10128. canAffectMesh(mesh: AbstractMesh): boolean;
  10129. /**
  10130. * Sort function to order lights for rendering.
  10131. * @param a First Light object to compare to second.
  10132. * @param b Second Light object to compare first.
  10133. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10134. */
  10135. static CompareLightsPriority(a: Light, b: Light): number;
  10136. /**
  10137. * Releases resources associated with this node.
  10138. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10139. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10140. */
  10141. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10142. /**
  10143. * Returns the light type ID (integer).
  10144. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10145. */
  10146. getTypeID(): number;
  10147. /**
  10148. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10149. * @returns the scaled intensity in intensity mode unit
  10150. */
  10151. getScaledIntensity(): number;
  10152. /**
  10153. * Returns a new Light object, named "name", from the current one.
  10154. * @param name The name of the cloned light
  10155. * @returns the new created light
  10156. */
  10157. clone(name: string): Nullable<Light>;
  10158. /**
  10159. * Serializes the current light into a Serialization object.
  10160. * @returns the serialized object.
  10161. */
  10162. serialize(): any;
  10163. /**
  10164. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10165. * This new light is named "name" and added to the passed scene.
  10166. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10167. * @param name The friendly name of the light
  10168. * @param scene The scene the new light will belong to
  10169. * @returns the constructor function
  10170. */
  10171. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10172. /**
  10173. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10174. * @param parsedLight The JSON representation of the light
  10175. * @param scene The scene to create the parsed light in
  10176. * @returns the created light after parsing
  10177. */
  10178. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10179. private _hookArrayForExcluded;
  10180. private _hookArrayForIncludedOnly;
  10181. private _resyncMeshes;
  10182. /**
  10183. * Forces the meshes to update their light related information in their rendering used effects
  10184. * @hidden Internal Use Only
  10185. */
  10186. _markMeshesAsLightDirty(): void;
  10187. /**
  10188. * Recomputes the cached photometric scale if needed.
  10189. */
  10190. private _computePhotometricScale;
  10191. /**
  10192. * Returns the Photometric Scale according to the light type and intensity mode.
  10193. */
  10194. private _getPhotometricScale;
  10195. /**
  10196. * Reorder the light in the scene according to their defined priority.
  10197. * @hidden Internal Use Only
  10198. */
  10199. _reorderLightsInScene(): void;
  10200. /**
  10201. * Prepares the list of defines specific to the light type.
  10202. * @param defines the list of defines
  10203. * @param lightIndex defines the index of the light for the effect
  10204. */
  10205. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10206. }
  10207. }
  10208. declare module BABYLON {
  10209. /**
  10210. * Interface used to define Action
  10211. */
  10212. export interface IAction {
  10213. /**
  10214. * Trigger for the action
  10215. */
  10216. trigger: number;
  10217. /** Options of the trigger */
  10218. triggerOptions: any;
  10219. /**
  10220. * Gets the trigger parameters
  10221. * @returns the trigger parameters
  10222. */
  10223. getTriggerParameter(): any;
  10224. /**
  10225. * Internal only - executes current action event
  10226. * @hidden
  10227. */
  10228. _executeCurrent(evt?: ActionEvent): void;
  10229. /**
  10230. * Serialize placeholder for child classes
  10231. * @param parent of child
  10232. * @returns the serialized object
  10233. */
  10234. serialize(parent: any): any;
  10235. /**
  10236. * Internal only
  10237. * @hidden
  10238. */
  10239. _prepare(): void;
  10240. /**
  10241. * Internal only - manager for action
  10242. * @hidden
  10243. */
  10244. _actionManager: AbstractActionManager;
  10245. /**
  10246. * Adds action to chain of actions, may be a DoNothingAction
  10247. * @param action defines the next action to execute
  10248. * @returns The action passed in
  10249. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10250. */
  10251. then(action: IAction): IAction;
  10252. }
  10253. /**
  10254. * The action to be carried out following a trigger
  10255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10256. */
  10257. export class Action implements IAction {
  10258. /** the trigger, with or without parameters, for the action */
  10259. triggerOptions: any;
  10260. /**
  10261. * Trigger for the action
  10262. */
  10263. trigger: number;
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. private _nextActiveAction;
  10270. private _child;
  10271. private _condition?;
  10272. private _triggerParameter;
  10273. /**
  10274. * An event triggered prior to action being executed.
  10275. */
  10276. onBeforeExecuteObservable: Observable<Action>;
  10277. /**
  10278. * Creates a new Action
  10279. * @param triggerOptions the trigger, with or without parameters, for the action
  10280. * @param condition an optional determinant of action
  10281. */
  10282. constructor(
  10283. /** the trigger, with or without parameters, for the action */
  10284. triggerOptions: any, condition?: Condition);
  10285. /**
  10286. * Internal only
  10287. * @hidden
  10288. */
  10289. _prepare(): void;
  10290. /**
  10291. * Gets the trigger parameters
  10292. * @returns the trigger parameters
  10293. */
  10294. getTriggerParameter(): any;
  10295. /**
  10296. * Internal only - executes current action event
  10297. * @hidden
  10298. */
  10299. _executeCurrent(evt?: ActionEvent): void;
  10300. /**
  10301. * Execute placeholder for child classes
  10302. * @param evt optional action event
  10303. */
  10304. execute(evt?: ActionEvent): void;
  10305. /**
  10306. * Skips to next active action
  10307. */
  10308. skipToNextActiveAction(): void;
  10309. /**
  10310. * Adds action to chain of actions, may be a DoNothingAction
  10311. * @param action defines the next action to execute
  10312. * @returns The action passed in
  10313. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10314. */
  10315. then(action: Action): Action;
  10316. /**
  10317. * Internal only
  10318. * @hidden
  10319. */
  10320. _getProperty(propertyPath: string): string;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. _getEffectiveTarget(target: any, propertyPath: string): any;
  10326. /**
  10327. * Serialize placeholder for child classes
  10328. * @param parent of child
  10329. * @returns the serialized object
  10330. */
  10331. serialize(parent: any): any;
  10332. /**
  10333. * Internal only called by serialize
  10334. * @hidden
  10335. */
  10336. protected _serialize(serializedAction: any, parent?: any): any;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. static _SerializeValueAsString: (value: any) => string;
  10342. /**
  10343. * Internal only
  10344. * @hidden
  10345. */
  10346. static _GetTargetProperty: (target: Node | Scene) => {
  10347. name: string;
  10348. targetType: string;
  10349. value: string;
  10350. };
  10351. }
  10352. }
  10353. declare module BABYLON {
  10354. /**
  10355. * A Condition applied to an Action
  10356. */
  10357. export class Condition {
  10358. /**
  10359. * Internal only - manager for action
  10360. * @hidden
  10361. */
  10362. _actionManager: ActionManager;
  10363. /**
  10364. * Internal only
  10365. * @hidden
  10366. */
  10367. _evaluationId: number;
  10368. /**
  10369. * Internal only
  10370. * @hidden
  10371. */
  10372. _currentResult: boolean;
  10373. /**
  10374. * Creates a new Condition
  10375. * @param actionManager the manager of the action the condition is applied to
  10376. */
  10377. constructor(actionManager: ActionManager);
  10378. /**
  10379. * Check if the current condition is valid
  10380. * @returns a boolean
  10381. */
  10382. isValid(): boolean;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. _getProperty(propertyPath: string): string;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. _getEffectiveTarget(target: any, propertyPath: string): any;
  10393. /**
  10394. * Serialize placeholder for child classes
  10395. * @returns the serialized object
  10396. */
  10397. serialize(): any;
  10398. /**
  10399. * Internal only
  10400. * @hidden
  10401. */
  10402. protected _serialize(serializedCondition: any): any;
  10403. }
  10404. /**
  10405. * Defines specific conditional operators as extensions of Condition
  10406. */
  10407. export class ValueCondition extends Condition {
  10408. /** path to specify the property of the target the conditional operator uses */
  10409. propertyPath: string;
  10410. /** the value compared by the conditional operator against the current value of the property */
  10411. value: any;
  10412. /** the conditional operator, default ValueCondition.IsEqual */
  10413. operator: number;
  10414. /**
  10415. * Internal only
  10416. * @hidden
  10417. */
  10418. private static _IsEqual;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. private static _IsDifferent;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. private static _IsGreater;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. private static _IsLesser;
  10434. /**
  10435. * returns the number for IsEqual
  10436. */
  10437. static readonly IsEqual: number;
  10438. /**
  10439. * Returns the number for IsDifferent
  10440. */
  10441. static readonly IsDifferent: number;
  10442. /**
  10443. * Returns the number for IsGreater
  10444. */
  10445. static readonly IsGreater: number;
  10446. /**
  10447. * Returns the number for IsLesser
  10448. */
  10449. static readonly IsLesser: number;
  10450. /**
  10451. * Internal only The action manager for the condition
  10452. * @hidden
  10453. */
  10454. _actionManager: ActionManager;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private _target;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private _effectiveTarget;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private _property;
  10470. /**
  10471. * Creates a new ValueCondition
  10472. * @param actionManager manager for the action the condition applies to
  10473. * @param target for the action
  10474. * @param propertyPath path to specify the property of the target the conditional operator uses
  10475. * @param value the value compared by the conditional operator against the current value of the property
  10476. * @param operator the conditional operator, default ValueCondition.IsEqual
  10477. */
  10478. constructor(actionManager: ActionManager, target: any,
  10479. /** path to specify the property of the target the conditional operator uses */
  10480. propertyPath: string,
  10481. /** the value compared by the conditional operator against the current value of the property */
  10482. value: any,
  10483. /** the conditional operator, default ValueCondition.IsEqual */
  10484. operator?: number);
  10485. /**
  10486. * Compares the given value with the property value for the specified conditional operator
  10487. * @returns the result of the comparison
  10488. */
  10489. isValid(): boolean;
  10490. /**
  10491. * Serialize the ValueCondition into a JSON compatible object
  10492. * @returns serialization object
  10493. */
  10494. serialize(): any;
  10495. /**
  10496. * Gets the name of the conditional operator for the ValueCondition
  10497. * @param operator the conditional operator
  10498. * @returns the name
  10499. */
  10500. static GetOperatorName(operator: number): string;
  10501. }
  10502. /**
  10503. * Defines a predicate condition as an extension of Condition
  10504. */
  10505. export class PredicateCondition extends Condition {
  10506. /** defines the predicate function used to validate the condition */
  10507. predicate: () => boolean;
  10508. /**
  10509. * Internal only - manager for action
  10510. * @hidden
  10511. */
  10512. _actionManager: ActionManager;
  10513. /**
  10514. * Creates a new PredicateCondition
  10515. * @param actionManager manager for the action the condition applies to
  10516. * @param predicate defines the predicate function used to validate the condition
  10517. */
  10518. constructor(actionManager: ActionManager,
  10519. /** defines the predicate function used to validate the condition */
  10520. predicate: () => boolean);
  10521. /**
  10522. * @returns the validity of the predicate condition
  10523. */
  10524. isValid(): boolean;
  10525. }
  10526. /**
  10527. * Defines a state condition as an extension of Condition
  10528. */
  10529. export class StateCondition extends Condition {
  10530. /** Value to compare with target state */
  10531. value: string;
  10532. /**
  10533. * Internal only - manager for action
  10534. * @hidden
  10535. */
  10536. _actionManager: ActionManager;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private _target;
  10542. /**
  10543. * Creates a new StateCondition
  10544. * @param actionManager manager for the action the condition applies to
  10545. * @param target of the condition
  10546. * @param value to compare with target state
  10547. */
  10548. constructor(actionManager: ActionManager, target: any,
  10549. /** Value to compare with target state */
  10550. value: string);
  10551. /**
  10552. * Gets a boolean indicating if the current condition is met
  10553. * @returns the validity of the state
  10554. */
  10555. isValid(): boolean;
  10556. /**
  10557. * Serialize the StateCondition into a JSON compatible object
  10558. * @returns serialization object
  10559. */
  10560. serialize(): any;
  10561. }
  10562. }
  10563. declare module BABYLON {
  10564. /**
  10565. * This defines an action responsible to toggle a boolean once triggered.
  10566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class SwitchBooleanAction extends Action {
  10569. /**
  10570. * The path to the boolean property in the target object
  10571. */
  10572. propertyPath: string;
  10573. private _target;
  10574. private _effectiveTarget;
  10575. private _property;
  10576. /**
  10577. * Instantiate the action
  10578. * @param triggerOptions defines the trigger options
  10579. * @param target defines the object containing the boolean
  10580. * @param propertyPath defines the path to the boolean property in the target object
  10581. * @param condition defines the trigger related conditions
  10582. */
  10583. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10584. /** @hidden */
  10585. _prepare(): void;
  10586. /**
  10587. * Execute the action toggle the boolean value.
  10588. */
  10589. execute(): void;
  10590. /**
  10591. * Serializes the actions and its related information.
  10592. * @param parent defines the object to serialize in
  10593. * @returns the serialized object
  10594. */
  10595. serialize(parent: any): any;
  10596. }
  10597. /**
  10598. * This defines an action responsible to set a the state field of the target
  10599. * to a desired value once triggered.
  10600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10601. */
  10602. export class SetStateAction extends Action {
  10603. /**
  10604. * The value to store in the state field.
  10605. */
  10606. value: string;
  10607. private _target;
  10608. /**
  10609. * Instantiate the action
  10610. * @param triggerOptions defines the trigger options
  10611. * @param target defines the object containing the state property
  10612. * @param value defines the value to store in the state field
  10613. * @param condition defines the trigger related conditions
  10614. */
  10615. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10616. /**
  10617. * Execute the action and store the value on the target state property.
  10618. */
  10619. execute(): void;
  10620. /**
  10621. * Serializes the actions and its related information.
  10622. * @param parent defines the object to serialize in
  10623. * @returns the serialized object
  10624. */
  10625. serialize(parent: any): any;
  10626. }
  10627. /**
  10628. * This defines an action responsible to set a property of the target
  10629. * to a desired value once triggered.
  10630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10631. */
  10632. export class SetValueAction extends Action {
  10633. /**
  10634. * The path of the property to set in the target.
  10635. */
  10636. propertyPath: string;
  10637. /**
  10638. * The value to set in the property
  10639. */
  10640. value: any;
  10641. private _target;
  10642. private _effectiveTarget;
  10643. private _property;
  10644. /**
  10645. * Instantiate the action
  10646. * @param triggerOptions defines the trigger options
  10647. * @param target defines the object containing the property
  10648. * @param propertyPath defines the path of the property to set in the target
  10649. * @param value defines the value to set in the property
  10650. * @param condition defines the trigger related conditions
  10651. */
  10652. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10653. /** @hidden */
  10654. _prepare(): void;
  10655. /**
  10656. * Execute the action and set the targetted property to the desired value.
  10657. */
  10658. execute(): void;
  10659. /**
  10660. * Serializes the actions and its related information.
  10661. * @param parent defines the object to serialize in
  10662. * @returns the serialized object
  10663. */
  10664. serialize(parent: any): any;
  10665. }
  10666. /**
  10667. * This defines an action responsible to increment the target value
  10668. * to a desired value once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class IncrementValueAction extends Action {
  10672. /**
  10673. * The path of the property to increment in the target.
  10674. */
  10675. propertyPath: string;
  10676. /**
  10677. * The value we should increment the property by.
  10678. */
  10679. value: any;
  10680. private _target;
  10681. private _effectiveTarget;
  10682. private _property;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the object containing the property
  10687. * @param propertyPath defines the path of the property to increment in the target
  10688. * @param value defines the value value we should increment the property by
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and increment the target of the value amount.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible to start an animation once triggered.
  10707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10708. */
  10709. export class PlayAnimationAction extends Action {
  10710. /**
  10711. * Where the animation should start (animation frame)
  10712. */
  10713. from: number;
  10714. /**
  10715. * Where the animation should stop (animation frame)
  10716. */
  10717. to: number;
  10718. /**
  10719. * Define if the animation should loop or stop after the first play.
  10720. */
  10721. loop?: boolean;
  10722. private _target;
  10723. /**
  10724. * Instantiate the action
  10725. * @param triggerOptions defines the trigger options
  10726. * @param target defines the target animation or animation name
  10727. * @param from defines from where the animation should start (animation frame)
  10728. * @param end defines where the animation should stop (animation frame)
  10729. * @param loop defines if the animation should loop or stop after the first play
  10730. * @param condition defines the trigger related conditions
  10731. */
  10732. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10733. /** @hidden */
  10734. _prepare(): void;
  10735. /**
  10736. * Execute the action and play the animation.
  10737. */
  10738. execute(): void;
  10739. /**
  10740. * Serializes the actions and its related information.
  10741. * @param parent defines the object to serialize in
  10742. * @returns the serialized object
  10743. */
  10744. serialize(parent: any): any;
  10745. }
  10746. /**
  10747. * This defines an action responsible to stop an animation once triggered.
  10748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10749. */
  10750. export class StopAnimationAction extends Action {
  10751. private _target;
  10752. /**
  10753. * Instantiate the action
  10754. * @param triggerOptions defines the trigger options
  10755. * @param target defines the target animation or animation name
  10756. * @param condition defines the trigger related conditions
  10757. */
  10758. constructor(triggerOptions: any, target: any, condition?: Condition);
  10759. /** @hidden */
  10760. _prepare(): void;
  10761. /**
  10762. * Execute the action and stop the animation.
  10763. */
  10764. execute(): void;
  10765. /**
  10766. * Serializes the actions and its related information.
  10767. * @param parent defines the object to serialize in
  10768. * @returns the serialized object
  10769. */
  10770. serialize(parent: any): any;
  10771. }
  10772. /**
  10773. * This defines an action responsible that does nothing once triggered.
  10774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10775. */
  10776. export class DoNothingAction extends Action {
  10777. /**
  10778. * Instantiate the action
  10779. * @param triggerOptions defines the trigger options
  10780. * @param condition defines the trigger related conditions
  10781. */
  10782. constructor(triggerOptions?: any, condition?: Condition);
  10783. /**
  10784. * Execute the action and do nothing.
  10785. */
  10786. execute(): void;
  10787. /**
  10788. * Serializes the actions and its related information.
  10789. * @param parent defines the object to serialize in
  10790. * @returns the serialized object
  10791. */
  10792. serialize(parent: any): any;
  10793. }
  10794. /**
  10795. * This defines an action responsible to trigger several actions once triggered.
  10796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10797. */
  10798. export class CombineAction extends Action {
  10799. /**
  10800. * The list of aggregated animations to run.
  10801. */
  10802. children: Action[];
  10803. /**
  10804. * Instantiate the action
  10805. * @param triggerOptions defines the trigger options
  10806. * @param children defines the list of aggregated animations to run
  10807. * @param condition defines the trigger related conditions
  10808. */
  10809. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10810. /** @hidden */
  10811. _prepare(): void;
  10812. /**
  10813. * Execute the action and executes all the aggregated actions.
  10814. */
  10815. execute(evt: ActionEvent): void;
  10816. /**
  10817. * Serializes the actions and its related information.
  10818. * @param parent defines the object to serialize in
  10819. * @returns the serialized object
  10820. */
  10821. serialize(parent: any): any;
  10822. }
  10823. /**
  10824. * This defines an action responsible to run code (external event) once triggered.
  10825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10826. */
  10827. export class ExecuteCodeAction extends Action {
  10828. /**
  10829. * The callback function to run.
  10830. */
  10831. func: (evt: ActionEvent) => void;
  10832. /**
  10833. * Instantiate the action
  10834. * @param triggerOptions defines the trigger options
  10835. * @param func defines the callback function to run
  10836. * @param condition defines the trigger related conditions
  10837. */
  10838. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10839. /**
  10840. * Execute the action and run the attached code.
  10841. */
  10842. execute(evt: ActionEvent): void;
  10843. }
  10844. /**
  10845. * This defines an action responsible to set the parent property of the target once triggered.
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10847. */
  10848. export class SetParentAction extends Action {
  10849. private _parent;
  10850. private _target;
  10851. /**
  10852. * Instantiate the action
  10853. * @param triggerOptions defines the trigger options
  10854. * @param target defines the target containing the parent property
  10855. * @param parent defines from where the animation should start (animation frame)
  10856. * @param condition defines the trigger related conditions
  10857. */
  10858. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10859. /** @hidden */
  10860. _prepare(): void;
  10861. /**
  10862. * Execute the action and set the parent property.
  10863. */
  10864. execute(): void;
  10865. /**
  10866. * Serializes the actions and its related information.
  10867. * @param parent defines the object to serialize in
  10868. * @returns the serialized object
  10869. */
  10870. serialize(parent: any): any;
  10871. }
  10872. }
  10873. declare module BABYLON {
  10874. /**
  10875. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10876. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10878. */
  10879. export class ActionManager extends AbstractActionManager {
  10880. /**
  10881. * Nothing
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly NothingTrigger: number;
  10885. /**
  10886. * On pick
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnPickTrigger: number;
  10890. /**
  10891. * On left pick
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10893. */
  10894. static readonly OnLeftPickTrigger: number;
  10895. /**
  10896. * On right pick
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10898. */
  10899. static readonly OnRightPickTrigger: number;
  10900. /**
  10901. * On center pick
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10903. */
  10904. static readonly OnCenterPickTrigger: number;
  10905. /**
  10906. * On pick down
  10907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10908. */
  10909. static readonly OnPickDownTrigger: number;
  10910. /**
  10911. * On double pick
  10912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10913. */
  10914. static readonly OnDoublePickTrigger: number;
  10915. /**
  10916. * On pick up
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10918. */
  10919. static readonly OnPickUpTrigger: number;
  10920. /**
  10921. * On pick out.
  10922. * This trigger will only be raised if you also declared a OnPickDown
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10924. */
  10925. static readonly OnPickOutTrigger: number;
  10926. /**
  10927. * On long press
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10929. */
  10930. static readonly OnLongPressTrigger: number;
  10931. /**
  10932. * On pointer over
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10934. */
  10935. static readonly OnPointerOverTrigger: number;
  10936. /**
  10937. * On pointer out
  10938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10939. */
  10940. static readonly OnPointerOutTrigger: number;
  10941. /**
  10942. * On every frame
  10943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10944. */
  10945. static readonly OnEveryFrameTrigger: number;
  10946. /**
  10947. * On intersection enter
  10948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10949. */
  10950. static readonly OnIntersectionEnterTrigger: number;
  10951. /**
  10952. * On intersection exit
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10954. */
  10955. static readonly OnIntersectionExitTrigger: number;
  10956. /**
  10957. * On key down
  10958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10959. */
  10960. static readonly OnKeyDownTrigger: number;
  10961. /**
  10962. * On key up
  10963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10964. */
  10965. static readonly OnKeyUpTrigger: number;
  10966. private _scene;
  10967. /**
  10968. * Creates a new action manager
  10969. * @param scene defines the hosting scene
  10970. */
  10971. constructor(scene: Scene);
  10972. /**
  10973. * Releases all associated resources
  10974. */
  10975. dispose(): void;
  10976. /**
  10977. * Gets hosting scene
  10978. * @returns the hosting scene
  10979. */
  10980. getScene(): Scene;
  10981. /**
  10982. * Does this action manager handles actions of any of the given triggers
  10983. * @param triggers defines the triggers to be tested
  10984. * @return a boolean indicating whether one (or more) of the triggers is handled
  10985. */
  10986. hasSpecificTriggers(triggers: number[]): boolean;
  10987. /**
  10988. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10989. * speed.
  10990. * @param triggerA defines the trigger to be tested
  10991. * @param triggerB defines the trigger to be tested
  10992. * @return a boolean indicating whether one (or more) of the triggers is handled
  10993. */
  10994. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10995. /**
  10996. * Does this action manager handles actions of a given trigger
  10997. * @param trigger defines the trigger to be tested
  10998. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10999. * @return whether the trigger is handled
  11000. */
  11001. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11002. /**
  11003. * Does this action manager has pointer triggers
  11004. */
  11005. readonly hasPointerTriggers: boolean;
  11006. /**
  11007. * Does this action manager has pick triggers
  11008. */
  11009. readonly hasPickTriggers: boolean;
  11010. /**
  11011. * Registers an action to this action manager
  11012. * @param action defines the action to be registered
  11013. * @return the action amended (prepared) after registration
  11014. */
  11015. registerAction(action: IAction): Nullable<IAction>;
  11016. /**
  11017. * Unregisters an action to this action manager
  11018. * @param action defines the action to be unregistered
  11019. * @return a boolean indicating whether the action has been unregistered
  11020. */
  11021. unregisterAction(action: IAction): Boolean;
  11022. /**
  11023. * Process a specific trigger
  11024. * @param trigger defines the trigger to process
  11025. * @param evt defines the event details to be processed
  11026. */
  11027. processTrigger(trigger: number, evt?: IActionEvent): void;
  11028. /** @hidden */
  11029. _getEffectiveTarget(target: any, propertyPath: string): any;
  11030. /** @hidden */
  11031. _getProperty(propertyPath: string): string;
  11032. /**
  11033. * Serialize this manager to a JSON object
  11034. * @param name defines the property name to store this manager
  11035. * @returns a JSON representation of this manager
  11036. */
  11037. serialize(name: string): any;
  11038. /**
  11039. * Creates a new ActionManager from a JSON data
  11040. * @param parsedActions defines the JSON data to read from
  11041. * @param object defines the hosting mesh
  11042. * @param scene defines the hosting scene
  11043. */
  11044. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11045. /**
  11046. * Get a trigger name by index
  11047. * @param trigger defines the trigger index
  11048. * @returns a trigger name
  11049. */
  11050. static GetTriggerName(trigger: number): string;
  11051. }
  11052. }
  11053. declare module BABYLON {
  11054. /**
  11055. * Class representing a ray with position and direction
  11056. */
  11057. export class Ray {
  11058. /** origin point */
  11059. origin: Vector3;
  11060. /** direction */
  11061. direction: Vector3;
  11062. /** length of the ray */
  11063. length: number;
  11064. private static readonly TmpVector3;
  11065. private _tmpRay;
  11066. /**
  11067. * Creates a new ray
  11068. * @param origin origin point
  11069. * @param direction direction
  11070. * @param length length of the ray
  11071. */
  11072. constructor(
  11073. /** origin point */
  11074. origin: Vector3,
  11075. /** direction */
  11076. direction: Vector3,
  11077. /** length of the ray */
  11078. length?: number);
  11079. /**
  11080. * Checks if the ray intersects a box
  11081. * @param minimum bound of the box
  11082. * @param maximum bound of the box
  11083. * @param intersectionTreshold extra extend to be added to the box in all direction
  11084. * @returns if the box was hit
  11085. */
  11086. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11087. /**
  11088. * Checks if the ray intersects a box
  11089. * @param box the bounding box to check
  11090. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11091. * @returns if the box was hit
  11092. */
  11093. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11094. /**
  11095. * If the ray hits a sphere
  11096. * @param sphere the bounding sphere to check
  11097. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11098. * @returns true if it hits the sphere
  11099. */
  11100. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11101. /**
  11102. * If the ray hits a triange
  11103. * @param vertex0 triangle vertex
  11104. * @param vertex1 triangle vertex
  11105. * @param vertex2 triangle vertex
  11106. * @returns intersection information if hit
  11107. */
  11108. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11109. /**
  11110. * Checks if ray intersects a plane
  11111. * @param plane the plane to check
  11112. * @returns the distance away it was hit
  11113. */
  11114. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11115. /**
  11116. * Calculate the intercept of a ray on a given axis
  11117. * @param axis to check 'x' | 'y' | 'z'
  11118. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11119. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11120. */
  11121. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11122. /**
  11123. * Checks if ray intersects a mesh
  11124. * @param mesh the mesh to check
  11125. * @param fastCheck if only the bounding box should checked
  11126. * @returns picking info of the intersecton
  11127. */
  11128. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11129. /**
  11130. * Checks if ray intersects a mesh
  11131. * @param meshes the meshes to check
  11132. * @param fastCheck if only the bounding box should checked
  11133. * @param results array to store result in
  11134. * @returns Array of picking infos
  11135. */
  11136. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11137. private _comparePickingInfo;
  11138. private static smallnum;
  11139. private static rayl;
  11140. /**
  11141. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11142. * @param sega the first point of the segment to test the intersection against
  11143. * @param segb the second point of the segment to test the intersection against
  11144. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11145. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11146. */
  11147. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11148. /**
  11149. * Update the ray from viewport position
  11150. * @param x position
  11151. * @param y y position
  11152. * @param viewportWidth viewport width
  11153. * @param viewportHeight viewport height
  11154. * @param world world matrix
  11155. * @param view view matrix
  11156. * @param projection projection matrix
  11157. * @returns this ray updated
  11158. */
  11159. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11160. /**
  11161. * Creates a ray with origin and direction of 0,0,0
  11162. * @returns the new ray
  11163. */
  11164. static Zero(): Ray;
  11165. /**
  11166. * Creates a new ray from screen space and viewport
  11167. * @param x position
  11168. * @param y y position
  11169. * @param viewportWidth viewport width
  11170. * @param viewportHeight viewport height
  11171. * @param world world matrix
  11172. * @param view view matrix
  11173. * @param projection projection matrix
  11174. * @returns new ray
  11175. */
  11176. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11177. /**
  11178. * 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
  11179. * transformed to the given world matrix.
  11180. * @param origin The origin point
  11181. * @param end The end point
  11182. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11183. * @returns the new ray
  11184. */
  11185. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11186. /**
  11187. * Transforms a ray by a matrix
  11188. * @param ray ray to transform
  11189. * @param matrix matrix to apply
  11190. * @returns the resulting new ray
  11191. */
  11192. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11193. /**
  11194. * Transforms a ray by a matrix
  11195. * @param ray ray to transform
  11196. * @param matrix matrix to apply
  11197. * @param result ray to store result in
  11198. */
  11199. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11200. /**
  11201. * Unproject a ray from screen space to object space
  11202. * @param sourceX defines the screen space x coordinate to use
  11203. * @param sourceY defines the screen space y coordinate to use
  11204. * @param viewportWidth defines the current width of the viewport
  11205. * @param viewportHeight defines the current height of the viewport
  11206. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11207. * @param view defines the view matrix to use
  11208. * @param projection defines the projection matrix to use
  11209. */
  11210. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11211. }
  11212. /**
  11213. * Type used to define predicate used to select faces when a mesh intersection is detected
  11214. */
  11215. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11216. interface Scene {
  11217. /** @hidden */
  11218. _tempPickingRay: Nullable<Ray>;
  11219. /** @hidden */
  11220. _cachedRayForTransform: Ray;
  11221. /** @hidden */
  11222. _pickWithRayInverseMatrix: Matrix;
  11223. /** @hidden */
  11224. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11225. /** @hidden */
  11226. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11227. }
  11228. }
  11229. declare module BABYLON {
  11230. /**
  11231. * Groups all the scene component constants in one place to ease maintenance.
  11232. * @hidden
  11233. */
  11234. export class SceneComponentConstants {
  11235. static readonly NAME_EFFECTLAYER: string;
  11236. static readonly NAME_LAYER: string;
  11237. static readonly NAME_LENSFLARESYSTEM: string;
  11238. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11239. static readonly NAME_PARTICLESYSTEM: string;
  11240. static readonly NAME_GAMEPAD: string;
  11241. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11242. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11243. static readonly NAME_DEPTHRENDERER: string;
  11244. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11245. static readonly NAME_SPRITE: string;
  11246. static readonly NAME_OUTLINERENDERER: string;
  11247. static readonly NAME_PROCEDURALTEXTURE: string;
  11248. static readonly NAME_SHADOWGENERATOR: string;
  11249. static readonly NAME_OCTREE: string;
  11250. static readonly NAME_PHYSICSENGINE: string;
  11251. static readonly NAME_AUDIO: string;
  11252. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11253. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11255. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11256. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11257. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11258. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11259. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11260. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11261. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11262. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11263. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11264. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11265. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11266. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11267. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11268. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11269. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11270. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11271. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11272. static readonly STEP_AFTERRENDER_AUDIO: number;
  11273. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11274. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11275. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11276. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11277. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11278. static readonly STEP_POINTERMOVE_SPRITE: number;
  11279. static readonly STEP_POINTERDOWN_SPRITE: number;
  11280. static readonly STEP_POINTERUP_SPRITE: number;
  11281. }
  11282. /**
  11283. * This represents a scene component.
  11284. *
  11285. * This is used to decouple the dependency the scene is having on the different workloads like
  11286. * layers, post processes...
  11287. */
  11288. export interface ISceneComponent {
  11289. /**
  11290. * The name of the component. Each component must have a unique name.
  11291. */
  11292. name: string;
  11293. /**
  11294. * The scene the component belongs to.
  11295. */
  11296. scene: Scene;
  11297. /**
  11298. * Register the component to one instance of a scene.
  11299. */
  11300. register(): void;
  11301. /**
  11302. * Rebuilds the elements related to this component in case of
  11303. * context lost for instance.
  11304. */
  11305. rebuild(): void;
  11306. /**
  11307. * Disposes the component and the associated ressources.
  11308. */
  11309. dispose(): void;
  11310. }
  11311. /**
  11312. * This represents a SERIALIZABLE scene component.
  11313. *
  11314. * This extends Scene Component to add Serialization methods on top.
  11315. */
  11316. export interface ISceneSerializableComponent extends ISceneComponent {
  11317. /**
  11318. * Adds all the elements from the container to the scene
  11319. * @param container the container holding the elements
  11320. */
  11321. addFromContainer(container: AbstractScene): void;
  11322. /**
  11323. * Removes all the elements in the container from the scene
  11324. * @param container contains the elements to remove
  11325. * @param dispose if the removed element should be disposed (default: false)
  11326. */
  11327. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11328. /**
  11329. * Serializes the component data to the specified json object
  11330. * @param serializationObject The object to serialize to
  11331. */
  11332. serialize(serializationObject: any): void;
  11333. }
  11334. /**
  11335. * Strong typing of a Mesh related stage step action
  11336. */
  11337. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11338. /**
  11339. * Strong typing of a Evaluate Sub Mesh related stage step action
  11340. */
  11341. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11342. /**
  11343. * Strong typing of a Active Mesh related stage step action
  11344. */
  11345. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11346. /**
  11347. * Strong typing of a Camera related stage step action
  11348. */
  11349. export type CameraStageAction = (camera: Camera) => void;
  11350. /**
  11351. * Strong typing of a Camera Frame buffer related stage step action
  11352. */
  11353. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11354. /**
  11355. * Strong typing of a Render Target related stage step action
  11356. */
  11357. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11358. /**
  11359. * Strong typing of a RenderingGroup related stage step action
  11360. */
  11361. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11362. /**
  11363. * Strong typing of a Mesh Render related stage step action
  11364. */
  11365. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11366. /**
  11367. * Strong typing of a simple stage step action
  11368. */
  11369. export type SimpleStageAction = () => void;
  11370. /**
  11371. * Strong typing of a render target action.
  11372. */
  11373. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11374. /**
  11375. * Strong typing of a pointer move action.
  11376. */
  11377. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11378. /**
  11379. * Strong typing of a pointer up/down action.
  11380. */
  11381. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11382. /**
  11383. * Representation of a stage in the scene (Basically a list of ordered steps)
  11384. * @hidden
  11385. */
  11386. export class Stage<T extends Function> extends Array<{
  11387. index: number;
  11388. component: ISceneComponent;
  11389. action: T;
  11390. }> {
  11391. /**
  11392. * Hide ctor from the rest of the world.
  11393. * @param items The items to add.
  11394. */
  11395. private constructor();
  11396. /**
  11397. * Creates a new Stage.
  11398. * @returns A new instance of a Stage
  11399. */
  11400. static Create<T extends Function>(): Stage<T>;
  11401. /**
  11402. * Registers a step in an ordered way in the targeted stage.
  11403. * @param index Defines the position to register the step in
  11404. * @param component Defines the component attached to the step
  11405. * @param action Defines the action to launch during the step
  11406. */
  11407. registerStep(index: number, component: ISceneComponent, action: T): void;
  11408. /**
  11409. * Clears all the steps from the stage.
  11410. */
  11411. clear(): void;
  11412. }
  11413. }
  11414. declare module BABYLON {
  11415. interface Scene {
  11416. /** @hidden */
  11417. _pointerOverSprite: Nullable<Sprite>;
  11418. /** @hidden */
  11419. _pickedDownSprite: Nullable<Sprite>;
  11420. /** @hidden */
  11421. _tempSpritePickingRay: Nullable<Ray>;
  11422. /**
  11423. * All of the sprite managers added to this scene
  11424. * @see http://doc.babylonjs.com/babylon101/sprites
  11425. */
  11426. spriteManagers: Array<ISpriteManager>;
  11427. /**
  11428. * An event triggered when sprites rendering is about to start
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11432. /**
  11433. * An event triggered when sprites rendering is done
  11434. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11435. */
  11436. onAfterSpritesRenderingObservable: Observable<Scene>;
  11437. /** @hidden */
  11438. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11439. /** Launch a ray to try to pick a sprite in the scene
  11440. * @param x position on screen
  11441. * @param y position on screen
  11442. * @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
  11443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11445. * @returns a PickingInfo
  11446. */
  11447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11448. /** Use the given ray to pick a sprite in the scene
  11449. * @param ray The ray (in world space) to use to pick meshes
  11450. * @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
  11451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11452. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11453. * @returns a PickingInfo
  11454. */
  11455. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11456. /** @hidden */
  11457. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11458. /** Launch a ray to try to pick sprites in the scene
  11459. * @param x position on screen
  11460. * @param y position on screen
  11461. * @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
  11462. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11463. * @returns a PickingInfo array
  11464. */
  11465. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11466. /** Use the given ray to pick sprites in the scene
  11467. * @param ray The ray (in world space) to use to pick meshes
  11468. * @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
  11469. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11470. * @returns a PickingInfo array
  11471. */
  11472. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11473. /**
  11474. * Force the sprite under the pointer
  11475. * @param sprite defines the sprite to use
  11476. */
  11477. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11478. /**
  11479. * Gets the sprite under the pointer
  11480. * @returns a Sprite or null if no sprite is under the pointer
  11481. */
  11482. getPointerOverSprite(): Nullable<Sprite>;
  11483. }
  11484. /**
  11485. * Defines the sprite scene component responsible to manage sprites
  11486. * in a given scene.
  11487. */
  11488. export class SpriteSceneComponent implements ISceneComponent {
  11489. /**
  11490. * The component name helpfull to identify the component in the list of scene components.
  11491. */
  11492. readonly name: string;
  11493. /**
  11494. * The scene the component belongs to.
  11495. */
  11496. scene: Scene;
  11497. /** @hidden */
  11498. private _spritePredicate;
  11499. /**
  11500. * Creates a new instance of the component for the given scene
  11501. * @param scene Defines the scene to register the component in
  11502. */
  11503. constructor(scene: Scene);
  11504. /**
  11505. * Registers the component in a given scene
  11506. */
  11507. register(): void;
  11508. /**
  11509. * Rebuilds the elements related to this component in case of
  11510. * context lost for instance.
  11511. */
  11512. rebuild(): void;
  11513. /**
  11514. * Disposes the component and the associated ressources.
  11515. */
  11516. dispose(): void;
  11517. private _pickSpriteButKeepRay;
  11518. private _pointerMove;
  11519. private _pointerDown;
  11520. private _pointerUp;
  11521. }
  11522. }
  11523. declare module BABYLON {
  11524. /** @hidden */
  11525. export var fogFragmentDeclaration: {
  11526. name: string;
  11527. shader: string;
  11528. };
  11529. }
  11530. declare module BABYLON {
  11531. /** @hidden */
  11532. export var fogFragment: {
  11533. name: string;
  11534. shader: string;
  11535. };
  11536. }
  11537. declare module BABYLON {
  11538. /** @hidden */
  11539. export var spritesPixelShader: {
  11540. name: string;
  11541. shader: string;
  11542. };
  11543. }
  11544. declare module BABYLON {
  11545. /** @hidden */
  11546. export var fogVertexDeclaration: {
  11547. name: string;
  11548. shader: string;
  11549. };
  11550. }
  11551. declare module BABYLON {
  11552. /** @hidden */
  11553. export var spritesVertexShader: {
  11554. name: string;
  11555. shader: string;
  11556. };
  11557. }
  11558. declare module BABYLON {
  11559. /**
  11560. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11561. */
  11562. export interface ISpriteManager extends IDisposable {
  11563. /**
  11564. * Restricts the camera to viewing objects with the same layerMask.
  11565. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11566. */
  11567. layerMask: number;
  11568. /**
  11569. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11570. */
  11571. isPickable: boolean;
  11572. /**
  11573. * Specifies the rendering group id for this mesh (0 by default)
  11574. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11575. */
  11576. renderingGroupId: number;
  11577. /**
  11578. * Defines the list of sprites managed by the manager.
  11579. */
  11580. sprites: Array<Sprite>;
  11581. /**
  11582. * Tests the intersection of a sprite with a specific ray.
  11583. * @param ray The ray we are sending to test the collision
  11584. * @param camera The camera space we are sending rays in
  11585. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11586. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11587. * @returns picking info or null.
  11588. */
  11589. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11590. /**
  11591. * Intersects the sprites with a ray
  11592. * @param ray defines the ray to intersect with
  11593. * @param camera defines the current active camera
  11594. * @param predicate defines a predicate used to select candidate sprites
  11595. * @returns null if no hit or a PickingInfo array
  11596. */
  11597. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11598. /**
  11599. * Renders the list of sprites on screen.
  11600. */
  11601. render(): void;
  11602. }
  11603. /**
  11604. * Class used to manage multiple sprites on the same spritesheet
  11605. * @see http://doc.babylonjs.com/babylon101/sprites
  11606. */
  11607. export class SpriteManager implements ISpriteManager {
  11608. /** defines the manager's name */
  11609. name: string;
  11610. /** Gets the list of sprites */
  11611. sprites: Sprite[];
  11612. /** Gets or sets the rendering group id (0 by default) */
  11613. renderingGroupId: number;
  11614. /** Gets or sets camera layer mask */
  11615. layerMask: number;
  11616. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11617. fogEnabled: boolean;
  11618. /** Gets or sets a boolean indicating if the sprites are pickable */
  11619. isPickable: boolean;
  11620. /** Defines the default width of a cell in the spritesheet */
  11621. cellWidth: number;
  11622. /** Defines the default height of a cell in the spritesheet */
  11623. cellHeight: number;
  11624. /** Associative array from JSON sprite data file */
  11625. private _cellData;
  11626. /** Array of sprite names from JSON sprite data file */
  11627. private _spriteMap;
  11628. /** True when packed cell data from JSON file is ready*/
  11629. private _packedAndReady;
  11630. /**
  11631. * An event triggered when the manager is disposed.
  11632. */
  11633. onDisposeObservable: Observable<SpriteManager>;
  11634. private _onDisposeObserver;
  11635. /**
  11636. * Callback called when the manager is disposed
  11637. */
  11638. onDispose: () => void;
  11639. private _capacity;
  11640. private _fromPacked;
  11641. private _spriteTexture;
  11642. private _epsilon;
  11643. private _scene;
  11644. private _vertexData;
  11645. private _buffer;
  11646. private _vertexBuffers;
  11647. private _indexBuffer;
  11648. private _effectBase;
  11649. private _effectFog;
  11650. /**
  11651. * Gets or sets the spritesheet texture
  11652. */
  11653. texture: Texture;
  11654. /**
  11655. * Creates a new sprite manager
  11656. * @param name defines the manager's name
  11657. * @param imgUrl defines the sprite sheet url
  11658. * @param capacity defines the maximum allowed number of sprites
  11659. * @param cellSize defines the size of a sprite cell
  11660. * @param scene defines the hosting scene
  11661. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11662. * @param samplingMode defines the smapling mode to use with spritesheet
  11663. * @param fromPacked set to false; do not alter
  11664. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11665. */
  11666. constructor(
  11667. /** defines the manager's name */
  11668. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11669. private _makePacked;
  11670. private _appendSpriteVertex;
  11671. /**
  11672. * Intersects the sprites with a ray
  11673. * @param ray defines the ray to intersect with
  11674. * @param camera defines the current active camera
  11675. * @param predicate defines a predicate used to select candidate sprites
  11676. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11677. * @returns null if no hit or a PickingInfo
  11678. */
  11679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11680. /**
  11681. * Intersects the sprites with a ray
  11682. * @param ray defines the ray to intersect with
  11683. * @param camera defines the current active camera
  11684. * @param predicate defines a predicate used to select candidate sprites
  11685. * @returns null if no hit or a PickingInfo array
  11686. */
  11687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11688. /**
  11689. * Render all child sprites
  11690. */
  11691. render(): void;
  11692. /**
  11693. * Release associated resources
  11694. */
  11695. dispose(): void;
  11696. }
  11697. }
  11698. declare module BABYLON {
  11699. /**
  11700. * Class used to represent a sprite
  11701. * @see http://doc.babylonjs.com/babylon101/sprites
  11702. */
  11703. export class Sprite {
  11704. /** defines the name */
  11705. name: string;
  11706. /** Gets or sets the current world position */
  11707. position: Vector3;
  11708. /** Gets or sets the main color */
  11709. color: Color4;
  11710. /** Gets or sets the width */
  11711. width: number;
  11712. /** Gets or sets the height */
  11713. height: number;
  11714. /** Gets or sets rotation angle */
  11715. angle: number;
  11716. /** Gets or sets the cell index in the sprite sheet */
  11717. cellIndex: number;
  11718. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11719. cellRef: string;
  11720. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11721. invertU: number;
  11722. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11723. invertV: number;
  11724. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11725. disposeWhenFinishedAnimating: boolean;
  11726. /** Gets the list of attached animations */
  11727. animations: Animation[];
  11728. /** Gets or sets a boolean indicating if the sprite can be picked */
  11729. isPickable: boolean;
  11730. /**
  11731. * Gets or sets the associated action manager
  11732. */
  11733. actionManager: Nullable<ActionManager>;
  11734. private _animationStarted;
  11735. private _loopAnimation;
  11736. private _fromIndex;
  11737. private _toIndex;
  11738. private _delay;
  11739. private _direction;
  11740. private _manager;
  11741. private _time;
  11742. private _onAnimationEnd;
  11743. /**
  11744. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11745. */
  11746. isVisible: boolean;
  11747. /**
  11748. * Gets or sets the sprite size
  11749. */
  11750. size: number;
  11751. /**
  11752. * Creates a new Sprite
  11753. * @param name defines the name
  11754. * @param manager defines the manager
  11755. */
  11756. constructor(
  11757. /** defines the name */
  11758. name: string, manager: ISpriteManager);
  11759. /**
  11760. * Starts an animation
  11761. * @param from defines the initial key
  11762. * @param to defines the end key
  11763. * @param loop defines if the animation must loop
  11764. * @param delay defines the start delay (in ms)
  11765. * @param onAnimationEnd defines a callback to call when animation ends
  11766. */
  11767. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11768. /** Stops current animation (if any) */
  11769. stopAnimation(): void;
  11770. /** @hidden */
  11771. _animate(deltaTime: number): void;
  11772. /** Release associated resources */
  11773. dispose(): void;
  11774. }
  11775. }
  11776. declare module BABYLON {
  11777. /**
  11778. * Information about the result of picking within a scene
  11779. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11780. */
  11781. export class PickingInfo {
  11782. /** @hidden */
  11783. _pickingUnavailable: boolean;
  11784. /**
  11785. * If the pick collided with an object
  11786. */
  11787. hit: boolean;
  11788. /**
  11789. * Distance away where the pick collided
  11790. */
  11791. distance: number;
  11792. /**
  11793. * The location of pick collision
  11794. */
  11795. pickedPoint: Nullable<Vector3>;
  11796. /**
  11797. * The mesh corresponding the the pick collision
  11798. */
  11799. pickedMesh: Nullable<AbstractMesh>;
  11800. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11801. bu: number;
  11802. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11803. bv: number;
  11804. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11805. faceId: number;
  11806. /** Id of the the submesh that was picked */
  11807. subMeshId: number;
  11808. /** If a sprite was picked, this will be the sprite the pick collided with */
  11809. pickedSprite: Nullable<Sprite>;
  11810. /**
  11811. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11812. */
  11813. originMesh: Nullable<AbstractMesh>;
  11814. /**
  11815. * The ray that was used to perform the picking.
  11816. */
  11817. ray: Nullable<Ray>;
  11818. /**
  11819. * Gets the normal correspodning to the face the pick collided with
  11820. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11821. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11822. * @returns The normal correspodning to the face the pick collided with
  11823. */
  11824. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11825. /**
  11826. * Gets the texture coordinates of where the pick occured
  11827. * @returns the vector containing the coordnates of the texture
  11828. */
  11829. getTextureCoordinates(): Nullable<Vector2>;
  11830. }
  11831. }
  11832. declare module BABYLON {
  11833. /**
  11834. * Gather the list of pointer event types as constants.
  11835. */
  11836. export class PointerEventTypes {
  11837. /**
  11838. * 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.
  11839. */
  11840. static readonly POINTERDOWN: number;
  11841. /**
  11842. * The pointerup event is fired when a pointer is no longer active.
  11843. */
  11844. static readonly POINTERUP: number;
  11845. /**
  11846. * The pointermove event is fired when a pointer changes coordinates.
  11847. */
  11848. static readonly POINTERMOVE: number;
  11849. /**
  11850. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11851. */
  11852. static readonly POINTERWHEEL: number;
  11853. /**
  11854. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11855. */
  11856. static readonly POINTERPICK: number;
  11857. /**
  11858. * The pointertap event is fired when a the object has been touched and released without drag.
  11859. */
  11860. static readonly POINTERTAP: number;
  11861. /**
  11862. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11863. */
  11864. static readonly POINTERDOUBLETAP: number;
  11865. }
  11866. /**
  11867. * Base class of pointer info types.
  11868. */
  11869. export class PointerInfoBase {
  11870. /**
  11871. * Defines the type of event (PointerEventTypes)
  11872. */
  11873. type: number;
  11874. /**
  11875. * Defines the related dom event
  11876. */
  11877. event: PointerEvent | MouseWheelEvent;
  11878. /**
  11879. * Instantiates the base class of pointers info.
  11880. * @param type Defines the type of event (PointerEventTypes)
  11881. * @param event Defines the related dom event
  11882. */
  11883. constructor(
  11884. /**
  11885. * Defines the type of event (PointerEventTypes)
  11886. */
  11887. type: number,
  11888. /**
  11889. * Defines the related dom event
  11890. */
  11891. event: PointerEvent | MouseWheelEvent);
  11892. }
  11893. /**
  11894. * This class is used to store pointer related info for the onPrePointerObservable event.
  11895. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11896. */
  11897. export class PointerInfoPre extends PointerInfoBase {
  11898. /**
  11899. * Ray from a pointer if availible (eg. 6dof controller)
  11900. */
  11901. ray: Nullable<Ray>;
  11902. /**
  11903. * Defines the local position of the pointer on the canvas.
  11904. */
  11905. localPosition: Vector2;
  11906. /**
  11907. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11908. */
  11909. skipOnPointerObservable: boolean;
  11910. /**
  11911. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11912. * @param type Defines the type of event (PointerEventTypes)
  11913. * @param event Defines the related dom event
  11914. * @param localX Defines the local x coordinates of the pointer when the event occured
  11915. * @param localY Defines the local y coordinates of the pointer when the event occured
  11916. */
  11917. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11918. }
  11919. /**
  11920. * This type contains all the data related to a pointer event in Babylon.js.
  11921. * 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.
  11922. */
  11923. export class PointerInfo extends PointerInfoBase {
  11924. /**
  11925. * Defines the picking info associated to the info (if any)\
  11926. */
  11927. pickInfo: Nullable<PickingInfo>;
  11928. /**
  11929. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11930. * @param type Defines the type of event (PointerEventTypes)
  11931. * @param event Defines the related dom event
  11932. * @param pickInfo Defines the picking info associated to the info (if any)\
  11933. */
  11934. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11935. /**
  11936. * Defines the picking info associated to the info (if any)\
  11937. */
  11938. pickInfo: Nullable<PickingInfo>);
  11939. }
  11940. /**
  11941. * Data relating to a touch event on the screen.
  11942. */
  11943. export interface PointerTouch {
  11944. /**
  11945. * X coordinate of touch.
  11946. */
  11947. x: number;
  11948. /**
  11949. * Y coordinate of touch.
  11950. */
  11951. y: number;
  11952. /**
  11953. * Id of touch. Unique for each finger.
  11954. */
  11955. pointerId: number;
  11956. /**
  11957. * Event type passed from DOM.
  11958. */
  11959. type: any;
  11960. }
  11961. }
  11962. declare module BABYLON {
  11963. /**
  11964. * Manage the mouse inputs to control the movement of a free camera.
  11965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11966. */
  11967. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11968. /**
  11969. * Define if touch is enabled in the mouse input
  11970. */
  11971. touchEnabled: boolean;
  11972. /**
  11973. * Defines the camera the input is attached to.
  11974. */
  11975. camera: FreeCamera;
  11976. /**
  11977. * Defines the buttons associated with the input to handle camera move.
  11978. */
  11979. buttons: number[];
  11980. /**
  11981. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11982. */
  11983. angularSensibility: number;
  11984. private _pointerInput;
  11985. private _onMouseMove;
  11986. private _observer;
  11987. private previousPosition;
  11988. /**
  11989. * Observable for when a pointer move event occurs containing the move offset
  11990. */
  11991. onPointerMovedObservable: Observable<{
  11992. offsetX: number;
  11993. offsetY: number;
  11994. }>;
  11995. /**
  11996. * @hidden
  11997. * If the camera should be rotated automatically based on pointer movement
  11998. */
  11999. _allowCameraRotation: boolean;
  12000. /**
  12001. * Manage the mouse inputs to control the movement of a free camera.
  12002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12003. * @param touchEnabled Defines if touch is enabled or not
  12004. */
  12005. constructor(
  12006. /**
  12007. * Define if touch is enabled in the mouse input
  12008. */
  12009. touchEnabled?: boolean);
  12010. /**
  12011. * Attach the input controls to a specific dom element to get the input from.
  12012. * @param element Defines the element the controls should be listened from
  12013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12014. */
  12015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12016. /**
  12017. * Called on JS contextmenu event.
  12018. * Override this method to provide functionality.
  12019. */
  12020. protected onContextMenu(evt: PointerEvent): void;
  12021. /**
  12022. * Detach the current controls from the specified dom element.
  12023. * @param element Defines the element to stop listening the inputs from
  12024. */
  12025. detachControl(element: Nullable<HTMLElement>): void;
  12026. /**
  12027. * Gets the class name of the current intput.
  12028. * @returns the class name
  12029. */
  12030. getClassName(): string;
  12031. /**
  12032. * Get the friendly name associated with the input class.
  12033. * @returns the input friendly name
  12034. */
  12035. getSimpleName(): string;
  12036. }
  12037. }
  12038. declare module BABYLON {
  12039. /**
  12040. * Manage the touch inputs to control the movement of a free camera.
  12041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12042. */
  12043. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12044. /**
  12045. * Defines the camera the input is attached to.
  12046. */
  12047. camera: FreeCamera;
  12048. /**
  12049. * Defines the touch sensibility for rotation.
  12050. * The higher the faster.
  12051. */
  12052. touchAngularSensibility: number;
  12053. /**
  12054. * Defines the touch sensibility for move.
  12055. * The higher the faster.
  12056. */
  12057. touchMoveSensibility: number;
  12058. private _offsetX;
  12059. private _offsetY;
  12060. private _pointerPressed;
  12061. private _pointerInput;
  12062. private _observer;
  12063. private _onLostFocus;
  12064. /**
  12065. * Attach the input controls to a specific dom element to get the input from.
  12066. * @param element Defines the element the controls should be listened from
  12067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12068. */
  12069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12070. /**
  12071. * Detach the current controls from the specified dom element.
  12072. * @param element Defines the element to stop listening the inputs from
  12073. */
  12074. detachControl(element: Nullable<HTMLElement>): void;
  12075. /**
  12076. * Update the current camera state depending on the inputs that have been used this frame.
  12077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12078. */
  12079. checkInputs(): void;
  12080. /**
  12081. * Gets the class name of the current intput.
  12082. * @returns the class name
  12083. */
  12084. getClassName(): string;
  12085. /**
  12086. * Get the friendly name associated with the input class.
  12087. * @returns the input friendly name
  12088. */
  12089. getSimpleName(): string;
  12090. }
  12091. }
  12092. declare module BABYLON {
  12093. /**
  12094. * Default Inputs manager for the FreeCamera.
  12095. * It groups all the default supported inputs for ease of use.
  12096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12097. */
  12098. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12099. /**
  12100. * @hidden
  12101. */
  12102. _mouseInput: Nullable<FreeCameraMouseInput>;
  12103. /**
  12104. * Instantiates a new FreeCameraInputsManager.
  12105. * @param camera Defines the camera the inputs belong to
  12106. */
  12107. constructor(camera: FreeCamera);
  12108. /**
  12109. * Add keyboard input support to the input manager.
  12110. * @returns the current input manager
  12111. */
  12112. addKeyboard(): FreeCameraInputsManager;
  12113. /**
  12114. * Add mouse input support to the input manager.
  12115. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12116. * @returns the current input manager
  12117. */
  12118. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12119. /**
  12120. * Removes the mouse input support from the manager
  12121. * @returns the current input manager
  12122. */
  12123. removeMouse(): FreeCameraInputsManager;
  12124. /**
  12125. * Add touch input support to the input manager.
  12126. * @returns the current input manager
  12127. */
  12128. addTouch(): FreeCameraInputsManager;
  12129. /**
  12130. * Remove all attached input methods from a camera
  12131. */
  12132. clear(): void;
  12133. }
  12134. }
  12135. declare module BABYLON {
  12136. /**
  12137. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12138. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12140. */
  12141. export class FreeCamera extends TargetCamera {
  12142. /**
  12143. * Define the collision ellipsoid of the camera.
  12144. * This is helpful to simulate a camera body like the player body around the camera
  12145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12146. */
  12147. ellipsoid: Vector3;
  12148. /**
  12149. * Define an offset for the position of the ellipsoid around the camera.
  12150. * This can be helpful to determine the center of the body near the gravity center of the body
  12151. * instead of its head.
  12152. */
  12153. ellipsoidOffset: Vector3;
  12154. /**
  12155. * Enable or disable collisions of the camera with the rest of the scene objects.
  12156. */
  12157. checkCollisions: boolean;
  12158. /**
  12159. * Enable or disable gravity on the camera.
  12160. */
  12161. applyGravity: boolean;
  12162. /**
  12163. * Define the input manager associated to the camera.
  12164. */
  12165. inputs: FreeCameraInputsManager;
  12166. /**
  12167. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12168. * Higher values reduce sensitivity.
  12169. */
  12170. /**
  12171. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12172. * Higher values reduce sensitivity.
  12173. */
  12174. angularSensibility: number;
  12175. /**
  12176. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12177. */
  12178. keysUp: number[];
  12179. /**
  12180. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12181. */
  12182. keysDown: number[];
  12183. /**
  12184. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12185. */
  12186. keysLeft: number[];
  12187. /**
  12188. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12189. */
  12190. keysRight: number[];
  12191. /**
  12192. * Event raised when the camera collide with a mesh in the scene.
  12193. */
  12194. onCollide: (collidedMesh: AbstractMesh) => void;
  12195. private _collider;
  12196. private _needMoveForGravity;
  12197. private _oldPosition;
  12198. private _diffPosition;
  12199. private _newPosition;
  12200. /** @hidden */
  12201. _localDirection: Vector3;
  12202. /** @hidden */
  12203. _transformedDirection: Vector3;
  12204. /**
  12205. * Instantiates a Free Camera.
  12206. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12207. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12209. * @param name Define the name of the camera in the scene
  12210. * @param position Define the start position of the camera in the scene
  12211. * @param scene Define the scene the camera belongs to
  12212. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12213. */
  12214. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12215. /**
  12216. * Attached controls to the current camera.
  12217. * @param element Defines the element the controls should be listened from
  12218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12219. */
  12220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12221. /**
  12222. * Detach the current controls from the camera.
  12223. * The camera will stop reacting to inputs.
  12224. * @param element Defines the element to stop listening the inputs from
  12225. */
  12226. detachControl(element: HTMLElement): void;
  12227. private _collisionMask;
  12228. /**
  12229. * Define a collision mask to limit the list of object the camera can collide with
  12230. */
  12231. collisionMask: number;
  12232. /** @hidden */
  12233. _collideWithWorld(displacement: Vector3): void;
  12234. private _onCollisionPositionChange;
  12235. /** @hidden */
  12236. _checkInputs(): void;
  12237. /** @hidden */
  12238. _decideIfNeedsToMove(): boolean;
  12239. /** @hidden */
  12240. _updatePosition(): void;
  12241. /**
  12242. * Destroy the camera and release the current resources hold by it.
  12243. */
  12244. dispose(): void;
  12245. /**
  12246. * Gets the current object class name.
  12247. * @return the class name
  12248. */
  12249. getClassName(): string;
  12250. }
  12251. }
  12252. declare module BABYLON {
  12253. /**
  12254. * Represents a gamepad control stick position
  12255. */
  12256. export class StickValues {
  12257. /**
  12258. * The x component of the control stick
  12259. */
  12260. x: number;
  12261. /**
  12262. * The y component of the control stick
  12263. */
  12264. y: number;
  12265. /**
  12266. * Initializes the gamepad x and y control stick values
  12267. * @param x The x component of the gamepad control stick value
  12268. * @param y The y component of the gamepad control stick value
  12269. */
  12270. constructor(
  12271. /**
  12272. * The x component of the control stick
  12273. */
  12274. x: number,
  12275. /**
  12276. * The y component of the control stick
  12277. */
  12278. y: number);
  12279. }
  12280. /**
  12281. * An interface which manages callbacks for gamepad button changes
  12282. */
  12283. export interface GamepadButtonChanges {
  12284. /**
  12285. * Called when a gamepad has been changed
  12286. */
  12287. changed: boolean;
  12288. /**
  12289. * Called when a gamepad press event has been triggered
  12290. */
  12291. pressChanged: boolean;
  12292. /**
  12293. * Called when a touch event has been triggered
  12294. */
  12295. touchChanged: boolean;
  12296. /**
  12297. * Called when a value has changed
  12298. */
  12299. valueChanged: boolean;
  12300. }
  12301. /**
  12302. * Represents a gamepad
  12303. */
  12304. export class Gamepad {
  12305. /**
  12306. * The id of the gamepad
  12307. */
  12308. id: string;
  12309. /**
  12310. * The index of the gamepad
  12311. */
  12312. index: number;
  12313. /**
  12314. * The browser gamepad
  12315. */
  12316. browserGamepad: any;
  12317. /**
  12318. * Specifies what type of gamepad this represents
  12319. */
  12320. type: number;
  12321. private _leftStick;
  12322. private _rightStick;
  12323. /** @hidden */
  12324. _isConnected: boolean;
  12325. private _leftStickAxisX;
  12326. private _leftStickAxisY;
  12327. private _rightStickAxisX;
  12328. private _rightStickAxisY;
  12329. /**
  12330. * Triggered when the left control stick has been changed
  12331. */
  12332. private _onleftstickchanged;
  12333. /**
  12334. * Triggered when the right control stick has been changed
  12335. */
  12336. private _onrightstickchanged;
  12337. /**
  12338. * Represents a gamepad controller
  12339. */
  12340. static GAMEPAD: number;
  12341. /**
  12342. * Represents a generic controller
  12343. */
  12344. static GENERIC: number;
  12345. /**
  12346. * Represents an XBox controller
  12347. */
  12348. static XBOX: number;
  12349. /**
  12350. * Represents a pose-enabled controller
  12351. */
  12352. static POSE_ENABLED: number;
  12353. /**
  12354. * Represents an Dual Shock controller
  12355. */
  12356. static DUALSHOCK: number;
  12357. /**
  12358. * Specifies whether the left control stick should be Y-inverted
  12359. */
  12360. protected _invertLeftStickY: boolean;
  12361. /**
  12362. * Specifies if the gamepad has been connected
  12363. */
  12364. readonly isConnected: boolean;
  12365. /**
  12366. * Initializes the gamepad
  12367. * @param id The id of the gamepad
  12368. * @param index The index of the gamepad
  12369. * @param browserGamepad The browser gamepad
  12370. * @param leftStickX The x component of the left joystick
  12371. * @param leftStickY The y component of the left joystick
  12372. * @param rightStickX The x component of the right joystick
  12373. * @param rightStickY The y component of the right joystick
  12374. */
  12375. constructor(
  12376. /**
  12377. * The id of the gamepad
  12378. */
  12379. id: string,
  12380. /**
  12381. * The index of the gamepad
  12382. */
  12383. index: number,
  12384. /**
  12385. * The browser gamepad
  12386. */
  12387. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12388. /**
  12389. * Callback triggered when the left joystick has changed
  12390. * @param callback
  12391. */
  12392. onleftstickchanged(callback: (values: StickValues) => void): void;
  12393. /**
  12394. * Callback triggered when the right joystick has changed
  12395. * @param callback
  12396. */
  12397. onrightstickchanged(callback: (values: StickValues) => void): void;
  12398. /**
  12399. * Gets the left joystick
  12400. */
  12401. /**
  12402. * Sets the left joystick values
  12403. */
  12404. leftStick: StickValues;
  12405. /**
  12406. * Gets the right joystick
  12407. */
  12408. /**
  12409. * Sets the right joystick value
  12410. */
  12411. rightStick: StickValues;
  12412. /**
  12413. * Updates the gamepad joystick positions
  12414. */
  12415. update(): void;
  12416. /**
  12417. * Disposes the gamepad
  12418. */
  12419. dispose(): void;
  12420. }
  12421. /**
  12422. * Represents a generic gamepad
  12423. */
  12424. export class GenericPad extends Gamepad {
  12425. private _buttons;
  12426. private _onbuttondown;
  12427. private _onbuttonup;
  12428. /**
  12429. * Observable triggered when a button has been pressed
  12430. */
  12431. onButtonDownObservable: Observable<number>;
  12432. /**
  12433. * Observable triggered when a button has been released
  12434. */
  12435. onButtonUpObservable: Observable<number>;
  12436. /**
  12437. * Callback triggered when a button has been pressed
  12438. * @param callback Called when a button has been pressed
  12439. */
  12440. onbuttondown(callback: (buttonPressed: number) => void): void;
  12441. /**
  12442. * Callback triggered when a button has been released
  12443. * @param callback Called when a button has been released
  12444. */
  12445. onbuttonup(callback: (buttonReleased: number) => void): void;
  12446. /**
  12447. * Initializes the generic gamepad
  12448. * @param id The id of the generic gamepad
  12449. * @param index The index of the generic gamepad
  12450. * @param browserGamepad The browser gamepad
  12451. */
  12452. constructor(id: string, index: number, browserGamepad: any);
  12453. private _setButtonValue;
  12454. /**
  12455. * Updates the generic gamepad
  12456. */
  12457. update(): void;
  12458. /**
  12459. * Disposes the generic gamepad
  12460. */
  12461. dispose(): void;
  12462. }
  12463. }
  12464. declare module BABYLON {
  12465. interface Engine {
  12466. /**
  12467. * Creates a raw texture
  12468. * @param data defines the data to store in the texture
  12469. * @param width defines the width of the texture
  12470. * @param height defines the height of the texture
  12471. * @param format defines the format of the data
  12472. * @param generateMipMaps defines if the engine should generate the mip levels
  12473. * @param invertY defines if data must be stored with Y axis inverted
  12474. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12475. * @param compression defines the compression used (null by default)
  12476. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12477. * @returns the raw texture inside an InternalTexture
  12478. */
  12479. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12480. /**
  12481. * Update a raw texture
  12482. * @param texture defines the texture to update
  12483. * @param data defines the data to store in the texture
  12484. * @param format defines the format of the data
  12485. * @param invertY defines if data must be stored with Y axis inverted
  12486. */
  12487. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12488. /**
  12489. * Update a raw texture
  12490. * @param texture defines the texture to update
  12491. * @param data defines the data to store in the texture
  12492. * @param format defines the format of the data
  12493. * @param invertY defines if data must be stored with Y axis inverted
  12494. * @param compression defines the compression used (null by default)
  12495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12496. */
  12497. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12498. /**
  12499. * Creates a new raw cube texture
  12500. * @param data defines the array of data to use to create each face
  12501. * @param size defines the size of the textures
  12502. * @param format defines the format of the data
  12503. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12504. * @param generateMipMaps defines if the engine should generate the mip levels
  12505. * @param invertY defines if data must be stored with Y axis inverted
  12506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12507. * @param compression defines the compression used (null by default)
  12508. * @returns the cube texture as an InternalTexture
  12509. */
  12510. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12511. /**
  12512. * Update a raw cube texture
  12513. * @param texture defines the texture to udpdate
  12514. * @param data defines the data to store
  12515. * @param format defines the data format
  12516. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12517. * @param invertY defines if data must be stored with Y axis inverted
  12518. */
  12519. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12520. /**
  12521. * Update a raw cube texture
  12522. * @param texture defines the texture to udpdate
  12523. * @param data defines the data to store
  12524. * @param format defines the data format
  12525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12526. * @param invertY defines if data must be stored with Y axis inverted
  12527. * @param compression defines the compression used (null by default)
  12528. */
  12529. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12530. /**
  12531. * Update a raw cube texture
  12532. * @param texture defines the texture to udpdate
  12533. * @param data defines the data to store
  12534. * @param format defines the data format
  12535. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12536. * @param invertY defines if data must be stored with Y axis inverted
  12537. * @param compression defines the compression used (null by default)
  12538. * @param level defines which level of the texture to update
  12539. */
  12540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12541. /**
  12542. * Creates a new raw cube texture from a specified url
  12543. * @param url defines the url where the data is located
  12544. * @param scene defines the current scene
  12545. * @param size defines the size of the textures
  12546. * @param format defines the format of the data
  12547. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12548. * @param noMipmap defines if the engine should avoid generating the mip levels
  12549. * @param callback defines a callback used to extract texture data from loaded data
  12550. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12551. * @param onLoad defines a callback called when texture is loaded
  12552. * @param onError defines a callback called if there is an error
  12553. * @returns the cube texture as an InternalTexture
  12554. */
  12555. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12556. /**
  12557. * Creates a new raw cube texture from a specified url
  12558. * @param url defines the url where the data is located
  12559. * @param scene defines the current scene
  12560. * @param size defines the size of the textures
  12561. * @param format defines the format of the data
  12562. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12563. * @param noMipmap defines if the engine should avoid generating the mip levels
  12564. * @param callback defines a callback used to extract texture data from loaded data
  12565. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12566. * @param onLoad defines a callback called when texture is loaded
  12567. * @param onError defines a callback called if there is an error
  12568. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12569. * @param invertY defines if data must be stored with Y axis inverted
  12570. * @returns the cube texture as an InternalTexture
  12571. */
  12572. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12573. /**
  12574. * Creates a new raw 3D texture
  12575. * @param data defines the data used to create the texture
  12576. * @param width defines the width of the texture
  12577. * @param height defines the height of the texture
  12578. * @param depth defines the depth of the texture
  12579. * @param format defines the format of the texture
  12580. * @param generateMipMaps defines if the engine must generate mip levels
  12581. * @param invertY defines if data must be stored with Y axis inverted
  12582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12583. * @param compression defines the compressed used (can be null)
  12584. * @param textureType defines the compressed used (can be null)
  12585. * @returns a new raw 3D texture (stored in an InternalTexture)
  12586. */
  12587. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12588. /**
  12589. * Update a raw 3D texture
  12590. * @param texture defines the texture to update
  12591. * @param data defines the data to store
  12592. * @param format defines the data format
  12593. * @param invertY defines if data must be stored with Y axis inverted
  12594. */
  12595. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12596. /**
  12597. * Update a raw 3D texture
  12598. * @param texture defines the texture to update
  12599. * @param data defines the data to store
  12600. * @param format defines the data format
  12601. * @param invertY defines if data must be stored with Y axis inverted
  12602. * @param compression defines the used compression (can be null)
  12603. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12604. */
  12605. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12606. /**
  12607. * Creates a new raw 2D array texture
  12608. * @param data defines the data used to create the texture
  12609. * @param width defines the width of the texture
  12610. * @param height defines the height of the texture
  12611. * @param depth defines the number of layers of the texture
  12612. * @param format defines the format of the texture
  12613. * @param generateMipMaps defines if the engine must generate mip levels
  12614. * @param invertY defines if data must be stored with Y axis inverted
  12615. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12616. * @param compression defines the compressed used (can be null)
  12617. * @param textureType defines the compressed used (can be null)
  12618. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12619. */
  12620. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12621. /**
  12622. * Update a raw 2D array texture
  12623. * @param texture defines the texture to update
  12624. * @param data defines the data to store
  12625. * @param format defines the data format
  12626. * @param invertY defines if data must be stored with Y axis inverted
  12627. */
  12628. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12629. /**
  12630. * Update a raw 2D array texture
  12631. * @param texture defines the texture to update
  12632. * @param data defines the data to store
  12633. * @param format defines the data format
  12634. * @param invertY defines if data must be stored with Y axis inverted
  12635. * @param compression defines the used compression (can be null)
  12636. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12637. */
  12638. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12639. }
  12640. }
  12641. declare module BABYLON {
  12642. /**
  12643. * Raw texture can help creating a texture directly from an array of data.
  12644. * This can be super useful if you either get the data from an uncompressed source or
  12645. * if you wish to create your texture pixel by pixel.
  12646. */
  12647. export class RawTexture extends Texture {
  12648. /**
  12649. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12650. */
  12651. format: number;
  12652. private _engine;
  12653. /**
  12654. * Instantiates a new RawTexture.
  12655. * Raw texture can help creating a texture directly from an array of data.
  12656. * This can be super useful if you either get the data from an uncompressed source or
  12657. * if you wish to create your texture pixel by pixel.
  12658. * @param data define the array of data to use to create the texture
  12659. * @param width define the width of the texture
  12660. * @param height define the height of the texture
  12661. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12662. * @param scene define the scene the texture belongs to
  12663. * @param generateMipMaps define whether mip maps should be generated or not
  12664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12667. */
  12668. constructor(data: ArrayBufferView, width: number, height: number,
  12669. /**
  12670. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12671. */
  12672. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12673. /**
  12674. * Updates the texture underlying data.
  12675. * @param data Define the new data of the texture
  12676. */
  12677. update(data: ArrayBufferView): void;
  12678. /**
  12679. * Creates a luminance texture from some data.
  12680. * @param data Define the texture data
  12681. * @param width Define the width of the texture
  12682. * @param height Define the height of the texture
  12683. * @param scene Define the scene the texture belongs to
  12684. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12685. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12686. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12687. * @returns the luminance texture
  12688. */
  12689. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12690. /**
  12691. * Creates a luminance alpha texture from some data.
  12692. * @param data Define the texture data
  12693. * @param width Define the width of the texture
  12694. * @param height Define the height of the texture
  12695. * @param scene Define the scene the texture belongs to
  12696. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12697. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12698. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12699. * @returns the luminance alpha texture
  12700. */
  12701. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12702. /**
  12703. * Creates an alpha texture from some data.
  12704. * @param data Define the texture data
  12705. * @param width Define the width of the texture
  12706. * @param height Define the height of the texture
  12707. * @param scene Define the scene the texture belongs to
  12708. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12709. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12710. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12711. * @returns the alpha texture
  12712. */
  12713. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12714. /**
  12715. * Creates a RGB texture from some data.
  12716. * @param data Define the texture data
  12717. * @param width Define the width of the texture
  12718. * @param height Define the height of the texture
  12719. * @param scene Define the scene the texture belongs to
  12720. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12721. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12722. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12723. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12724. * @returns the RGB alpha texture
  12725. */
  12726. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12727. /**
  12728. * Creates a RGBA texture from some data.
  12729. * @param data Define the texture data
  12730. * @param width Define the width of the texture
  12731. * @param height Define the height of the texture
  12732. * @param scene Define the scene the texture belongs to
  12733. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12734. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12735. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12736. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12737. * @returns the RGBA texture
  12738. */
  12739. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12740. /**
  12741. * Creates a R texture from some data.
  12742. * @param data Define the texture data
  12743. * @param width Define the width of the texture
  12744. * @param height Define the height of the texture
  12745. * @param scene Define the scene the texture belongs to
  12746. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12747. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12748. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12749. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12750. * @returns the R texture
  12751. */
  12752. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12753. }
  12754. }
  12755. declare module BABYLON {
  12756. /**
  12757. * Interface for the size containing width and height
  12758. */
  12759. export interface ISize {
  12760. /**
  12761. * Width
  12762. */
  12763. width: number;
  12764. /**
  12765. * Heighht
  12766. */
  12767. height: number;
  12768. }
  12769. /**
  12770. * Size containing widht and height
  12771. */
  12772. export class Size implements ISize {
  12773. /**
  12774. * Width
  12775. */
  12776. width: number;
  12777. /**
  12778. * Height
  12779. */
  12780. height: number;
  12781. /**
  12782. * Creates a Size object from the given width and height (floats).
  12783. * @param width width of the new size
  12784. * @param height height of the new size
  12785. */
  12786. constructor(width: number, height: number);
  12787. /**
  12788. * Returns a string with the Size width and height
  12789. * @returns a string with the Size width and height
  12790. */
  12791. toString(): string;
  12792. /**
  12793. * "Size"
  12794. * @returns the string "Size"
  12795. */
  12796. getClassName(): string;
  12797. /**
  12798. * Returns the Size hash code.
  12799. * @returns a hash code for a unique width and height
  12800. */
  12801. getHashCode(): number;
  12802. /**
  12803. * Updates the current size from the given one.
  12804. * @param src the given size
  12805. */
  12806. copyFrom(src: Size): void;
  12807. /**
  12808. * Updates in place the current Size from the given floats.
  12809. * @param width width of the new size
  12810. * @param height height of the new size
  12811. * @returns the updated Size.
  12812. */
  12813. copyFromFloats(width: number, height: number): Size;
  12814. /**
  12815. * Updates in place the current Size from the given floats.
  12816. * @param width width to set
  12817. * @param height height to set
  12818. * @returns the updated Size.
  12819. */
  12820. set(width: number, height: number): Size;
  12821. /**
  12822. * Multiplies the width and height by numbers
  12823. * @param w factor to multiple the width by
  12824. * @param h factor to multiple the height by
  12825. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12826. */
  12827. multiplyByFloats(w: number, h: number): Size;
  12828. /**
  12829. * Clones the size
  12830. * @returns a new Size copied from the given one.
  12831. */
  12832. clone(): Size;
  12833. /**
  12834. * True if the current Size and the given one width and height are strictly equal.
  12835. * @param other the other size to compare against
  12836. * @returns True if the current Size and the given one width and height are strictly equal.
  12837. */
  12838. equals(other: Size): boolean;
  12839. /**
  12840. * The surface of the Size : width * height (float).
  12841. */
  12842. readonly surface: number;
  12843. /**
  12844. * Create a new size of zero
  12845. * @returns a new Size set to (0.0, 0.0)
  12846. */
  12847. static Zero(): Size;
  12848. /**
  12849. * Sums the width and height of two sizes
  12850. * @param otherSize size to add to this size
  12851. * @returns a new Size set as the addition result of the current Size and the given one.
  12852. */
  12853. add(otherSize: Size): Size;
  12854. /**
  12855. * Subtracts the width and height of two
  12856. * @param otherSize size to subtract to this size
  12857. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12858. */
  12859. subtract(otherSize: Size): Size;
  12860. /**
  12861. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12862. * @param start starting size to lerp between
  12863. * @param end end size to lerp between
  12864. * @param amount amount to lerp between the start and end values
  12865. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12866. */
  12867. static Lerp(start: Size, end: Size, amount: number): Size;
  12868. }
  12869. }
  12870. declare module BABYLON {
  12871. /**
  12872. * Defines a runtime animation
  12873. */
  12874. export class RuntimeAnimation {
  12875. private _events;
  12876. /**
  12877. * The current frame of the runtime animation
  12878. */
  12879. private _currentFrame;
  12880. /**
  12881. * The animation used by the runtime animation
  12882. */
  12883. private _animation;
  12884. /**
  12885. * The target of the runtime animation
  12886. */
  12887. private _target;
  12888. /**
  12889. * The initiating animatable
  12890. */
  12891. private _host;
  12892. /**
  12893. * The original value of the runtime animation
  12894. */
  12895. private _originalValue;
  12896. /**
  12897. * The original blend value of the runtime animation
  12898. */
  12899. private _originalBlendValue;
  12900. /**
  12901. * The offsets cache of the runtime animation
  12902. */
  12903. private _offsetsCache;
  12904. /**
  12905. * The high limits cache of the runtime animation
  12906. */
  12907. private _highLimitsCache;
  12908. /**
  12909. * Specifies if the runtime animation has been stopped
  12910. */
  12911. private _stopped;
  12912. /**
  12913. * The blending factor of the runtime animation
  12914. */
  12915. private _blendingFactor;
  12916. /**
  12917. * The BabylonJS scene
  12918. */
  12919. private _scene;
  12920. /**
  12921. * The current value of the runtime animation
  12922. */
  12923. private _currentValue;
  12924. /** @hidden */
  12925. _animationState: _IAnimationState;
  12926. /**
  12927. * The active target of the runtime animation
  12928. */
  12929. private _activeTargets;
  12930. private _currentActiveTarget;
  12931. private _directTarget;
  12932. /**
  12933. * The target path of the runtime animation
  12934. */
  12935. private _targetPath;
  12936. /**
  12937. * The weight of the runtime animation
  12938. */
  12939. private _weight;
  12940. /**
  12941. * The ratio offset of the runtime animation
  12942. */
  12943. private _ratioOffset;
  12944. /**
  12945. * The previous delay of the runtime animation
  12946. */
  12947. private _previousDelay;
  12948. /**
  12949. * The previous ratio of the runtime animation
  12950. */
  12951. private _previousRatio;
  12952. private _enableBlending;
  12953. private _keys;
  12954. private _minFrame;
  12955. private _maxFrame;
  12956. private _minValue;
  12957. private _maxValue;
  12958. private _targetIsArray;
  12959. /**
  12960. * Gets the current frame of the runtime animation
  12961. */
  12962. readonly currentFrame: number;
  12963. /**
  12964. * Gets the weight of the runtime animation
  12965. */
  12966. readonly weight: number;
  12967. /**
  12968. * Gets the current value of the runtime animation
  12969. */
  12970. readonly currentValue: any;
  12971. /**
  12972. * Gets the target path of the runtime animation
  12973. */
  12974. readonly targetPath: string;
  12975. /**
  12976. * Gets the actual target of the runtime animation
  12977. */
  12978. readonly target: any;
  12979. /** @hidden */
  12980. _onLoop: () => void;
  12981. /**
  12982. * Create a new RuntimeAnimation object
  12983. * @param target defines the target of the animation
  12984. * @param animation defines the source animation object
  12985. * @param scene defines the hosting scene
  12986. * @param host defines the initiating Animatable
  12987. */
  12988. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12989. private _preparePath;
  12990. /**
  12991. * Gets the animation from the runtime animation
  12992. */
  12993. readonly animation: Animation;
  12994. /**
  12995. * Resets the runtime animation to the beginning
  12996. * @param restoreOriginal defines whether to restore the target property to the original value
  12997. */
  12998. reset(restoreOriginal?: boolean): void;
  12999. /**
  13000. * Specifies if the runtime animation is stopped
  13001. * @returns Boolean specifying if the runtime animation is stopped
  13002. */
  13003. isStopped(): boolean;
  13004. /**
  13005. * Disposes of the runtime animation
  13006. */
  13007. dispose(): void;
  13008. /**
  13009. * Apply the interpolated value to the target
  13010. * @param currentValue defines the value computed by the animation
  13011. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13012. */
  13013. setValue(currentValue: any, weight: number): void;
  13014. private _getOriginalValues;
  13015. private _setValue;
  13016. /**
  13017. * Gets the loop pmode of the runtime animation
  13018. * @returns Loop Mode
  13019. */
  13020. private _getCorrectLoopMode;
  13021. /**
  13022. * Move the current animation to a given frame
  13023. * @param frame defines the frame to move to
  13024. */
  13025. goToFrame(frame: number): void;
  13026. /**
  13027. * @hidden Internal use only
  13028. */
  13029. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13030. /**
  13031. * Execute the current animation
  13032. * @param delay defines the delay to add to the current frame
  13033. * @param from defines the lower bound of the animation range
  13034. * @param to defines the upper bound of the animation range
  13035. * @param loop defines if the current animation must loop
  13036. * @param speedRatio defines the current speed ratio
  13037. * @param weight defines the weight of the animation (default is -1 so no weight)
  13038. * @param onLoop optional callback called when animation loops
  13039. * @returns a boolean indicating if the animation is running
  13040. */
  13041. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13042. }
  13043. }
  13044. declare module BABYLON {
  13045. /**
  13046. * Class used to store an actual running animation
  13047. */
  13048. export class Animatable {
  13049. /** defines the target object */
  13050. target: any;
  13051. /** defines the starting frame number (default is 0) */
  13052. fromFrame: number;
  13053. /** defines the ending frame number (default is 100) */
  13054. toFrame: number;
  13055. /** defines if the animation must loop (default is false) */
  13056. loopAnimation: boolean;
  13057. /** defines a callback to call when animation ends if it is not looping */
  13058. onAnimationEnd?: (() => void) | null | undefined;
  13059. /** defines a callback to call when animation loops */
  13060. onAnimationLoop?: (() => void) | null | undefined;
  13061. private _localDelayOffset;
  13062. private _pausedDelay;
  13063. private _runtimeAnimations;
  13064. private _paused;
  13065. private _scene;
  13066. private _speedRatio;
  13067. private _weight;
  13068. private _syncRoot;
  13069. /**
  13070. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13071. * This will only apply for non looping animation (default is true)
  13072. */
  13073. disposeOnEnd: boolean;
  13074. /**
  13075. * Gets a boolean indicating if the animation has started
  13076. */
  13077. animationStarted: boolean;
  13078. /**
  13079. * Observer raised when the animation ends
  13080. */
  13081. onAnimationEndObservable: Observable<Animatable>;
  13082. /**
  13083. * Observer raised when the animation loops
  13084. */
  13085. onAnimationLoopObservable: Observable<Animatable>;
  13086. /**
  13087. * Gets the root Animatable used to synchronize and normalize animations
  13088. */
  13089. readonly syncRoot: Nullable<Animatable>;
  13090. /**
  13091. * Gets the current frame of the first RuntimeAnimation
  13092. * Used to synchronize Animatables
  13093. */
  13094. readonly masterFrame: number;
  13095. /**
  13096. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13097. */
  13098. weight: number;
  13099. /**
  13100. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13101. */
  13102. speedRatio: number;
  13103. /**
  13104. * Creates a new Animatable
  13105. * @param scene defines the hosting scene
  13106. * @param target defines the target object
  13107. * @param fromFrame defines the starting frame number (default is 0)
  13108. * @param toFrame defines the ending frame number (default is 100)
  13109. * @param loopAnimation defines if the animation must loop (default is false)
  13110. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13111. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13112. * @param animations defines a group of animation to add to the new Animatable
  13113. * @param onAnimationLoop defines a callback to call when animation loops
  13114. */
  13115. constructor(scene: Scene,
  13116. /** defines the target object */
  13117. target: any,
  13118. /** defines the starting frame number (default is 0) */
  13119. fromFrame?: number,
  13120. /** defines the ending frame number (default is 100) */
  13121. toFrame?: number,
  13122. /** defines if the animation must loop (default is false) */
  13123. loopAnimation?: boolean, speedRatio?: number,
  13124. /** defines a callback to call when animation ends if it is not looping */
  13125. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13126. /** defines a callback to call when animation loops */
  13127. onAnimationLoop?: (() => void) | null | undefined);
  13128. /**
  13129. * Synchronize and normalize current Animatable with a source Animatable
  13130. * This is useful when using animation weights and when animations are not of the same length
  13131. * @param root defines the root Animatable to synchronize with
  13132. * @returns the current Animatable
  13133. */
  13134. syncWith(root: Animatable): Animatable;
  13135. /**
  13136. * Gets the list of runtime animations
  13137. * @returns an array of RuntimeAnimation
  13138. */
  13139. getAnimations(): RuntimeAnimation[];
  13140. /**
  13141. * Adds more animations to the current animatable
  13142. * @param target defines the target of the animations
  13143. * @param animations defines the new animations to add
  13144. */
  13145. appendAnimations(target: any, animations: Animation[]): void;
  13146. /**
  13147. * Gets the source animation for a specific property
  13148. * @param property defines the propertyu to look for
  13149. * @returns null or the source animation for the given property
  13150. */
  13151. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13152. /**
  13153. * Gets the runtime animation for a specific property
  13154. * @param property defines the propertyu to look for
  13155. * @returns null or the runtime animation for the given property
  13156. */
  13157. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13158. /**
  13159. * Resets the animatable to its original state
  13160. */
  13161. reset(): void;
  13162. /**
  13163. * Allows the animatable to blend with current running animations
  13164. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13165. * @param blendingSpeed defines the blending speed to use
  13166. */
  13167. enableBlending(blendingSpeed: number): void;
  13168. /**
  13169. * Disable animation blending
  13170. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13171. */
  13172. disableBlending(): void;
  13173. /**
  13174. * Jump directly to a given frame
  13175. * @param frame defines the frame to jump to
  13176. */
  13177. goToFrame(frame: number): void;
  13178. /**
  13179. * Pause the animation
  13180. */
  13181. pause(): void;
  13182. /**
  13183. * Restart the animation
  13184. */
  13185. restart(): void;
  13186. private _raiseOnAnimationEnd;
  13187. /**
  13188. * Stop and delete the current animation
  13189. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13190. * @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)
  13191. */
  13192. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13193. /**
  13194. * Wait asynchronously for the animation to end
  13195. * @returns a promise which will be fullfilled when the animation ends
  13196. */
  13197. waitAsync(): Promise<Animatable>;
  13198. /** @hidden */
  13199. _animate(delay: number): boolean;
  13200. }
  13201. interface Scene {
  13202. /** @hidden */
  13203. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13204. /** @hidden */
  13205. _processLateAnimationBindingsForMatrices(holder: {
  13206. totalWeight: number;
  13207. animations: RuntimeAnimation[];
  13208. originalValue: Matrix;
  13209. }): any;
  13210. /** @hidden */
  13211. _processLateAnimationBindingsForQuaternions(holder: {
  13212. totalWeight: number;
  13213. animations: RuntimeAnimation[];
  13214. originalValue: Quaternion;
  13215. }, refQuaternion: Quaternion): Quaternion;
  13216. /** @hidden */
  13217. _processLateAnimationBindings(): void;
  13218. /**
  13219. * Will start the animation sequence of a given target
  13220. * @param target defines the target
  13221. * @param from defines from which frame should animation start
  13222. * @param to defines until which frame should animation run.
  13223. * @param weight defines the weight to apply to the animation (1.0 by default)
  13224. * @param loop defines if the animation loops
  13225. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13226. * @param onAnimationEnd defines the function to be executed when the animation ends
  13227. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13228. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13229. * @param onAnimationLoop defines the callback to call when an animation loops
  13230. * @returns the animatable object created for this animation
  13231. */
  13232. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13233. /**
  13234. * Will start the animation sequence of a given target
  13235. * @param target defines the target
  13236. * @param from defines from which frame should animation start
  13237. * @param to defines until which frame should animation run.
  13238. * @param loop defines if the animation loops
  13239. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13240. * @param onAnimationEnd defines the function to be executed when the animation ends
  13241. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13242. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13243. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13244. * @param onAnimationLoop defines the callback to call when an animation loops
  13245. * @returns the animatable object created for this animation
  13246. */
  13247. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13248. /**
  13249. * Will start the animation sequence of a given target and its hierarchy
  13250. * @param target defines the target
  13251. * @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.
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param loop defines if the animation loops
  13255. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13256. * @param onAnimationEnd defines the function to be executed when the animation ends
  13257. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13258. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the list of created animatables
  13262. */
  13263. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13264. /**
  13265. * Begin a new animation on a given node
  13266. * @param target defines the target where the animation will take place
  13267. * @param animations defines the list of animations to start
  13268. * @param from defines the initial value
  13269. * @param to defines the final value
  13270. * @param loop defines if you want animation to loop (off by default)
  13271. * @param speedRatio defines the speed ratio to apply to all animations
  13272. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13273. * @param onAnimationLoop defines the callback to call when an animation loops
  13274. * @returns the list of created animatables
  13275. */
  13276. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13277. /**
  13278. * Begin a new animation on a given node and its hierarchy
  13279. * @param target defines the root node where the animation will take place
  13280. * @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.
  13281. * @param animations defines the list of animations to start
  13282. * @param from defines the initial value
  13283. * @param to defines the final value
  13284. * @param loop defines if you want animation to loop (off by default)
  13285. * @param speedRatio defines the speed ratio to apply to all animations
  13286. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13287. * @param onAnimationLoop defines the callback to call when an animation loops
  13288. * @returns the list of animatables created for all nodes
  13289. */
  13290. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13291. /**
  13292. * Gets the animatable associated with a specific target
  13293. * @param target defines the target of the animatable
  13294. * @returns the required animatable if found
  13295. */
  13296. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13297. /**
  13298. * Gets all animatables associated with a given target
  13299. * @param target defines the target to look animatables for
  13300. * @returns an array of Animatables
  13301. */
  13302. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13303. /**
  13304. * Stops and removes all animations that have been applied to the scene
  13305. */
  13306. stopAllAnimations(): void;
  13307. /**
  13308. * Gets the current delta time used by animation engine
  13309. */
  13310. deltaTime: number;
  13311. }
  13312. interface Bone {
  13313. /**
  13314. * Copy an animation range from another bone
  13315. * @param source defines the source bone
  13316. * @param rangeName defines the range name to copy
  13317. * @param frameOffset defines the frame offset
  13318. * @param rescaleAsRequired defines if rescaling must be applied if required
  13319. * @param skelDimensionsRatio defines the scaling ratio
  13320. * @returns true if operation was successful
  13321. */
  13322. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13323. }
  13324. }
  13325. declare module BABYLON {
  13326. /**
  13327. * Class used to override all child animations of a given target
  13328. */
  13329. export class AnimationPropertiesOverride {
  13330. /**
  13331. * Gets or sets a value indicating if animation blending must be used
  13332. */
  13333. enableBlending: boolean;
  13334. /**
  13335. * Gets or sets the blending speed to use when enableBlending is true
  13336. */
  13337. blendingSpeed: number;
  13338. /**
  13339. * Gets or sets the default loop mode to use
  13340. */
  13341. loopMode: number;
  13342. }
  13343. }
  13344. declare module BABYLON {
  13345. /**
  13346. * Class used to handle skinning animations
  13347. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13348. */
  13349. export class Skeleton implements IAnimatable {
  13350. /** defines the skeleton name */
  13351. name: string;
  13352. /** defines the skeleton Id */
  13353. id: string;
  13354. /**
  13355. * Defines the list of child bones
  13356. */
  13357. bones: Bone[];
  13358. /**
  13359. * Defines an estimate of the dimension of the skeleton at rest
  13360. */
  13361. dimensionsAtRest: Vector3;
  13362. /**
  13363. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13364. */
  13365. needInitialSkinMatrix: boolean;
  13366. /**
  13367. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13368. */
  13369. overrideMesh: Nullable<AbstractMesh>;
  13370. /**
  13371. * Gets the list of animations attached to this skeleton
  13372. */
  13373. animations: Array<Animation>;
  13374. private _scene;
  13375. private _isDirty;
  13376. private _transformMatrices;
  13377. private _transformMatrixTexture;
  13378. private _meshesWithPoseMatrix;
  13379. private _animatables;
  13380. private _identity;
  13381. private _synchronizedWithMesh;
  13382. private _ranges;
  13383. private _lastAbsoluteTransformsUpdateId;
  13384. private _canUseTextureForBones;
  13385. private _uniqueId;
  13386. /** @hidden */
  13387. _numBonesWithLinkedTransformNode: number;
  13388. /** @hidden */
  13389. _hasWaitingData: Nullable<boolean>;
  13390. /**
  13391. * Specifies if the skeleton should be serialized
  13392. */
  13393. doNotSerialize: boolean;
  13394. private _useTextureToStoreBoneMatrices;
  13395. /**
  13396. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13397. * Please note that this option is not available if the hardware does not support it
  13398. */
  13399. useTextureToStoreBoneMatrices: boolean;
  13400. private _animationPropertiesOverride;
  13401. /**
  13402. * Gets or sets the animation properties override
  13403. */
  13404. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13405. /**
  13406. * List of inspectable custom properties (used by the Inspector)
  13407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13408. */
  13409. inspectableCustomProperties: IInspectable[];
  13410. /**
  13411. * An observable triggered before computing the skeleton's matrices
  13412. */
  13413. onBeforeComputeObservable: Observable<Skeleton>;
  13414. /**
  13415. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13416. */
  13417. readonly isUsingTextureForMatrices: boolean;
  13418. /**
  13419. * Gets the unique ID of this skeleton
  13420. */
  13421. readonly uniqueId: number;
  13422. /**
  13423. * Creates a new skeleton
  13424. * @param name defines the skeleton name
  13425. * @param id defines the skeleton Id
  13426. * @param scene defines the hosting scene
  13427. */
  13428. constructor(
  13429. /** defines the skeleton name */
  13430. name: string,
  13431. /** defines the skeleton Id */
  13432. id: string, scene: Scene);
  13433. /**
  13434. * Gets the current object class name.
  13435. * @return the class name
  13436. */
  13437. getClassName(): string;
  13438. /**
  13439. * Returns an array containing the root bones
  13440. * @returns an array containing the root bones
  13441. */
  13442. getChildren(): Array<Bone>;
  13443. /**
  13444. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13445. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13446. * @returns a Float32Array containing matrices data
  13447. */
  13448. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13449. /**
  13450. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13451. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13452. * @returns a raw texture containing the data
  13453. */
  13454. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13455. /**
  13456. * Gets the current hosting scene
  13457. * @returns a scene object
  13458. */
  13459. getScene(): Scene;
  13460. /**
  13461. * Gets a string representing the current skeleton data
  13462. * @param fullDetails defines a boolean indicating if we want a verbose version
  13463. * @returns a string representing the current skeleton data
  13464. */
  13465. toString(fullDetails?: boolean): string;
  13466. /**
  13467. * Get bone's index searching by name
  13468. * @param name defines bone's name to search for
  13469. * @return the indice of the bone. Returns -1 if not found
  13470. */
  13471. getBoneIndexByName(name: string): number;
  13472. /**
  13473. * Creater a new animation range
  13474. * @param name defines the name of the range
  13475. * @param from defines the start key
  13476. * @param to defines the end key
  13477. */
  13478. createAnimationRange(name: string, from: number, to: number): void;
  13479. /**
  13480. * Delete a specific animation range
  13481. * @param name defines the name of the range
  13482. * @param deleteFrames defines if frames must be removed as well
  13483. */
  13484. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13485. /**
  13486. * Gets a specific animation range
  13487. * @param name defines the name of the range to look for
  13488. * @returns the requested animation range or null if not found
  13489. */
  13490. getAnimationRange(name: string): Nullable<AnimationRange>;
  13491. /**
  13492. * Gets the list of all animation ranges defined on this skeleton
  13493. * @returns an array
  13494. */
  13495. getAnimationRanges(): Nullable<AnimationRange>[];
  13496. /**
  13497. * Copy animation range from a source skeleton.
  13498. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13499. * @param source defines the source skeleton
  13500. * @param name defines the name of the range to copy
  13501. * @param rescaleAsRequired defines if rescaling must be applied if required
  13502. * @returns true if operation was successful
  13503. */
  13504. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13505. /**
  13506. * Forces the skeleton to go to rest pose
  13507. */
  13508. returnToRest(): void;
  13509. private _getHighestAnimationFrame;
  13510. /**
  13511. * Begin a specific animation range
  13512. * @param name defines the name of the range to start
  13513. * @param loop defines if looping must be turned on (false by default)
  13514. * @param speedRatio defines the speed ratio to apply (1 by default)
  13515. * @param onAnimationEnd defines a callback which will be called when animation will end
  13516. * @returns a new animatable
  13517. */
  13518. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13519. /** @hidden */
  13520. _markAsDirty(): void;
  13521. /** @hidden */
  13522. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13523. /** @hidden */
  13524. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13525. private _computeTransformMatrices;
  13526. /**
  13527. * Build all resources required to render a skeleton
  13528. */
  13529. prepare(): void;
  13530. /**
  13531. * Gets the list of animatables currently running for this skeleton
  13532. * @returns an array of animatables
  13533. */
  13534. getAnimatables(): IAnimatable[];
  13535. /**
  13536. * Clone the current skeleton
  13537. * @param name defines the name of the new skeleton
  13538. * @param id defines the id of the new skeleton
  13539. * @returns the new skeleton
  13540. */
  13541. clone(name: string, id?: string): Skeleton;
  13542. /**
  13543. * Enable animation blending for this skeleton
  13544. * @param blendingSpeed defines the blending speed to apply
  13545. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13546. */
  13547. enableBlending(blendingSpeed?: number): void;
  13548. /**
  13549. * Releases all resources associated with the current skeleton
  13550. */
  13551. dispose(): void;
  13552. /**
  13553. * Serialize the skeleton in a JSON object
  13554. * @returns a JSON object
  13555. */
  13556. serialize(): any;
  13557. /**
  13558. * Creates a new skeleton from serialized data
  13559. * @param parsedSkeleton defines the serialized data
  13560. * @param scene defines the hosting scene
  13561. * @returns a new skeleton
  13562. */
  13563. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13564. /**
  13565. * Compute all node absolute transforms
  13566. * @param forceUpdate defines if computation must be done even if cache is up to date
  13567. */
  13568. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13569. /**
  13570. * Gets the root pose matrix
  13571. * @returns a matrix
  13572. */
  13573. getPoseMatrix(): Nullable<Matrix>;
  13574. /**
  13575. * Sorts bones per internal index
  13576. */
  13577. sortBones(): void;
  13578. private _sortBones;
  13579. }
  13580. }
  13581. declare module BABYLON {
  13582. /**
  13583. * Class used to store bone information
  13584. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13585. */
  13586. export class Bone extends Node {
  13587. /**
  13588. * defines the bone name
  13589. */
  13590. name: string;
  13591. private static _tmpVecs;
  13592. private static _tmpQuat;
  13593. private static _tmpMats;
  13594. /**
  13595. * Gets the list of child bones
  13596. */
  13597. children: Bone[];
  13598. /** Gets the animations associated with this bone */
  13599. animations: Animation[];
  13600. /**
  13601. * Gets or sets bone length
  13602. */
  13603. length: number;
  13604. /**
  13605. * @hidden Internal only
  13606. * Set this value to map this bone to a different index in the transform matrices
  13607. * Set this value to -1 to exclude the bone from the transform matrices
  13608. */
  13609. _index: Nullable<number>;
  13610. private _skeleton;
  13611. private _localMatrix;
  13612. private _restPose;
  13613. private _baseMatrix;
  13614. private _absoluteTransform;
  13615. private _invertedAbsoluteTransform;
  13616. private _parent;
  13617. private _scalingDeterminant;
  13618. private _worldTransform;
  13619. private _localScaling;
  13620. private _localRotation;
  13621. private _localPosition;
  13622. private _needToDecompose;
  13623. private _needToCompose;
  13624. /** @hidden */
  13625. _linkedTransformNode: Nullable<TransformNode>;
  13626. /** @hidden */
  13627. _waitingTransformNodeId: Nullable<string>;
  13628. /** @hidden */
  13629. /** @hidden */
  13630. _matrix: Matrix;
  13631. /**
  13632. * Create a new bone
  13633. * @param name defines the bone name
  13634. * @param skeleton defines the parent skeleton
  13635. * @param parentBone defines the parent (can be null if the bone is the root)
  13636. * @param localMatrix defines the local matrix
  13637. * @param restPose defines the rest pose matrix
  13638. * @param baseMatrix defines the base matrix
  13639. * @param index defines index of the bone in the hiearchy
  13640. */
  13641. constructor(
  13642. /**
  13643. * defines the bone name
  13644. */
  13645. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13646. /**
  13647. * Gets the current object class name.
  13648. * @return the class name
  13649. */
  13650. getClassName(): string;
  13651. /**
  13652. * Gets the parent skeleton
  13653. * @returns a skeleton
  13654. */
  13655. getSkeleton(): Skeleton;
  13656. /**
  13657. * Gets parent bone
  13658. * @returns a bone or null if the bone is the root of the bone hierarchy
  13659. */
  13660. getParent(): Nullable<Bone>;
  13661. /**
  13662. * Returns an array containing the root bones
  13663. * @returns an array containing the root bones
  13664. */
  13665. getChildren(): Array<Bone>;
  13666. /**
  13667. * Gets the node index in matrix array generated for rendering
  13668. * @returns the node index
  13669. */
  13670. getIndex(): number;
  13671. /**
  13672. * Sets the parent bone
  13673. * @param parent defines the parent (can be null if the bone is the root)
  13674. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13675. */
  13676. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13677. /**
  13678. * Gets the local matrix
  13679. * @returns a matrix
  13680. */
  13681. getLocalMatrix(): Matrix;
  13682. /**
  13683. * Gets the base matrix (initial matrix which remains unchanged)
  13684. * @returns a matrix
  13685. */
  13686. getBaseMatrix(): Matrix;
  13687. /**
  13688. * Gets the rest pose matrix
  13689. * @returns a matrix
  13690. */
  13691. getRestPose(): Matrix;
  13692. /**
  13693. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13694. */
  13695. getWorldMatrix(): Matrix;
  13696. /**
  13697. * Sets the local matrix to rest pose matrix
  13698. */
  13699. returnToRest(): void;
  13700. /**
  13701. * Gets the inverse of the absolute transform matrix.
  13702. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13703. * @returns a matrix
  13704. */
  13705. getInvertedAbsoluteTransform(): Matrix;
  13706. /**
  13707. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13708. * @returns a matrix
  13709. */
  13710. getAbsoluteTransform(): Matrix;
  13711. /**
  13712. * Links with the given transform node.
  13713. * The local matrix of this bone is copied from the transform node every frame.
  13714. * @param transformNode defines the transform node to link to
  13715. */
  13716. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13717. /**
  13718. * Gets the node used to drive the bone's transformation
  13719. * @returns a transform node or null
  13720. */
  13721. getTransformNode(): Nullable<TransformNode>;
  13722. /** Gets or sets current position (in local space) */
  13723. position: Vector3;
  13724. /** Gets or sets current rotation (in local space) */
  13725. rotation: Vector3;
  13726. /** Gets or sets current rotation quaternion (in local space) */
  13727. rotationQuaternion: Quaternion;
  13728. /** Gets or sets current scaling (in local space) */
  13729. scaling: Vector3;
  13730. /**
  13731. * Gets the animation properties override
  13732. */
  13733. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13734. private _decompose;
  13735. private _compose;
  13736. /**
  13737. * Update the base and local matrices
  13738. * @param matrix defines the new base or local matrix
  13739. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13740. * @param updateLocalMatrix defines if the local matrix should be updated
  13741. */
  13742. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13743. /** @hidden */
  13744. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13745. /**
  13746. * Flag the bone as dirty (Forcing it to update everything)
  13747. */
  13748. markAsDirty(): void;
  13749. /** @hidden */
  13750. _markAsDirtyAndCompose(): void;
  13751. private _markAsDirtyAndDecompose;
  13752. /**
  13753. * Translate the bone in local or world space
  13754. * @param vec The amount to translate the bone
  13755. * @param space The space that the translation is in
  13756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13757. */
  13758. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13759. /**
  13760. * Set the postion of the bone in local or world space
  13761. * @param position The position to set the bone
  13762. * @param space The space that the position is in
  13763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13764. */
  13765. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13766. /**
  13767. * Set the absolute position of the bone (world space)
  13768. * @param position The position to set the bone
  13769. * @param mesh The mesh that this bone is attached to
  13770. */
  13771. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13772. /**
  13773. * Scale the bone on the x, y and z axes (in local space)
  13774. * @param x The amount to scale the bone on the x axis
  13775. * @param y The amount to scale the bone on the y axis
  13776. * @param z The amount to scale the bone on the z axis
  13777. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13778. */
  13779. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13780. /**
  13781. * Set the bone scaling in local space
  13782. * @param scale defines the scaling vector
  13783. */
  13784. setScale(scale: Vector3): void;
  13785. /**
  13786. * Gets the current scaling in local space
  13787. * @returns the current scaling vector
  13788. */
  13789. getScale(): Vector3;
  13790. /**
  13791. * Gets the current scaling in local space and stores it in a target vector
  13792. * @param result defines the target vector
  13793. */
  13794. getScaleToRef(result: Vector3): void;
  13795. /**
  13796. * Set the yaw, pitch, and roll of the bone in local or world space
  13797. * @param yaw The rotation of the bone on the y axis
  13798. * @param pitch The rotation of the bone on the x axis
  13799. * @param roll The rotation of the bone on the z axis
  13800. * @param space The space that the axes of rotation are in
  13801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13802. */
  13803. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13804. /**
  13805. * Add a rotation to the bone on an axis in local or world space
  13806. * @param axis The axis to rotate the bone on
  13807. * @param amount The amount to rotate the bone
  13808. * @param space The space that the axis is in
  13809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13810. */
  13811. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13812. /**
  13813. * Set the rotation of the bone to a particular axis angle in local or world space
  13814. * @param axis The axis to rotate the bone on
  13815. * @param angle The angle that the bone should be rotated to
  13816. * @param space The space that the axis is in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. */
  13819. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13820. /**
  13821. * Set the euler rotation of the bone in local of world space
  13822. * @param rotation The euler rotation that the bone should be set to
  13823. * @param space The space that the rotation is in
  13824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13825. */
  13826. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13827. /**
  13828. * Set the quaternion rotation of the bone in local of world space
  13829. * @param quat The quaternion rotation that the bone should be set to
  13830. * @param space The space that the rotation is in
  13831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13832. */
  13833. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13834. /**
  13835. * Set the rotation matrix of the bone in local of world space
  13836. * @param rotMat The rotation matrix that the bone should be set to
  13837. * @param space The space that the rotation is in
  13838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13839. */
  13840. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13841. private _rotateWithMatrix;
  13842. private _getNegativeRotationToRef;
  13843. /**
  13844. * Get the position of the bone in local or world space
  13845. * @param space The space that the returned position is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. * @returns The position of the bone
  13848. */
  13849. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13850. /**
  13851. * Copy the position of the bone to a vector3 in local or world space
  13852. * @param space The space that the returned position is in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. * @param result The vector3 to copy the position to
  13855. */
  13856. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13857. /**
  13858. * Get the absolute position of the bone (world space)
  13859. * @param mesh The mesh that this bone is attached to
  13860. * @returns The absolute position of the bone
  13861. */
  13862. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13863. /**
  13864. * Copy the absolute position of the bone (world space) to the result param
  13865. * @param mesh The mesh that this bone is attached to
  13866. * @param result The vector3 to copy the absolute position to
  13867. */
  13868. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13869. /**
  13870. * Compute the absolute transforms of this bone and its children
  13871. */
  13872. computeAbsoluteTransforms(): void;
  13873. /**
  13874. * Get the world direction from an axis that is in the local space of the bone
  13875. * @param localAxis The local direction that is used to compute the world direction
  13876. * @param mesh The mesh that this bone is attached to
  13877. * @returns The world direction
  13878. */
  13879. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13880. /**
  13881. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13882. * @param localAxis The local direction that is used to compute the world direction
  13883. * @param mesh The mesh that this bone is attached to
  13884. * @param result The vector3 that the world direction will be copied to
  13885. */
  13886. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13887. /**
  13888. * Get the euler rotation of the bone in local or world space
  13889. * @param space The space that the rotation should be in
  13890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13891. * @returns The euler rotation
  13892. */
  13893. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13894. /**
  13895. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13896. * @param space The space that the rotation should be in
  13897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13898. * @param result The vector3 that the rotation should be copied to
  13899. */
  13900. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13901. /**
  13902. * Get the quaternion rotation of the bone in either local or world space
  13903. * @param space The space that the rotation should be in
  13904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13905. * @returns The quaternion rotation
  13906. */
  13907. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13908. /**
  13909. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13910. * @param space The space that the rotation should be in
  13911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13912. * @param result The quaternion that the rotation should be copied to
  13913. */
  13914. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13915. /**
  13916. * Get the rotation matrix of the bone in local or world space
  13917. * @param space The space that the rotation should be in
  13918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13919. * @returns The rotation matrix
  13920. */
  13921. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13922. /**
  13923. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13924. * @param space The space that the rotation should be in
  13925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13926. * @param result The quaternion that the rotation should be copied to
  13927. */
  13928. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13929. /**
  13930. * Get the world position of a point that is in the local space of the bone
  13931. * @param position The local position
  13932. * @param mesh The mesh that this bone is attached to
  13933. * @returns The world position
  13934. */
  13935. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13936. /**
  13937. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13938. * @param position The local position
  13939. * @param mesh The mesh that this bone is attached to
  13940. * @param result The vector3 that the world position should be copied to
  13941. */
  13942. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13943. /**
  13944. * Get the local position of a point that is in world space
  13945. * @param position The world position
  13946. * @param mesh The mesh that this bone is attached to
  13947. * @returns The local position
  13948. */
  13949. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13950. /**
  13951. * Get the local position of a point that is in world space and copy it to the result param
  13952. * @param position The world position
  13953. * @param mesh The mesh that this bone is attached to
  13954. * @param result The vector3 that the local position should be copied to
  13955. */
  13956. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13957. }
  13958. }
  13959. declare module BABYLON {
  13960. /**
  13961. * 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.
  13962. * @see https://doc.babylonjs.com/how_to/transformnode
  13963. */
  13964. export class TransformNode extends Node {
  13965. /**
  13966. * Object will not rotate to face the camera
  13967. */
  13968. static BILLBOARDMODE_NONE: number;
  13969. /**
  13970. * Object will rotate to face the camera but only on the x axis
  13971. */
  13972. static BILLBOARDMODE_X: number;
  13973. /**
  13974. * Object will rotate to face the camera but only on the y axis
  13975. */
  13976. static BILLBOARDMODE_Y: number;
  13977. /**
  13978. * Object will rotate to face the camera but only on the z axis
  13979. */
  13980. static BILLBOARDMODE_Z: number;
  13981. /**
  13982. * Object will rotate to face the camera
  13983. */
  13984. static BILLBOARDMODE_ALL: number;
  13985. /**
  13986. * Object will rotate to face the camera's position instead of orientation
  13987. */
  13988. static BILLBOARDMODE_USE_POSITION: number;
  13989. private _forward;
  13990. private _forwardInverted;
  13991. private _up;
  13992. private _right;
  13993. private _rightInverted;
  13994. private _position;
  13995. private _rotation;
  13996. private _rotationQuaternion;
  13997. protected _scaling: Vector3;
  13998. protected _isDirty: boolean;
  13999. private _transformToBoneReferal;
  14000. private _isAbsoluteSynced;
  14001. private _billboardMode;
  14002. /**
  14003. * Gets or sets the billboard mode. Default is 0.
  14004. *
  14005. * | Value | Type | Description |
  14006. * | --- | --- | --- |
  14007. * | 0 | BILLBOARDMODE_NONE | |
  14008. * | 1 | BILLBOARDMODE_X | |
  14009. * | 2 | BILLBOARDMODE_Y | |
  14010. * | 4 | BILLBOARDMODE_Z | |
  14011. * | 7 | BILLBOARDMODE_ALL | |
  14012. *
  14013. */
  14014. billboardMode: number;
  14015. private _preserveParentRotationForBillboard;
  14016. /**
  14017. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14018. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14019. */
  14020. preserveParentRotationForBillboard: boolean;
  14021. /**
  14022. * 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
  14023. */
  14024. scalingDeterminant: number;
  14025. private _infiniteDistance;
  14026. /**
  14027. * Gets or sets the distance of the object to max, often used by skybox
  14028. */
  14029. infiniteDistance: boolean;
  14030. /**
  14031. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14032. * By default the system will update normals to compensate
  14033. */
  14034. ignoreNonUniformScaling: boolean;
  14035. /**
  14036. * 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
  14037. */
  14038. reIntegrateRotationIntoRotationQuaternion: boolean;
  14039. /** @hidden */
  14040. _poseMatrix: Nullable<Matrix>;
  14041. /** @hidden */
  14042. _localMatrix: Matrix;
  14043. private _usePivotMatrix;
  14044. private _absolutePosition;
  14045. private _absoluteScaling;
  14046. private _absoluteRotationQuaternion;
  14047. private _pivotMatrix;
  14048. private _pivotMatrixInverse;
  14049. protected _postMultiplyPivotMatrix: boolean;
  14050. protected _isWorldMatrixFrozen: boolean;
  14051. /** @hidden */
  14052. _indexInSceneTransformNodesArray: number;
  14053. /**
  14054. * An event triggered after the world matrix is updated
  14055. */
  14056. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14057. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14058. /**
  14059. * Gets a string identifying the name of the class
  14060. * @returns "TransformNode" string
  14061. */
  14062. getClassName(): string;
  14063. /**
  14064. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14065. */
  14066. position: Vector3;
  14067. /**
  14068. * 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)).
  14069. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14070. */
  14071. rotation: Vector3;
  14072. /**
  14073. * 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)).
  14074. */
  14075. scaling: Vector3;
  14076. /**
  14077. * 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).
  14078. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14079. */
  14080. rotationQuaternion: Nullable<Quaternion>;
  14081. /**
  14082. * The forward direction of that transform in world space.
  14083. */
  14084. readonly forward: Vector3;
  14085. /**
  14086. * The up direction of that transform in world space.
  14087. */
  14088. readonly up: Vector3;
  14089. /**
  14090. * The right direction of that transform in world space.
  14091. */
  14092. readonly right: Vector3;
  14093. /**
  14094. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14095. * @param matrix the matrix to copy the pose from
  14096. * @returns this TransformNode.
  14097. */
  14098. updatePoseMatrix(matrix: Matrix): TransformNode;
  14099. /**
  14100. * Returns the mesh Pose matrix.
  14101. * @returns the pose matrix
  14102. */
  14103. getPoseMatrix(): Matrix;
  14104. /** @hidden */
  14105. _isSynchronized(): boolean;
  14106. /** @hidden */
  14107. _initCache(): void;
  14108. /**
  14109. * Flag the transform node as dirty (Forcing it to update everything)
  14110. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14111. * @returns this transform node
  14112. */
  14113. markAsDirty(property: string): TransformNode;
  14114. /**
  14115. * Returns the current mesh absolute position.
  14116. * Returns a Vector3.
  14117. */
  14118. readonly absolutePosition: Vector3;
  14119. /**
  14120. * Returns the current mesh absolute scaling.
  14121. * Returns a Vector3.
  14122. */
  14123. readonly absoluteScaling: Vector3;
  14124. /**
  14125. * Returns the current mesh absolute rotation.
  14126. * Returns a Quaternion.
  14127. */
  14128. readonly absoluteRotationQuaternion: Quaternion;
  14129. /**
  14130. * Sets a new matrix to apply before all other transformation
  14131. * @param matrix defines the transform matrix
  14132. * @returns the current TransformNode
  14133. */
  14134. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14135. /**
  14136. * Sets a new pivot matrix to the current node
  14137. * @param matrix defines the new pivot matrix to use
  14138. * @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
  14139. * @returns the current TransformNode
  14140. */
  14141. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14142. /**
  14143. * Returns the mesh pivot matrix.
  14144. * Default : Identity.
  14145. * @returns the matrix
  14146. */
  14147. getPivotMatrix(): Matrix;
  14148. /**
  14149. * Instantiate (when possible) or clone that node with its hierarchy
  14150. * @param newParent defines the new parent to use for the instance (or clone)
  14151. * @param options defines options to configure how copy is done
  14152. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14153. * @returns an instance (or a clone) of the current node with its hiearchy
  14154. */
  14155. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14156. doNotInstantiate: boolean;
  14157. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14158. /**
  14159. * Prevents the World matrix to be computed any longer
  14160. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14161. * @returns the TransformNode.
  14162. */
  14163. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14164. /**
  14165. * Allows back the World matrix computation.
  14166. * @returns the TransformNode.
  14167. */
  14168. unfreezeWorldMatrix(): this;
  14169. /**
  14170. * True if the World matrix has been frozen.
  14171. */
  14172. readonly isWorldMatrixFrozen: boolean;
  14173. /**
  14174. * Retuns the mesh absolute position in the World.
  14175. * @returns a Vector3.
  14176. */
  14177. getAbsolutePosition(): Vector3;
  14178. /**
  14179. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14180. * @param absolutePosition the absolute position to set
  14181. * @returns the TransformNode.
  14182. */
  14183. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14184. /**
  14185. * Sets the mesh position in its local space.
  14186. * @param vector3 the position to set in localspace
  14187. * @returns the TransformNode.
  14188. */
  14189. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14190. /**
  14191. * Returns the mesh position in the local space from the current World matrix values.
  14192. * @returns a new Vector3.
  14193. */
  14194. getPositionExpressedInLocalSpace(): Vector3;
  14195. /**
  14196. * Translates the mesh along the passed Vector3 in its local space.
  14197. * @param vector3 the distance to translate in localspace
  14198. * @returns the TransformNode.
  14199. */
  14200. locallyTranslate(vector3: Vector3): TransformNode;
  14201. private static _lookAtVectorCache;
  14202. /**
  14203. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14204. * @param targetPoint the position (must be in same space as current mesh) to look at
  14205. * @param yawCor optional yaw (y-axis) correction in radians
  14206. * @param pitchCor optional pitch (x-axis) correction in radians
  14207. * @param rollCor optional roll (z-axis) correction in radians
  14208. * @param space the choosen space of the target
  14209. * @returns the TransformNode.
  14210. */
  14211. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14212. /**
  14213. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14214. * This Vector3 is expressed in the World space.
  14215. * @param localAxis axis to rotate
  14216. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14217. */
  14218. getDirection(localAxis: Vector3): Vector3;
  14219. /**
  14220. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14221. * localAxis is expressed in the mesh local space.
  14222. * result is computed in the Wordl space from the mesh World matrix.
  14223. * @param localAxis axis to rotate
  14224. * @param result the resulting transformnode
  14225. * @returns this TransformNode.
  14226. */
  14227. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14228. /**
  14229. * Sets this transform node rotation to the given local axis.
  14230. * @param localAxis the axis in local space
  14231. * @param yawCor optional yaw (y-axis) correction in radians
  14232. * @param pitchCor optional pitch (x-axis) correction in radians
  14233. * @param rollCor optional roll (z-axis) correction in radians
  14234. * @returns this TransformNode
  14235. */
  14236. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14237. /**
  14238. * Sets a new pivot point to the current node
  14239. * @param point defines the new pivot point to use
  14240. * @param space defines if the point is in world or local space (local by default)
  14241. * @returns the current TransformNode
  14242. */
  14243. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14244. /**
  14245. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14246. * @returns the pivot point
  14247. */
  14248. getPivotPoint(): Vector3;
  14249. /**
  14250. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14251. * @param result the vector3 to store the result
  14252. * @returns this TransformNode.
  14253. */
  14254. getPivotPointToRef(result: Vector3): TransformNode;
  14255. /**
  14256. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14257. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14258. */
  14259. getAbsolutePivotPoint(): Vector3;
  14260. /**
  14261. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14262. * @param result vector3 to store the result
  14263. * @returns this TransformNode.
  14264. */
  14265. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14266. /**
  14267. * Defines the passed node as the parent of the current node.
  14268. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14269. * @see https://doc.babylonjs.com/how_to/parenting
  14270. * @param node the node ot set as the parent
  14271. * @returns this TransformNode.
  14272. */
  14273. setParent(node: Nullable<Node>): TransformNode;
  14274. private _nonUniformScaling;
  14275. /**
  14276. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14277. */
  14278. readonly nonUniformScaling: boolean;
  14279. /** @hidden */
  14280. _updateNonUniformScalingState(value: boolean): boolean;
  14281. /**
  14282. * Attach the current TransformNode to another TransformNode associated with a bone
  14283. * @param bone Bone affecting the TransformNode
  14284. * @param affectedTransformNode TransformNode associated with the bone
  14285. * @returns this object
  14286. */
  14287. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14288. /**
  14289. * Detach the transform node if its associated with a bone
  14290. * @returns this object
  14291. */
  14292. detachFromBone(): TransformNode;
  14293. private static _rotationAxisCache;
  14294. /**
  14295. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14296. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14297. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14298. * The passed axis is also normalized.
  14299. * @param axis the axis to rotate around
  14300. * @param amount the amount to rotate in radians
  14301. * @param space Space to rotate in (Default: local)
  14302. * @returns the TransformNode.
  14303. */
  14304. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14305. /**
  14306. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14307. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14308. * The passed axis is also normalized. .
  14309. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14310. * @param point the point to rotate around
  14311. * @param axis the axis to rotate around
  14312. * @param amount the amount to rotate in radians
  14313. * @returns the TransformNode
  14314. */
  14315. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14316. /**
  14317. * Translates the mesh along the axis vector for the passed distance in the given space.
  14318. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14319. * @param axis the axis to translate in
  14320. * @param distance the distance to translate
  14321. * @param space Space to rotate in (Default: local)
  14322. * @returns the TransformNode.
  14323. */
  14324. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14325. /**
  14326. * Adds a rotation step to the mesh current rotation.
  14327. * x, y, z are Euler angles expressed in radians.
  14328. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14329. * This means this rotation is made in the mesh local space only.
  14330. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14331. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14332. * ```javascript
  14333. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14334. * ```
  14335. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14336. * 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.
  14337. * @param x Rotation to add
  14338. * @param y Rotation to add
  14339. * @param z Rotation to add
  14340. * @returns the TransformNode.
  14341. */
  14342. addRotation(x: number, y: number, z: number): TransformNode;
  14343. /**
  14344. * @hidden
  14345. */
  14346. protected _getEffectiveParent(): Nullable<Node>;
  14347. /**
  14348. * Computes the world matrix of the node
  14349. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14350. * @returns the world matrix
  14351. */
  14352. computeWorldMatrix(force?: boolean): Matrix;
  14353. protected _afterComputeWorldMatrix(): void;
  14354. /**
  14355. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14356. * @param func callback function to add
  14357. *
  14358. * @returns the TransformNode.
  14359. */
  14360. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14361. /**
  14362. * Removes a registered callback function.
  14363. * @param func callback function to remove
  14364. * @returns the TransformNode.
  14365. */
  14366. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14367. /**
  14368. * Gets the position of the current mesh in camera space
  14369. * @param camera defines the camera to use
  14370. * @returns a position
  14371. */
  14372. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14373. /**
  14374. * Returns the distance from the mesh to the active camera
  14375. * @param camera defines the camera to use
  14376. * @returns the distance
  14377. */
  14378. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14379. /**
  14380. * Clone the current transform node
  14381. * @param name Name of the new clone
  14382. * @param newParent New parent for the clone
  14383. * @param doNotCloneChildren Do not clone children hierarchy
  14384. * @returns the new transform node
  14385. */
  14386. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14387. /**
  14388. * Serializes the objects information.
  14389. * @param currentSerializationObject defines the object to serialize in
  14390. * @returns the serialized object
  14391. */
  14392. serialize(currentSerializationObject?: any): any;
  14393. /**
  14394. * Returns a new TransformNode object parsed from the source provided.
  14395. * @param parsedTransformNode is the source.
  14396. * @param scene the scne the object belongs to
  14397. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14398. * @returns a new TransformNode object parsed from the source provided.
  14399. */
  14400. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14401. /**
  14402. * Get all child-transformNodes of this node
  14403. * @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
  14404. * @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
  14405. * @returns an array of TransformNode
  14406. */
  14407. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14408. /**
  14409. * Releases resources associated with this transform node.
  14410. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14411. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14412. */
  14413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14414. /**
  14415. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14416. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14417. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14418. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14419. * @returns the current mesh
  14420. */
  14421. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14422. private _syncAbsoluteScalingAndRotation;
  14423. }
  14424. }
  14425. declare module BABYLON {
  14426. /**
  14427. * Defines the types of pose enabled controllers that are supported
  14428. */
  14429. export enum PoseEnabledControllerType {
  14430. /**
  14431. * HTC Vive
  14432. */
  14433. VIVE = 0,
  14434. /**
  14435. * Oculus Rift
  14436. */
  14437. OCULUS = 1,
  14438. /**
  14439. * Windows mixed reality
  14440. */
  14441. WINDOWS = 2,
  14442. /**
  14443. * Samsung gear VR
  14444. */
  14445. GEAR_VR = 3,
  14446. /**
  14447. * Google Daydream
  14448. */
  14449. DAYDREAM = 4,
  14450. /**
  14451. * Generic
  14452. */
  14453. GENERIC = 5
  14454. }
  14455. /**
  14456. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14457. */
  14458. export interface MutableGamepadButton {
  14459. /**
  14460. * Value of the button/trigger
  14461. */
  14462. value: number;
  14463. /**
  14464. * If the button/trigger is currently touched
  14465. */
  14466. touched: boolean;
  14467. /**
  14468. * If the button/trigger is currently pressed
  14469. */
  14470. pressed: boolean;
  14471. }
  14472. /**
  14473. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14474. * @hidden
  14475. */
  14476. export interface ExtendedGamepadButton extends GamepadButton {
  14477. /**
  14478. * If the button/trigger is currently pressed
  14479. */
  14480. readonly pressed: boolean;
  14481. /**
  14482. * If the button/trigger is currently touched
  14483. */
  14484. readonly touched: boolean;
  14485. /**
  14486. * Value of the button/trigger
  14487. */
  14488. readonly value: number;
  14489. }
  14490. /** @hidden */
  14491. export interface _GamePadFactory {
  14492. /**
  14493. * Returns wether or not the current gamepad can be created for this type of controller.
  14494. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14495. * @returns true if it can be created, otherwise false
  14496. */
  14497. canCreate(gamepadInfo: any): boolean;
  14498. /**
  14499. * Creates a new instance of the Gamepad.
  14500. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14501. * @returns the new gamepad instance
  14502. */
  14503. create(gamepadInfo: any): Gamepad;
  14504. }
  14505. /**
  14506. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14507. */
  14508. export class PoseEnabledControllerHelper {
  14509. /** @hidden */
  14510. static _ControllerFactories: _GamePadFactory[];
  14511. /** @hidden */
  14512. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14513. /**
  14514. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14515. * @param vrGamepad the gamepad to initialized
  14516. * @returns a vr controller of the type the gamepad identified as
  14517. */
  14518. static InitiateController(vrGamepad: any): Gamepad;
  14519. }
  14520. /**
  14521. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14522. */
  14523. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14524. /**
  14525. * If the controller is used in a webXR session
  14526. */
  14527. isXR: boolean;
  14528. private _deviceRoomPosition;
  14529. private _deviceRoomRotationQuaternion;
  14530. /**
  14531. * The device position in babylon space
  14532. */
  14533. devicePosition: Vector3;
  14534. /**
  14535. * The device rotation in babylon space
  14536. */
  14537. deviceRotationQuaternion: Quaternion;
  14538. /**
  14539. * The scale factor of the device in babylon space
  14540. */
  14541. deviceScaleFactor: number;
  14542. /**
  14543. * (Likely devicePosition should be used instead) The device position in its room space
  14544. */
  14545. position: Vector3;
  14546. /**
  14547. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14548. */
  14549. rotationQuaternion: Quaternion;
  14550. /**
  14551. * The type of controller (Eg. Windows mixed reality)
  14552. */
  14553. controllerType: PoseEnabledControllerType;
  14554. protected _calculatedPosition: Vector3;
  14555. private _calculatedRotation;
  14556. /**
  14557. * The raw pose from the device
  14558. */
  14559. rawPose: DevicePose;
  14560. private _trackPosition;
  14561. private _maxRotationDistFromHeadset;
  14562. private _draggedRoomRotation;
  14563. /**
  14564. * @hidden
  14565. */
  14566. _disableTrackPosition(fixedPosition: Vector3): void;
  14567. /**
  14568. * Internal, the mesh attached to the controller
  14569. * @hidden
  14570. */
  14571. _mesh: Nullable<AbstractMesh>;
  14572. private _poseControlledCamera;
  14573. private _leftHandSystemQuaternion;
  14574. /**
  14575. * Internal, matrix used to convert room space to babylon space
  14576. * @hidden
  14577. */
  14578. _deviceToWorld: Matrix;
  14579. /**
  14580. * Node to be used when casting a ray from the controller
  14581. * @hidden
  14582. */
  14583. _pointingPoseNode: Nullable<TransformNode>;
  14584. /**
  14585. * Name of the child mesh that can be used to cast a ray from the controller
  14586. */
  14587. static readonly POINTING_POSE: string;
  14588. /**
  14589. * Creates a new PoseEnabledController from a gamepad
  14590. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14591. */
  14592. constructor(browserGamepad: any);
  14593. private _workingMatrix;
  14594. /**
  14595. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14596. */
  14597. update(): void;
  14598. /**
  14599. * Updates only the pose device and mesh without doing any button event checking
  14600. */
  14601. protected _updatePoseAndMesh(): void;
  14602. /**
  14603. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14604. * @param poseData raw pose fromthe device
  14605. */
  14606. updateFromDevice(poseData: DevicePose): void;
  14607. /**
  14608. * @hidden
  14609. */
  14610. _meshAttachedObservable: Observable<AbstractMesh>;
  14611. /**
  14612. * Attaches a mesh to the controller
  14613. * @param mesh the mesh to be attached
  14614. */
  14615. attachToMesh(mesh: AbstractMesh): void;
  14616. /**
  14617. * Attaches the controllers mesh to a camera
  14618. * @param camera the camera the mesh should be attached to
  14619. */
  14620. attachToPoseControlledCamera(camera: TargetCamera): void;
  14621. /**
  14622. * Disposes of the controller
  14623. */
  14624. dispose(): void;
  14625. /**
  14626. * The mesh that is attached to the controller
  14627. */
  14628. readonly mesh: Nullable<AbstractMesh>;
  14629. /**
  14630. * Gets the ray of the controller in the direction the controller is pointing
  14631. * @param length the length the resulting ray should be
  14632. * @returns a ray in the direction the controller is pointing
  14633. */
  14634. getForwardRay(length?: number): Ray;
  14635. }
  14636. }
  14637. declare module BABYLON {
  14638. /**
  14639. * Defines the WebVRController object that represents controllers tracked in 3D space
  14640. */
  14641. export abstract class WebVRController extends PoseEnabledController {
  14642. /**
  14643. * Internal, the default controller model for the controller
  14644. */
  14645. protected _defaultModel: Nullable<AbstractMesh>;
  14646. /**
  14647. * Fired when the trigger state has changed
  14648. */
  14649. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14650. /**
  14651. * Fired when the main button state has changed
  14652. */
  14653. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14654. /**
  14655. * Fired when the secondary button state has changed
  14656. */
  14657. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14658. /**
  14659. * Fired when the pad state has changed
  14660. */
  14661. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14662. /**
  14663. * Fired when controllers stick values have changed
  14664. */
  14665. onPadValuesChangedObservable: Observable<StickValues>;
  14666. /**
  14667. * Array of button availible on the controller
  14668. */
  14669. protected _buttons: Array<MutableGamepadButton>;
  14670. private _onButtonStateChange;
  14671. /**
  14672. * Fired when a controller button's state has changed
  14673. * @param callback the callback containing the button that was modified
  14674. */
  14675. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14676. /**
  14677. * X and Y axis corresponding to the controllers joystick
  14678. */
  14679. pad: StickValues;
  14680. /**
  14681. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14682. */
  14683. hand: string;
  14684. /**
  14685. * The default controller model for the controller
  14686. */
  14687. readonly defaultModel: Nullable<AbstractMesh>;
  14688. /**
  14689. * Creates a new WebVRController from a gamepad
  14690. * @param vrGamepad the gamepad that the WebVRController should be created from
  14691. */
  14692. constructor(vrGamepad: any);
  14693. /**
  14694. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14695. */
  14696. update(): void;
  14697. /**
  14698. * Function to be called when a button is modified
  14699. */
  14700. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14701. /**
  14702. * Loads a mesh and attaches it to the controller
  14703. * @param scene the scene the mesh should be added to
  14704. * @param meshLoaded callback for when the mesh has been loaded
  14705. */
  14706. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14707. private _setButtonValue;
  14708. private _changes;
  14709. private _checkChanges;
  14710. /**
  14711. * Disposes of th webVRCOntroller
  14712. */
  14713. dispose(): void;
  14714. }
  14715. }
  14716. declare module BABYLON {
  14717. /**
  14718. * The HemisphericLight simulates the ambient environment light,
  14719. * so the passed direction is the light reflection direction, not the incoming direction.
  14720. */
  14721. export class HemisphericLight extends Light {
  14722. /**
  14723. * The groundColor is the light in the opposite direction to the one specified during creation.
  14724. * 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.
  14725. */
  14726. groundColor: Color3;
  14727. /**
  14728. * The light reflection direction, not the incoming direction.
  14729. */
  14730. direction: Vector3;
  14731. /**
  14732. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14733. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14734. * The HemisphericLight can't cast shadows.
  14735. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14736. * @param name The friendly name of the light
  14737. * @param direction The direction of the light reflection
  14738. * @param scene The scene the light belongs to
  14739. */
  14740. constructor(name: string, direction: Vector3, scene: Scene);
  14741. protected _buildUniformLayout(): void;
  14742. /**
  14743. * Returns the string "HemisphericLight".
  14744. * @return The class name
  14745. */
  14746. getClassName(): string;
  14747. /**
  14748. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14749. * Returns the updated direction.
  14750. * @param target The target the direction should point to
  14751. * @return The computed direction
  14752. */
  14753. setDirectionToTarget(target: Vector3): Vector3;
  14754. /**
  14755. * Returns the shadow generator associated to the light.
  14756. * @returns Always null for hemispheric lights because it does not support shadows.
  14757. */
  14758. getShadowGenerator(): Nullable<IShadowGenerator>;
  14759. /**
  14760. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14761. * @param effect The effect to update
  14762. * @param lightIndex The index of the light in the effect to update
  14763. * @returns The hemispheric light
  14764. */
  14765. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14766. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14767. /**
  14768. * Computes the world matrix of the node
  14769. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14770. * @param useWasUpdatedFlag defines a reserved property
  14771. * @returns the world matrix
  14772. */
  14773. computeWorldMatrix(): Matrix;
  14774. /**
  14775. * Returns the integer 3.
  14776. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14777. */
  14778. getTypeID(): number;
  14779. /**
  14780. * Prepares the list of defines specific to the light type.
  14781. * @param defines the list of defines
  14782. * @param lightIndex defines the index of the light for the effect
  14783. */
  14784. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14785. }
  14786. }
  14787. declare module BABYLON {
  14788. /** @hidden */
  14789. export var vrMultiviewToSingleviewPixelShader: {
  14790. name: string;
  14791. shader: string;
  14792. };
  14793. }
  14794. declare module BABYLON {
  14795. /**
  14796. * Renders to multiple views with a single draw call
  14797. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14798. */
  14799. export class MultiviewRenderTarget extends RenderTargetTexture {
  14800. /**
  14801. * Creates a multiview render target
  14802. * @param scene scene used with the render target
  14803. * @param size the size of the render target (used for each view)
  14804. */
  14805. constructor(scene: Scene, size?: number | {
  14806. width: number;
  14807. height: number;
  14808. } | {
  14809. ratio: number;
  14810. });
  14811. /**
  14812. * @hidden
  14813. * @param faceIndex the face index, if its a cube texture
  14814. */
  14815. _bindFrameBuffer(faceIndex?: number): void;
  14816. /**
  14817. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14818. * @returns the view count
  14819. */
  14820. getViewCount(): number;
  14821. }
  14822. }
  14823. declare module BABYLON {
  14824. /**
  14825. * Represents a camera frustum
  14826. */
  14827. export class Frustum {
  14828. /**
  14829. * Gets the planes representing the frustum
  14830. * @param transform matrix to be applied to the returned planes
  14831. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14832. */
  14833. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14834. /**
  14835. * Gets the near frustum plane transformed by the transform matrix
  14836. * @param transform transformation matrix to be applied to the resulting frustum plane
  14837. * @param frustumPlane the resuling frustum plane
  14838. */
  14839. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14840. /**
  14841. * Gets the far frustum plane transformed by the transform matrix
  14842. * @param transform transformation matrix to be applied to the resulting frustum plane
  14843. * @param frustumPlane the resuling frustum plane
  14844. */
  14845. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14846. /**
  14847. * Gets the left frustum plane transformed by the transform matrix
  14848. * @param transform transformation matrix to be applied to the resulting frustum plane
  14849. * @param frustumPlane the resuling frustum plane
  14850. */
  14851. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14852. /**
  14853. * Gets the right frustum plane transformed by the transform matrix
  14854. * @param transform transformation matrix to be applied to the resulting frustum plane
  14855. * @param frustumPlane the resuling frustum plane
  14856. */
  14857. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14858. /**
  14859. * Gets the top frustum plane transformed by the transform matrix
  14860. * @param transform transformation matrix to be applied to the resulting frustum plane
  14861. * @param frustumPlane the resuling frustum plane
  14862. */
  14863. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14864. /**
  14865. * Gets the bottom frustum plane transformed by the transform matrix
  14866. * @param transform transformation matrix to be applied to the resulting frustum plane
  14867. * @param frustumPlane the resuling frustum plane
  14868. */
  14869. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14870. /**
  14871. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14872. * @param transform transformation matrix to be applied to the resulting frustum planes
  14873. * @param frustumPlanes the resuling frustum planes
  14874. */
  14875. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14876. }
  14877. }
  14878. declare module BABYLON {
  14879. interface Engine {
  14880. /**
  14881. * Creates a new multiview render target
  14882. * @param width defines the width of the texture
  14883. * @param height defines the height of the texture
  14884. * @returns the created multiview texture
  14885. */
  14886. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14887. /**
  14888. * Binds a multiview framebuffer to be drawn to
  14889. * @param multiviewTexture texture to bind
  14890. */
  14891. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14892. }
  14893. interface Camera {
  14894. /**
  14895. * @hidden
  14896. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14897. */
  14898. _useMultiviewToSingleView: boolean;
  14899. /**
  14900. * @hidden
  14901. * 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)
  14902. */
  14903. _multiviewTexture: Nullable<RenderTargetTexture>;
  14904. /**
  14905. * @hidden
  14906. * ensures the multiview texture of the camera exists and has the specified width/height
  14907. * @param width height to set on the multiview texture
  14908. * @param height width to set on the multiview texture
  14909. */
  14910. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14911. }
  14912. interface Scene {
  14913. /** @hidden */
  14914. _transformMatrixR: Matrix;
  14915. /** @hidden */
  14916. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14917. /** @hidden */
  14918. _createMultiviewUbo(): void;
  14919. /** @hidden */
  14920. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14921. /** @hidden */
  14922. _renderMultiviewToSingleView(camera: Camera): void;
  14923. }
  14924. }
  14925. declare module BABYLON {
  14926. /**
  14927. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14928. * This will not be used for webXR as it supports displaying texture arrays directly
  14929. */
  14930. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14931. /**
  14932. * Initializes a VRMultiviewToSingleview
  14933. * @param name name of the post process
  14934. * @param camera camera to be applied to
  14935. * @param scaleFactor scaling factor to the size of the output texture
  14936. */
  14937. constructor(name: string, camera: Camera, scaleFactor: number);
  14938. }
  14939. }
  14940. declare module BABYLON {
  14941. /**
  14942. * Interface used to define additional presentation attributes
  14943. */
  14944. export interface IVRPresentationAttributes {
  14945. /**
  14946. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14947. */
  14948. highRefreshRate: boolean;
  14949. /**
  14950. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14951. */
  14952. foveationLevel: number;
  14953. }
  14954. interface Engine {
  14955. /** @hidden */
  14956. _vrDisplay: any;
  14957. /** @hidden */
  14958. _vrSupported: boolean;
  14959. /** @hidden */
  14960. _oldSize: Size;
  14961. /** @hidden */
  14962. _oldHardwareScaleFactor: number;
  14963. /** @hidden */
  14964. _vrExclusivePointerMode: boolean;
  14965. /** @hidden */
  14966. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14967. /** @hidden */
  14968. _onVRDisplayPointerRestricted: () => void;
  14969. /** @hidden */
  14970. _onVRDisplayPointerUnrestricted: () => void;
  14971. /** @hidden */
  14972. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14973. /** @hidden */
  14974. _onVrDisplayDisconnect: Nullable<() => void>;
  14975. /** @hidden */
  14976. _onVrDisplayPresentChange: Nullable<() => void>;
  14977. /**
  14978. * Observable signaled when VR display mode changes
  14979. */
  14980. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14981. /**
  14982. * Observable signaled when VR request present is complete
  14983. */
  14984. onVRRequestPresentComplete: Observable<boolean>;
  14985. /**
  14986. * Observable signaled when VR request present starts
  14987. */
  14988. onVRRequestPresentStart: Observable<Engine>;
  14989. /**
  14990. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14991. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14992. */
  14993. isInVRExclusivePointerMode: boolean;
  14994. /**
  14995. * Gets a boolean indicating if a webVR device was detected
  14996. * @returns true if a webVR device was detected
  14997. */
  14998. isVRDevicePresent(): boolean;
  14999. /**
  15000. * Gets the current webVR device
  15001. * @returns the current webVR device (or null)
  15002. */
  15003. getVRDevice(): any;
  15004. /**
  15005. * Initializes a webVR display and starts listening to display change events
  15006. * The onVRDisplayChangedObservable will be notified upon these changes
  15007. * @returns A promise containing a VRDisplay and if vr is supported
  15008. */
  15009. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15010. /** @hidden */
  15011. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15012. /**
  15013. * Gets or sets the presentation attributes used to configure VR rendering
  15014. */
  15015. vrPresentationAttributes?: IVRPresentationAttributes;
  15016. /**
  15017. * Call this function to switch to webVR mode
  15018. * Will do nothing if webVR is not supported or if there is no webVR device
  15019. * @param options the webvr options provided to the camera. mainly used for multiview
  15020. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15021. */
  15022. enableVR(options: WebVROptions): void;
  15023. /** @hidden */
  15024. _onVRFullScreenTriggered(): void;
  15025. }
  15026. }
  15027. declare module BABYLON {
  15028. /**
  15029. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15030. * IMPORTANT!! The data is right-hand data.
  15031. * @export
  15032. * @interface DevicePose
  15033. */
  15034. export interface DevicePose {
  15035. /**
  15036. * The position of the device, values in array are [x,y,z].
  15037. */
  15038. readonly position: Nullable<Float32Array>;
  15039. /**
  15040. * The linearVelocity of the device, values in array are [x,y,z].
  15041. */
  15042. readonly linearVelocity: Nullable<Float32Array>;
  15043. /**
  15044. * The linearAcceleration of the device, values in array are [x,y,z].
  15045. */
  15046. readonly linearAcceleration: Nullable<Float32Array>;
  15047. /**
  15048. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15049. */
  15050. readonly orientation: Nullable<Float32Array>;
  15051. /**
  15052. * The angularVelocity of the device, values in array are [x,y,z].
  15053. */
  15054. readonly angularVelocity: Nullable<Float32Array>;
  15055. /**
  15056. * The angularAcceleration of the device, values in array are [x,y,z].
  15057. */
  15058. readonly angularAcceleration: Nullable<Float32Array>;
  15059. }
  15060. /**
  15061. * Interface representing a pose controlled object in Babylon.
  15062. * A pose controlled object has both regular pose values as well as pose values
  15063. * from an external device such as a VR head mounted display
  15064. */
  15065. export interface PoseControlled {
  15066. /**
  15067. * The position of the object in babylon space.
  15068. */
  15069. position: Vector3;
  15070. /**
  15071. * The rotation quaternion of the object in babylon space.
  15072. */
  15073. rotationQuaternion: Quaternion;
  15074. /**
  15075. * The position of the device in babylon space.
  15076. */
  15077. devicePosition?: Vector3;
  15078. /**
  15079. * The rotation quaternion of the device in babylon space.
  15080. */
  15081. deviceRotationQuaternion: Quaternion;
  15082. /**
  15083. * The raw pose coming from the device.
  15084. */
  15085. rawPose: Nullable<DevicePose>;
  15086. /**
  15087. * The scale of the device to be used when translating from device space to babylon space.
  15088. */
  15089. deviceScaleFactor: number;
  15090. /**
  15091. * Updates the poseControlled values based on the input device pose.
  15092. * @param poseData the pose data to update the object with
  15093. */
  15094. updateFromDevice(poseData: DevicePose): void;
  15095. }
  15096. /**
  15097. * Set of options to customize the webVRCamera
  15098. */
  15099. export interface WebVROptions {
  15100. /**
  15101. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15102. */
  15103. trackPosition?: boolean;
  15104. /**
  15105. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15106. */
  15107. positionScale?: number;
  15108. /**
  15109. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15110. */
  15111. displayName?: string;
  15112. /**
  15113. * Should the native controller meshes be initialized. (default: true)
  15114. */
  15115. controllerMeshes?: boolean;
  15116. /**
  15117. * Creating a default HemiLight only on controllers. (default: true)
  15118. */
  15119. defaultLightingOnControllers?: boolean;
  15120. /**
  15121. * If you don't want to use the default VR button of the helper. (default: false)
  15122. */
  15123. useCustomVRButton?: boolean;
  15124. /**
  15125. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15126. */
  15127. customVRButton?: HTMLButtonElement;
  15128. /**
  15129. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15130. */
  15131. rayLength?: number;
  15132. /**
  15133. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15134. */
  15135. defaultHeight?: number;
  15136. /**
  15137. * If multiview should be used if availible (default: false)
  15138. */
  15139. useMultiview?: boolean;
  15140. }
  15141. /**
  15142. * This represents a WebVR camera.
  15143. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15144. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15145. */
  15146. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15147. private webVROptions;
  15148. /**
  15149. * @hidden
  15150. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15151. */
  15152. _vrDevice: any;
  15153. /**
  15154. * The rawPose of the vrDevice.
  15155. */
  15156. rawPose: Nullable<DevicePose>;
  15157. private _onVREnabled;
  15158. private _specsVersion;
  15159. private _attached;
  15160. private _frameData;
  15161. protected _descendants: Array<Node>;
  15162. private _deviceRoomPosition;
  15163. /** @hidden */
  15164. _deviceRoomRotationQuaternion: Quaternion;
  15165. private _standingMatrix;
  15166. /**
  15167. * Represents device position in babylon space.
  15168. */
  15169. devicePosition: Vector3;
  15170. /**
  15171. * Represents device rotation in babylon space.
  15172. */
  15173. deviceRotationQuaternion: Quaternion;
  15174. /**
  15175. * The scale of the device to be used when translating from device space to babylon space.
  15176. */
  15177. deviceScaleFactor: number;
  15178. private _deviceToWorld;
  15179. private _worldToDevice;
  15180. /**
  15181. * References to the webVR controllers for the vrDevice.
  15182. */
  15183. controllers: Array<WebVRController>;
  15184. /**
  15185. * Emits an event when a controller is attached.
  15186. */
  15187. onControllersAttachedObservable: Observable<WebVRController[]>;
  15188. /**
  15189. * Emits an event when a controller's mesh has been loaded;
  15190. */
  15191. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15192. /**
  15193. * Emits an event when the HMD's pose has been updated.
  15194. */
  15195. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15196. private _poseSet;
  15197. /**
  15198. * If the rig cameras be used as parent instead of this camera.
  15199. */
  15200. rigParenting: boolean;
  15201. private _lightOnControllers;
  15202. private _defaultHeight?;
  15203. /**
  15204. * Instantiates a WebVRFreeCamera.
  15205. * @param name The name of the WebVRFreeCamera
  15206. * @param position The starting anchor position for the camera
  15207. * @param scene The scene the camera belongs to
  15208. * @param webVROptions a set of customizable options for the webVRCamera
  15209. */
  15210. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15211. /**
  15212. * Gets the device distance from the ground in meters.
  15213. * @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.
  15214. */
  15215. deviceDistanceToRoomGround(): number;
  15216. /**
  15217. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15218. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15219. */
  15220. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15221. /**
  15222. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15223. * @returns A promise with a boolean set to if the standing matrix is supported.
  15224. */
  15225. useStandingMatrixAsync(): Promise<boolean>;
  15226. /**
  15227. * Disposes the camera
  15228. */
  15229. dispose(): void;
  15230. /**
  15231. * Gets a vrController by name.
  15232. * @param name The name of the controller to retreive
  15233. * @returns the controller matching the name specified or null if not found
  15234. */
  15235. getControllerByName(name: string): Nullable<WebVRController>;
  15236. private _leftController;
  15237. /**
  15238. * The controller corresponding to the users left hand.
  15239. */
  15240. readonly leftController: Nullable<WebVRController>;
  15241. private _rightController;
  15242. /**
  15243. * The controller corresponding to the users right hand.
  15244. */
  15245. readonly rightController: Nullable<WebVRController>;
  15246. /**
  15247. * Casts a ray forward from the vrCamera's gaze.
  15248. * @param length Length of the ray (default: 100)
  15249. * @returns the ray corresponding to the gaze
  15250. */
  15251. getForwardRay(length?: number): Ray;
  15252. /**
  15253. * @hidden
  15254. * Updates the camera based on device's frame data
  15255. */
  15256. _checkInputs(): void;
  15257. /**
  15258. * Updates the poseControlled values based on the input device pose.
  15259. * @param poseData Pose coming from the device
  15260. */
  15261. updateFromDevice(poseData: DevicePose): void;
  15262. private _htmlElementAttached;
  15263. private _detachIfAttached;
  15264. /**
  15265. * WebVR's attach control will start broadcasting frames to the device.
  15266. * Note that in certain browsers (chrome for example) this function must be called
  15267. * within a user-interaction callback. Example:
  15268. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15269. *
  15270. * @param element html element to attach the vrDevice to
  15271. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15272. */
  15273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15274. /**
  15275. * Detaches the camera from the html element and disables VR
  15276. *
  15277. * @param element html element to detach from
  15278. */
  15279. detachControl(element: HTMLElement): void;
  15280. /**
  15281. * @returns the name of this class
  15282. */
  15283. getClassName(): string;
  15284. /**
  15285. * Calls resetPose on the vrDisplay
  15286. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15287. */
  15288. resetToCurrentRotation(): void;
  15289. /**
  15290. * @hidden
  15291. * Updates the rig cameras (left and right eye)
  15292. */
  15293. _updateRigCameras(): void;
  15294. private _workingVector;
  15295. private _oneVector;
  15296. private _workingMatrix;
  15297. private updateCacheCalled;
  15298. private _correctPositionIfNotTrackPosition;
  15299. /**
  15300. * @hidden
  15301. * Updates the cached values of the camera
  15302. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15303. */
  15304. _updateCache(ignoreParentClass?: boolean): void;
  15305. /**
  15306. * @hidden
  15307. * Get current device position in babylon world
  15308. */
  15309. _computeDevicePosition(): void;
  15310. /**
  15311. * Updates the current device position and rotation in the babylon world
  15312. */
  15313. update(): void;
  15314. /**
  15315. * @hidden
  15316. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15317. * @returns an identity matrix
  15318. */
  15319. _getViewMatrix(): Matrix;
  15320. private _tmpMatrix;
  15321. /**
  15322. * This function is called by the two RIG cameras.
  15323. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15324. * @hidden
  15325. */
  15326. _getWebVRViewMatrix(): Matrix;
  15327. /** @hidden */
  15328. _getWebVRProjectionMatrix(): Matrix;
  15329. private _onGamepadConnectedObserver;
  15330. private _onGamepadDisconnectedObserver;
  15331. private _updateCacheWhenTrackingDisabledObserver;
  15332. /**
  15333. * Initializes the controllers and their meshes
  15334. */
  15335. initControllers(): void;
  15336. }
  15337. }
  15338. declare module BABYLON {
  15339. /**
  15340. * Size options for a post process
  15341. */
  15342. export type PostProcessOptions = {
  15343. width: number;
  15344. height: number;
  15345. };
  15346. /**
  15347. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15348. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15349. */
  15350. export class PostProcess {
  15351. /** Name of the PostProcess. */
  15352. name: string;
  15353. /**
  15354. * Gets or sets the unique id of the post process
  15355. */
  15356. uniqueId: number;
  15357. /**
  15358. * Width of the texture to apply the post process on
  15359. */
  15360. width: number;
  15361. /**
  15362. * Height of the texture to apply the post process on
  15363. */
  15364. height: number;
  15365. /**
  15366. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15367. * @hidden
  15368. */
  15369. _outputTexture: Nullable<InternalTexture>;
  15370. /**
  15371. * Sampling mode used by the shader
  15372. * See https://doc.babylonjs.com/classes/3.1/texture
  15373. */
  15374. renderTargetSamplingMode: number;
  15375. /**
  15376. * Clear color to use when screen clearing
  15377. */
  15378. clearColor: Color4;
  15379. /**
  15380. * If the buffer needs to be cleared before applying the post process. (default: true)
  15381. * Should be set to false if shader will overwrite all previous pixels.
  15382. */
  15383. autoClear: boolean;
  15384. /**
  15385. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15386. */
  15387. alphaMode: number;
  15388. /**
  15389. * Sets the setAlphaBlendConstants of the babylon engine
  15390. */
  15391. alphaConstants: Color4;
  15392. /**
  15393. * Animations to be used for the post processing
  15394. */
  15395. animations: Animation[];
  15396. /**
  15397. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15398. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15399. */
  15400. enablePixelPerfectMode: boolean;
  15401. /**
  15402. * Force the postprocess to be applied without taking in account viewport
  15403. */
  15404. forceFullscreenViewport: boolean;
  15405. /**
  15406. * List of inspectable custom properties (used by the Inspector)
  15407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15408. */
  15409. inspectableCustomProperties: IInspectable[];
  15410. /**
  15411. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15412. *
  15413. * | Value | Type | Description |
  15414. * | ----- | ----------------------------------- | ----------- |
  15415. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15416. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15417. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15418. *
  15419. */
  15420. scaleMode: number;
  15421. /**
  15422. * Force textures to be a power of two (default: false)
  15423. */
  15424. alwaysForcePOT: boolean;
  15425. private _samples;
  15426. /**
  15427. * Number of sample textures (default: 1)
  15428. */
  15429. samples: number;
  15430. /**
  15431. * Modify the scale of the post process to be the same as the viewport (default: false)
  15432. */
  15433. adaptScaleToCurrentViewport: boolean;
  15434. private _camera;
  15435. private _scene;
  15436. private _engine;
  15437. private _options;
  15438. private _reusable;
  15439. private _textureType;
  15440. /**
  15441. * Smart array of input and output textures for the post process.
  15442. * @hidden
  15443. */
  15444. _textures: SmartArray<InternalTexture>;
  15445. /**
  15446. * The index in _textures that corresponds to the output texture.
  15447. * @hidden
  15448. */
  15449. _currentRenderTextureInd: number;
  15450. private _effect;
  15451. private _samplers;
  15452. private _fragmentUrl;
  15453. private _vertexUrl;
  15454. private _parameters;
  15455. private _scaleRatio;
  15456. protected _indexParameters: any;
  15457. private _shareOutputWithPostProcess;
  15458. private _texelSize;
  15459. private _forcedOutputTexture;
  15460. /**
  15461. * Returns the fragment url or shader name used in the post process.
  15462. * @returns the fragment url or name in the shader store.
  15463. */
  15464. getEffectName(): string;
  15465. /**
  15466. * An event triggered when the postprocess is activated.
  15467. */
  15468. onActivateObservable: Observable<Camera>;
  15469. private _onActivateObserver;
  15470. /**
  15471. * A function that is added to the onActivateObservable
  15472. */
  15473. onActivate: Nullable<(camera: Camera) => void>;
  15474. /**
  15475. * An event triggered when the postprocess changes its size.
  15476. */
  15477. onSizeChangedObservable: Observable<PostProcess>;
  15478. private _onSizeChangedObserver;
  15479. /**
  15480. * A function that is added to the onSizeChangedObservable
  15481. */
  15482. onSizeChanged: (postProcess: PostProcess) => void;
  15483. /**
  15484. * An event triggered when the postprocess applies its effect.
  15485. */
  15486. onApplyObservable: Observable<Effect>;
  15487. private _onApplyObserver;
  15488. /**
  15489. * A function that is added to the onApplyObservable
  15490. */
  15491. onApply: (effect: Effect) => void;
  15492. /**
  15493. * An event triggered before rendering the postprocess
  15494. */
  15495. onBeforeRenderObservable: Observable<Effect>;
  15496. private _onBeforeRenderObserver;
  15497. /**
  15498. * A function that is added to the onBeforeRenderObservable
  15499. */
  15500. onBeforeRender: (effect: Effect) => void;
  15501. /**
  15502. * An event triggered after rendering the postprocess
  15503. */
  15504. onAfterRenderObservable: Observable<Effect>;
  15505. private _onAfterRenderObserver;
  15506. /**
  15507. * A function that is added to the onAfterRenderObservable
  15508. */
  15509. onAfterRender: (efect: Effect) => void;
  15510. /**
  15511. * 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
  15512. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15513. */
  15514. inputTexture: InternalTexture;
  15515. /**
  15516. * Gets the camera which post process is applied to.
  15517. * @returns The camera the post process is applied to.
  15518. */
  15519. getCamera(): Camera;
  15520. /**
  15521. * Gets the texel size of the postprocess.
  15522. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15523. */
  15524. readonly texelSize: Vector2;
  15525. /**
  15526. * Creates a new instance PostProcess
  15527. * @param name The name of the PostProcess.
  15528. * @param fragmentUrl The url of the fragment shader to be used.
  15529. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15530. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15531. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15532. * @param camera The camera to apply the render pass to.
  15533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15534. * @param engine The engine which the post process will be applied. (default: current engine)
  15535. * @param reusable If the post process can be reused on the same frame. (default: false)
  15536. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15537. * @param textureType Type of textures used when performing the post process. (default: 0)
  15538. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15539. * @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
  15540. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15541. */
  15542. constructor(
  15543. /** Name of the PostProcess. */
  15544. 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);
  15545. /**
  15546. * Gets a string idenfifying the name of the class
  15547. * @returns "PostProcess" string
  15548. */
  15549. getClassName(): string;
  15550. /**
  15551. * Gets the engine which this post process belongs to.
  15552. * @returns The engine the post process was enabled with.
  15553. */
  15554. getEngine(): Engine;
  15555. /**
  15556. * The effect that is created when initializing the post process.
  15557. * @returns The created effect corresponding the the postprocess.
  15558. */
  15559. getEffect(): Effect;
  15560. /**
  15561. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15562. * @param postProcess The post process to share the output with.
  15563. * @returns This post process.
  15564. */
  15565. shareOutputWith(postProcess: PostProcess): PostProcess;
  15566. /**
  15567. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15568. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15569. */
  15570. useOwnOutput(): void;
  15571. /**
  15572. * Updates the effect with the current post process compile time values and recompiles the shader.
  15573. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15574. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15575. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15576. * @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
  15577. * @param onCompiled Called when the shader has been compiled.
  15578. * @param onError Called if there is an error when compiling a shader.
  15579. */
  15580. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15581. /**
  15582. * The post process is reusable if it can be used multiple times within one frame.
  15583. * @returns If the post process is reusable
  15584. */
  15585. isReusable(): boolean;
  15586. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15587. markTextureDirty(): void;
  15588. /**
  15589. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15590. * 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.
  15591. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15592. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15593. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15594. * @returns The target texture that was bound to be written to.
  15595. */
  15596. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15597. /**
  15598. * If the post process is supported.
  15599. */
  15600. readonly isSupported: boolean;
  15601. /**
  15602. * The aspect ratio of the output texture.
  15603. */
  15604. readonly aspectRatio: number;
  15605. /**
  15606. * Get a value indicating if the post-process is ready to be used
  15607. * @returns true if the post-process is ready (shader is compiled)
  15608. */
  15609. isReady(): boolean;
  15610. /**
  15611. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15612. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15613. */
  15614. apply(): Nullable<Effect>;
  15615. private _disposeTextures;
  15616. /**
  15617. * Disposes the post process.
  15618. * @param camera The camera to dispose the post process on.
  15619. */
  15620. dispose(camera?: Camera): void;
  15621. }
  15622. }
  15623. declare module BABYLON {
  15624. /** @hidden */
  15625. export var kernelBlurVaryingDeclaration: {
  15626. name: string;
  15627. shader: string;
  15628. };
  15629. }
  15630. declare module BABYLON {
  15631. /** @hidden */
  15632. export var kernelBlurFragment: {
  15633. name: string;
  15634. shader: string;
  15635. };
  15636. }
  15637. declare module BABYLON {
  15638. /** @hidden */
  15639. export var kernelBlurFragment2: {
  15640. name: string;
  15641. shader: string;
  15642. };
  15643. }
  15644. declare module BABYLON {
  15645. /** @hidden */
  15646. export var kernelBlurPixelShader: {
  15647. name: string;
  15648. shader: string;
  15649. };
  15650. }
  15651. declare module BABYLON {
  15652. /** @hidden */
  15653. export var kernelBlurVertex: {
  15654. name: string;
  15655. shader: string;
  15656. };
  15657. }
  15658. declare module BABYLON {
  15659. /** @hidden */
  15660. export var kernelBlurVertexShader: {
  15661. name: string;
  15662. shader: string;
  15663. };
  15664. }
  15665. declare module BABYLON {
  15666. /**
  15667. * The Blur Post Process which blurs an image based on a kernel and direction.
  15668. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15669. */
  15670. export class BlurPostProcess extends PostProcess {
  15671. /** The direction in which to blur the image. */
  15672. direction: Vector2;
  15673. private blockCompilation;
  15674. protected _kernel: number;
  15675. protected _idealKernel: number;
  15676. protected _packedFloat: boolean;
  15677. private _staticDefines;
  15678. /**
  15679. * Sets the length in pixels of the blur sample region
  15680. */
  15681. /**
  15682. * Gets the length in pixels of the blur sample region
  15683. */
  15684. kernel: number;
  15685. /**
  15686. * Sets wether or not the blur needs to unpack/repack floats
  15687. */
  15688. /**
  15689. * Gets wether or not the blur is unpacking/repacking floats
  15690. */
  15691. packedFloat: boolean;
  15692. /**
  15693. * Creates a new instance BlurPostProcess
  15694. * @param name The name of the effect.
  15695. * @param direction The direction in which to blur the image.
  15696. * @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.
  15697. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15698. * @param camera The camera to apply the render pass to.
  15699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15700. * @param engine The engine which the post process will be applied. (default: current engine)
  15701. * @param reusable If the post process can be reused on the same frame. (default: false)
  15702. * @param textureType Type of textures used when performing the post process. (default: 0)
  15703. * @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)
  15704. */
  15705. constructor(name: string,
  15706. /** The direction in which to blur the image. */
  15707. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15708. /**
  15709. * Updates the effect with the current post process compile time values and recompiles the shader.
  15710. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15711. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15712. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15713. * @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
  15714. * @param onCompiled Called when the shader has been compiled.
  15715. * @param onError Called if there is an error when compiling a shader.
  15716. */
  15717. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15718. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15719. /**
  15720. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15721. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15722. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15723. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15724. * The gaps between physical kernels are compensated for in the weighting of the samples
  15725. * @param idealKernel Ideal blur kernel.
  15726. * @return Nearest best kernel.
  15727. */
  15728. protected _nearestBestKernel(idealKernel: number): number;
  15729. /**
  15730. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15731. * @param x The point on the Gaussian distribution to sample.
  15732. * @return the value of the Gaussian function at x.
  15733. */
  15734. protected _gaussianWeight(x: number): number;
  15735. /**
  15736. * Generates a string that can be used as a floating point number in GLSL.
  15737. * @param x Value to print.
  15738. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15739. * @return GLSL float string.
  15740. */
  15741. protected _glslFloat(x: number, decimalFigures?: number): string;
  15742. }
  15743. }
  15744. declare module BABYLON {
  15745. /**
  15746. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15747. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15748. * You can then easily use it as a reflectionTexture on a flat surface.
  15749. * In case the surface is not a plane, please consider relying on reflection probes.
  15750. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15751. */
  15752. export class MirrorTexture extends RenderTargetTexture {
  15753. private scene;
  15754. /**
  15755. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15756. * 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.
  15757. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15758. */
  15759. mirrorPlane: Plane;
  15760. /**
  15761. * Define the blur ratio used to blur the reflection if needed.
  15762. */
  15763. blurRatio: number;
  15764. /**
  15765. * Define the adaptive blur kernel used to blur the reflection if needed.
  15766. * This will autocompute the closest best match for the `blurKernel`
  15767. */
  15768. adaptiveBlurKernel: number;
  15769. /**
  15770. * Define the blur kernel used to blur the reflection if needed.
  15771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15772. */
  15773. blurKernel: number;
  15774. /**
  15775. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15776. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15777. */
  15778. blurKernelX: number;
  15779. /**
  15780. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15781. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15782. */
  15783. blurKernelY: number;
  15784. private _autoComputeBlurKernel;
  15785. protected _onRatioRescale(): void;
  15786. private _updateGammaSpace;
  15787. private _imageProcessingConfigChangeObserver;
  15788. private _transformMatrix;
  15789. private _mirrorMatrix;
  15790. private _savedViewMatrix;
  15791. private _blurX;
  15792. private _blurY;
  15793. private _adaptiveBlurKernel;
  15794. private _blurKernelX;
  15795. private _blurKernelY;
  15796. private _blurRatio;
  15797. /**
  15798. * Instantiates a Mirror Texture.
  15799. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15800. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15801. * You can then easily use it as a reflectionTexture on a flat surface.
  15802. * In case the surface is not a plane, please consider relying on reflection probes.
  15803. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15804. * @param name
  15805. * @param size
  15806. * @param scene
  15807. * @param generateMipMaps
  15808. * @param type
  15809. * @param samplingMode
  15810. * @param generateDepthBuffer
  15811. */
  15812. constructor(name: string, size: number | {
  15813. width: number;
  15814. height: number;
  15815. } | {
  15816. ratio: number;
  15817. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15818. private _preparePostProcesses;
  15819. /**
  15820. * Clone the mirror texture.
  15821. * @returns the cloned texture
  15822. */
  15823. clone(): MirrorTexture;
  15824. /**
  15825. * Serialize the texture to a JSON representation you could use in Parse later on
  15826. * @returns the serialized JSON representation
  15827. */
  15828. serialize(): any;
  15829. /**
  15830. * Dispose the texture and release its associated resources.
  15831. */
  15832. dispose(): void;
  15833. }
  15834. }
  15835. declare module BABYLON {
  15836. /**
  15837. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15838. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15839. */
  15840. export class Texture extends BaseTexture {
  15841. /**
  15842. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15843. */
  15844. static SerializeBuffers: boolean;
  15845. /** @hidden */
  15846. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15847. /** @hidden */
  15848. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15849. /** @hidden */
  15850. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15851. /** nearest is mag = nearest and min = nearest and mip = linear */
  15852. static readonly NEAREST_SAMPLINGMODE: number;
  15853. /** nearest is mag = nearest and min = nearest and mip = linear */
  15854. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15855. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15856. static readonly BILINEAR_SAMPLINGMODE: number;
  15857. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15858. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15859. /** Trilinear is mag = linear and min = linear and mip = linear */
  15860. static readonly TRILINEAR_SAMPLINGMODE: number;
  15861. /** Trilinear is mag = linear and min = linear and mip = linear */
  15862. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15863. /** mag = nearest and min = nearest and mip = nearest */
  15864. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15865. /** mag = nearest and min = linear and mip = nearest */
  15866. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15867. /** mag = nearest and min = linear and mip = linear */
  15868. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15869. /** mag = nearest and min = linear and mip = none */
  15870. static readonly NEAREST_LINEAR: number;
  15871. /** mag = nearest and min = nearest and mip = none */
  15872. static readonly NEAREST_NEAREST: number;
  15873. /** mag = linear and min = nearest and mip = nearest */
  15874. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15875. /** mag = linear and min = nearest and mip = linear */
  15876. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15877. /** mag = linear and min = linear and mip = none */
  15878. static readonly LINEAR_LINEAR: number;
  15879. /** mag = linear and min = nearest and mip = none */
  15880. static readonly LINEAR_NEAREST: number;
  15881. /** Explicit coordinates mode */
  15882. static readonly EXPLICIT_MODE: number;
  15883. /** Spherical coordinates mode */
  15884. static readonly SPHERICAL_MODE: number;
  15885. /** Planar coordinates mode */
  15886. static readonly PLANAR_MODE: number;
  15887. /** Cubic coordinates mode */
  15888. static readonly CUBIC_MODE: number;
  15889. /** Projection coordinates mode */
  15890. static readonly PROJECTION_MODE: number;
  15891. /** Inverse Cubic coordinates mode */
  15892. static readonly SKYBOX_MODE: number;
  15893. /** Inverse Cubic coordinates mode */
  15894. static readonly INVCUBIC_MODE: number;
  15895. /** Equirectangular coordinates mode */
  15896. static readonly EQUIRECTANGULAR_MODE: number;
  15897. /** Equirectangular Fixed coordinates mode */
  15898. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15899. /** Equirectangular Fixed Mirrored coordinates mode */
  15900. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15901. /** Texture is not repeating outside of 0..1 UVs */
  15902. static readonly CLAMP_ADDRESSMODE: number;
  15903. /** Texture is repeating outside of 0..1 UVs */
  15904. static readonly WRAP_ADDRESSMODE: number;
  15905. /** Texture is repeating and mirrored */
  15906. static readonly MIRROR_ADDRESSMODE: number;
  15907. /**
  15908. * 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
  15909. */
  15910. static UseSerializedUrlIfAny: boolean;
  15911. /**
  15912. * Define the url of the texture.
  15913. */
  15914. url: Nullable<string>;
  15915. /**
  15916. * Define an offset on the texture to offset the u coordinates of the UVs
  15917. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15918. */
  15919. uOffset: number;
  15920. /**
  15921. * Define an offset on the texture to offset the v coordinates of the UVs
  15922. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15923. */
  15924. vOffset: number;
  15925. /**
  15926. * Define an offset on the texture to scale the u coordinates of the UVs
  15927. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15928. */
  15929. uScale: number;
  15930. /**
  15931. * Define an offset on the texture to scale the v coordinates of the UVs
  15932. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15933. */
  15934. vScale: number;
  15935. /**
  15936. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15937. * @see http://doc.babylonjs.com/how_to/more_materials
  15938. */
  15939. uAng: number;
  15940. /**
  15941. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15942. * @see http://doc.babylonjs.com/how_to/more_materials
  15943. */
  15944. vAng: number;
  15945. /**
  15946. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15947. * @see http://doc.babylonjs.com/how_to/more_materials
  15948. */
  15949. wAng: number;
  15950. /**
  15951. * Defines the center of rotation (U)
  15952. */
  15953. uRotationCenter: number;
  15954. /**
  15955. * Defines the center of rotation (V)
  15956. */
  15957. vRotationCenter: number;
  15958. /**
  15959. * Defines the center of rotation (W)
  15960. */
  15961. wRotationCenter: number;
  15962. /**
  15963. * Are mip maps generated for this texture or not.
  15964. */
  15965. readonly noMipmap: boolean;
  15966. /**
  15967. * List of inspectable custom properties (used by the Inspector)
  15968. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15969. */
  15970. inspectableCustomProperties: Nullable<IInspectable[]>;
  15971. private _noMipmap;
  15972. /** @hidden */
  15973. _invertY: boolean;
  15974. private _rowGenerationMatrix;
  15975. private _cachedTextureMatrix;
  15976. private _projectionModeMatrix;
  15977. private _t0;
  15978. private _t1;
  15979. private _t2;
  15980. private _cachedUOffset;
  15981. private _cachedVOffset;
  15982. private _cachedUScale;
  15983. private _cachedVScale;
  15984. private _cachedUAng;
  15985. private _cachedVAng;
  15986. private _cachedWAng;
  15987. private _cachedProjectionMatrixId;
  15988. private _cachedCoordinatesMode;
  15989. /** @hidden */
  15990. protected _initialSamplingMode: number;
  15991. /** @hidden */
  15992. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15993. private _deleteBuffer;
  15994. protected _format: Nullable<number>;
  15995. private _delayedOnLoad;
  15996. private _delayedOnError;
  15997. private _mimeType?;
  15998. /**
  15999. * Observable triggered once the texture has been loaded.
  16000. */
  16001. onLoadObservable: Observable<Texture>;
  16002. protected _isBlocking: boolean;
  16003. /**
  16004. * Is the texture preventing material to render while loading.
  16005. * If false, a default texture will be used instead of the loading one during the preparation step.
  16006. */
  16007. isBlocking: boolean;
  16008. /**
  16009. * Get the current sampling mode associated with the texture.
  16010. */
  16011. readonly samplingMode: number;
  16012. /**
  16013. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16014. */
  16015. readonly invertY: boolean;
  16016. /**
  16017. * Instantiates a new texture.
  16018. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16019. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16020. * @param url defines the url of the picture to load as a texture
  16021. * @param scene defines the scene or engine the texture will belong to
  16022. * @param noMipmap defines if the texture will require mip maps or not
  16023. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16024. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16025. * @param onLoad defines a callback triggered when the texture has been loaded
  16026. * @param onError defines a callback triggered when an error occurred during the loading session
  16027. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16028. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16029. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16030. * @param mimeType defines an optional mime type information
  16031. */
  16032. 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);
  16033. /**
  16034. * Update the url (and optional buffer) of this texture if url was null during construction.
  16035. * @param url the url of the texture
  16036. * @param buffer the buffer of the texture (defaults to null)
  16037. * @param onLoad callback called when the texture is loaded (defaults to null)
  16038. */
  16039. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16040. /**
  16041. * Finish the loading sequence of a texture flagged as delayed load.
  16042. * @hidden
  16043. */
  16044. delayLoad(): void;
  16045. private _prepareRowForTextureGeneration;
  16046. /**
  16047. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16048. * @returns the transform matrix of the texture.
  16049. */
  16050. getTextureMatrix(uBase?: number): Matrix;
  16051. /**
  16052. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16053. * @returns The reflection texture transform
  16054. */
  16055. getReflectionTextureMatrix(): Matrix;
  16056. /**
  16057. * Clones the texture.
  16058. * @returns the cloned texture
  16059. */
  16060. clone(): Texture;
  16061. /**
  16062. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16063. * @returns The JSON representation of the texture
  16064. */
  16065. serialize(): any;
  16066. /**
  16067. * Get the current class name of the texture useful for serialization or dynamic coding.
  16068. * @returns "Texture"
  16069. */
  16070. getClassName(): string;
  16071. /**
  16072. * Dispose the texture and release its associated resources.
  16073. */
  16074. dispose(): void;
  16075. /**
  16076. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16077. * @param parsedTexture Define the JSON representation of the texture
  16078. * @param scene Define the scene the parsed texture should be instantiated in
  16079. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16080. * @returns The parsed texture if successful
  16081. */
  16082. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16083. /**
  16084. * Creates a texture from its base 64 representation.
  16085. * @param data Define the base64 payload without the data: prefix
  16086. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16087. * @param scene Define the scene the texture should belong to
  16088. * @param noMipmap Forces the texture to not create mip map information if true
  16089. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16090. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16091. * @param onLoad define a callback triggered when the texture has been loaded
  16092. * @param onError define a callback triggered when an error occurred during the loading session
  16093. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16094. * @returns the created texture
  16095. */
  16096. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16097. /**
  16098. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16099. * @param data Define the base64 payload without the data: prefix
  16100. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16101. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16102. * @param scene Define the scene the texture should belong to
  16103. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16104. * @param noMipmap Forces the texture to not create mip map information if true
  16105. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16106. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16107. * @param onLoad define a callback triggered when the texture has been loaded
  16108. * @param onError define a callback triggered when an error occurred during the loading session
  16109. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16110. * @returns the created texture
  16111. */
  16112. 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;
  16113. }
  16114. }
  16115. declare module BABYLON {
  16116. /**
  16117. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16118. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16119. */
  16120. export class PostProcessManager {
  16121. private _scene;
  16122. private _indexBuffer;
  16123. private _vertexBuffers;
  16124. /**
  16125. * Creates a new instance PostProcess
  16126. * @param scene The scene that the post process is associated with.
  16127. */
  16128. constructor(scene: Scene);
  16129. private _prepareBuffers;
  16130. private _buildIndexBuffer;
  16131. /**
  16132. * Rebuilds the vertex buffers of the manager.
  16133. * @hidden
  16134. */
  16135. _rebuild(): void;
  16136. /**
  16137. * Prepares a frame to be run through a post process.
  16138. * @param sourceTexture The input texture to the post procesess. (default: null)
  16139. * @param postProcesses An array of post processes to be run. (default: null)
  16140. * @returns True if the post processes were able to be run.
  16141. * @hidden
  16142. */
  16143. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16144. /**
  16145. * Manually render a set of post processes to a texture.
  16146. * @param postProcesses An array of post processes to be run.
  16147. * @param targetTexture The target texture to render to.
  16148. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16149. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16150. * @param lodLevel defines which lod of the texture to render to
  16151. */
  16152. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16153. /**
  16154. * Finalize the result of the output of the postprocesses.
  16155. * @param doNotPresent If true the result will not be displayed to the screen.
  16156. * @param targetTexture The target texture to render to.
  16157. * @param faceIndex The index of the face to bind the target texture to.
  16158. * @param postProcesses The array of post processes to render.
  16159. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16160. * @hidden
  16161. */
  16162. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16163. /**
  16164. * Disposes of the post process manager.
  16165. */
  16166. dispose(): void;
  16167. }
  16168. }
  16169. declare module BABYLON {
  16170. /** Interface used by value gradients (color, factor, ...) */
  16171. export interface IValueGradient {
  16172. /**
  16173. * Gets or sets the gradient value (between 0 and 1)
  16174. */
  16175. gradient: number;
  16176. }
  16177. /** Class used to store color4 gradient */
  16178. export class ColorGradient implements IValueGradient {
  16179. /**
  16180. * Gets or sets the gradient value (between 0 and 1)
  16181. */
  16182. gradient: number;
  16183. /**
  16184. * Gets or sets first associated color
  16185. */
  16186. color1: Color4;
  16187. /**
  16188. * Gets or sets second associated color
  16189. */
  16190. color2?: Color4;
  16191. /**
  16192. * Will get a color picked randomly between color1 and color2.
  16193. * If color2 is undefined then color1 will be used
  16194. * @param result defines the target Color4 to store the result in
  16195. */
  16196. getColorToRef(result: Color4): void;
  16197. }
  16198. /** Class used to store color 3 gradient */
  16199. export class Color3Gradient implements IValueGradient {
  16200. /**
  16201. * Gets or sets the gradient value (between 0 and 1)
  16202. */
  16203. gradient: number;
  16204. /**
  16205. * Gets or sets the associated color
  16206. */
  16207. color: Color3;
  16208. }
  16209. /** Class used to store factor gradient */
  16210. export class FactorGradient implements IValueGradient {
  16211. /**
  16212. * Gets or sets the gradient value (between 0 and 1)
  16213. */
  16214. gradient: number;
  16215. /**
  16216. * Gets or sets first associated factor
  16217. */
  16218. factor1: number;
  16219. /**
  16220. * Gets or sets second associated factor
  16221. */
  16222. factor2?: number;
  16223. /**
  16224. * Will get a number picked randomly between factor1 and factor2.
  16225. * If factor2 is undefined then factor1 will be used
  16226. * @returns the picked number
  16227. */
  16228. getFactor(): number;
  16229. }
  16230. /**
  16231. * Helper used to simplify some generic gradient tasks
  16232. */
  16233. export class GradientHelper {
  16234. /**
  16235. * Gets the current gradient from an array of IValueGradient
  16236. * @param ratio defines the current ratio to get
  16237. * @param gradients defines the array of IValueGradient
  16238. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16239. */
  16240. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16241. }
  16242. }
  16243. declare module BABYLON {
  16244. interface ThinEngine {
  16245. /**
  16246. * Creates a dynamic texture
  16247. * @param width defines the width of the texture
  16248. * @param height defines the height of the texture
  16249. * @param generateMipMaps defines if the engine should generate the mip levels
  16250. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16251. * @returns the dynamic texture inside an InternalTexture
  16252. */
  16253. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16254. /**
  16255. * Update the content of a dynamic texture
  16256. * @param texture defines the texture to update
  16257. * @param canvas defines the canvas containing the source
  16258. * @param invertY defines if data must be stored with Y axis inverted
  16259. * @param premulAlpha defines if alpha is stored as premultiplied
  16260. * @param format defines the format of the data
  16261. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16262. */
  16263. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16264. }
  16265. }
  16266. declare module BABYLON {
  16267. /**
  16268. * Helper class used to generate a canvas to manipulate images
  16269. */
  16270. export class CanvasGenerator {
  16271. /**
  16272. * Create a new canvas (or offscreen canvas depending on the context)
  16273. * @param width defines the expected width
  16274. * @param height defines the expected height
  16275. * @return a new canvas or offscreen canvas
  16276. */
  16277. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16278. }
  16279. }
  16280. declare module BABYLON {
  16281. /**
  16282. * A class extending Texture allowing drawing on a texture
  16283. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16284. */
  16285. export class DynamicTexture extends Texture {
  16286. private _generateMipMaps;
  16287. private _canvas;
  16288. private _context;
  16289. private _engine;
  16290. /**
  16291. * Creates a DynamicTexture
  16292. * @param name defines the name of the texture
  16293. * @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
  16294. * @param scene defines the scene where you want the texture
  16295. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16296. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16297. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16298. */
  16299. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16300. /**
  16301. * Get the current class name of the texture useful for serialization or dynamic coding.
  16302. * @returns "DynamicTexture"
  16303. */
  16304. getClassName(): string;
  16305. /**
  16306. * Gets the current state of canRescale
  16307. */
  16308. readonly canRescale: boolean;
  16309. private _recreate;
  16310. /**
  16311. * Scales the texture
  16312. * @param ratio the scale factor to apply to both width and height
  16313. */
  16314. scale(ratio: number): void;
  16315. /**
  16316. * Resizes the texture
  16317. * @param width the new width
  16318. * @param height the new height
  16319. */
  16320. scaleTo(width: number, height: number): void;
  16321. /**
  16322. * Gets the context of the canvas used by the texture
  16323. * @returns the canvas context of the dynamic texture
  16324. */
  16325. getContext(): CanvasRenderingContext2D;
  16326. /**
  16327. * Clears the texture
  16328. */
  16329. clear(): void;
  16330. /**
  16331. * Updates the texture
  16332. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16333. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16334. */
  16335. update(invertY?: boolean, premulAlpha?: boolean): void;
  16336. /**
  16337. * Draws text onto the texture
  16338. * @param text defines the text to be drawn
  16339. * @param x defines the placement of the text from the left
  16340. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16341. * @param font defines the font to be used with font-style, font-size, font-name
  16342. * @param color defines the color used for the text
  16343. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16344. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16345. * @param update defines whether texture is immediately update (default is true)
  16346. */
  16347. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16348. /**
  16349. * Clones the texture
  16350. * @returns the clone of the texture.
  16351. */
  16352. clone(): DynamicTexture;
  16353. /**
  16354. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16355. * @returns a serialized dynamic texture object
  16356. */
  16357. serialize(): any;
  16358. /** @hidden */
  16359. _rebuild(): void;
  16360. }
  16361. }
  16362. declare module BABYLON {
  16363. interface AbstractScene {
  16364. /**
  16365. * The list of procedural textures added to the scene
  16366. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16367. */
  16368. proceduralTextures: Array<ProceduralTexture>;
  16369. }
  16370. /**
  16371. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16372. * in a given scene.
  16373. */
  16374. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16375. /**
  16376. * The component name helpfull to identify the component in the list of scene components.
  16377. */
  16378. readonly name: string;
  16379. /**
  16380. * The scene the component belongs to.
  16381. */
  16382. scene: Scene;
  16383. /**
  16384. * Creates a new instance of the component for the given scene
  16385. * @param scene Defines the scene to register the component in
  16386. */
  16387. constructor(scene: Scene);
  16388. /**
  16389. * Registers the component in a given scene
  16390. */
  16391. register(): void;
  16392. /**
  16393. * Rebuilds the elements related to this component in case of
  16394. * context lost for instance.
  16395. */
  16396. rebuild(): void;
  16397. /**
  16398. * Disposes the component and the associated ressources.
  16399. */
  16400. dispose(): void;
  16401. private _beforeClear;
  16402. }
  16403. }
  16404. declare module BABYLON {
  16405. interface ThinEngine {
  16406. /**
  16407. * Creates a new render target cube texture
  16408. * @param size defines the size of the texture
  16409. * @param options defines the options used to create the texture
  16410. * @returns a new render target cube texture stored in an InternalTexture
  16411. */
  16412. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16413. }
  16414. }
  16415. declare module BABYLON {
  16416. /** @hidden */
  16417. export var proceduralVertexShader: {
  16418. name: string;
  16419. shader: string;
  16420. };
  16421. }
  16422. declare module BABYLON {
  16423. /**
  16424. * 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.
  16425. * This is the base class of any Procedural texture and contains most of the shareable code.
  16426. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16427. */
  16428. export class ProceduralTexture extends Texture {
  16429. isCube: boolean;
  16430. /**
  16431. * Define if the texture is enabled or not (disabled texture will not render)
  16432. */
  16433. isEnabled: boolean;
  16434. /**
  16435. * Define if the texture must be cleared before rendering (default is true)
  16436. */
  16437. autoClear: boolean;
  16438. /**
  16439. * Callback called when the texture is generated
  16440. */
  16441. onGenerated: () => void;
  16442. /**
  16443. * Event raised when the texture is generated
  16444. */
  16445. onGeneratedObservable: Observable<ProceduralTexture>;
  16446. /** @hidden */
  16447. _generateMipMaps: boolean;
  16448. /** @hidden **/
  16449. _effect: Effect;
  16450. /** @hidden */
  16451. _textures: {
  16452. [key: string]: Texture;
  16453. };
  16454. private _size;
  16455. private _currentRefreshId;
  16456. private _refreshRate;
  16457. private _vertexBuffers;
  16458. private _indexBuffer;
  16459. private _uniforms;
  16460. private _samplers;
  16461. private _fragment;
  16462. private _floats;
  16463. private _ints;
  16464. private _floatsArrays;
  16465. private _colors3;
  16466. private _colors4;
  16467. private _vectors2;
  16468. private _vectors3;
  16469. private _matrices;
  16470. private _fallbackTexture;
  16471. private _fallbackTextureUsed;
  16472. private _engine;
  16473. private _cachedDefines;
  16474. private _contentUpdateId;
  16475. private _contentData;
  16476. /**
  16477. * Instantiates a new procedural texture.
  16478. * 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.
  16479. * This is the base class of any Procedural texture and contains most of the shareable code.
  16480. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16481. * @param name Define the name of the texture
  16482. * @param size Define the size of the texture to create
  16483. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16484. * @param scene Define the scene the texture belongs to
  16485. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16486. * @param generateMipMaps Define if the texture should creates mip maps or not
  16487. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16488. */
  16489. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16490. /**
  16491. * The effect that is created when initializing the post process.
  16492. * @returns The created effect corresponding the the postprocess.
  16493. */
  16494. getEffect(): Effect;
  16495. /**
  16496. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16497. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16498. */
  16499. getContent(): Nullable<ArrayBufferView>;
  16500. private _createIndexBuffer;
  16501. /** @hidden */
  16502. _rebuild(): void;
  16503. /**
  16504. * Resets the texture in order to recreate its associated resources.
  16505. * This can be called in case of context loss
  16506. */
  16507. reset(): void;
  16508. protected _getDefines(): string;
  16509. /**
  16510. * Is the texture ready to be used ? (rendered at least once)
  16511. * @returns true if ready, otherwise, false.
  16512. */
  16513. isReady(): boolean;
  16514. /**
  16515. * Resets the refresh counter of the texture and start bak from scratch.
  16516. * Could be useful to regenerate the texture if it is setup to render only once.
  16517. */
  16518. resetRefreshCounter(): void;
  16519. /**
  16520. * Set the fragment shader to use in order to render the texture.
  16521. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16522. */
  16523. setFragment(fragment: any): void;
  16524. /**
  16525. * Define the refresh rate of the texture or the rendering frequency.
  16526. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16527. */
  16528. refreshRate: number;
  16529. /** @hidden */
  16530. _shouldRender(): boolean;
  16531. /**
  16532. * Get the size the texture is rendering at.
  16533. * @returns the size (texture is always squared)
  16534. */
  16535. getRenderSize(): number;
  16536. /**
  16537. * Resize the texture to new value.
  16538. * @param size Define the new size the texture should have
  16539. * @param generateMipMaps Define whether the new texture should create mip maps
  16540. */
  16541. resize(size: number, generateMipMaps: boolean): void;
  16542. private _checkUniform;
  16543. /**
  16544. * Set a texture in the shader program used to render.
  16545. * @param name Define the name of the uniform samplers as defined in the shader
  16546. * @param texture Define the texture to bind to this sampler
  16547. * @return the texture itself allowing "fluent" like uniform updates
  16548. */
  16549. setTexture(name: string, texture: Texture): ProceduralTexture;
  16550. /**
  16551. * Set a float in the shader.
  16552. * @param name Define the name of the uniform as defined in the shader
  16553. * @param value Define the value to give to the uniform
  16554. * @return the texture itself allowing "fluent" like uniform updates
  16555. */
  16556. setFloat(name: string, value: number): ProceduralTexture;
  16557. /**
  16558. * Set a int in the shader.
  16559. * @param name Define the name of the uniform as defined in the shader
  16560. * @param value Define the value to give to the uniform
  16561. * @return the texture itself allowing "fluent" like uniform updates
  16562. */
  16563. setInt(name: string, value: number): ProceduralTexture;
  16564. /**
  16565. * Set an array of floats in the shader.
  16566. * @param name Define the name of the uniform as defined in the shader
  16567. * @param value Define the value to give to the uniform
  16568. * @return the texture itself allowing "fluent" like uniform updates
  16569. */
  16570. setFloats(name: string, value: number[]): ProceduralTexture;
  16571. /**
  16572. * Set a vec3 in the shader from a Color3.
  16573. * @param name Define the name of the uniform as defined in the shader
  16574. * @param value Define the value to give to the uniform
  16575. * @return the texture itself allowing "fluent" like uniform updates
  16576. */
  16577. setColor3(name: string, value: Color3): ProceduralTexture;
  16578. /**
  16579. * Set a vec4 in the shader from a Color4.
  16580. * @param name Define the name of the uniform as defined in the shader
  16581. * @param value Define the value to give to the uniform
  16582. * @return the texture itself allowing "fluent" like uniform updates
  16583. */
  16584. setColor4(name: string, value: Color4): ProceduralTexture;
  16585. /**
  16586. * Set a vec2 in the shader from a Vector2.
  16587. * @param name Define the name of the uniform as defined in the shader
  16588. * @param value Define the value to give to the uniform
  16589. * @return the texture itself allowing "fluent" like uniform updates
  16590. */
  16591. setVector2(name: string, value: Vector2): ProceduralTexture;
  16592. /**
  16593. * Set a vec3 in the shader from a Vector3.
  16594. * @param name Define the name of the uniform as defined in the shader
  16595. * @param value Define the value to give to the uniform
  16596. * @return the texture itself allowing "fluent" like uniform updates
  16597. */
  16598. setVector3(name: string, value: Vector3): ProceduralTexture;
  16599. /**
  16600. * Set a mat4 in the shader from a MAtrix.
  16601. * @param name Define the name of the uniform as defined in the shader
  16602. * @param value Define the value to give to the uniform
  16603. * @return the texture itself allowing "fluent" like uniform updates
  16604. */
  16605. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16606. /**
  16607. * Render the texture to its associated render target.
  16608. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16609. */
  16610. render(useCameraPostProcess?: boolean): void;
  16611. /**
  16612. * Clone the texture.
  16613. * @returns the cloned texture
  16614. */
  16615. clone(): ProceduralTexture;
  16616. /**
  16617. * Dispose the texture and release its asoociated resources.
  16618. */
  16619. dispose(): void;
  16620. }
  16621. }
  16622. declare module BABYLON {
  16623. /**
  16624. * This represents the base class for particle system in Babylon.
  16625. * 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.
  16626. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16627. * @example https://doc.babylonjs.com/babylon101/particles
  16628. */
  16629. export class BaseParticleSystem {
  16630. /**
  16631. * Source color is added to the destination color without alpha affecting the result
  16632. */
  16633. static BLENDMODE_ONEONE: number;
  16634. /**
  16635. * Blend current color and particle color using particle’s alpha
  16636. */
  16637. static BLENDMODE_STANDARD: number;
  16638. /**
  16639. * Add current color and particle color multiplied by particle’s alpha
  16640. */
  16641. static BLENDMODE_ADD: number;
  16642. /**
  16643. * Multiply current color with particle color
  16644. */
  16645. static BLENDMODE_MULTIPLY: number;
  16646. /**
  16647. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16648. */
  16649. static BLENDMODE_MULTIPLYADD: number;
  16650. /**
  16651. * List of animations used by the particle system.
  16652. */
  16653. animations: Animation[];
  16654. /**
  16655. * The id of the Particle system.
  16656. */
  16657. id: string;
  16658. /**
  16659. * The friendly name of the Particle system.
  16660. */
  16661. name: string;
  16662. /**
  16663. * The rendering group used by the Particle system to chose when to render.
  16664. */
  16665. renderingGroupId: number;
  16666. /**
  16667. * The emitter represents the Mesh or position we are attaching the particle system to.
  16668. */
  16669. emitter: Nullable<AbstractMesh | Vector3>;
  16670. /**
  16671. * The maximum number of particles to emit per frame
  16672. */
  16673. emitRate: number;
  16674. /**
  16675. * If you want to launch only a few particles at once, that can be done, as well.
  16676. */
  16677. manualEmitCount: number;
  16678. /**
  16679. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16680. */
  16681. updateSpeed: number;
  16682. /**
  16683. * The amount of time the particle system is running (depends of the overall update speed).
  16684. */
  16685. targetStopDuration: number;
  16686. /**
  16687. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16688. */
  16689. disposeOnStop: boolean;
  16690. /**
  16691. * Minimum power of emitting particles.
  16692. */
  16693. minEmitPower: number;
  16694. /**
  16695. * Maximum power of emitting particles.
  16696. */
  16697. maxEmitPower: number;
  16698. /**
  16699. * Minimum life time of emitting particles.
  16700. */
  16701. minLifeTime: number;
  16702. /**
  16703. * Maximum life time of emitting particles.
  16704. */
  16705. maxLifeTime: number;
  16706. /**
  16707. * Minimum Size of emitting particles.
  16708. */
  16709. minSize: number;
  16710. /**
  16711. * Maximum Size of emitting particles.
  16712. */
  16713. maxSize: number;
  16714. /**
  16715. * Minimum scale of emitting particles on X axis.
  16716. */
  16717. minScaleX: number;
  16718. /**
  16719. * Maximum scale of emitting particles on X axis.
  16720. */
  16721. maxScaleX: number;
  16722. /**
  16723. * Minimum scale of emitting particles on Y axis.
  16724. */
  16725. minScaleY: number;
  16726. /**
  16727. * Maximum scale of emitting particles on Y axis.
  16728. */
  16729. maxScaleY: number;
  16730. /**
  16731. * Gets or sets the minimal initial rotation in radians.
  16732. */
  16733. minInitialRotation: number;
  16734. /**
  16735. * Gets or sets the maximal initial rotation in radians.
  16736. */
  16737. maxInitialRotation: number;
  16738. /**
  16739. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16740. */
  16741. minAngularSpeed: number;
  16742. /**
  16743. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16744. */
  16745. maxAngularSpeed: number;
  16746. /**
  16747. * The texture used to render each particle. (this can be a spritesheet)
  16748. */
  16749. particleTexture: Nullable<Texture>;
  16750. /**
  16751. * The layer mask we are rendering the particles through.
  16752. */
  16753. layerMask: number;
  16754. /**
  16755. * This can help using your own shader to render the particle system.
  16756. * The according effect will be created
  16757. */
  16758. customShader: any;
  16759. /**
  16760. * By default particle system starts as soon as they are created. This prevents the
  16761. * automatic start to happen and let you decide when to start emitting particles.
  16762. */
  16763. preventAutoStart: boolean;
  16764. private _noiseTexture;
  16765. /**
  16766. * Gets or sets a texture used to add random noise to particle positions
  16767. */
  16768. noiseTexture: Nullable<ProceduralTexture>;
  16769. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16770. noiseStrength: Vector3;
  16771. /**
  16772. * Callback triggered when the particle animation is ending.
  16773. */
  16774. onAnimationEnd: Nullable<() => void>;
  16775. /**
  16776. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16777. */
  16778. blendMode: number;
  16779. /**
  16780. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16781. * to override the particles.
  16782. */
  16783. forceDepthWrite: boolean;
  16784. /** 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 */
  16785. preWarmCycles: number;
  16786. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16787. preWarmStepOffset: number;
  16788. /**
  16789. * 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)
  16790. */
  16791. spriteCellChangeSpeed: number;
  16792. /**
  16793. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16794. */
  16795. startSpriteCellID: number;
  16796. /**
  16797. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16798. */
  16799. endSpriteCellID: number;
  16800. /**
  16801. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16802. */
  16803. spriteCellWidth: number;
  16804. /**
  16805. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16806. */
  16807. spriteCellHeight: number;
  16808. /**
  16809. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16810. */
  16811. spriteRandomStartCell: boolean;
  16812. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16813. translationPivot: Vector2;
  16814. /** @hidden */
  16815. protected _isAnimationSheetEnabled: boolean;
  16816. /**
  16817. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16818. */
  16819. beginAnimationOnStart: boolean;
  16820. /**
  16821. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16822. */
  16823. beginAnimationFrom: number;
  16824. /**
  16825. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16826. */
  16827. beginAnimationTo: number;
  16828. /**
  16829. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16830. */
  16831. beginAnimationLoop: boolean;
  16832. /**
  16833. * Gets or sets a world offset applied to all particles
  16834. */
  16835. worldOffset: Vector3;
  16836. /**
  16837. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16838. */
  16839. isAnimationSheetEnabled: boolean;
  16840. /**
  16841. * Get hosting scene
  16842. * @returns the scene
  16843. */
  16844. getScene(): Scene;
  16845. /**
  16846. * You can use gravity if you want to give an orientation to your particles.
  16847. */
  16848. gravity: Vector3;
  16849. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16850. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16851. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16852. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16853. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16854. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16855. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16856. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16857. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16858. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16859. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16860. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16861. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16862. /**
  16863. * Defines the delay in milliseconds before starting the system (0 by default)
  16864. */
  16865. startDelay: number;
  16866. /**
  16867. * Gets the current list of drag gradients.
  16868. * You must use addDragGradient and removeDragGradient to udpate this list
  16869. * @returns the list of drag gradients
  16870. */
  16871. getDragGradients(): Nullable<Array<FactorGradient>>;
  16872. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16873. limitVelocityDamping: number;
  16874. /**
  16875. * Gets the current list of limit velocity gradients.
  16876. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16877. * @returns the list of limit velocity gradients
  16878. */
  16879. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16880. /**
  16881. * Gets the current list of color gradients.
  16882. * You must use addColorGradient and removeColorGradient to udpate this list
  16883. * @returns the list of color gradients
  16884. */
  16885. getColorGradients(): Nullable<Array<ColorGradient>>;
  16886. /**
  16887. * Gets the current list of size gradients.
  16888. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16889. * @returns the list of size gradients
  16890. */
  16891. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16892. /**
  16893. * Gets the current list of color remap gradients.
  16894. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16895. * @returns the list of color remap gradients
  16896. */
  16897. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16898. /**
  16899. * Gets the current list of alpha remap gradients.
  16900. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16901. * @returns the list of alpha remap gradients
  16902. */
  16903. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16904. /**
  16905. * Gets the current list of life time gradients.
  16906. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16907. * @returns the list of life time gradients
  16908. */
  16909. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16910. /**
  16911. * Gets the current list of angular speed gradients.
  16912. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16913. * @returns the list of angular speed gradients
  16914. */
  16915. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16916. /**
  16917. * Gets the current list of velocity gradients.
  16918. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16919. * @returns the list of velocity gradients
  16920. */
  16921. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16922. /**
  16923. * Gets the current list of start size gradients.
  16924. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16925. * @returns the list of start size gradients
  16926. */
  16927. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16928. /**
  16929. * Gets the current list of emit rate gradients.
  16930. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16931. * @returns the list of emit rate gradients
  16932. */
  16933. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16934. /**
  16935. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16936. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16937. */
  16938. direction1: Vector3;
  16939. /**
  16940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16941. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16942. */
  16943. direction2: Vector3;
  16944. /**
  16945. * 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.
  16946. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16947. */
  16948. minEmitBox: Vector3;
  16949. /**
  16950. * 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.
  16951. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16952. */
  16953. maxEmitBox: Vector3;
  16954. /**
  16955. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16956. */
  16957. color1: Color4;
  16958. /**
  16959. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16960. */
  16961. color2: Color4;
  16962. /**
  16963. * Color the particle will have at the end of its lifetime
  16964. */
  16965. colorDead: Color4;
  16966. /**
  16967. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16968. */
  16969. textureMask: Color4;
  16970. /**
  16971. * The particle emitter type defines the emitter used by the particle system.
  16972. * It can be for example box, sphere, or cone...
  16973. */
  16974. particleEmitterType: IParticleEmitterType;
  16975. /** @hidden */
  16976. _isSubEmitter: boolean;
  16977. /**
  16978. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16979. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16980. */
  16981. billboardMode: number;
  16982. protected _isBillboardBased: boolean;
  16983. /**
  16984. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16985. */
  16986. isBillboardBased: boolean;
  16987. /**
  16988. * The scene the particle system belongs to.
  16989. */
  16990. protected _scene: Scene;
  16991. /**
  16992. * Local cache of defines for image processing.
  16993. */
  16994. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16995. /**
  16996. * Default configuration related to image processing available in the standard Material.
  16997. */
  16998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16999. /**
  17000. * Gets the image processing configuration used either in this material.
  17001. */
  17002. /**
  17003. * Sets the Default image processing configuration used either in the this material.
  17004. *
  17005. * If sets to null, the scene one is in use.
  17006. */
  17007. imageProcessingConfiguration: ImageProcessingConfiguration;
  17008. /**
  17009. * Attaches a new image processing configuration to the Standard Material.
  17010. * @param configuration
  17011. */
  17012. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17013. /** @hidden */
  17014. protected _reset(): void;
  17015. /** @hidden */
  17016. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17017. /**
  17018. * Instantiates a particle system.
  17019. * 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.
  17020. * @param name The name of the particle system
  17021. */
  17022. constructor(name: string);
  17023. /**
  17024. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17025. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17026. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17027. * @returns the emitter
  17028. */
  17029. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17030. /**
  17031. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17032. * @param radius The radius of the hemisphere to emit from
  17033. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17034. * @returns the emitter
  17035. */
  17036. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17037. /**
  17038. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17039. * @param radius The radius of the sphere to emit from
  17040. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17041. * @returns the emitter
  17042. */
  17043. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17044. /**
  17045. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17046. * @param radius The radius of the sphere to emit from
  17047. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17048. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17049. * @returns the emitter
  17050. */
  17051. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17052. /**
  17053. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17054. * @param radius The radius of the emission cylinder
  17055. * @param height The height of the emission cylinder
  17056. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17057. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17058. * @returns the emitter
  17059. */
  17060. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17061. /**
  17062. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17063. * @param radius The radius of the cylinder to emit from
  17064. * @param height The height of the emission cylinder
  17065. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17066. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17067. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17068. * @returns the emitter
  17069. */
  17070. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17071. /**
  17072. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17073. * @param radius The radius of the cone to emit from
  17074. * @param angle The base angle of the cone
  17075. * @returns the emitter
  17076. */
  17077. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17078. /**
  17079. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17080. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17082. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17083. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17084. * @returns the emitter
  17085. */
  17086. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17087. }
  17088. }
  17089. declare module BABYLON {
  17090. /**
  17091. * Type of sub emitter
  17092. */
  17093. export enum SubEmitterType {
  17094. /**
  17095. * Attached to the particle over it's lifetime
  17096. */
  17097. ATTACHED = 0,
  17098. /**
  17099. * Created when the particle dies
  17100. */
  17101. END = 1
  17102. }
  17103. /**
  17104. * Sub emitter class used to emit particles from an existing particle
  17105. */
  17106. export class SubEmitter {
  17107. /**
  17108. * the particle system to be used by the sub emitter
  17109. */
  17110. particleSystem: ParticleSystem;
  17111. /**
  17112. * Type of the submitter (Default: END)
  17113. */
  17114. type: SubEmitterType;
  17115. /**
  17116. * 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)
  17117. * Note: This only is supported when using an emitter of type Mesh
  17118. */
  17119. inheritDirection: boolean;
  17120. /**
  17121. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17122. */
  17123. inheritedVelocityAmount: number;
  17124. /**
  17125. * Creates a sub emitter
  17126. * @param particleSystem the particle system to be used by the sub emitter
  17127. */
  17128. constructor(
  17129. /**
  17130. * the particle system to be used by the sub emitter
  17131. */
  17132. particleSystem: ParticleSystem);
  17133. /**
  17134. * Clones the sub emitter
  17135. * @returns the cloned sub emitter
  17136. */
  17137. clone(): SubEmitter;
  17138. /**
  17139. * Serialize current object to a JSON object
  17140. * @returns the serialized object
  17141. */
  17142. serialize(): any;
  17143. /** @hidden */
  17144. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17145. /**
  17146. * Creates a new SubEmitter from a serialized JSON version
  17147. * @param serializationObject defines the JSON object to read from
  17148. * @param scene defines the hosting scene
  17149. * @param rootUrl defines the rootUrl for data loading
  17150. * @returns a new SubEmitter
  17151. */
  17152. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17153. /** Release associated resources */
  17154. dispose(): void;
  17155. }
  17156. }
  17157. declare module BABYLON {
  17158. /** @hidden */
  17159. export var clipPlaneFragmentDeclaration: {
  17160. name: string;
  17161. shader: string;
  17162. };
  17163. }
  17164. declare module BABYLON {
  17165. /** @hidden */
  17166. export var imageProcessingDeclaration: {
  17167. name: string;
  17168. shader: string;
  17169. };
  17170. }
  17171. declare module BABYLON {
  17172. /** @hidden */
  17173. export var imageProcessingFunctions: {
  17174. name: string;
  17175. shader: string;
  17176. };
  17177. }
  17178. declare module BABYLON {
  17179. /** @hidden */
  17180. export var clipPlaneFragment: {
  17181. name: string;
  17182. shader: string;
  17183. };
  17184. }
  17185. declare module BABYLON {
  17186. /** @hidden */
  17187. export var particlesPixelShader: {
  17188. name: string;
  17189. shader: string;
  17190. };
  17191. }
  17192. declare module BABYLON {
  17193. /** @hidden */
  17194. export var clipPlaneVertexDeclaration: {
  17195. name: string;
  17196. shader: string;
  17197. };
  17198. }
  17199. declare module BABYLON {
  17200. /** @hidden */
  17201. export var clipPlaneVertex: {
  17202. name: string;
  17203. shader: string;
  17204. };
  17205. }
  17206. declare module BABYLON {
  17207. /** @hidden */
  17208. export var particlesVertexShader: {
  17209. name: string;
  17210. shader: string;
  17211. };
  17212. }
  17213. declare module BABYLON {
  17214. /**
  17215. * This represents a particle system in Babylon.
  17216. * 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.
  17217. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17218. * @example https://doc.babylonjs.com/babylon101/particles
  17219. */
  17220. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17221. /**
  17222. * Billboard mode will only apply to Y axis
  17223. */
  17224. static readonly BILLBOARDMODE_Y: number;
  17225. /**
  17226. * Billboard mode will apply to all axes
  17227. */
  17228. static readonly BILLBOARDMODE_ALL: number;
  17229. /**
  17230. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17231. */
  17232. static readonly BILLBOARDMODE_STRETCHED: number;
  17233. /**
  17234. * This function can be defined to provide custom update for active particles.
  17235. * This function will be called instead of regular update (age, position, color, etc.).
  17236. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17237. */
  17238. updateFunction: (particles: Particle[]) => void;
  17239. private _emitterWorldMatrix;
  17240. /**
  17241. * This function can be defined to specify initial direction for every new particle.
  17242. * It by default use the emitterType defined function
  17243. */
  17244. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17245. /**
  17246. * This function can be defined to specify initial position for every new particle.
  17247. * It by default use the emitterType defined function
  17248. */
  17249. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17250. /**
  17251. * @hidden
  17252. */
  17253. _inheritedVelocityOffset: Vector3;
  17254. /**
  17255. * An event triggered when the system is disposed
  17256. */
  17257. onDisposeObservable: Observable<ParticleSystem>;
  17258. private _onDisposeObserver;
  17259. /**
  17260. * Sets a callback that will be triggered when the system is disposed
  17261. */
  17262. onDispose: () => void;
  17263. private _particles;
  17264. private _epsilon;
  17265. private _capacity;
  17266. private _stockParticles;
  17267. private _newPartsExcess;
  17268. private _vertexData;
  17269. private _vertexBuffer;
  17270. private _vertexBuffers;
  17271. private _spriteBuffer;
  17272. private _indexBuffer;
  17273. private _effect;
  17274. private _customEffect;
  17275. private _cachedDefines;
  17276. private _scaledColorStep;
  17277. private _colorDiff;
  17278. private _scaledDirection;
  17279. private _scaledGravity;
  17280. private _currentRenderId;
  17281. private _alive;
  17282. private _useInstancing;
  17283. private _started;
  17284. private _stopped;
  17285. private _actualFrame;
  17286. private _scaledUpdateSpeed;
  17287. private _vertexBufferSize;
  17288. /** @hidden */
  17289. _currentEmitRateGradient: Nullable<FactorGradient>;
  17290. /** @hidden */
  17291. _currentEmitRate1: number;
  17292. /** @hidden */
  17293. _currentEmitRate2: number;
  17294. /** @hidden */
  17295. _currentStartSizeGradient: Nullable<FactorGradient>;
  17296. /** @hidden */
  17297. _currentStartSize1: number;
  17298. /** @hidden */
  17299. _currentStartSize2: number;
  17300. private readonly _rawTextureWidth;
  17301. private _rampGradientsTexture;
  17302. private _useRampGradients;
  17303. /** Gets or sets a boolean indicating that ramp gradients must be used
  17304. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17305. */
  17306. useRampGradients: boolean;
  17307. /**
  17308. * 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.
  17309. * 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: [])
  17310. */
  17311. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17312. private _subEmitters;
  17313. /**
  17314. * @hidden
  17315. * If the particle systems emitter should be disposed when the particle system is disposed
  17316. */
  17317. _disposeEmitterOnDispose: boolean;
  17318. /**
  17319. * The current active Sub-systems, this property is used by the root particle system only.
  17320. */
  17321. activeSubSystems: Array<ParticleSystem>;
  17322. private _rootParticleSystem;
  17323. /**
  17324. * Gets the current list of active particles
  17325. */
  17326. readonly particles: Particle[];
  17327. /**
  17328. * Returns the string "ParticleSystem"
  17329. * @returns a string containing the class name
  17330. */
  17331. getClassName(): string;
  17332. /**
  17333. * Instantiates a particle system.
  17334. * 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.
  17335. * @param name The name of the particle system
  17336. * @param capacity The max number of particles alive at the same time
  17337. * @param scene The scene the particle system belongs to
  17338. * @param customEffect a custom effect used to change the way particles are rendered by default
  17339. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17340. * @param epsilon Offset used to render the particles
  17341. */
  17342. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17343. private _addFactorGradient;
  17344. private _removeFactorGradient;
  17345. /**
  17346. * Adds a new life time gradient
  17347. * @param gradient defines the gradient to use (between 0 and 1)
  17348. * @param factor defines the life time factor to affect to the specified gradient
  17349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17350. * @returns the current particle system
  17351. */
  17352. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17353. /**
  17354. * Remove a specific life time gradient
  17355. * @param gradient defines the gradient to remove
  17356. * @returns the current particle system
  17357. */
  17358. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17359. /**
  17360. * Adds a new size gradient
  17361. * @param gradient defines the gradient to use (between 0 and 1)
  17362. * @param factor defines the size factor to affect to the specified gradient
  17363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17364. * @returns the current particle system
  17365. */
  17366. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17367. /**
  17368. * Remove a specific size gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeSizeGradient(gradient: number): IParticleSystem;
  17373. /**
  17374. * Adds a new color remap gradient
  17375. * @param gradient defines the gradient to use (between 0 and 1)
  17376. * @param min defines the color remap minimal range
  17377. * @param max defines the color remap maximal range
  17378. * @returns the current particle system
  17379. */
  17380. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17381. /**
  17382. * Remove a specific color remap gradient
  17383. * @param gradient defines the gradient to remove
  17384. * @returns the current particle system
  17385. */
  17386. removeColorRemapGradient(gradient: number): IParticleSystem;
  17387. /**
  17388. * Adds a new alpha remap gradient
  17389. * @param gradient defines the gradient to use (between 0 and 1)
  17390. * @param min defines the alpha remap minimal range
  17391. * @param max defines the alpha remap maximal range
  17392. * @returns the current particle system
  17393. */
  17394. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17395. /**
  17396. * Remove a specific alpha remap gradient
  17397. * @param gradient defines the gradient to remove
  17398. * @returns the current particle system
  17399. */
  17400. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17401. /**
  17402. * Adds a new angular speed gradient
  17403. * @param gradient defines the gradient to use (between 0 and 1)
  17404. * @param factor defines the angular speed to affect to the specified gradient
  17405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17406. * @returns the current particle system
  17407. */
  17408. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17409. /**
  17410. * Remove a specific angular speed gradient
  17411. * @param gradient defines the gradient to remove
  17412. * @returns the current particle system
  17413. */
  17414. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17415. /**
  17416. * Adds a new velocity gradient
  17417. * @param gradient defines the gradient to use (between 0 and 1)
  17418. * @param factor defines the velocity to affect to the specified gradient
  17419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17420. * @returns the current particle system
  17421. */
  17422. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17423. /**
  17424. * Remove a specific velocity gradient
  17425. * @param gradient defines the gradient to remove
  17426. * @returns the current particle system
  17427. */
  17428. removeVelocityGradient(gradient: number): IParticleSystem;
  17429. /**
  17430. * Adds a new limit velocity gradient
  17431. * @param gradient defines the gradient to use (between 0 and 1)
  17432. * @param factor defines the limit velocity value to affect to the specified gradient
  17433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17434. * @returns the current particle system
  17435. */
  17436. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17437. /**
  17438. * Remove a specific limit velocity gradient
  17439. * @param gradient defines the gradient to remove
  17440. * @returns the current particle system
  17441. */
  17442. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17443. /**
  17444. * Adds a new drag gradient
  17445. * @param gradient defines the gradient to use (between 0 and 1)
  17446. * @param factor defines the drag value to affect to the specified gradient
  17447. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17448. * @returns the current particle system
  17449. */
  17450. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17451. /**
  17452. * Remove a specific drag gradient
  17453. * @param gradient defines the gradient to remove
  17454. * @returns the current particle system
  17455. */
  17456. removeDragGradient(gradient: number): IParticleSystem;
  17457. /**
  17458. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17459. * @param gradient defines the gradient to use (between 0 and 1)
  17460. * @param factor defines the emit rate value to affect to the specified gradient
  17461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17462. * @returns the current particle system
  17463. */
  17464. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17465. /**
  17466. * Remove a specific emit rate gradient
  17467. * @param gradient defines the gradient to remove
  17468. * @returns the current particle system
  17469. */
  17470. removeEmitRateGradient(gradient: number): IParticleSystem;
  17471. /**
  17472. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17473. * @param gradient defines the gradient to use (between 0 and 1)
  17474. * @param factor defines the start size value to affect to the specified gradient
  17475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17476. * @returns the current particle system
  17477. */
  17478. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17479. /**
  17480. * Remove a specific start size gradient
  17481. * @param gradient defines the gradient to remove
  17482. * @returns the current particle system
  17483. */
  17484. removeStartSizeGradient(gradient: number): IParticleSystem;
  17485. private _createRampGradientTexture;
  17486. /**
  17487. * Gets the current list of ramp gradients.
  17488. * You must use addRampGradient and removeRampGradient to udpate this list
  17489. * @returns the list of ramp gradients
  17490. */
  17491. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17492. /**
  17493. * Adds a new ramp gradient used to remap particle colors
  17494. * @param gradient defines the gradient to use (between 0 and 1)
  17495. * @param color defines the color to affect to the specified gradient
  17496. * @returns the current particle system
  17497. */
  17498. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17499. /**
  17500. * Remove a specific ramp gradient
  17501. * @param gradient defines the gradient to remove
  17502. * @returns the current particle system
  17503. */
  17504. removeRampGradient(gradient: number): ParticleSystem;
  17505. /**
  17506. * Adds a new color gradient
  17507. * @param gradient defines the gradient to use (between 0 and 1)
  17508. * @param color1 defines the color to affect to the specified gradient
  17509. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17510. * @returns this particle system
  17511. */
  17512. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17513. /**
  17514. * Remove a specific color gradient
  17515. * @param gradient defines the gradient to remove
  17516. * @returns this particle system
  17517. */
  17518. removeColorGradient(gradient: number): IParticleSystem;
  17519. private _fetchR;
  17520. protected _reset(): void;
  17521. private _resetEffect;
  17522. private _createVertexBuffers;
  17523. private _createIndexBuffer;
  17524. /**
  17525. * Gets the maximum number of particles active at the same time.
  17526. * @returns The max number of active particles.
  17527. */
  17528. getCapacity(): number;
  17529. /**
  17530. * Gets whether there are still active particles in the system.
  17531. * @returns True if it is alive, otherwise false.
  17532. */
  17533. isAlive(): boolean;
  17534. /**
  17535. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17536. * @returns True if it has been started, otherwise false.
  17537. */
  17538. isStarted(): boolean;
  17539. private _prepareSubEmitterInternalArray;
  17540. /**
  17541. * Starts the particle system and begins to emit
  17542. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17543. */
  17544. start(delay?: number): void;
  17545. /**
  17546. * Stops the particle system.
  17547. * @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.
  17548. */
  17549. stop(stopSubEmitters?: boolean): void;
  17550. /**
  17551. * Remove all active particles
  17552. */
  17553. reset(): void;
  17554. /**
  17555. * @hidden (for internal use only)
  17556. */
  17557. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17558. /**
  17559. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17560. * Its lifetime will start back at 0.
  17561. */
  17562. recycleParticle: (particle: Particle) => void;
  17563. private _stopSubEmitters;
  17564. private _createParticle;
  17565. private _removeFromRoot;
  17566. private _emitFromParticle;
  17567. private _update;
  17568. /** @hidden */
  17569. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17570. /** @hidden */
  17571. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17572. /** @hidden */
  17573. private _getEffect;
  17574. /**
  17575. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17576. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17577. */
  17578. animate(preWarmOnly?: boolean): void;
  17579. private _appendParticleVertices;
  17580. /**
  17581. * Rebuilds the particle system.
  17582. */
  17583. rebuild(): void;
  17584. /**
  17585. * Is this system ready to be used/rendered
  17586. * @return true if the system is ready
  17587. */
  17588. isReady(): boolean;
  17589. private _render;
  17590. /**
  17591. * Renders the particle system in its current state.
  17592. * @returns the current number of particles
  17593. */
  17594. render(): number;
  17595. /**
  17596. * Disposes the particle system and free the associated resources
  17597. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17598. */
  17599. dispose(disposeTexture?: boolean): void;
  17600. /**
  17601. * Clones the particle system.
  17602. * @param name The name of the cloned object
  17603. * @param newEmitter The new emitter to use
  17604. * @returns the cloned particle system
  17605. */
  17606. clone(name: string, newEmitter: any): ParticleSystem;
  17607. /**
  17608. * Serializes the particle system to a JSON object.
  17609. * @returns the JSON object
  17610. */
  17611. serialize(): any;
  17612. /** @hidden */
  17613. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17614. /** @hidden */
  17615. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17616. /**
  17617. * Parses a JSON object to create a particle system.
  17618. * @param parsedParticleSystem The JSON object to parse
  17619. * @param scene The scene to create the particle system in
  17620. * @param rootUrl The root url to use to load external dependencies like texture
  17621. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17622. * @returns the Parsed particle system
  17623. */
  17624. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17625. }
  17626. }
  17627. declare module BABYLON {
  17628. /**
  17629. * A particle represents one of the element emitted by a particle system.
  17630. * This is mainly define by its coordinates, direction, velocity and age.
  17631. */
  17632. export class Particle {
  17633. /**
  17634. * The particle system the particle belongs to.
  17635. */
  17636. particleSystem: ParticleSystem;
  17637. private static _Count;
  17638. /**
  17639. * Unique ID of the particle
  17640. */
  17641. id: number;
  17642. /**
  17643. * The world position of the particle in the scene.
  17644. */
  17645. position: Vector3;
  17646. /**
  17647. * The world direction of the particle in the scene.
  17648. */
  17649. direction: Vector3;
  17650. /**
  17651. * The color of the particle.
  17652. */
  17653. color: Color4;
  17654. /**
  17655. * The color change of the particle per step.
  17656. */
  17657. colorStep: Color4;
  17658. /**
  17659. * Defines how long will the life of the particle be.
  17660. */
  17661. lifeTime: number;
  17662. /**
  17663. * The current age of the particle.
  17664. */
  17665. age: number;
  17666. /**
  17667. * The current size of the particle.
  17668. */
  17669. size: number;
  17670. /**
  17671. * The current scale of the particle.
  17672. */
  17673. scale: Vector2;
  17674. /**
  17675. * The current angle of the particle.
  17676. */
  17677. angle: number;
  17678. /**
  17679. * Defines how fast is the angle changing.
  17680. */
  17681. angularSpeed: number;
  17682. /**
  17683. * Defines the cell index used by the particle to be rendered from a sprite.
  17684. */
  17685. cellIndex: number;
  17686. /**
  17687. * The information required to support color remapping
  17688. */
  17689. remapData: Vector4;
  17690. /** @hidden */
  17691. _randomCellOffset?: number;
  17692. /** @hidden */
  17693. _initialDirection: Nullable<Vector3>;
  17694. /** @hidden */
  17695. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17696. /** @hidden */
  17697. _initialStartSpriteCellID: number;
  17698. /** @hidden */
  17699. _initialEndSpriteCellID: number;
  17700. /** @hidden */
  17701. _currentColorGradient: Nullable<ColorGradient>;
  17702. /** @hidden */
  17703. _currentColor1: Color4;
  17704. /** @hidden */
  17705. _currentColor2: Color4;
  17706. /** @hidden */
  17707. _currentSizeGradient: Nullable<FactorGradient>;
  17708. /** @hidden */
  17709. _currentSize1: number;
  17710. /** @hidden */
  17711. _currentSize2: number;
  17712. /** @hidden */
  17713. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17714. /** @hidden */
  17715. _currentAngularSpeed1: number;
  17716. /** @hidden */
  17717. _currentAngularSpeed2: number;
  17718. /** @hidden */
  17719. _currentVelocityGradient: Nullable<FactorGradient>;
  17720. /** @hidden */
  17721. _currentVelocity1: number;
  17722. /** @hidden */
  17723. _currentVelocity2: number;
  17724. /** @hidden */
  17725. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17726. /** @hidden */
  17727. _currentLimitVelocity1: number;
  17728. /** @hidden */
  17729. _currentLimitVelocity2: number;
  17730. /** @hidden */
  17731. _currentDragGradient: Nullable<FactorGradient>;
  17732. /** @hidden */
  17733. _currentDrag1: number;
  17734. /** @hidden */
  17735. _currentDrag2: number;
  17736. /** @hidden */
  17737. _randomNoiseCoordinates1: Vector3;
  17738. /** @hidden */
  17739. _randomNoiseCoordinates2: Vector3;
  17740. /**
  17741. * Creates a new instance Particle
  17742. * @param particleSystem the particle system the particle belongs to
  17743. */
  17744. constructor(
  17745. /**
  17746. * The particle system the particle belongs to.
  17747. */
  17748. particleSystem: ParticleSystem);
  17749. private updateCellInfoFromSystem;
  17750. /**
  17751. * Defines how the sprite cell index is updated for the particle
  17752. */
  17753. updateCellIndex(): void;
  17754. /** @hidden */
  17755. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17756. /** @hidden */
  17757. _inheritParticleInfoToSubEmitters(): void;
  17758. /** @hidden */
  17759. _reset(): void;
  17760. /**
  17761. * Copy the properties of particle to another one.
  17762. * @param other the particle to copy the information to.
  17763. */
  17764. copyTo(other: Particle): void;
  17765. }
  17766. }
  17767. declare module BABYLON {
  17768. /**
  17769. * Particle emitter represents a volume emitting particles.
  17770. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17771. */
  17772. export interface IParticleEmitterType {
  17773. /**
  17774. * Called by the particle System when the direction is computed for the created particle.
  17775. * @param worldMatrix is the world matrix of the particle system
  17776. * @param directionToUpdate is the direction vector to update with the result
  17777. * @param particle is the particle we are computed the direction for
  17778. */
  17779. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17780. /**
  17781. * Called by the particle System when the position is computed for the created particle.
  17782. * @param worldMatrix is the world matrix of the particle system
  17783. * @param positionToUpdate is the position vector to update with the result
  17784. * @param particle is the particle we are computed the position for
  17785. */
  17786. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17787. /**
  17788. * Clones the current emitter and returns a copy of it
  17789. * @returns the new emitter
  17790. */
  17791. clone(): IParticleEmitterType;
  17792. /**
  17793. * Called by the GPUParticleSystem to setup the update shader
  17794. * @param effect defines the update shader
  17795. */
  17796. applyToShader(effect: Effect): void;
  17797. /**
  17798. * Returns a string to use to update the GPU particles update shader
  17799. * @returns the effect defines string
  17800. */
  17801. getEffectDefines(): string;
  17802. /**
  17803. * Returns a string representing the class name
  17804. * @returns a string containing the class name
  17805. */
  17806. getClassName(): string;
  17807. /**
  17808. * Serializes the particle system to a JSON object.
  17809. * @returns the JSON object
  17810. */
  17811. serialize(): any;
  17812. /**
  17813. * Parse properties from a JSON object
  17814. * @param serializationObject defines the JSON object
  17815. */
  17816. parse(serializationObject: any): void;
  17817. }
  17818. }
  17819. declare module BABYLON {
  17820. /**
  17821. * Particle emitter emitting particles from the inside of a box.
  17822. * It emits the particles randomly between 2 given directions.
  17823. */
  17824. export class BoxParticleEmitter implements IParticleEmitterType {
  17825. /**
  17826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17827. */
  17828. direction1: Vector3;
  17829. /**
  17830. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17831. */
  17832. direction2: Vector3;
  17833. /**
  17834. * 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.
  17835. */
  17836. minEmitBox: Vector3;
  17837. /**
  17838. * 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.
  17839. */
  17840. maxEmitBox: Vector3;
  17841. /**
  17842. * Creates a new instance BoxParticleEmitter
  17843. */
  17844. constructor();
  17845. /**
  17846. * Called by the particle System when the direction is computed for the created particle.
  17847. * @param worldMatrix is the world matrix of the particle system
  17848. * @param directionToUpdate is the direction vector to update with the result
  17849. * @param particle is the particle we are computed the direction for
  17850. */
  17851. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17852. /**
  17853. * Called by the particle System when the position is computed for the created particle.
  17854. * @param worldMatrix is the world matrix of the particle system
  17855. * @param positionToUpdate is the position vector to update with the result
  17856. * @param particle is the particle we are computed the position for
  17857. */
  17858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17859. /**
  17860. * Clones the current emitter and returns a copy of it
  17861. * @returns the new emitter
  17862. */
  17863. clone(): BoxParticleEmitter;
  17864. /**
  17865. * Called by the GPUParticleSystem to setup the update shader
  17866. * @param effect defines the update shader
  17867. */
  17868. applyToShader(effect: Effect): void;
  17869. /**
  17870. * Returns a string to use to update the GPU particles update shader
  17871. * @returns a string containng the defines string
  17872. */
  17873. getEffectDefines(): string;
  17874. /**
  17875. * Returns the string "BoxParticleEmitter"
  17876. * @returns a string containing the class name
  17877. */
  17878. getClassName(): string;
  17879. /**
  17880. * Serializes the particle system to a JSON object.
  17881. * @returns the JSON object
  17882. */
  17883. serialize(): any;
  17884. /**
  17885. * Parse properties from a JSON object
  17886. * @param serializationObject defines the JSON object
  17887. */
  17888. parse(serializationObject: any): void;
  17889. }
  17890. }
  17891. declare module BABYLON {
  17892. /**
  17893. * Particle emitter emitting particles from the inside of a cone.
  17894. * It emits the particles alongside the cone volume from the base to the particle.
  17895. * The emission direction might be randomized.
  17896. */
  17897. export class ConeParticleEmitter implements IParticleEmitterType {
  17898. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17899. directionRandomizer: number;
  17900. private _radius;
  17901. private _angle;
  17902. private _height;
  17903. /**
  17904. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17905. */
  17906. radiusRange: number;
  17907. /**
  17908. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17909. */
  17910. heightRange: number;
  17911. /**
  17912. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17913. */
  17914. emitFromSpawnPointOnly: boolean;
  17915. /**
  17916. * Gets or sets the radius of the emission cone
  17917. */
  17918. radius: number;
  17919. /**
  17920. * Gets or sets the angle of the emission cone
  17921. */
  17922. angle: number;
  17923. private _buildHeight;
  17924. /**
  17925. * Creates a new instance ConeParticleEmitter
  17926. * @param radius the radius of the emission cone (1 by default)
  17927. * @param angle the cone base angle (PI by default)
  17928. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17929. */
  17930. constructor(radius?: number, angle?: number,
  17931. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17932. directionRandomizer?: number);
  17933. /**
  17934. * Called by the particle System when the direction is computed for the created particle.
  17935. * @param worldMatrix is the world matrix of the particle system
  17936. * @param directionToUpdate is the direction vector to update with the result
  17937. * @param particle is the particle we are computed the direction for
  17938. */
  17939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17940. /**
  17941. * Called by the particle System when the position is computed for the created particle.
  17942. * @param worldMatrix is the world matrix of the particle system
  17943. * @param positionToUpdate is the position vector to update with the result
  17944. * @param particle is the particle we are computed the position for
  17945. */
  17946. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17947. /**
  17948. * Clones the current emitter and returns a copy of it
  17949. * @returns the new emitter
  17950. */
  17951. clone(): ConeParticleEmitter;
  17952. /**
  17953. * Called by the GPUParticleSystem to setup the update shader
  17954. * @param effect defines the update shader
  17955. */
  17956. applyToShader(effect: Effect): void;
  17957. /**
  17958. * Returns a string to use to update the GPU particles update shader
  17959. * @returns a string containng the defines string
  17960. */
  17961. getEffectDefines(): string;
  17962. /**
  17963. * Returns the string "ConeParticleEmitter"
  17964. * @returns a string containing the class name
  17965. */
  17966. getClassName(): string;
  17967. /**
  17968. * Serializes the particle system to a JSON object.
  17969. * @returns the JSON object
  17970. */
  17971. serialize(): any;
  17972. /**
  17973. * Parse properties from a JSON object
  17974. * @param serializationObject defines the JSON object
  17975. */
  17976. parse(serializationObject: any): void;
  17977. }
  17978. }
  17979. declare module BABYLON {
  17980. /**
  17981. * Particle emitter emitting particles from the inside of a cylinder.
  17982. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17983. */
  17984. export class CylinderParticleEmitter implements IParticleEmitterType {
  17985. /**
  17986. * The radius of the emission cylinder.
  17987. */
  17988. radius: number;
  17989. /**
  17990. * The height of the emission cylinder.
  17991. */
  17992. height: number;
  17993. /**
  17994. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17995. */
  17996. radiusRange: number;
  17997. /**
  17998. * How much to randomize the particle direction [0-1].
  17999. */
  18000. directionRandomizer: number;
  18001. /**
  18002. * Creates a new instance CylinderParticleEmitter
  18003. * @param radius the radius of the emission cylinder (1 by default)
  18004. * @param height the height of the emission cylinder (1 by default)
  18005. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18006. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18007. */
  18008. constructor(
  18009. /**
  18010. * The radius of the emission cylinder.
  18011. */
  18012. radius?: number,
  18013. /**
  18014. * The height of the emission cylinder.
  18015. */
  18016. height?: number,
  18017. /**
  18018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18019. */
  18020. radiusRange?: number,
  18021. /**
  18022. * How much to randomize the particle direction [0-1].
  18023. */
  18024. directionRandomizer?: number);
  18025. /**
  18026. * Called by the particle System when the direction is computed for the created particle.
  18027. * @param worldMatrix is the world matrix of the particle system
  18028. * @param directionToUpdate is the direction vector to update with the result
  18029. * @param particle is the particle we are computed the direction for
  18030. */
  18031. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18032. /**
  18033. * Called by the particle System when the position is computed for the created particle.
  18034. * @param worldMatrix is the world matrix of the particle system
  18035. * @param positionToUpdate is the position vector to update with the result
  18036. * @param particle is the particle we are computed the position for
  18037. */
  18038. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18039. /**
  18040. * Clones the current emitter and returns a copy of it
  18041. * @returns the new emitter
  18042. */
  18043. clone(): CylinderParticleEmitter;
  18044. /**
  18045. * Called by the GPUParticleSystem to setup the update shader
  18046. * @param effect defines the update shader
  18047. */
  18048. applyToShader(effect: Effect): void;
  18049. /**
  18050. * Returns a string to use to update the GPU particles update shader
  18051. * @returns a string containng the defines string
  18052. */
  18053. getEffectDefines(): string;
  18054. /**
  18055. * Returns the string "CylinderParticleEmitter"
  18056. * @returns a string containing the class name
  18057. */
  18058. getClassName(): string;
  18059. /**
  18060. * Serializes the particle system to a JSON object.
  18061. * @returns the JSON object
  18062. */
  18063. serialize(): any;
  18064. /**
  18065. * Parse properties from a JSON object
  18066. * @param serializationObject defines the JSON object
  18067. */
  18068. parse(serializationObject: any): void;
  18069. }
  18070. /**
  18071. * Particle emitter emitting particles from the inside of a cylinder.
  18072. * It emits the particles randomly between two vectors.
  18073. */
  18074. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18075. /**
  18076. * The min limit of the emission direction.
  18077. */
  18078. direction1: Vector3;
  18079. /**
  18080. * The max limit of the emission direction.
  18081. */
  18082. direction2: Vector3;
  18083. /**
  18084. * Creates a new instance CylinderDirectedParticleEmitter
  18085. * @param radius the radius of the emission cylinder (1 by default)
  18086. * @param height the height of the emission cylinder (1 by default)
  18087. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18088. * @param direction1 the min limit of the emission direction (up vector by default)
  18089. * @param direction2 the max limit of the emission direction (up vector by default)
  18090. */
  18091. constructor(radius?: number, height?: number, radiusRange?: number,
  18092. /**
  18093. * The min limit of the emission direction.
  18094. */
  18095. direction1?: Vector3,
  18096. /**
  18097. * The max limit of the emission direction.
  18098. */
  18099. direction2?: Vector3);
  18100. /**
  18101. * Called by the particle System when the direction is computed for the created particle.
  18102. * @param worldMatrix is the world matrix of the particle system
  18103. * @param directionToUpdate is the direction vector to update with the result
  18104. * @param particle is the particle we are computed the direction for
  18105. */
  18106. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18107. /**
  18108. * Clones the current emitter and returns a copy of it
  18109. * @returns the new emitter
  18110. */
  18111. clone(): CylinderDirectedParticleEmitter;
  18112. /**
  18113. * Called by the GPUParticleSystem to setup the update shader
  18114. * @param effect defines the update shader
  18115. */
  18116. applyToShader(effect: Effect): void;
  18117. /**
  18118. * Returns a string to use to update the GPU particles update shader
  18119. * @returns a string containng the defines string
  18120. */
  18121. getEffectDefines(): string;
  18122. /**
  18123. * Returns the string "CylinderDirectedParticleEmitter"
  18124. * @returns a string containing the class name
  18125. */
  18126. getClassName(): string;
  18127. /**
  18128. * Serializes the particle system to a JSON object.
  18129. * @returns the JSON object
  18130. */
  18131. serialize(): any;
  18132. /**
  18133. * Parse properties from a JSON object
  18134. * @param serializationObject defines the JSON object
  18135. */
  18136. parse(serializationObject: any): void;
  18137. }
  18138. }
  18139. declare module BABYLON {
  18140. /**
  18141. * Particle emitter emitting particles from the inside of a hemisphere.
  18142. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18143. */
  18144. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18145. /**
  18146. * The radius of the emission hemisphere.
  18147. */
  18148. radius: number;
  18149. /**
  18150. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18151. */
  18152. radiusRange: number;
  18153. /**
  18154. * How much to randomize the particle direction [0-1].
  18155. */
  18156. directionRandomizer: number;
  18157. /**
  18158. * Creates a new instance HemisphericParticleEmitter
  18159. * @param radius the radius of the emission hemisphere (1 by default)
  18160. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18161. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18162. */
  18163. constructor(
  18164. /**
  18165. * The radius of the emission hemisphere.
  18166. */
  18167. radius?: number,
  18168. /**
  18169. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18170. */
  18171. radiusRange?: number,
  18172. /**
  18173. * How much to randomize the particle direction [0-1].
  18174. */
  18175. directionRandomizer?: number);
  18176. /**
  18177. * Called by the particle System when the direction is computed for the created particle.
  18178. * @param worldMatrix is the world matrix of the particle system
  18179. * @param directionToUpdate is the direction vector to update with the result
  18180. * @param particle is the particle we are computed the direction for
  18181. */
  18182. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18183. /**
  18184. * Called by the particle System when the position is computed for the created particle.
  18185. * @param worldMatrix is the world matrix of the particle system
  18186. * @param positionToUpdate is the position vector to update with the result
  18187. * @param particle is the particle we are computed the position for
  18188. */
  18189. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18190. /**
  18191. * Clones the current emitter and returns a copy of it
  18192. * @returns the new emitter
  18193. */
  18194. clone(): HemisphericParticleEmitter;
  18195. /**
  18196. * Called by the GPUParticleSystem to setup the update shader
  18197. * @param effect defines the update shader
  18198. */
  18199. applyToShader(effect: Effect): void;
  18200. /**
  18201. * Returns a string to use to update the GPU particles update shader
  18202. * @returns a string containng the defines string
  18203. */
  18204. getEffectDefines(): string;
  18205. /**
  18206. * Returns the string "HemisphericParticleEmitter"
  18207. * @returns a string containing the class name
  18208. */
  18209. getClassName(): string;
  18210. /**
  18211. * Serializes the particle system to a JSON object.
  18212. * @returns the JSON object
  18213. */
  18214. serialize(): any;
  18215. /**
  18216. * Parse properties from a JSON object
  18217. * @param serializationObject defines the JSON object
  18218. */
  18219. parse(serializationObject: any): void;
  18220. }
  18221. }
  18222. declare module BABYLON {
  18223. /**
  18224. * Particle emitter emitting particles from a point.
  18225. * It emits the particles randomly between 2 given directions.
  18226. */
  18227. export class PointParticleEmitter implements IParticleEmitterType {
  18228. /**
  18229. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18230. */
  18231. direction1: Vector3;
  18232. /**
  18233. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18234. */
  18235. direction2: Vector3;
  18236. /**
  18237. * Creates a new instance PointParticleEmitter
  18238. */
  18239. constructor();
  18240. /**
  18241. * Called by the particle System when the direction is computed for the created particle.
  18242. * @param worldMatrix is the world matrix of the particle system
  18243. * @param directionToUpdate is the direction vector to update with the result
  18244. * @param particle is the particle we are computed the direction for
  18245. */
  18246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18247. /**
  18248. * Called by the particle System when the position is computed for the created particle.
  18249. * @param worldMatrix is the world matrix of the particle system
  18250. * @param positionToUpdate is the position vector to update with the result
  18251. * @param particle is the particle we are computed the position for
  18252. */
  18253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18254. /**
  18255. * Clones the current emitter and returns a copy of it
  18256. * @returns the new emitter
  18257. */
  18258. clone(): PointParticleEmitter;
  18259. /**
  18260. * Called by the GPUParticleSystem to setup the update shader
  18261. * @param effect defines the update shader
  18262. */
  18263. applyToShader(effect: Effect): void;
  18264. /**
  18265. * Returns a string to use to update the GPU particles update shader
  18266. * @returns a string containng the defines string
  18267. */
  18268. getEffectDefines(): string;
  18269. /**
  18270. * Returns the string "PointParticleEmitter"
  18271. * @returns a string containing the class name
  18272. */
  18273. getClassName(): string;
  18274. /**
  18275. * Serializes the particle system to a JSON object.
  18276. * @returns the JSON object
  18277. */
  18278. serialize(): any;
  18279. /**
  18280. * Parse properties from a JSON object
  18281. * @param serializationObject defines the JSON object
  18282. */
  18283. parse(serializationObject: any): void;
  18284. }
  18285. }
  18286. declare module BABYLON {
  18287. /**
  18288. * Particle emitter emitting particles from the inside of a sphere.
  18289. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18290. */
  18291. export class SphereParticleEmitter implements IParticleEmitterType {
  18292. /**
  18293. * The radius of the emission sphere.
  18294. */
  18295. radius: number;
  18296. /**
  18297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18298. */
  18299. radiusRange: number;
  18300. /**
  18301. * How much to randomize the particle direction [0-1].
  18302. */
  18303. directionRandomizer: number;
  18304. /**
  18305. * Creates a new instance SphereParticleEmitter
  18306. * @param radius the radius of the emission sphere (1 by default)
  18307. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18308. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18309. */
  18310. constructor(
  18311. /**
  18312. * The radius of the emission sphere.
  18313. */
  18314. radius?: number,
  18315. /**
  18316. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18317. */
  18318. radiusRange?: number,
  18319. /**
  18320. * How much to randomize the particle direction [0-1].
  18321. */
  18322. directionRandomizer?: number);
  18323. /**
  18324. * Called by the particle System when the direction is computed for the created particle.
  18325. * @param worldMatrix is the world matrix of the particle system
  18326. * @param directionToUpdate is the direction vector to update with the result
  18327. * @param particle is the particle we are computed the direction for
  18328. */
  18329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18330. /**
  18331. * Called by the particle System when the position is computed for the created particle.
  18332. * @param worldMatrix is the world matrix of the particle system
  18333. * @param positionToUpdate is the position vector to update with the result
  18334. * @param particle is the particle we are computed the position for
  18335. */
  18336. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18337. /**
  18338. * Clones the current emitter and returns a copy of it
  18339. * @returns the new emitter
  18340. */
  18341. clone(): SphereParticleEmitter;
  18342. /**
  18343. * Called by the GPUParticleSystem to setup the update shader
  18344. * @param effect defines the update shader
  18345. */
  18346. applyToShader(effect: Effect): void;
  18347. /**
  18348. * Returns a string to use to update the GPU particles update shader
  18349. * @returns a string containng the defines string
  18350. */
  18351. getEffectDefines(): string;
  18352. /**
  18353. * Returns the string "SphereParticleEmitter"
  18354. * @returns a string containing the class name
  18355. */
  18356. getClassName(): string;
  18357. /**
  18358. * Serializes the particle system to a JSON object.
  18359. * @returns the JSON object
  18360. */
  18361. serialize(): any;
  18362. /**
  18363. * Parse properties from a JSON object
  18364. * @param serializationObject defines the JSON object
  18365. */
  18366. parse(serializationObject: any): void;
  18367. }
  18368. /**
  18369. * Particle emitter emitting particles from the inside of a sphere.
  18370. * It emits the particles randomly between two vectors.
  18371. */
  18372. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18373. /**
  18374. * The min limit of the emission direction.
  18375. */
  18376. direction1: Vector3;
  18377. /**
  18378. * The max limit of the emission direction.
  18379. */
  18380. direction2: Vector3;
  18381. /**
  18382. * Creates a new instance SphereDirectedParticleEmitter
  18383. * @param radius the radius of the emission sphere (1 by default)
  18384. * @param direction1 the min limit of the emission direction (up vector by default)
  18385. * @param direction2 the max limit of the emission direction (up vector by default)
  18386. */
  18387. constructor(radius?: number,
  18388. /**
  18389. * The min limit of the emission direction.
  18390. */
  18391. direction1?: Vector3,
  18392. /**
  18393. * The max limit of the emission direction.
  18394. */
  18395. direction2?: Vector3);
  18396. /**
  18397. * Called by the particle System when the direction is computed for the created particle.
  18398. * @param worldMatrix is the world matrix of the particle system
  18399. * @param directionToUpdate is the direction vector to update with the result
  18400. * @param particle is the particle we are computed the direction for
  18401. */
  18402. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18403. /**
  18404. * Clones the current emitter and returns a copy of it
  18405. * @returns the new emitter
  18406. */
  18407. clone(): SphereDirectedParticleEmitter;
  18408. /**
  18409. * Called by the GPUParticleSystem to setup the update shader
  18410. * @param effect defines the update shader
  18411. */
  18412. applyToShader(effect: Effect): void;
  18413. /**
  18414. * Returns a string to use to update the GPU particles update shader
  18415. * @returns a string containng the defines string
  18416. */
  18417. getEffectDefines(): string;
  18418. /**
  18419. * Returns the string "SphereDirectedParticleEmitter"
  18420. * @returns a string containing the class name
  18421. */
  18422. getClassName(): string;
  18423. /**
  18424. * Serializes the particle system to a JSON object.
  18425. * @returns the JSON object
  18426. */
  18427. serialize(): any;
  18428. /**
  18429. * Parse properties from a JSON object
  18430. * @param serializationObject defines the JSON object
  18431. */
  18432. parse(serializationObject: any): void;
  18433. }
  18434. }
  18435. declare module BABYLON {
  18436. /**
  18437. * Interface representing a particle system in Babylon.js.
  18438. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18439. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18440. */
  18441. export interface IParticleSystem {
  18442. /**
  18443. * List of animations used by the particle system.
  18444. */
  18445. animations: Animation[];
  18446. /**
  18447. * The id of the Particle system.
  18448. */
  18449. id: string;
  18450. /**
  18451. * The name of the Particle system.
  18452. */
  18453. name: string;
  18454. /**
  18455. * The emitter represents the Mesh or position we are attaching the particle system to.
  18456. */
  18457. emitter: Nullable<AbstractMesh | Vector3>;
  18458. /**
  18459. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18460. */
  18461. isBillboardBased: boolean;
  18462. /**
  18463. * The rendering group used by the Particle system to chose when to render.
  18464. */
  18465. renderingGroupId: number;
  18466. /**
  18467. * The layer mask we are rendering the particles through.
  18468. */
  18469. layerMask: number;
  18470. /**
  18471. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18472. */
  18473. updateSpeed: number;
  18474. /**
  18475. * The amount of time the particle system is running (depends of the overall update speed).
  18476. */
  18477. targetStopDuration: number;
  18478. /**
  18479. * The texture used to render each particle. (this can be a spritesheet)
  18480. */
  18481. particleTexture: Nullable<Texture>;
  18482. /**
  18483. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18484. */
  18485. blendMode: number;
  18486. /**
  18487. * Minimum life time of emitting particles.
  18488. */
  18489. minLifeTime: number;
  18490. /**
  18491. * Maximum life time of emitting particles.
  18492. */
  18493. maxLifeTime: number;
  18494. /**
  18495. * Minimum Size of emitting particles.
  18496. */
  18497. minSize: number;
  18498. /**
  18499. * Maximum Size of emitting particles.
  18500. */
  18501. maxSize: number;
  18502. /**
  18503. * Minimum scale of emitting particles on X axis.
  18504. */
  18505. minScaleX: number;
  18506. /**
  18507. * Maximum scale of emitting particles on X axis.
  18508. */
  18509. maxScaleX: number;
  18510. /**
  18511. * Minimum scale of emitting particles on Y axis.
  18512. */
  18513. minScaleY: number;
  18514. /**
  18515. * Maximum scale of emitting particles on Y axis.
  18516. */
  18517. maxScaleY: number;
  18518. /**
  18519. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18520. */
  18521. color1: Color4;
  18522. /**
  18523. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18524. */
  18525. color2: Color4;
  18526. /**
  18527. * Color the particle will have at the end of its lifetime.
  18528. */
  18529. colorDead: Color4;
  18530. /**
  18531. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18532. */
  18533. emitRate: number;
  18534. /**
  18535. * You can use gravity if you want to give an orientation to your particles.
  18536. */
  18537. gravity: Vector3;
  18538. /**
  18539. * Minimum power of emitting particles.
  18540. */
  18541. minEmitPower: number;
  18542. /**
  18543. * Maximum power of emitting particles.
  18544. */
  18545. maxEmitPower: number;
  18546. /**
  18547. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18548. */
  18549. minAngularSpeed: number;
  18550. /**
  18551. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18552. */
  18553. maxAngularSpeed: number;
  18554. /**
  18555. * Gets or sets the minimal initial rotation in radians.
  18556. */
  18557. minInitialRotation: number;
  18558. /**
  18559. * Gets or sets the maximal initial rotation in radians.
  18560. */
  18561. maxInitialRotation: number;
  18562. /**
  18563. * The particle emitter type defines the emitter used by the particle system.
  18564. * It can be for example box, sphere, or cone...
  18565. */
  18566. particleEmitterType: Nullable<IParticleEmitterType>;
  18567. /**
  18568. * Defines the delay in milliseconds before starting the system (0 by default)
  18569. */
  18570. startDelay: number;
  18571. /**
  18572. * 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
  18573. */
  18574. preWarmCycles: number;
  18575. /**
  18576. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18577. */
  18578. preWarmStepOffset: number;
  18579. /**
  18580. * 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)
  18581. */
  18582. spriteCellChangeSpeed: number;
  18583. /**
  18584. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18585. */
  18586. startSpriteCellID: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18589. */
  18590. endSpriteCellID: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18593. */
  18594. spriteCellWidth: number;
  18595. /**
  18596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18597. */
  18598. spriteCellHeight: number;
  18599. /**
  18600. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18601. */
  18602. spriteRandomStartCell: boolean;
  18603. /**
  18604. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18605. */
  18606. isAnimationSheetEnabled: boolean;
  18607. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18608. translationPivot: Vector2;
  18609. /**
  18610. * Gets or sets a texture used to add random noise to particle positions
  18611. */
  18612. noiseTexture: Nullable<BaseTexture>;
  18613. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18614. noiseStrength: Vector3;
  18615. /**
  18616. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18617. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18618. */
  18619. billboardMode: number;
  18620. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18621. limitVelocityDamping: number;
  18622. /**
  18623. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18624. */
  18625. beginAnimationOnStart: boolean;
  18626. /**
  18627. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18628. */
  18629. beginAnimationFrom: number;
  18630. /**
  18631. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationTo: number;
  18634. /**
  18635. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18636. */
  18637. beginAnimationLoop: boolean;
  18638. /**
  18639. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18640. */
  18641. disposeOnStop: boolean;
  18642. /**
  18643. * Gets the maximum number of particles active at the same time.
  18644. * @returns The max number of active particles.
  18645. */
  18646. getCapacity(): number;
  18647. /**
  18648. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18649. * @returns True if it has been started, otherwise false.
  18650. */
  18651. isStarted(): boolean;
  18652. /**
  18653. * Animates the particle system for this frame.
  18654. */
  18655. animate(): void;
  18656. /**
  18657. * Renders the particle system in its current state.
  18658. * @returns the current number of particles
  18659. */
  18660. render(): number;
  18661. /**
  18662. * Dispose the particle system and frees its associated resources.
  18663. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18664. */
  18665. dispose(disposeTexture?: boolean): void;
  18666. /**
  18667. * Clones the particle system.
  18668. * @param name The name of the cloned object
  18669. * @param newEmitter The new emitter to use
  18670. * @returns the cloned particle system
  18671. */
  18672. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18673. /**
  18674. * Serializes the particle system to a JSON object.
  18675. * @returns the JSON object
  18676. */
  18677. serialize(): any;
  18678. /**
  18679. * Rebuild the particle system
  18680. */
  18681. rebuild(): void;
  18682. /**
  18683. * Starts the particle system and begins to emit
  18684. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18685. */
  18686. start(delay?: number): void;
  18687. /**
  18688. * Stops the particle system.
  18689. */
  18690. stop(): void;
  18691. /**
  18692. * Remove all active particles
  18693. */
  18694. reset(): void;
  18695. /**
  18696. * Is this system ready to be used/rendered
  18697. * @return true if the system is ready
  18698. */
  18699. isReady(): boolean;
  18700. /**
  18701. * Adds a new color gradient
  18702. * @param gradient defines the gradient to use (between 0 and 1)
  18703. * @param color1 defines the color to affect to the specified gradient
  18704. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18705. * @returns the current particle system
  18706. */
  18707. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18708. /**
  18709. * Remove a specific color gradient
  18710. * @param gradient defines the gradient to remove
  18711. * @returns the current particle system
  18712. */
  18713. removeColorGradient(gradient: number): IParticleSystem;
  18714. /**
  18715. * Adds a new size gradient
  18716. * @param gradient defines the gradient to use (between 0 and 1)
  18717. * @param factor defines the size factor to affect to the specified gradient
  18718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18719. * @returns the current particle system
  18720. */
  18721. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18722. /**
  18723. * Remove a specific size gradient
  18724. * @param gradient defines the gradient to remove
  18725. * @returns the current particle system
  18726. */
  18727. removeSizeGradient(gradient: number): IParticleSystem;
  18728. /**
  18729. * Gets the current list of color gradients.
  18730. * You must use addColorGradient and removeColorGradient to udpate this list
  18731. * @returns the list of color gradients
  18732. */
  18733. getColorGradients(): Nullable<Array<ColorGradient>>;
  18734. /**
  18735. * Gets the current list of size gradients.
  18736. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18737. * @returns the list of size gradients
  18738. */
  18739. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18740. /**
  18741. * Gets the current list of angular speed gradients.
  18742. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18743. * @returns the list of angular speed gradients
  18744. */
  18745. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18746. /**
  18747. * Adds a new angular speed gradient
  18748. * @param gradient defines the gradient to use (between 0 and 1)
  18749. * @param factor defines the angular speed to affect to the specified gradient
  18750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18751. * @returns the current particle system
  18752. */
  18753. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18754. /**
  18755. * Remove a specific angular speed gradient
  18756. * @param gradient defines the gradient to remove
  18757. * @returns the current particle system
  18758. */
  18759. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18760. /**
  18761. * Gets the current list of velocity gradients.
  18762. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18763. * @returns the list of velocity gradients
  18764. */
  18765. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18766. /**
  18767. * Adds a new velocity gradient
  18768. * @param gradient defines the gradient to use (between 0 and 1)
  18769. * @param factor defines the velocity to affect to the specified gradient
  18770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18771. * @returns the current particle system
  18772. */
  18773. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18774. /**
  18775. * Remove a specific velocity gradient
  18776. * @param gradient defines the gradient to remove
  18777. * @returns the current particle system
  18778. */
  18779. removeVelocityGradient(gradient: number): IParticleSystem;
  18780. /**
  18781. * Gets the current list of limit velocity gradients.
  18782. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18783. * @returns the list of limit velocity gradients
  18784. */
  18785. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18786. /**
  18787. * Adds a new limit velocity gradient
  18788. * @param gradient defines the gradient to use (between 0 and 1)
  18789. * @param factor defines the limit velocity to affect to the specified gradient
  18790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18791. * @returns the current particle system
  18792. */
  18793. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18794. /**
  18795. * Remove a specific limit velocity gradient
  18796. * @param gradient defines the gradient to remove
  18797. * @returns the current particle system
  18798. */
  18799. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18800. /**
  18801. * Adds a new drag gradient
  18802. * @param gradient defines the gradient to use (between 0 and 1)
  18803. * @param factor defines the drag to affect to the specified gradient
  18804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18805. * @returns the current particle system
  18806. */
  18807. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18808. /**
  18809. * Remove a specific drag gradient
  18810. * @param gradient defines the gradient to remove
  18811. * @returns the current particle system
  18812. */
  18813. removeDragGradient(gradient: number): IParticleSystem;
  18814. /**
  18815. * Gets the current list of drag gradients.
  18816. * You must use addDragGradient and removeDragGradient to udpate this list
  18817. * @returns the list of drag gradients
  18818. */
  18819. getDragGradients(): Nullable<Array<FactorGradient>>;
  18820. /**
  18821. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18822. * @param gradient defines the gradient to use (between 0 and 1)
  18823. * @param factor defines the emit rate to affect to the specified gradient
  18824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18825. * @returns the current particle system
  18826. */
  18827. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18828. /**
  18829. * Remove a specific emit rate gradient
  18830. * @param gradient defines the gradient to remove
  18831. * @returns the current particle system
  18832. */
  18833. removeEmitRateGradient(gradient: number): IParticleSystem;
  18834. /**
  18835. * Gets the current list of emit rate gradients.
  18836. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18837. * @returns the list of emit rate gradients
  18838. */
  18839. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18840. /**
  18841. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18842. * @param gradient defines the gradient to use (between 0 and 1)
  18843. * @param factor defines the start size to affect to the specified gradient
  18844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18845. * @returns the current particle system
  18846. */
  18847. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18848. /**
  18849. * Remove a specific start size gradient
  18850. * @param gradient defines the gradient to remove
  18851. * @returns the current particle system
  18852. */
  18853. removeStartSizeGradient(gradient: number): IParticleSystem;
  18854. /**
  18855. * Gets the current list of start size gradients.
  18856. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18857. * @returns the list of start size gradients
  18858. */
  18859. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18860. /**
  18861. * Adds a new life time gradient
  18862. * @param gradient defines the gradient to use (between 0 and 1)
  18863. * @param factor defines the life time factor to affect to the specified gradient
  18864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18865. * @returns the current particle system
  18866. */
  18867. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18868. /**
  18869. * Remove a specific life time gradient
  18870. * @param gradient defines the gradient to remove
  18871. * @returns the current particle system
  18872. */
  18873. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18874. /**
  18875. * Gets the current list of life time gradients.
  18876. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18877. * @returns the list of life time gradients
  18878. */
  18879. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18880. /**
  18881. * Gets the current list of color gradients.
  18882. * You must use addColorGradient and removeColorGradient to udpate this list
  18883. * @returns the list of color gradients
  18884. */
  18885. getColorGradients(): Nullable<Array<ColorGradient>>;
  18886. /**
  18887. * Adds a new ramp gradient used to remap particle colors
  18888. * @param gradient defines the gradient to use (between 0 and 1)
  18889. * @param color defines the color to affect to the specified gradient
  18890. * @returns the current particle system
  18891. */
  18892. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18893. /**
  18894. * Gets the current list of ramp gradients.
  18895. * You must use addRampGradient and removeRampGradient to udpate this list
  18896. * @returns the list of ramp gradients
  18897. */
  18898. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18899. /** Gets or sets a boolean indicating that ramp gradients must be used
  18900. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18901. */
  18902. useRampGradients: boolean;
  18903. /**
  18904. * Adds a new color remap gradient
  18905. * @param gradient defines the gradient to use (between 0 and 1)
  18906. * @param min defines the color remap minimal range
  18907. * @param max defines the color remap maximal range
  18908. * @returns the current particle system
  18909. */
  18910. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18911. /**
  18912. * Gets the current list of color remap gradients.
  18913. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18914. * @returns the list of color remap gradients
  18915. */
  18916. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18917. /**
  18918. * Adds a new alpha remap gradient
  18919. * @param gradient defines the gradient to use (between 0 and 1)
  18920. * @param min defines the alpha remap minimal range
  18921. * @param max defines the alpha remap maximal range
  18922. * @returns the current particle system
  18923. */
  18924. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18925. /**
  18926. * Gets the current list of alpha remap gradients.
  18927. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18928. * @returns the list of alpha remap gradients
  18929. */
  18930. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18931. /**
  18932. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18933. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18934. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18935. * @returns the emitter
  18936. */
  18937. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18938. /**
  18939. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18940. * @param radius The radius of the hemisphere to emit from
  18941. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18942. * @returns the emitter
  18943. */
  18944. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18945. /**
  18946. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18947. * @param radius The radius of the sphere to emit from
  18948. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18949. * @returns the emitter
  18950. */
  18951. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18952. /**
  18953. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18954. * @param radius The radius of the sphere to emit from
  18955. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18956. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18957. * @returns the emitter
  18958. */
  18959. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18960. /**
  18961. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18962. * @param radius The radius of the emission cylinder
  18963. * @param height The height of the emission cylinder
  18964. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18965. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18966. * @returns the emitter
  18967. */
  18968. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18969. /**
  18970. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18971. * @param radius The radius of the cylinder to emit from
  18972. * @param height The height of the emission cylinder
  18973. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18974. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18975. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18976. * @returns the emitter
  18977. */
  18978. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18979. /**
  18980. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18981. * @param radius The radius of the cone to emit from
  18982. * @param angle The base angle of the cone
  18983. * @returns the emitter
  18984. */
  18985. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18986. /**
  18987. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18988. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18989. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18990. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18991. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18992. * @returns the emitter
  18993. */
  18994. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18995. /**
  18996. * Get hosting scene
  18997. * @returns the scene
  18998. */
  18999. getScene(): Scene;
  19000. }
  19001. }
  19002. declare module BABYLON {
  19003. /**
  19004. * Creates an instance based on a source mesh.
  19005. */
  19006. export class InstancedMesh extends AbstractMesh {
  19007. private _sourceMesh;
  19008. private _currentLOD;
  19009. /** @hidden */
  19010. _indexInSourceMeshInstanceArray: number;
  19011. constructor(name: string, source: Mesh);
  19012. /**
  19013. * Returns the string "InstancedMesh".
  19014. */
  19015. getClassName(): string;
  19016. /** Gets the list of lights affecting that mesh */
  19017. readonly lightSources: Light[];
  19018. _resyncLightSources(): void;
  19019. _resyncLightSource(light: Light): void;
  19020. _removeLightSource(light: Light, dispose: boolean): void;
  19021. /**
  19022. * If the source mesh receives shadows
  19023. */
  19024. readonly receiveShadows: boolean;
  19025. /**
  19026. * The material of the source mesh
  19027. */
  19028. readonly material: Nullable<Material>;
  19029. /**
  19030. * Visibility of the source mesh
  19031. */
  19032. readonly visibility: number;
  19033. /**
  19034. * Skeleton of the source mesh
  19035. */
  19036. readonly skeleton: Nullable<Skeleton>;
  19037. /**
  19038. * Rendering ground id of the source mesh
  19039. */
  19040. renderingGroupId: number;
  19041. /**
  19042. * Returns the total number of vertices (integer).
  19043. */
  19044. getTotalVertices(): number;
  19045. /**
  19046. * Returns a positive integer : the total number of indices in this mesh geometry.
  19047. * @returns the numner of indices or zero if the mesh has no geometry.
  19048. */
  19049. getTotalIndices(): number;
  19050. /**
  19051. * The source mesh of the instance
  19052. */
  19053. readonly sourceMesh: Mesh;
  19054. /**
  19055. * Is this node ready to be used/rendered
  19056. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19057. * @return {boolean} is it ready
  19058. */
  19059. isReady(completeCheck?: boolean): boolean;
  19060. /**
  19061. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19062. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19063. * @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.
  19064. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19065. */
  19066. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19067. /**
  19068. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19069. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19070. * The `data` are either a numeric array either a Float32Array.
  19071. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19072. * 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).
  19073. * Note that a new underlying VertexBuffer object is created each call.
  19074. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19075. *
  19076. * Possible `kind` values :
  19077. * - VertexBuffer.PositionKind
  19078. * - VertexBuffer.UVKind
  19079. * - VertexBuffer.UV2Kind
  19080. * - VertexBuffer.UV3Kind
  19081. * - VertexBuffer.UV4Kind
  19082. * - VertexBuffer.UV5Kind
  19083. * - VertexBuffer.UV6Kind
  19084. * - VertexBuffer.ColorKind
  19085. * - VertexBuffer.MatricesIndicesKind
  19086. * - VertexBuffer.MatricesIndicesExtraKind
  19087. * - VertexBuffer.MatricesWeightsKind
  19088. * - VertexBuffer.MatricesWeightsExtraKind
  19089. *
  19090. * Returns the Mesh.
  19091. */
  19092. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19093. /**
  19094. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19095. * If the mesh has no geometry, it is simply returned as it is.
  19096. * The `data` are either a numeric array either a Float32Array.
  19097. * No new underlying VertexBuffer object is created.
  19098. * 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.
  19099. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19100. *
  19101. * Possible `kind` values :
  19102. * - VertexBuffer.PositionKind
  19103. * - VertexBuffer.UVKind
  19104. * - VertexBuffer.UV2Kind
  19105. * - VertexBuffer.UV3Kind
  19106. * - VertexBuffer.UV4Kind
  19107. * - VertexBuffer.UV5Kind
  19108. * - VertexBuffer.UV6Kind
  19109. * - VertexBuffer.ColorKind
  19110. * - VertexBuffer.MatricesIndicesKind
  19111. * - VertexBuffer.MatricesIndicesExtraKind
  19112. * - VertexBuffer.MatricesWeightsKind
  19113. * - VertexBuffer.MatricesWeightsExtraKind
  19114. *
  19115. * Returns the Mesh.
  19116. */
  19117. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19118. /**
  19119. * Sets the mesh indices.
  19120. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19121. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19122. * This method creates a new index buffer each call.
  19123. * Returns the Mesh.
  19124. */
  19125. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19126. /**
  19127. * Boolean : True if the mesh owns the requested kind of data.
  19128. */
  19129. isVerticesDataPresent(kind: string): boolean;
  19130. /**
  19131. * Returns an array of indices (IndicesArray).
  19132. */
  19133. getIndices(): Nullable<IndicesArray>;
  19134. readonly _positions: Nullable<Vector3[]>;
  19135. /**
  19136. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19137. * This means the mesh underlying bounding box and sphere are recomputed.
  19138. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19139. * @returns the current mesh
  19140. */
  19141. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19142. /** @hidden */
  19143. _preActivate(): InstancedMesh;
  19144. /** @hidden */
  19145. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19146. /** @hidden */
  19147. _postActivate(): void;
  19148. getWorldMatrix(): Matrix;
  19149. readonly isAnInstance: boolean;
  19150. /**
  19151. * Returns the current associated LOD AbstractMesh.
  19152. */
  19153. getLOD(camera: Camera): AbstractMesh;
  19154. /** @hidden */
  19155. _syncSubMeshes(): InstancedMesh;
  19156. /** @hidden */
  19157. _generatePointsArray(): boolean;
  19158. /**
  19159. * Creates a new InstancedMesh from the current mesh.
  19160. * - name (string) : the cloned mesh name
  19161. * - newParent (optional Node) : the optional Node to parent the clone to.
  19162. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19163. *
  19164. * Returns the clone.
  19165. */
  19166. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19167. /**
  19168. * Disposes the InstancedMesh.
  19169. * Returns nothing.
  19170. */
  19171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19172. }
  19173. interface Mesh {
  19174. /**
  19175. * Register a custom buffer that will be instanced
  19176. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19177. * @param kind defines the buffer kind
  19178. * @param stride defines the stride in floats
  19179. */
  19180. registerInstancedBuffer(kind: string, stride: number): void;
  19181. /** @hidden */
  19182. _userInstancedBuffersStorage: {
  19183. data: {
  19184. [key: string]: Float32Array;
  19185. };
  19186. sizes: {
  19187. [key: string]: number;
  19188. };
  19189. vertexBuffers: {
  19190. [key: string]: Nullable<VertexBuffer>;
  19191. };
  19192. strides: {
  19193. [key: string]: number;
  19194. };
  19195. };
  19196. }
  19197. interface AbstractMesh {
  19198. /**
  19199. * Object used to store instanced buffers defined by user
  19200. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19201. */
  19202. instancedBuffers: {
  19203. [key: string]: any;
  19204. };
  19205. }
  19206. }
  19207. declare module BABYLON {
  19208. /**
  19209. * Defines the options associated with the creation of a shader material.
  19210. */
  19211. export interface IShaderMaterialOptions {
  19212. /**
  19213. * Does the material work in alpha blend mode
  19214. */
  19215. needAlphaBlending: boolean;
  19216. /**
  19217. * Does the material work in alpha test mode
  19218. */
  19219. needAlphaTesting: boolean;
  19220. /**
  19221. * The list of attribute names used in the shader
  19222. */
  19223. attributes: string[];
  19224. /**
  19225. * The list of unifrom names used in the shader
  19226. */
  19227. uniforms: string[];
  19228. /**
  19229. * The list of UBO names used in the shader
  19230. */
  19231. uniformBuffers: string[];
  19232. /**
  19233. * The list of sampler names used in the shader
  19234. */
  19235. samplers: string[];
  19236. /**
  19237. * The list of defines used in the shader
  19238. */
  19239. defines: string[];
  19240. }
  19241. /**
  19242. * 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.
  19243. *
  19244. * This returned material effects how the mesh will look based on the code in the shaders.
  19245. *
  19246. * @see http://doc.babylonjs.com/how_to/shader_material
  19247. */
  19248. export class ShaderMaterial extends Material {
  19249. private _shaderPath;
  19250. private _options;
  19251. private _textures;
  19252. private _textureArrays;
  19253. private _floats;
  19254. private _ints;
  19255. private _floatsArrays;
  19256. private _colors3;
  19257. private _colors3Arrays;
  19258. private _colors4;
  19259. private _colors4Arrays;
  19260. private _vectors2;
  19261. private _vectors3;
  19262. private _vectors4;
  19263. private _matrices;
  19264. private _matrixArrays;
  19265. private _matrices3x3;
  19266. private _matrices2x2;
  19267. private _vectors2Arrays;
  19268. private _vectors3Arrays;
  19269. private _vectors4Arrays;
  19270. private _cachedWorldViewMatrix;
  19271. private _cachedWorldViewProjectionMatrix;
  19272. private _renderId;
  19273. private _multiview;
  19274. /**
  19275. * Instantiate a new shader material.
  19276. * 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.
  19277. * This returned material effects how the mesh will look based on the code in the shaders.
  19278. * @see http://doc.babylonjs.com/how_to/shader_material
  19279. * @param name Define the name of the material in the scene
  19280. * @param scene Define the scene the material belongs to
  19281. * @param shaderPath Defines the route to the shader code in one of three ways:
  19282. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19283. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19284. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19285. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19286. * @param options Define the options used to create the shader
  19287. */
  19288. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19289. /**
  19290. * Gets the shader path used to define the shader code
  19291. * It can be modified to trigger a new compilation
  19292. */
  19293. /**
  19294. * Sets the shader path used to define the shader code
  19295. * It can be modified to trigger a new compilation
  19296. */
  19297. shaderPath: any;
  19298. /**
  19299. * Gets the options used to compile the shader.
  19300. * They can be modified to trigger a new compilation
  19301. */
  19302. readonly options: IShaderMaterialOptions;
  19303. /**
  19304. * Gets the current class name of the material e.g. "ShaderMaterial"
  19305. * Mainly use in serialization.
  19306. * @returns the class name
  19307. */
  19308. getClassName(): string;
  19309. /**
  19310. * Specifies if the material will require alpha blending
  19311. * @returns a boolean specifying if alpha blending is needed
  19312. */
  19313. needAlphaBlending(): boolean;
  19314. /**
  19315. * Specifies if this material should be rendered in alpha test mode
  19316. * @returns a boolean specifying if an alpha test is needed.
  19317. */
  19318. needAlphaTesting(): boolean;
  19319. private _checkUniform;
  19320. /**
  19321. * Set a texture in the shader.
  19322. * @param name Define the name of the uniform samplers as defined in the shader
  19323. * @param texture Define the texture to bind to this sampler
  19324. * @return the material itself allowing "fluent" like uniform updates
  19325. */
  19326. setTexture(name: string, texture: Texture): ShaderMaterial;
  19327. /**
  19328. * Set a texture array in the shader.
  19329. * @param name Define the name of the uniform sampler array as defined in the shader
  19330. * @param textures Define the list of textures to bind to this sampler
  19331. * @return the material itself allowing "fluent" like uniform updates
  19332. */
  19333. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19334. /**
  19335. * Set a float in the shader.
  19336. * @param name Define the name of the uniform as defined in the shader
  19337. * @param value Define the value to give to the uniform
  19338. * @return the material itself allowing "fluent" like uniform updates
  19339. */
  19340. setFloat(name: string, value: number): ShaderMaterial;
  19341. /**
  19342. * Set a int in the shader.
  19343. * @param name Define the name of the uniform as defined in the shader
  19344. * @param value Define the value to give to the uniform
  19345. * @return the material itself allowing "fluent" like uniform updates
  19346. */
  19347. setInt(name: string, value: number): ShaderMaterial;
  19348. /**
  19349. * Set an array of floats in the shader.
  19350. * @param name Define the name of the uniform as defined in the shader
  19351. * @param value Define the value to give to the uniform
  19352. * @return the material itself allowing "fluent" like uniform updates
  19353. */
  19354. setFloats(name: string, value: number[]): ShaderMaterial;
  19355. /**
  19356. * Set a vec3 in the shader from a Color3.
  19357. * @param name Define the name of the uniform as defined in the shader
  19358. * @param value Define the value to give to the uniform
  19359. * @return the material itself allowing "fluent" like uniform updates
  19360. */
  19361. setColor3(name: string, value: Color3): ShaderMaterial;
  19362. /**
  19363. * Set a vec3 array in the shader from a Color3 array.
  19364. * @param name Define the name of the uniform as defined in the shader
  19365. * @param value Define the value to give to the uniform
  19366. * @return the material itself allowing "fluent" like uniform updates
  19367. */
  19368. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19369. /**
  19370. * Set a vec4 in the shader from a Color4.
  19371. * @param name Define the name of the uniform as defined in the shader
  19372. * @param value Define the value to give to the uniform
  19373. * @return the material itself allowing "fluent" like uniform updates
  19374. */
  19375. setColor4(name: string, value: Color4): ShaderMaterial;
  19376. /**
  19377. * Set a vec4 array in the shader from a Color4 array.
  19378. * @param name Define the name of the uniform as defined in the shader
  19379. * @param value Define the value to give to the uniform
  19380. * @return the material itself allowing "fluent" like uniform updates
  19381. */
  19382. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19383. /**
  19384. * Set a vec2 in the shader from a Vector2.
  19385. * @param name Define the name of the uniform as defined in the shader
  19386. * @param value Define the value to give to the uniform
  19387. * @return the material itself allowing "fluent" like uniform updates
  19388. */
  19389. setVector2(name: string, value: Vector2): ShaderMaterial;
  19390. /**
  19391. * Set a vec3 in the shader from a Vector3.
  19392. * @param name Define the name of the uniform as defined in the shader
  19393. * @param value Define the value to give to the uniform
  19394. * @return the material itself allowing "fluent" like uniform updates
  19395. */
  19396. setVector3(name: string, value: Vector3): ShaderMaterial;
  19397. /**
  19398. * Set a vec4 in the shader from a Vector4.
  19399. * @param name Define the name of the uniform as defined in the shader
  19400. * @param value Define the value to give to the uniform
  19401. * @return the material itself allowing "fluent" like uniform updates
  19402. */
  19403. setVector4(name: string, value: Vector4): ShaderMaterial;
  19404. /**
  19405. * Set a mat4 in the shader from a Matrix.
  19406. * @param name Define the name of the uniform as defined in the shader
  19407. * @param value Define the value to give to the uniform
  19408. * @return the material itself allowing "fluent" like uniform updates
  19409. */
  19410. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19411. /**
  19412. * Set a float32Array in the shader from a matrix array.
  19413. * @param name Define the name of the uniform as defined in the shader
  19414. * @param value Define the value to give to the uniform
  19415. * @return the material itself allowing "fluent" like uniform updates
  19416. */
  19417. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19418. /**
  19419. * Set a mat3 in the shader from a Float32Array.
  19420. * @param name Define the name of the uniform as defined in the shader
  19421. * @param value Define the value to give to the uniform
  19422. * @return the material itself allowing "fluent" like uniform updates
  19423. */
  19424. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19425. /**
  19426. * Set a mat2 in the shader from a Float32Array.
  19427. * @param name Define the name of the uniform as defined in the shader
  19428. * @param value Define the value to give to the uniform
  19429. * @return the material itself allowing "fluent" like uniform updates
  19430. */
  19431. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19432. /**
  19433. * Set a vec2 array in the shader from a number array.
  19434. * @param name Define the name of the uniform as defined in the shader
  19435. * @param value Define the value to give to the uniform
  19436. * @return the material itself allowing "fluent" like uniform updates
  19437. */
  19438. setArray2(name: string, value: number[]): ShaderMaterial;
  19439. /**
  19440. * Set a vec3 array in the shader from a number array.
  19441. * @param name Define the name of the uniform as defined in the shader
  19442. * @param value Define the value to give to the uniform
  19443. * @return the material itself allowing "fluent" like uniform updates
  19444. */
  19445. setArray3(name: string, value: number[]): ShaderMaterial;
  19446. /**
  19447. * Set a vec4 array in the shader from a number array.
  19448. * @param name Define the name of the uniform as defined in the shader
  19449. * @param value Define the value to give to the uniform
  19450. * @return the material itself allowing "fluent" like uniform updates
  19451. */
  19452. setArray4(name: string, value: number[]): ShaderMaterial;
  19453. private _checkCache;
  19454. /**
  19455. * Specifies that the submesh is ready to be used
  19456. * @param mesh defines the mesh to check
  19457. * @param subMesh defines which submesh to check
  19458. * @param useInstances specifies that instances should be used
  19459. * @returns a boolean indicating that the submesh is ready or not
  19460. */
  19461. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19462. /**
  19463. * Checks if the material is ready to render the requested mesh
  19464. * @param mesh Define the mesh to render
  19465. * @param useInstances Define whether or not the material is used with instances
  19466. * @returns true if ready, otherwise false
  19467. */
  19468. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19469. /**
  19470. * Binds the world matrix to the material
  19471. * @param world defines the world transformation matrix
  19472. */
  19473. bindOnlyWorldMatrix(world: Matrix): void;
  19474. /**
  19475. * Binds the material to the mesh
  19476. * @param world defines the world transformation matrix
  19477. * @param mesh defines the mesh to bind the material to
  19478. */
  19479. bind(world: Matrix, mesh?: Mesh): void;
  19480. /**
  19481. * Gets the active textures from the material
  19482. * @returns an array of textures
  19483. */
  19484. getActiveTextures(): BaseTexture[];
  19485. /**
  19486. * Specifies if the material uses a texture
  19487. * @param texture defines the texture to check against the material
  19488. * @returns a boolean specifying if the material uses the texture
  19489. */
  19490. hasTexture(texture: BaseTexture): boolean;
  19491. /**
  19492. * Makes a duplicate of the material, and gives it a new name
  19493. * @param name defines the new name for the duplicated material
  19494. * @returns the cloned material
  19495. */
  19496. clone(name: string): ShaderMaterial;
  19497. /**
  19498. * Disposes the material
  19499. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19500. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19501. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19502. */
  19503. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19504. /**
  19505. * Serializes this material in a JSON representation
  19506. * @returns the serialized material object
  19507. */
  19508. serialize(): any;
  19509. /**
  19510. * Creates a shader material from parsed shader material data
  19511. * @param source defines the JSON represnetation of the material
  19512. * @param scene defines the hosting scene
  19513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19514. * @returns a new material
  19515. */
  19516. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19517. }
  19518. }
  19519. declare module BABYLON {
  19520. /** @hidden */
  19521. export var colorPixelShader: {
  19522. name: string;
  19523. shader: string;
  19524. };
  19525. }
  19526. declare module BABYLON {
  19527. /** @hidden */
  19528. export var colorVertexShader: {
  19529. name: string;
  19530. shader: string;
  19531. };
  19532. }
  19533. declare module BABYLON {
  19534. /**
  19535. * Line mesh
  19536. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19537. */
  19538. export class LinesMesh extends Mesh {
  19539. /**
  19540. * If vertex color should be applied to the mesh
  19541. */
  19542. readonly useVertexColor?: boolean | undefined;
  19543. /**
  19544. * If vertex alpha should be applied to the mesh
  19545. */
  19546. readonly useVertexAlpha?: boolean | undefined;
  19547. /**
  19548. * Color of the line (Default: White)
  19549. */
  19550. color: Color3;
  19551. /**
  19552. * Alpha of the line (Default: 1)
  19553. */
  19554. alpha: number;
  19555. /**
  19556. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19557. * This margin is expressed in world space coordinates, so its value may vary.
  19558. * Default value is 0.1
  19559. */
  19560. intersectionThreshold: number;
  19561. private _colorShader;
  19562. private color4;
  19563. /**
  19564. * Creates a new LinesMesh
  19565. * @param name defines the name
  19566. * @param scene defines the hosting scene
  19567. * @param parent defines the parent mesh if any
  19568. * @param source defines the optional source LinesMesh used to clone data from
  19569. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19570. * When false, achieved by calling a clone(), also passing False.
  19571. * This will make creation of children, recursive.
  19572. * @param useVertexColor defines if this LinesMesh supports vertex color
  19573. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19574. */
  19575. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19576. /**
  19577. * If vertex color should be applied to the mesh
  19578. */
  19579. useVertexColor?: boolean | undefined,
  19580. /**
  19581. * If vertex alpha should be applied to the mesh
  19582. */
  19583. useVertexAlpha?: boolean | undefined);
  19584. private _addClipPlaneDefine;
  19585. private _removeClipPlaneDefine;
  19586. isReady(): boolean;
  19587. /**
  19588. * Returns the string "LineMesh"
  19589. */
  19590. getClassName(): string;
  19591. /**
  19592. * @hidden
  19593. */
  19594. /**
  19595. * @hidden
  19596. */
  19597. material: Material;
  19598. /**
  19599. * @hidden
  19600. */
  19601. readonly checkCollisions: boolean;
  19602. /** @hidden */
  19603. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19604. /** @hidden */
  19605. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19606. /**
  19607. * Disposes of the line mesh
  19608. * @param doNotRecurse If children should be disposed
  19609. */
  19610. dispose(doNotRecurse?: boolean): void;
  19611. /**
  19612. * Returns a new LineMesh object cloned from the current one.
  19613. */
  19614. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19615. /**
  19616. * Creates a new InstancedLinesMesh object from the mesh model.
  19617. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19618. * @param name defines the name of the new instance
  19619. * @returns a new InstancedLinesMesh
  19620. */
  19621. createInstance(name: string): InstancedLinesMesh;
  19622. }
  19623. /**
  19624. * Creates an instance based on a source LinesMesh
  19625. */
  19626. export class InstancedLinesMesh extends InstancedMesh {
  19627. /**
  19628. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19629. * This margin is expressed in world space coordinates, so its value may vary.
  19630. * Initilized with the intersectionThreshold value of the source LinesMesh
  19631. */
  19632. intersectionThreshold: number;
  19633. constructor(name: string, source: LinesMesh);
  19634. /**
  19635. * Returns the string "InstancedLinesMesh".
  19636. */
  19637. getClassName(): string;
  19638. }
  19639. }
  19640. declare module BABYLON {
  19641. /** @hidden */
  19642. export var linePixelShader: {
  19643. name: string;
  19644. shader: string;
  19645. };
  19646. }
  19647. declare module BABYLON {
  19648. /** @hidden */
  19649. export var lineVertexShader: {
  19650. name: string;
  19651. shader: string;
  19652. };
  19653. }
  19654. declare module BABYLON {
  19655. interface AbstractMesh {
  19656. /**
  19657. * Gets the edgesRenderer associated with the mesh
  19658. */
  19659. edgesRenderer: Nullable<EdgesRenderer>;
  19660. }
  19661. interface LinesMesh {
  19662. /**
  19663. * Enables the edge rendering mode on the mesh.
  19664. * This mode makes the mesh edges visible
  19665. * @param epsilon defines the maximal distance between two angles to detect a face
  19666. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19667. * @returns the currentAbstractMesh
  19668. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19669. */
  19670. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19671. }
  19672. interface InstancedLinesMesh {
  19673. /**
  19674. * Enables the edge rendering mode on the mesh.
  19675. * This mode makes the mesh edges visible
  19676. * @param epsilon defines the maximal distance between two angles to detect a face
  19677. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19678. * @returns the current InstancedLinesMesh
  19679. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19680. */
  19681. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19682. }
  19683. /**
  19684. * Defines the minimum contract an Edges renderer should follow.
  19685. */
  19686. export interface IEdgesRenderer extends IDisposable {
  19687. /**
  19688. * Gets or sets a boolean indicating if the edgesRenderer is active
  19689. */
  19690. isEnabled: boolean;
  19691. /**
  19692. * Renders the edges of the attached mesh,
  19693. */
  19694. render(): void;
  19695. /**
  19696. * Checks wether or not the edges renderer is ready to render.
  19697. * @return true if ready, otherwise false.
  19698. */
  19699. isReady(): boolean;
  19700. }
  19701. /**
  19702. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19703. */
  19704. export class EdgesRenderer implements IEdgesRenderer {
  19705. /**
  19706. * Define the size of the edges with an orthographic camera
  19707. */
  19708. edgesWidthScalerForOrthographic: number;
  19709. /**
  19710. * Define the size of the edges with a perspective camera
  19711. */
  19712. edgesWidthScalerForPerspective: number;
  19713. protected _source: AbstractMesh;
  19714. protected _linesPositions: number[];
  19715. protected _linesNormals: number[];
  19716. protected _linesIndices: number[];
  19717. protected _epsilon: number;
  19718. protected _indicesCount: number;
  19719. protected _lineShader: ShaderMaterial;
  19720. protected _ib: DataBuffer;
  19721. protected _buffers: {
  19722. [key: string]: Nullable<VertexBuffer>;
  19723. };
  19724. protected _checkVerticesInsteadOfIndices: boolean;
  19725. private _meshRebuildObserver;
  19726. private _meshDisposeObserver;
  19727. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19728. isEnabled: boolean;
  19729. /**
  19730. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19731. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19732. * @param source Mesh used to create edges
  19733. * @param epsilon sum of angles in adjacency to check for edge
  19734. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19735. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19736. */
  19737. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19738. protected _prepareRessources(): void;
  19739. /** @hidden */
  19740. _rebuild(): void;
  19741. /**
  19742. * Releases the required resources for the edges renderer
  19743. */
  19744. dispose(): void;
  19745. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19746. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19747. /**
  19748. * Checks if the pair of p0 and p1 is en edge
  19749. * @param faceIndex
  19750. * @param edge
  19751. * @param faceNormals
  19752. * @param p0
  19753. * @param p1
  19754. * @private
  19755. */
  19756. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19757. /**
  19758. * push line into the position, normal and index buffer
  19759. * @protected
  19760. */
  19761. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19762. /**
  19763. * Generates lines edges from adjacencjes
  19764. * @private
  19765. */
  19766. _generateEdgesLines(): void;
  19767. /**
  19768. * Checks wether or not the edges renderer is ready to render.
  19769. * @return true if ready, otherwise false.
  19770. */
  19771. isReady(): boolean;
  19772. /**
  19773. * Renders the edges of the attached mesh,
  19774. */
  19775. render(): void;
  19776. }
  19777. /**
  19778. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19779. */
  19780. export class LineEdgesRenderer extends EdgesRenderer {
  19781. /**
  19782. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19783. * @param source LineMesh used to generate edges
  19784. * @param epsilon not important (specified angle for edge detection)
  19785. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19786. */
  19787. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19788. /**
  19789. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19790. */
  19791. _generateEdgesLines(): void;
  19792. }
  19793. }
  19794. declare module BABYLON {
  19795. /**
  19796. * This represents the object necessary to create a rendering group.
  19797. * This is exclusively used and created by the rendering manager.
  19798. * To modify the behavior, you use the available helpers in your scene or meshes.
  19799. * @hidden
  19800. */
  19801. export class RenderingGroup {
  19802. index: number;
  19803. private static _zeroVector;
  19804. private _scene;
  19805. private _opaqueSubMeshes;
  19806. private _transparentSubMeshes;
  19807. private _alphaTestSubMeshes;
  19808. private _depthOnlySubMeshes;
  19809. private _particleSystems;
  19810. private _spriteManagers;
  19811. private _opaqueSortCompareFn;
  19812. private _alphaTestSortCompareFn;
  19813. private _transparentSortCompareFn;
  19814. private _renderOpaque;
  19815. private _renderAlphaTest;
  19816. private _renderTransparent;
  19817. /** @hidden */
  19818. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19819. onBeforeTransparentRendering: () => void;
  19820. /**
  19821. * Set the opaque sort comparison function.
  19822. * If null the sub meshes will be render in the order they were created
  19823. */
  19824. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19825. /**
  19826. * Set the alpha test sort comparison function.
  19827. * If null the sub meshes will be render in the order they were created
  19828. */
  19829. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19830. /**
  19831. * Set the transparent sort comparison function.
  19832. * If null the sub meshes will be render in the order they were created
  19833. */
  19834. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19835. /**
  19836. * Creates a new rendering group.
  19837. * @param index The rendering group index
  19838. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19839. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19840. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19841. */
  19842. 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>);
  19843. /**
  19844. * Render all the sub meshes contained in the group.
  19845. * @param customRenderFunction Used to override the default render behaviour of the group.
  19846. * @returns true if rendered some submeshes.
  19847. */
  19848. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19849. /**
  19850. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19851. * @param subMeshes The submeshes to render
  19852. */
  19853. private renderOpaqueSorted;
  19854. /**
  19855. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19856. * @param subMeshes The submeshes to render
  19857. */
  19858. private renderAlphaTestSorted;
  19859. /**
  19860. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19861. * @param subMeshes The submeshes to render
  19862. */
  19863. private renderTransparentSorted;
  19864. /**
  19865. * Renders the submeshes in a specified order.
  19866. * @param subMeshes The submeshes to sort before render
  19867. * @param sortCompareFn The comparison function use to sort
  19868. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19869. * @param transparent Specifies to activate blending if true
  19870. */
  19871. private static renderSorted;
  19872. /**
  19873. * Renders the submeshes in the order they were dispatched (no sort applied).
  19874. * @param subMeshes The submeshes to render
  19875. */
  19876. private static renderUnsorted;
  19877. /**
  19878. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19879. * are rendered back to front if in the same alpha index.
  19880. *
  19881. * @param a The first submesh
  19882. * @param b The second submesh
  19883. * @returns The result of the comparison
  19884. */
  19885. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19886. /**
  19887. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19888. * are rendered back to front.
  19889. *
  19890. * @param a The first submesh
  19891. * @param b The second submesh
  19892. * @returns The result of the comparison
  19893. */
  19894. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19895. /**
  19896. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19897. * are rendered front to back (prevent overdraw).
  19898. *
  19899. * @param a The first submesh
  19900. * @param b The second submesh
  19901. * @returns The result of the comparison
  19902. */
  19903. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19904. /**
  19905. * Resets the different lists of submeshes to prepare a new frame.
  19906. */
  19907. prepare(): void;
  19908. dispose(): void;
  19909. /**
  19910. * Inserts the submesh in its correct queue depending on its material.
  19911. * @param subMesh The submesh to dispatch
  19912. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19913. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19914. */
  19915. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19916. dispatchSprites(spriteManager: ISpriteManager): void;
  19917. dispatchParticles(particleSystem: IParticleSystem): void;
  19918. private _renderParticles;
  19919. private _renderSprites;
  19920. }
  19921. }
  19922. declare module BABYLON {
  19923. /**
  19924. * Interface describing the different options available in the rendering manager
  19925. * regarding Auto Clear between groups.
  19926. */
  19927. export interface IRenderingManagerAutoClearSetup {
  19928. /**
  19929. * Defines whether or not autoclear is enable.
  19930. */
  19931. autoClear: boolean;
  19932. /**
  19933. * Defines whether or not to autoclear the depth buffer.
  19934. */
  19935. depth: boolean;
  19936. /**
  19937. * Defines whether or not to autoclear the stencil buffer.
  19938. */
  19939. stencil: boolean;
  19940. }
  19941. /**
  19942. * This class is used by the onRenderingGroupObservable
  19943. */
  19944. export class RenderingGroupInfo {
  19945. /**
  19946. * The Scene that being rendered
  19947. */
  19948. scene: Scene;
  19949. /**
  19950. * The camera currently used for the rendering pass
  19951. */
  19952. camera: Nullable<Camera>;
  19953. /**
  19954. * The ID of the renderingGroup being processed
  19955. */
  19956. renderingGroupId: number;
  19957. }
  19958. /**
  19959. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19960. * It is enable to manage the different groups as well as the different necessary sort functions.
  19961. * This should not be used directly aside of the few static configurations
  19962. */
  19963. export class RenderingManager {
  19964. /**
  19965. * The max id used for rendering groups (not included)
  19966. */
  19967. static MAX_RENDERINGGROUPS: number;
  19968. /**
  19969. * The min id used for rendering groups (included)
  19970. */
  19971. static MIN_RENDERINGGROUPS: number;
  19972. /**
  19973. * Used to globally prevent autoclearing scenes.
  19974. */
  19975. static AUTOCLEAR: boolean;
  19976. /**
  19977. * @hidden
  19978. */
  19979. _useSceneAutoClearSetup: boolean;
  19980. private _scene;
  19981. private _renderingGroups;
  19982. private _depthStencilBufferAlreadyCleaned;
  19983. private _autoClearDepthStencil;
  19984. private _customOpaqueSortCompareFn;
  19985. private _customAlphaTestSortCompareFn;
  19986. private _customTransparentSortCompareFn;
  19987. private _renderingGroupInfo;
  19988. /**
  19989. * Instantiates a new rendering group for a particular scene
  19990. * @param scene Defines the scene the groups belongs to
  19991. */
  19992. constructor(scene: Scene);
  19993. private _clearDepthStencilBuffer;
  19994. /**
  19995. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19996. * @hidden
  19997. */
  19998. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19999. /**
  20000. * Resets the different information of the group to prepare a new frame
  20001. * @hidden
  20002. */
  20003. reset(): void;
  20004. /**
  20005. * Dispose and release the group and its associated resources.
  20006. * @hidden
  20007. */
  20008. dispose(): void;
  20009. /**
  20010. * Clear the info related to rendering groups preventing retention points during dispose.
  20011. */
  20012. freeRenderingGroups(): void;
  20013. private _prepareRenderingGroup;
  20014. /**
  20015. * Add a sprite manager to the rendering manager in order to render it this frame.
  20016. * @param spriteManager Define the sprite manager to render
  20017. */
  20018. dispatchSprites(spriteManager: ISpriteManager): void;
  20019. /**
  20020. * Add a particle system to the rendering manager in order to render it this frame.
  20021. * @param particleSystem Define the particle system to render
  20022. */
  20023. dispatchParticles(particleSystem: IParticleSystem): void;
  20024. /**
  20025. * Add a submesh to the manager in order to render it this frame
  20026. * @param subMesh The submesh to dispatch
  20027. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20028. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20029. */
  20030. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20031. /**
  20032. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20033. * This allowed control for front to back rendering or reversly depending of the special needs.
  20034. *
  20035. * @param renderingGroupId The rendering group id corresponding to its index
  20036. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20037. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20038. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20039. */
  20040. 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;
  20041. /**
  20042. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20043. *
  20044. * @param renderingGroupId The rendering group id corresponding to its index
  20045. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20046. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20047. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20048. */
  20049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20050. /**
  20051. * Gets the current auto clear configuration for one rendering group of the rendering
  20052. * manager.
  20053. * @param index the rendering group index to get the information for
  20054. * @returns The auto clear setup for the requested rendering group
  20055. */
  20056. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20057. }
  20058. }
  20059. declare module BABYLON {
  20060. /**
  20061. * This Helps creating a texture that will be created from a camera in your scene.
  20062. * It is basically a dynamic texture that could be used to create special effects for instance.
  20063. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20064. */
  20065. export class RenderTargetTexture extends Texture {
  20066. isCube: boolean;
  20067. /**
  20068. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20069. */
  20070. static readonly REFRESHRATE_RENDER_ONCE: number;
  20071. /**
  20072. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20073. */
  20074. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20075. /**
  20076. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20077. * the central point of your effect and can save a lot of performances.
  20078. */
  20079. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20080. /**
  20081. * Use this predicate to dynamically define the list of mesh you want to render.
  20082. * If set, the renderList property will be overwritten.
  20083. */
  20084. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20085. private _renderList;
  20086. /**
  20087. * Use this list to define the list of mesh you want to render.
  20088. */
  20089. renderList: Nullable<Array<AbstractMesh>>;
  20090. private _hookArray;
  20091. /**
  20092. * Define if particles should be rendered in your texture.
  20093. */
  20094. renderParticles: boolean;
  20095. /**
  20096. * Define if sprites should be rendered in your texture.
  20097. */
  20098. renderSprites: boolean;
  20099. /**
  20100. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20101. */
  20102. coordinatesMode: number;
  20103. /**
  20104. * Define the camera used to render the texture.
  20105. */
  20106. activeCamera: Nullable<Camera>;
  20107. /**
  20108. * Override the render function of the texture with your own one.
  20109. */
  20110. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20111. /**
  20112. * Define if camera post processes should be use while rendering the texture.
  20113. */
  20114. useCameraPostProcesses: boolean;
  20115. /**
  20116. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20117. */
  20118. ignoreCameraViewport: boolean;
  20119. private _postProcessManager;
  20120. private _postProcesses;
  20121. private _resizeObserver;
  20122. /**
  20123. * An event triggered when the texture is unbind.
  20124. */
  20125. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20126. /**
  20127. * An event triggered when the texture is unbind.
  20128. */
  20129. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20130. private _onAfterUnbindObserver;
  20131. /**
  20132. * Set a after unbind callback in the texture.
  20133. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20134. */
  20135. onAfterUnbind: () => void;
  20136. /**
  20137. * An event triggered before rendering the texture
  20138. */
  20139. onBeforeRenderObservable: Observable<number>;
  20140. private _onBeforeRenderObserver;
  20141. /**
  20142. * Set a before render callback in the texture.
  20143. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20144. */
  20145. onBeforeRender: (faceIndex: number) => void;
  20146. /**
  20147. * An event triggered after rendering the texture
  20148. */
  20149. onAfterRenderObservable: Observable<number>;
  20150. private _onAfterRenderObserver;
  20151. /**
  20152. * Set a after render callback in the texture.
  20153. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20154. */
  20155. onAfterRender: (faceIndex: number) => void;
  20156. /**
  20157. * An event triggered after the texture clear
  20158. */
  20159. onClearObservable: Observable<Engine>;
  20160. private _onClearObserver;
  20161. /**
  20162. * Set a clear callback in the texture.
  20163. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20164. */
  20165. onClear: (Engine: Engine) => void;
  20166. /**
  20167. * An event triggered when the texture is resized.
  20168. */
  20169. onResizeObservable: Observable<RenderTargetTexture>;
  20170. /**
  20171. * Define the clear color of the Render Target if it should be different from the scene.
  20172. */
  20173. clearColor: Color4;
  20174. protected _size: number | {
  20175. width: number;
  20176. height: number;
  20177. };
  20178. protected _initialSizeParameter: number | {
  20179. width: number;
  20180. height: number;
  20181. } | {
  20182. ratio: number;
  20183. };
  20184. protected _sizeRatio: Nullable<number>;
  20185. /** @hidden */
  20186. _generateMipMaps: boolean;
  20187. protected _renderingManager: RenderingManager;
  20188. /** @hidden */
  20189. _waitingRenderList: string[];
  20190. protected _doNotChangeAspectRatio: boolean;
  20191. protected _currentRefreshId: number;
  20192. protected _refreshRate: number;
  20193. protected _textureMatrix: Matrix;
  20194. protected _samples: number;
  20195. protected _renderTargetOptions: RenderTargetCreationOptions;
  20196. /**
  20197. * Gets render target creation options that were used.
  20198. */
  20199. readonly renderTargetOptions: RenderTargetCreationOptions;
  20200. protected _engine: Engine;
  20201. protected _onRatioRescale(): void;
  20202. /**
  20203. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20204. * It must define where the camera used to render the texture is set
  20205. */
  20206. boundingBoxPosition: Vector3;
  20207. private _boundingBoxSize;
  20208. /**
  20209. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20210. * When defined, the cubemap will switch to local mode
  20211. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20212. * @example https://www.babylonjs-playground.com/#RNASML
  20213. */
  20214. boundingBoxSize: Vector3;
  20215. /**
  20216. * In case the RTT has been created with a depth texture, get the associated
  20217. * depth texture.
  20218. * Otherwise, return null.
  20219. */
  20220. depthStencilTexture: Nullable<InternalTexture>;
  20221. /**
  20222. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20223. * or used a shadow, depth texture...
  20224. * @param name The friendly name of the texture
  20225. * @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)
  20226. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20227. * @param generateMipMaps True if mip maps need to be generated after render.
  20228. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20229. * @param type The type of the buffer in the RTT (int, half float, float...)
  20230. * @param isCube True if a cube texture needs to be created
  20231. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20232. * @param generateDepthBuffer True to generate a depth buffer
  20233. * @param generateStencilBuffer True to generate a stencil buffer
  20234. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20235. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20236. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20237. */
  20238. constructor(name: string, size: number | {
  20239. width: number;
  20240. height: number;
  20241. } | {
  20242. ratio: number;
  20243. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20244. /**
  20245. * Creates a depth stencil texture.
  20246. * This is only available in WebGL 2 or with the depth texture extension available.
  20247. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20248. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20249. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20250. */
  20251. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20252. private _processSizeParameter;
  20253. /**
  20254. * Define the number of samples to use in case of MSAA.
  20255. * It defaults to one meaning no MSAA has been enabled.
  20256. */
  20257. samples: number;
  20258. /**
  20259. * Resets the refresh counter of the texture and start bak from scratch.
  20260. * Could be useful to regenerate the texture if it is setup to render only once.
  20261. */
  20262. resetRefreshCounter(): void;
  20263. /**
  20264. * Define the refresh rate of the texture or the rendering frequency.
  20265. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20266. */
  20267. refreshRate: number;
  20268. /**
  20269. * Adds a post process to the render target rendering passes.
  20270. * @param postProcess define the post process to add
  20271. */
  20272. addPostProcess(postProcess: PostProcess): void;
  20273. /**
  20274. * Clear all the post processes attached to the render target
  20275. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20276. */
  20277. clearPostProcesses(dispose?: boolean): void;
  20278. /**
  20279. * Remove one of the post process from the list of attached post processes to the texture
  20280. * @param postProcess define the post process to remove from the list
  20281. */
  20282. removePostProcess(postProcess: PostProcess): void;
  20283. /** @hidden */
  20284. _shouldRender(): boolean;
  20285. /**
  20286. * Gets the actual render size of the texture.
  20287. * @returns the width of the render size
  20288. */
  20289. getRenderSize(): number;
  20290. /**
  20291. * Gets the actual render width of the texture.
  20292. * @returns the width of the render size
  20293. */
  20294. getRenderWidth(): number;
  20295. /**
  20296. * Gets the actual render height of the texture.
  20297. * @returns the height of the render size
  20298. */
  20299. getRenderHeight(): number;
  20300. /**
  20301. * Get if the texture can be rescaled or not.
  20302. */
  20303. readonly canRescale: boolean;
  20304. /**
  20305. * Resize the texture using a ratio.
  20306. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20307. */
  20308. scale(ratio: number): void;
  20309. /**
  20310. * Get the texture reflection matrix used to rotate/transform the reflection.
  20311. * @returns the reflection matrix
  20312. */
  20313. getReflectionTextureMatrix(): Matrix;
  20314. /**
  20315. * Resize the texture to a new desired size.
  20316. * Be carrefull as it will recreate all the data in the new texture.
  20317. * @param size Define the new size. It can be:
  20318. * - a number for squared texture,
  20319. * - an object containing { width: number, height: number }
  20320. * - or an object containing a ratio { ratio: number }
  20321. */
  20322. resize(size: number | {
  20323. width: number;
  20324. height: number;
  20325. } | {
  20326. ratio: number;
  20327. }): void;
  20328. /**
  20329. * Renders all the objects from the render list into the texture.
  20330. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20331. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20332. */
  20333. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20334. private _bestReflectionRenderTargetDimension;
  20335. /**
  20336. * @hidden
  20337. * @param faceIndex face index to bind to if this is a cubetexture
  20338. */
  20339. _bindFrameBuffer(faceIndex?: number): void;
  20340. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20341. private renderToTarget;
  20342. /**
  20343. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20344. * This allowed control for front to back rendering or reversly depending of the special needs.
  20345. *
  20346. * @param renderingGroupId The rendering group id corresponding to its index
  20347. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20348. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20349. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20350. */
  20351. 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;
  20352. /**
  20353. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20354. *
  20355. * @param renderingGroupId The rendering group id corresponding to its index
  20356. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20357. */
  20358. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20359. /**
  20360. * Clones the texture.
  20361. * @returns the cloned texture
  20362. */
  20363. clone(): RenderTargetTexture;
  20364. /**
  20365. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20366. * @returns The JSON representation of the texture
  20367. */
  20368. serialize(): any;
  20369. /**
  20370. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20371. */
  20372. disposeFramebufferObjects(): void;
  20373. /**
  20374. * Dispose the texture and release its associated resources.
  20375. */
  20376. dispose(): void;
  20377. /** @hidden */
  20378. _rebuild(): void;
  20379. /**
  20380. * Clear the info related to rendering groups preventing retention point in material dispose.
  20381. */
  20382. freeRenderingGroups(): void;
  20383. /**
  20384. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20385. * @returns the view count
  20386. */
  20387. getViewCount(): number;
  20388. }
  20389. }
  20390. declare module BABYLON {
  20391. /**
  20392. * Options for compiling materials.
  20393. */
  20394. export interface IMaterialCompilationOptions {
  20395. /**
  20396. * Defines whether clip planes are enabled.
  20397. */
  20398. clipPlane: boolean;
  20399. /**
  20400. * Defines whether instances are enabled.
  20401. */
  20402. useInstances: boolean;
  20403. }
  20404. /**
  20405. * Base class for the main features of a material in Babylon.js
  20406. */
  20407. export class Material implements IAnimatable {
  20408. /**
  20409. * Returns the triangle fill mode
  20410. */
  20411. static readonly TriangleFillMode: number;
  20412. /**
  20413. * Returns the wireframe mode
  20414. */
  20415. static readonly WireFrameFillMode: number;
  20416. /**
  20417. * Returns the point fill mode
  20418. */
  20419. static readonly PointFillMode: number;
  20420. /**
  20421. * Returns the point list draw mode
  20422. */
  20423. static readonly PointListDrawMode: number;
  20424. /**
  20425. * Returns the line list draw mode
  20426. */
  20427. static readonly LineListDrawMode: number;
  20428. /**
  20429. * Returns the line loop draw mode
  20430. */
  20431. static readonly LineLoopDrawMode: number;
  20432. /**
  20433. * Returns the line strip draw mode
  20434. */
  20435. static readonly LineStripDrawMode: number;
  20436. /**
  20437. * Returns the triangle strip draw mode
  20438. */
  20439. static readonly TriangleStripDrawMode: number;
  20440. /**
  20441. * Returns the triangle fan draw mode
  20442. */
  20443. static readonly TriangleFanDrawMode: number;
  20444. /**
  20445. * Stores the clock-wise side orientation
  20446. */
  20447. static readonly ClockWiseSideOrientation: number;
  20448. /**
  20449. * Stores the counter clock-wise side orientation
  20450. */
  20451. static readonly CounterClockWiseSideOrientation: number;
  20452. /**
  20453. * The dirty texture flag value
  20454. */
  20455. static readonly TextureDirtyFlag: number;
  20456. /**
  20457. * The dirty light flag value
  20458. */
  20459. static readonly LightDirtyFlag: number;
  20460. /**
  20461. * The dirty fresnel flag value
  20462. */
  20463. static readonly FresnelDirtyFlag: number;
  20464. /**
  20465. * The dirty attribute flag value
  20466. */
  20467. static readonly AttributesDirtyFlag: number;
  20468. /**
  20469. * The dirty misc flag value
  20470. */
  20471. static readonly MiscDirtyFlag: number;
  20472. /**
  20473. * The all dirty flag value
  20474. */
  20475. static readonly AllDirtyFlag: number;
  20476. /**
  20477. * The ID of the material
  20478. */
  20479. id: string;
  20480. /**
  20481. * Gets or sets the unique id of the material
  20482. */
  20483. uniqueId: number;
  20484. /**
  20485. * The name of the material
  20486. */
  20487. name: string;
  20488. /**
  20489. * Gets or sets user defined metadata
  20490. */
  20491. metadata: any;
  20492. /**
  20493. * For internal use only. Please do not use.
  20494. */
  20495. reservedDataStore: any;
  20496. /**
  20497. * Specifies if the ready state should be checked on each call
  20498. */
  20499. checkReadyOnEveryCall: boolean;
  20500. /**
  20501. * Specifies if the ready state should be checked once
  20502. */
  20503. checkReadyOnlyOnce: boolean;
  20504. /**
  20505. * The state of the material
  20506. */
  20507. state: string;
  20508. /**
  20509. * The alpha value of the material
  20510. */
  20511. protected _alpha: number;
  20512. /**
  20513. * List of inspectable custom properties (used by the Inspector)
  20514. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20515. */
  20516. inspectableCustomProperties: IInspectable[];
  20517. /**
  20518. * Sets the alpha value of the material
  20519. */
  20520. /**
  20521. * Gets the alpha value of the material
  20522. */
  20523. alpha: number;
  20524. /**
  20525. * Specifies if back face culling is enabled
  20526. */
  20527. protected _backFaceCulling: boolean;
  20528. /**
  20529. * Sets the back-face culling state
  20530. */
  20531. /**
  20532. * Gets the back-face culling state
  20533. */
  20534. backFaceCulling: boolean;
  20535. /**
  20536. * Stores the value for side orientation
  20537. */
  20538. sideOrientation: number;
  20539. /**
  20540. * Callback triggered when the material is compiled
  20541. */
  20542. onCompiled: Nullable<(effect: Effect) => void>;
  20543. /**
  20544. * Callback triggered when an error occurs
  20545. */
  20546. onError: Nullable<(effect: Effect, errors: string) => void>;
  20547. /**
  20548. * Callback triggered to get the render target textures
  20549. */
  20550. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20551. /**
  20552. * Gets a boolean indicating that current material needs to register RTT
  20553. */
  20554. readonly hasRenderTargetTextures: boolean;
  20555. /**
  20556. * Specifies if the material should be serialized
  20557. */
  20558. doNotSerialize: boolean;
  20559. /**
  20560. * @hidden
  20561. */
  20562. _storeEffectOnSubMeshes: boolean;
  20563. /**
  20564. * Stores the animations for the material
  20565. */
  20566. animations: Nullable<Array<Animation>>;
  20567. /**
  20568. * An event triggered when the material is disposed
  20569. */
  20570. onDisposeObservable: Observable<Material>;
  20571. /**
  20572. * An observer which watches for dispose events
  20573. */
  20574. private _onDisposeObserver;
  20575. private _onUnBindObservable;
  20576. /**
  20577. * Called during a dispose event
  20578. */
  20579. onDispose: () => void;
  20580. private _onBindObservable;
  20581. /**
  20582. * An event triggered when the material is bound
  20583. */
  20584. readonly onBindObservable: Observable<AbstractMesh>;
  20585. /**
  20586. * An observer which watches for bind events
  20587. */
  20588. private _onBindObserver;
  20589. /**
  20590. * Called during a bind event
  20591. */
  20592. onBind: (Mesh: AbstractMesh) => void;
  20593. /**
  20594. * An event triggered when the material is unbound
  20595. */
  20596. readonly onUnBindObservable: Observable<Material>;
  20597. /**
  20598. * Stores the value of the alpha mode
  20599. */
  20600. private _alphaMode;
  20601. /**
  20602. * Sets the value of the alpha mode.
  20603. *
  20604. * | Value | Type | Description |
  20605. * | --- | --- | --- |
  20606. * | 0 | ALPHA_DISABLE | |
  20607. * | 1 | ALPHA_ADD | |
  20608. * | 2 | ALPHA_COMBINE | |
  20609. * | 3 | ALPHA_SUBTRACT | |
  20610. * | 4 | ALPHA_MULTIPLY | |
  20611. * | 5 | ALPHA_MAXIMIZED | |
  20612. * | 6 | ALPHA_ONEONE | |
  20613. * | 7 | ALPHA_PREMULTIPLIED | |
  20614. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20615. * | 9 | ALPHA_INTERPOLATE | |
  20616. * | 10 | ALPHA_SCREENMODE | |
  20617. *
  20618. */
  20619. /**
  20620. * Gets the value of the alpha mode
  20621. */
  20622. alphaMode: number;
  20623. /**
  20624. * Stores the state of the need depth pre-pass value
  20625. */
  20626. private _needDepthPrePass;
  20627. /**
  20628. * Sets the need depth pre-pass value
  20629. */
  20630. /**
  20631. * Gets the depth pre-pass value
  20632. */
  20633. needDepthPrePass: boolean;
  20634. /**
  20635. * Specifies if depth writing should be disabled
  20636. */
  20637. disableDepthWrite: boolean;
  20638. /**
  20639. * Specifies if depth writing should be forced
  20640. */
  20641. forceDepthWrite: boolean;
  20642. /**
  20643. * Specifies the depth function that should be used. 0 means the default engine function
  20644. */
  20645. depthFunction: number;
  20646. /**
  20647. * Specifies if there should be a separate pass for culling
  20648. */
  20649. separateCullingPass: boolean;
  20650. /**
  20651. * Stores the state specifing if fog should be enabled
  20652. */
  20653. private _fogEnabled;
  20654. /**
  20655. * Sets the state for enabling fog
  20656. */
  20657. /**
  20658. * Gets the value of the fog enabled state
  20659. */
  20660. fogEnabled: boolean;
  20661. /**
  20662. * Stores the size of points
  20663. */
  20664. pointSize: number;
  20665. /**
  20666. * Stores the z offset value
  20667. */
  20668. zOffset: number;
  20669. /**
  20670. * Gets a value specifying if wireframe mode is enabled
  20671. */
  20672. /**
  20673. * Sets the state of wireframe mode
  20674. */
  20675. wireframe: boolean;
  20676. /**
  20677. * Gets the value specifying if point clouds are enabled
  20678. */
  20679. /**
  20680. * Sets the state of point cloud mode
  20681. */
  20682. pointsCloud: boolean;
  20683. /**
  20684. * Gets the material fill mode
  20685. */
  20686. /**
  20687. * Sets the material fill mode
  20688. */
  20689. fillMode: number;
  20690. /**
  20691. * @hidden
  20692. * Stores the effects for the material
  20693. */
  20694. _effect: Nullable<Effect>;
  20695. /**
  20696. * @hidden
  20697. * Specifies if the material was previously ready
  20698. */
  20699. _wasPreviouslyReady: boolean;
  20700. /**
  20701. * Specifies if uniform buffers should be used
  20702. */
  20703. private _useUBO;
  20704. /**
  20705. * Stores a reference to the scene
  20706. */
  20707. private _scene;
  20708. /**
  20709. * Stores the fill mode state
  20710. */
  20711. private _fillMode;
  20712. /**
  20713. * Specifies if the depth write state should be cached
  20714. */
  20715. private _cachedDepthWriteState;
  20716. /**
  20717. * Specifies if the depth function state should be cached
  20718. */
  20719. private _cachedDepthFunctionState;
  20720. /**
  20721. * Stores the uniform buffer
  20722. */
  20723. protected _uniformBuffer: UniformBuffer;
  20724. /** @hidden */
  20725. _indexInSceneMaterialArray: number;
  20726. /** @hidden */
  20727. meshMap: Nullable<{
  20728. [id: string]: AbstractMesh | undefined;
  20729. }>;
  20730. /**
  20731. * Creates a material instance
  20732. * @param name defines the name of the material
  20733. * @param scene defines the scene to reference
  20734. * @param doNotAdd specifies if the material should be added to the scene
  20735. */
  20736. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20737. /**
  20738. * Returns a string representation of the current material
  20739. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20740. * @returns a string with material information
  20741. */
  20742. toString(fullDetails?: boolean): string;
  20743. /**
  20744. * Gets the class name of the material
  20745. * @returns a string with the class name of the material
  20746. */
  20747. getClassName(): string;
  20748. /**
  20749. * Specifies if updates for the material been locked
  20750. */
  20751. readonly isFrozen: boolean;
  20752. /**
  20753. * Locks updates for the material
  20754. */
  20755. freeze(): void;
  20756. /**
  20757. * Unlocks updates for the material
  20758. */
  20759. unfreeze(): void;
  20760. /**
  20761. * Specifies if the material is ready to be used
  20762. * @param mesh defines the mesh to check
  20763. * @param useInstances specifies if instances should be used
  20764. * @returns a boolean indicating if the material is ready to be used
  20765. */
  20766. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20767. /**
  20768. * Specifies that the submesh is ready to be used
  20769. * @param mesh defines the mesh to check
  20770. * @param subMesh defines which submesh to check
  20771. * @param useInstances specifies that instances should be used
  20772. * @returns a boolean indicating that the submesh is ready or not
  20773. */
  20774. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20775. /**
  20776. * Returns the material effect
  20777. * @returns the effect associated with the material
  20778. */
  20779. getEffect(): Nullable<Effect>;
  20780. /**
  20781. * Returns the current scene
  20782. * @returns a Scene
  20783. */
  20784. getScene(): Scene;
  20785. /**
  20786. * Specifies if the material will require alpha blending
  20787. * @returns a boolean specifying if alpha blending is needed
  20788. */
  20789. needAlphaBlending(): boolean;
  20790. /**
  20791. * Specifies if the mesh will require alpha blending
  20792. * @param mesh defines the mesh to check
  20793. * @returns a boolean specifying if alpha blending is needed for the mesh
  20794. */
  20795. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20796. /**
  20797. * Specifies if this material should be rendered in alpha test mode
  20798. * @returns a boolean specifying if an alpha test is needed.
  20799. */
  20800. needAlphaTesting(): boolean;
  20801. /**
  20802. * Gets the texture used for the alpha test
  20803. * @returns the texture to use for alpha testing
  20804. */
  20805. getAlphaTestTexture(): Nullable<BaseTexture>;
  20806. /**
  20807. * Marks the material to indicate that it needs to be re-calculated
  20808. */
  20809. markDirty(): void;
  20810. /** @hidden */
  20811. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20812. /**
  20813. * Binds the material to the mesh
  20814. * @param world defines the world transformation matrix
  20815. * @param mesh defines the mesh to bind the material to
  20816. */
  20817. bind(world: Matrix, mesh?: Mesh): void;
  20818. /**
  20819. * Binds the submesh to the material
  20820. * @param world defines the world transformation matrix
  20821. * @param mesh defines the mesh containing the submesh
  20822. * @param subMesh defines the submesh to bind the material to
  20823. */
  20824. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20825. /**
  20826. * Binds the world matrix to the material
  20827. * @param world defines the world transformation matrix
  20828. */
  20829. bindOnlyWorldMatrix(world: Matrix): void;
  20830. /**
  20831. * Binds the scene's uniform buffer to the effect.
  20832. * @param effect defines the effect to bind to the scene uniform buffer
  20833. * @param sceneUbo defines the uniform buffer storing scene data
  20834. */
  20835. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20836. /**
  20837. * Binds the view matrix to the effect
  20838. * @param effect defines the effect to bind the view matrix to
  20839. */
  20840. bindView(effect: Effect): void;
  20841. /**
  20842. * Binds the view projection matrix to the effect
  20843. * @param effect defines the effect to bind the view projection matrix to
  20844. */
  20845. bindViewProjection(effect: Effect): void;
  20846. /**
  20847. * Specifies if material alpha testing should be turned on for the mesh
  20848. * @param mesh defines the mesh to check
  20849. */
  20850. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20851. /**
  20852. * Processes to execute after binding the material to a mesh
  20853. * @param mesh defines the rendered mesh
  20854. */
  20855. protected _afterBind(mesh?: Mesh): void;
  20856. /**
  20857. * Unbinds the material from the mesh
  20858. */
  20859. unbind(): void;
  20860. /**
  20861. * Gets the active textures from the material
  20862. * @returns an array of textures
  20863. */
  20864. getActiveTextures(): BaseTexture[];
  20865. /**
  20866. * Specifies if the material uses a texture
  20867. * @param texture defines the texture to check against the material
  20868. * @returns a boolean specifying if the material uses the texture
  20869. */
  20870. hasTexture(texture: BaseTexture): boolean;
  20871. /**
  20872. * Makes a duplicate of the material, and gives it a new name
  20873. * @param name defines the new name for the duplicated material
  20874. * @returns the cloned material
  20875. */
  20876. clone(name: string): Nullable<Material>;
  20877. /**
  20878. * Gets the meshes bound to the material
  20879. * @returns an array of meshes bound to the material
  20880. */
  20881. getBindedMeshes(): AbstractMesh[];
  20882. /**
  20883. * Force shader compilation
  20884. * @param mesh defines the mesh associated with this material
  20885. * @param onCompiled defines a function to execute once the material is compiled
  20886. * @param options defines the options to configure the compilation
  20887. * @param onError defines a function to execute if the material fails compiling
  20888. */
  20889. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20890. /**
  20891. * Force shader compilation
  20892. * @param mesh defines the mesh that will use this material
  20893. * @param options defines additional options for compiling the shaders
  20894. * @returns a promise that resolves when the compilation completes
  20895. */
  20896. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20897. private static readonly _AllDirtyCallBack;
  20898. private static readonly _ImageProcessingDirtyCallBack;
  20899. private static readonly _TextureDirtyCallBack;
  20900. private static readonly _FresnelDirtyCallBack;
  20901. private static readonly _MiscDirtyCallBack;
  20902. private static readonly _LightsDirtyCallBack;
  20903. private static readonly _AttributeDirtyCallBack;
  20904. private static _FresnelAndMiscDirtyCallBack;
  20905. private static _TextureAndMiscDirtyCallBack;
  20906. private static readonly _DirtyCallbackArray;
  20907. private static readonly _RunDirtyCallBacks;
  20908. /**
  20909. * Marks a define in the material to indicate that it needs to be re-computed
  20910. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20911. */
  20912. markAsDirty(flag: number): void;
  20913. /**
  20914. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20915. * @param func defines a function which checks material defines against the submeshes
  20916. */
  20917. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20918. /**
  20919. * Indicates that we need to re-calculated for all submeshes
  20920. */
  20921. protected _markAllSubMeshesAsAllDirty(): void;
  20922. /**
  20923. * Indicates that image processing needs to be re-calculated for all submeshes
  20924. */
  20925. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20926. /**
  20927. * Indicates that textures need to be re-calculated for all submeshes
  20928. */
  20929. protected _markAllSubMeshesAsTexturesDirty(): void;
  20930. /**
  20931. * Indicates that fresnel needs to be re-calculated for all submeshes
  20932. */
  20933. protected _markAllSubMeshesAsFresnelDirty(): void;
  20934. /**
  20935. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20936. */
  20937. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20938. /**
  20939. * Indicates that lights need to be re-calculated for all submeshes
  20940. */
  20941. protected _markAllSubMeshesAsLightsDirty(): void;
  20942. /**
  20943. * Indicates that attributes need to be re-calculated for all submeshes
  20944. */
  20945. protected _markAllSubMeshesAsAttributesDirty(): void;
  20946. /**
  20947. * Indicates that misc needs to be re-calculated for all submeshes
  20948. */
  20949. protected _markAllSubMeshesAsMiscDirty(): void;
  20950. /**
  20951. * Indicates that textures and misc need to be re-calculated for all submeshes
  20952. */
  20953. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20954. /**
  20955. * Disposes the material
  20956. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20957. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20958. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20959. */
  20960. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20961. /** @hidden */
  20962. private releaseVertexArrayObject;
  20963. /**
  20964. * Serializes this material
  20965. * @returns the serialized material object
  20966. */
  20967. serialize(): any;
  20968. /**
  20969. * Creates a material from parsed material data
  20970. * @param parsedMaterial defines parsed material data
  20971. * @param scene defines the hosting scene
  20972. * @param rootUrl defines the root URL to use to load textures
  20973. * @returns a new material
  20974. */
  20975. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20976. }
  20977. }
  20978. declare module BABYLON {
  20979. /**
  20980. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20981. * separate meshes. This can be use to improve performances.
  20982. * @see http://doc.babylonjs.com/how_to/multi_materials
  20983. */
  20984. export class MultiMaterial extends Material {
  20985. private _subMaterials;
  20986. /**
  20987. * Gets or Sets the list of Materials used within the multi material.
  20988. * They need to be ordered according to the submeshes order in the associated mesh
  20989. */
  20990. subMaterials: Nullable<Material>[];
  20991. /**
  20992. * Function used to align with Node.getChildren()
  20993. * @returns the list of Materials used within the multi material
  20994. */
  20995. getChildren(): Nullable<Material>[];
  20996. /**
  20997. * Instantiates a new Multi Material
  20998. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20999. * separate meshes. This can be use to improve performances.
  21000. * @see http://doc.babylonjs.com/how_to/multi_materials
  21001. * @param name Define the name in the scene
  21002. * @param scene Define the scene the material belongs to
  21003. */
  21004. constructor(name: string, scene: Scene);
  21005. private _hookArray;
  21006. /**
  21007. * Get one of the submaterial by its index in the submaterials array
  21008. * @param index The index to look the sub material at
  21009. * @returns The Material if the index has been defined
  21010. */
  21011. getSubMaterial(index: number): Nullable<Material>;
  21012. /**
  21013. * Get the list of active textures for the whole sub materials list.
  21014. * @returns All the textures that will be used during the rendering
  21015. */
  21016. getActiveTextures(): BaseTexture[];
  21017. /**
  21018. * Gets the current class name of the material e.g. "MultiMaterial"
  21019. * Mainly use in serialization.
  21020. * @returns the class name
  21021. */
  21022. getClassName(): string;
  21023. /**
  21024. * Checks if the material is ready to render the requested sub mesh
  21025. * @param mesh Define the mesh the submesh belongs to
  21026. * @param subMesh Define the sub mesh to look readyness for
  21027. * @param useInstances Define whether or not the material is used with instances
  21028. * @returns true if ready, otherwise false
  21029. */
  21030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21031. /**
  21032. * Clones the current material and its related sub materials
  21033. * @param name Define the name of the newly cloned material
  21034. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21035. * @returns the cloned material
  21036. */
  21037. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21038. /**
  21039. * Serializes the materials into a JSON representation.
  21040. * @returns the JSON representation
  21041. */
  21042. serialize(): any;
  21043. /**
  21044. * Dispose the material and release its associated resources
  21045. * @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)
  21046. * @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)
  21047. * @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)
  21048. */
  21049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21050. /**
  21051. * Creates a MultiMaterial from parsed MultiMaterial data.
  21052. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21053. * @param scene defines the hosting scene
  21054. * @returns a new MultiMaterial
  21055. */
  21056. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21057. }
  21058. }
  21059. declare module BABYLON {
  21060. /**
  21061. * Base class for submeshes
  21062. */
  21063. export class BaseSubMesh {
  21064. /** @hidden */
  21065. _materialDefines: Nullable<MaterialDefines>;
  21066. /** @hidden */
  21067. _materialEffect: Nullable<Effect>;
  21068. /**
  21069. * Gets material defines used by the effect associated to the sub mesh
  21070. */
  21071. /**
  21072. * Sets material defines used by the effect associated to the sub mesh
  21073. */
  21074. materialDefines: Nullable<MaterialDefines>;
  21075. /**
  21076. * Gets associated effect
  21077. */
  21078. readonly effect: Nullable<Effect>;
  21079. /**
  21080. * Sets associated effect (effect used to render this submesh)
  21081. * @param effect defines the effect to associate with
  21082. * @param defines defines the set of defines used to compile this effect
  21083. */
  21084. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21085. }
  21086. /**
  21087. * Defines a subdivision inside a mesh
  21088. */
  21089. export class SubMesh extends BaseSubMesh implements ICullable {
  21090. /** the material index to use */
  21091. materialIndex: number;
  21092. /** vertex index start */
  21093. verticesStart: number;
  21094. /** vertices count */
  21095. verticesCount: number;
  21096. /** index start */
  21097. indexStart: number;
  21098. /** indices count */
  21099. indexCount: number;
  21100. /** @hidden */
  21101. _linesIndexCount: number;
  21102. private _mesh;
  21103. private _renderingMesh;
  21104. private _boundingInfo;
  21105. private _linesIndexBuffer;
  21106. /** @hidden */
  21107. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21108. /** @hidden */
  21109. _trianglePlanes: Plane[];
  21110. /** @hidden */
  21111. _lastColliderTransformMatrix: Nullable<Matrix>;
  21112. /** @hidden */
  21113. _renderId: number;
  21114. /** @hidden */
  21115. _alphaIndex: number;
  21116. /** @hidden */
  21117. _distanceToCamera: number;
  21118. /** @hidden */
  21119. _id: number;
  21120. private _currentMaterial;
  21121. /**
  21122. * Add a new submesh to a mesh
  21123. * @param materialIndex defines the material index to use
  21124. * @param verticesStart defines vertex index start
  21125. * @param verticesCount defines vertices count
  21126. * @param indexStart defines index start
  21127. * @param indexCount defines indices count
  21128. * @param mesh defines the parent mesh
  21129. * @param renderingMesh defines an optional rendering mesh
  21130. * @param createBoundingBox defines if bounding box should be created for this submesh
  21131. * @returns the new submesh
  21132. */
  21133. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21134. /**
  21135. * Creates a new submesh
  21136. * @param materialIndex defines the material index to use
  21137. * @param verticesStart defines vertex index start
  21138. * @param verticesCount defines vertices count
  21139. * @param indexStart defines index start
  21140. * @param indexCount defines indices count
  21141. * @param mesh defines the parent mesh
  21142. * @param renderingMesh defines an optional rendering mesh
  21143. * @param createBoundingBox defines if bounding box should be created for this submesh
  21144. */
  21145. constructor(
  21146. /** the material index to use */
  21147. materialIndex: number,
  21148. /** vertex index start */
  21149. verticesStart: number,
  21150. /** vertices count */
  21151. verticesCount: number,
  21152. /** index start */
  21153. indexStart: number,
  21154. /** indices count */
  21155. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21156. /**
  21157. * Returns true if this submesh covers the entire parent mesh
  21158. * @ignorenaming
  21159. */
  21160. readonly IsGlobal: boolean;
  21161. /**
  21162. * Returns the submesh BoudingInfo object
  21163. * @returns current bounding info (or mesh's one if the submesh is global)
  21164. */
  21165. getBoundingInfo(): BoundingInfo;
  21166. /**
  21167. * Sets the submesh BoundingInfo
  21168. * @param boundingInfo defines the new bounding info to use
  21169. * @returns the SubMesh
  21170. */
  21171. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21172. /**
  21173. * Returns the mesh of the current submesh
  21174. * @return the parent mesh
  21175. */
  21176. getMesh(): AbstractMesh;
  21177. /**
  21178. * Returns the rendering mesh of the submesh
  21179. * @returns the rendering mesh (could be different from parent mesh)
  21180. */
  21181. getRenderingMesh(): Mesh;
  21182. /**
  21183. * Returns the submesh material
  21184. * @returns null or the current material
  21185. */
  21186. getMaterial(): Nullable<Material>;
  21187. /**
  21188. * Sets a new updated BoundingInfo object to the submesh
  21189. * @param data defines an optional position array to use to determine the bounding info
  21190. * @returns the SubMesh
  21191. */
  21192. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21193. /** @hidden */
  21194. _checkCollision(collider: Collider): boolean;
  21195. /**
  21196. * Updates the submesh BoundingInfo
  21197. * @param world defines the world matrix to use to update the bounding info
  21198. * @returns the submesh
  21199. */
  21200. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21201. /**
  21202. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21203. * @param frustumPlanes defines the frustum planes
  21204. * @returns true if the submesh is intersecting with the frustum
  21205. */
  21206. isInFrustum(frustumPlanes: Plane[]): boolean;
  21207. /**
  21208. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21209. * @param frustumPlanes defines the frustum planes
  21210. * @returns true if the submesh is inside the frustum
  21211. */
  21212. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21213. /**
  21214. * Renders the submesh
  21215. * @param enableAlphaMode defines if alpha needs to be used
  21216. * @returns the submesh
  21217. */
  21218. render(enableAlphaMode: boolean): SubMesh;
  21219. /**
  21220. * @hidden
  21221. */
  21222. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21223. /**
  21224. * Checks if the submesh intersects with a ray
  21225. * @param ray defines the ray to test
  21226. * @returns true is the passed ray intersects the submesh bounding box
  21227. */
  21228. canIntersects(ray: Ray): boolean;
  21229. /**
  21230. * Intersects current submesh with a ray
  21231. * @param ray defines the ray to test
  21232. * @param positions defines mesh's positions array
  21233. * @param indices defines mesh's indices array
  21234. * @param fastCheck defines if only bounding info should be used
  21235. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21236. * @returns intersection info or null if no intersection
  21237. */
  21238. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21239. /** @hidden */
  21240. private _intersectLines;
  21241. /** @hidden */
  21242. private _intersectUnIndexedLines;
  21243. /** @hidden */
  21244. private _intersectTriangles;
  21245. /** @hidden */
  21246. private _intersectUnIndexedTriangles;
  21247. /** @hidden */
  21248. _rebuild(): void;
  21249. /**
  21250. * Creates a new submesh from the passed mesh
  21251. * @param newMesh defines the new hosting mesh
  21252. * @param newRenderingMesh defines an optional rendering mesh
  21253. * @returns the new submesh
  21254. */
  21255. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21256. /**
  21257. * Release associated resources
  21258. */
  21259. dispose(): void;
  21260. /**
  21261. * Gets the class name
  21262. * @returns the string "SubMesh".
  21263. */
  21264. getClassName(): string;
  21265. /**
  21266. * Creates a new submesh from indices data
  21267. * @param materialIndex the index of the main mesh material
  21268. * @param startIndex the index where to start the copy in the mesh indices array
  21269. * @param indexCount the number of indices to copy then from the startIndex
  21270. * @param mesh the main mesh to create the submesh from
  21271. * @param renderingMesh the optional rendering mesh
  21272. * @returns a new submesh
  21273. */
  21274. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21275. }
  21276. }
  21277. declare module BABYLON {
  21278. /**
  21279. * Class used to represent data loading progression
  21280. */
  21281. export class SceneLoaderFlags {
  21282. private static _ForceFullSceneLoadingForIncremental;
  21283. private static _ShowLoadingScreen;
  21284. private static _CleanBoneMatrixWeights;
  21285. private static _loggingLevel;
  21286. /**
  21287. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21288. */
  21289. static ForceFullSceneLoadingForIncremental: boolean;
  21290. /**
  21291. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21292. */
  21293. static ShowLoadingScreen: boolean;
  21294. /**
  21295. * Defines the current logging level (while loading the scene)
  21296. * @ignorenaming
  21297. */
  21298. static loggingLevel: number;
  21299. /**
  21300. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21301. */
  21302. static CleanBoneMatrixWeights: boolean;
  21303. }
  21304. }
  21305. declare module BABYLON {
  21306. /**
  21307. * Class used to store geometry data (vertex buffers + index buffer)
  21308. */
  21309. export class Geometry implements IGetSetVerticesData {
  21310. /**
  21311. * Gets or sets the ID of the geometry
  21312. */
  21313. id: string;
  21314. /**
  21315. * Gets or sets the unique ID of the geometry
  21316. */
  21317. uniqueId: number;
  21318. /**
  21319. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21320. */
  21321. delayLoadState: number;
  21322. /**
  21323. * Gets the file containing the data to load when running in delay load state
  21324. */
  21325. delayLoadingFile: Nullable<string>;
  21326. /**
  21327. * Callback called when the geometry is updated
  21328. */
  21329. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21330. private _scene;
  21331. private _engine;
  21332. private _meshes;
  21333. private _totalVertices;
  21334. /** @hidden */
  21335. _indices: IndicesArray;
  21336. /** @hidden */
  21337. _vertexBuffers: {
  21338. [key: string]: VertexBuffer;
  21339. };
  21340. private _isDisposed;
  21341. private _extend;
  21342. private _boundingBias;
  21343. /** @hidden */
  21344. _delayInfo: Array<string>;
  21345. private _indexBuffer;
  21346. private _indexBufferIsUpdatable;
  21347. /** @hidden */
  21348. _boundingInfo: Nullable<BoundingInfo>;
  21349. /** @hidden */
  21350. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21351. /** @hidden */
  21352. _softwareSkinningFrameId: number;
  21353. private _vertexArrayObjects;
  21354. private _updatable;
  21355. /** @hidden */
  21356. _positions: Nullable<Vector3[]>;
  21357. /**
  21358. * 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
  21359. */
  21360. /**
  21361. * 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
  21362. */
  21363. boundingBias: Vector2;
  21364. /**
  21365. * Static function used to attach a new empty geometry to a mesh
  21366. * @param mesh defines the mesh to attach the geometry to
  21367. * @returns the new Geometry
  21368. */
  21369. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21370. /**
  21371. * Creates a new geometry
  21372. * @param id defines the unique ID
  21373. * @param scene defines the hosting scene
  21374. * @param vertexData defines the VertexData used to get geometry data
  21375. * @param updatable defines if geometry must be updatable (false by default)
  21376. * @param mesh defines the mesh that will be associated with the geometry
  21377. */
  21378. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21379. /**
  21380. * Gets the current extend of the geometry
  21381. */
  21382. readonly extend: {
  21383. minimum: Vector3;
  21384. maximum: Vector3;
  21385. };
  21386. /**
  21387. * Gets the hosting scene
  21388. * @returns the hosting Scene
  21389. */
  21390. getScene(): Scene;
  21391. /**
  21392. * Gets the hosting engine
  21393. * @returns the hosting Engine
  21394. */
  21395. getEngine(): Engine;
  21396. /**
  21397. * Defines if the geometry is ready to use
  21398. * @returns true if the geometry is ready to be used
  21399. */
  21400. isReady(): boolean;
  21401. /**
  21402. * Gets a value indicating that the geometry should not be serialized
  21403. */
  21404. readonly doNotSerialize: boolean;
  21405. /** @hidden */
  21406. _rebuild(): void;
  21407. /**
  21408. * Affects all geometry data in one call
  21409. * @param vertexData defines the geometry data
  21410. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21411. */
  21412. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21413. /**
  21414. * Set specific vertex data
  21415. * @param kind defines the data kind (Position, normal, etc...)
  21416. * @param data defines the vertex data to use
  21417. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21418. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21419. */
  21420. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21421. /**
  21422. * Removes a specific vertex data
  21423. * @param kind defines the data kind (Position, normal, etc...)
  21424. */
  21425. removeVerticesData(kind: string): void;
  21426. /**
  21427. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21428. * @param buffer defines the vertex buffer to use
  21429. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21430. */
  21431. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21432. /**
  21433. * Update a specific vertex buffer
  21434. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21435. * It will do nothing if the buffer is not updatable
  21436. * @param kind defines the data kind (Position, normal, etc...)
  21437. * @param data defines the data to use
  21438. * @param offset defines the offset in the target buffer where to store the data
  21439. * @param useBytes set to true if the offset is in bytes
  21440. */
  21441. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21442. /**
  21443. * Update a specific vertex buffer
  21444. * This function will create a new buffer if the current one is not updatable
  21445. * @param kind defines the data kind (Position, normal, etc...)
  21446. * @param data defines the data to use
  21447. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21448. */
  21449. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21450. private _updateBoundingInfo;
  21451. /** @hidden */
  21452. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21453. /**
  21454. * Gets total number of vertices
  21455. * @returns the total number of vertices
  21456. */
  21457. getTotalVertices(): number;
  21458. /**
  21459. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21460. * @param kind defines the data kind (Position, normal, etc...)
  21461. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21462. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21463. * @returns a float array containing vertex data
  21464. */
  21465. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21466. /**
  21467. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21468. * @param kind defines the data kind (Position, normal, etc...)
  21469. * @returns true if the vertex buffer with the specified kind is updatable
  21470. */
  21471. isVertexBufferUpdatable(kind: string): boolean;
  21472. /**
  21473. * Gets a specific vertex buffer
  21474. * @param kind defines the data kind (Position, normal, etc...)
  21475. * @returns a VertexBuffer
  21476. */
  21477. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21478. /**
  21479. * Returns all vertex buffers
  21480. * @return an object holding all vertex buffers indexed by kind
  21481. */
  21482. getVertexBuffers(): Nullable<{
  21483. [key: string]: VertexBuffer;
  21484. }>;
  21485. /**
  21486. * Gets a boolean indicating if specific vertex buffer is present
  21487. * @param kind defines the data kind (Position, normal, etc...)
  21488. * @returns true if data is present
  21489. */
  21490. isVerticesDataPresent(kind: string): boolean;
  21491. /**
  21492. * Gets a list of all attached data kinds (Position, normal, etc...)
  21493. * @returns a list of string containing all kinds
  21494. */
  21495. getVerticesDataKinds(): string[];
  21496. /**
  21497. * Update index buffer
  21498. * @param indices defines the indices to store in the index buffer
  21499. * @param offset defines the offset in the target buffer where to store the data
  21500. * @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)
  21501. */
  21502. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21503. /**
  21504. * Creates a new index buffer
  21505. * @param indices defines the indices to store in the index buffer
  21506. * @param totalVertices defines the total number of vertices (could be null)
  21507. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21508. */
  21509. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21510. /**
  21511. * Return the total number of indices
  21512. * @returns the total number of indices
  21513. */
  21514. getTotalIndices(): number;
  21515. /**
  21516. * Gets the index buffer array
  21517. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21518. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21519. * @returns the index buffer array
  21520. */
  21521. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21522. /**
  21523. * Gets the index buffer
  21524. * @return the index buffer
  21525. */
  21526. getIndexBuffer(): Nullable<DataBuffer>;
  21527. /** @hidden */
  21528. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21529. /**
  21530. * Release the associated resources for a specific mesh
  21531. * @param mesh defines the source mesh
  21532. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21533. */
  21534. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21535. /**
  21536. * Apply current geometry to a given mesh
  21537. * @param mesh defines the mesh to apply geometry to
  21538. */
  21539. applyToMesh(mesh: Mesh): void;
  21540. private _updateExtend;
  21541. private _applyToMesh;
  21542. private notifyUpdate;
  21543. /**
  21544. * Load the geometry if it was flagged as delay loaded
  21545. * @param scene defines the hosting scene
  21546. * @param onLoaded defines a callback called when the geometry is loaded
  21547. */
  21548. load(scene: Scene, onLoaded?: () => void): void;
  21549. private _queueLoad;
  21550. /**
  21551. * Invert the geometry to move from a right handed system to a left handed one.
  21552. */
  21553. toLeftHanded(): void;
  21554. /** @hidden */
  21555. _resetPointsArrayCache(): void;
  21556. /** @hidden */
  21557. _generatePointsArray(): boolean;
  21558. /**
  21559. * Gets a value indicating if the geometry is disposed
  21560. * @returns true if the geometry was disposed
  21561. */
  21562. isDisposed(): boolean;
  21563. private _disposeVertexArrayObjects;
  21564. /**
  21565. * Free all associated resources
  21566. */
  21567. dispose(): void;
  21568. /**
  21569. * Clone the current geometry into a new geometry
  21570. * @param id defines the unique ID of the new geometry
  21571. * @returns a new geometry object
  21572. */
  21573. copy(id: string): Geometry;
  21574. /**
  21575. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21576. * @return a JSON representation of the current geometry data (without the vertices data)
  21577. */
  21578. serialize(): any;
  21579. private toNumberArray;
  21580. /**
  21581. * Serialize all vertices data into a JSON oject
  21582. * @returns a JSON representation of the current geometry data
  21583. */
  21584. serializeVerticeData(): any;
  21585. /**
  21586. * Extracts a clone of a mesh geometry
  21587. * @param mesh defines the source mesh
  21588. * @param id defines the unique ID of the new geometry object
  21589. * @returns the new geometry object
  21590. */
  21591. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21592. /**
  21593. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21594. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21595. * Be aware Math.random() could cause collisions, but:
  21596. * "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"
  21597. * @returns a string containing a new GUID
  21598. */
  21599. static RandomId(): string;
  21600. /** @hidden */
  21601. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21602. private static _CleanMatricesWeights;
  21603. /**
  21604. * Create a new geometry from persisted data (Using .babylon file format)
  21605. * @param parsedVertexData defines the persisted data
  21606. * @param scene defines the hosting scene
  21607. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21608. * @returns the new geometry object
  21609. */
  21610. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21611. }
  21612. }
  21613. declare module BABYLON {
  21614. /**
  21615. * Define an interface for all classes that will get and set the data on vertices
  21616. */
  21617. export interface IGetSetVerticesData {
  21618. /**
  21619. * Gets a boolean indicating if specific vertex data is present
  21620. * @param kind defines the vertex data kind to use
  21621. * @returns true is data kind is present
  21622. */
  21623. isVerticesDataPresent(kind: string): boolean;
  21624. /**
  21625. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21626. * @param kind defines the data kind (Position, normal, etc...)
  21627. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21628. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21629. * @returns a float array containing vertex data
  21630. */
  21631. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21632. /**
  21633. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21634. * @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.
  21635. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21636. * @returns the indices array or an empty array if the mesh has no geometry
  21637. */
  21638. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21639. /**
  21640. * Set specific vertex data
  21641. * @param kind defines the data kind (Position, normal, etc...)
  21642. * @param data defines the vertex data to use
  21643. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21644. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21645. */
  21646. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21647. /**
  21648. * Update a specific associated vertex buffer
  21649. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21650. * - VertexBuffer.PositionKind
  21651. * - VertexBuffer.UVKind
  21652. * - VertexBuffer.UV2Kind
  21653. * - VertexBuffer.UV3Kind
  21654. * - VertexBuffer.UV4Kind
  21655. * - VertexBuffer.UV5Kind
  21656. * - VertexBuffer.UV6Kind
  21657. * - VertexBuffer.ColorKind
  21658. * - VertexBuffer.MatricesIndicesKind
  21659. * - VertexBuffer.MatricesIndicesExtraKind
  21660. * - VertexBuffer.MatricesWeightsKind
  21661. * - VertexBuffer.MatricesWeightsExtraKind
  21662. * @param data defines the data source
  21663. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21664. * @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)
  21665. */
  21666. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21667. /**
  21668. * Creates a new index buffer
  21669. * @param indices defines the indices to store in the index buffer
  21670. * @param totalVertices defines the total number of vertices (could be null)
  21671. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21672. */
  21673. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21674. }
  21675. /**
  21676. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21677. */
  21678. export class VertexData {
  21679. /**
  21680. * Mesh side orientation : usually the external or front surface
  21681. */
  21682. static readonly FRONTSIDE: number;
  21683. /**
  21684. * Mesh side orientation : usually the internal or back surface
  21685. */
  21686. static readonly BACKSIDE: number;
  21687. /**
  21688. * Mesh side orientation : both internal and external or front and back surfaces
  21689. */
  21690. static readonly DOUBLESIDE: number;
  21691. /**
  21692. * Mesh side orientation : by default, `FRONTSIDE`
  21693. */
  21694. static readonly DEFAULTSIDE: number;
  21695. /**
  21696. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21697. */
  21698. positions: Nullable<FloatArray>;
  21699. /**
  21700. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21701. */
  21702. normals: Nullable<FloatArray>;
  21703. /**
  21704. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21705. */
  21706. tangents: Nullable<FloatArray>;
  21707. /**
  21708. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21709. */
  21710. uvs: Nullable<FloatArray>;
  21711. /**
  21712. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21713. */
  21714. uvs2: Nullable<FloatArray>;
  21715. /**
  21716. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21717. */
  21718. uvs3: Nullable<FloatArray>;
  21719. /**
  21720. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21721. */
  21722. uvs4: Nullable<FloatArray>;
  21723. /**
  21724. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21725. */
  21726. uvs5: Nullable<FloatArray>;
  21727. /**
  21728. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21729. */
  21730. uvs6: Nullable<FloatArray>;
  21731. /**
  21732. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21733. */
  21734. colors: Nullable<FloatArray>;
  21735. /**
  21736. * 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).
  21737. */
  21738. matricesIndices: Nullable<FloatArray>;
  21739. /**
  21740. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21741. */
  21742. matricesWeights: Nullable<FloatArray>;
  21743. /**
  21744. * An array extending the number of possible indices
  21745. */
  21746. matricesIndicesExtra: Nullable<FloatArray>;
  21747. /**
  21748. * An array extending the number of possible weights when the number of indices is extended
  21749. */
  21750. matricesWeightsExtra: Nullable<FloatArray>;
  21751. /**
  21752. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21753. */
  21754. indices: Nullable<IndicesArray>;
  21755. /**
  21756. * Uses the passed data array to set the set the values for the specified kind of data
  21757. * @param data a linear array of floating numbers
  21758. * @param kind the type of data that is being set, eg positions, colors etc
  21759. */
  21760. set(data: FloatArray, kind: string): void;
  21761. /**
  21762. * Associates the vertexData to the passed Mesh.
  21763. * Sets it as updatable or not (default `false`)
  21764. * @param mesh the mesh the vertexData is applied to
  21765. * @param updatable when used and having the value true allows new data to update the vertexData
  21766. * @returns the VertexData
  21767. */
  21768. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21769. /**
  21770. * Associates the vertexData to the passed Geometry.
  21771. * Sets it as updatable or not (default `false`)
  21772. * @param geometry the geometry the vertexData is applied to
  21773. * @param updatable when used and having the value true allows new data to update the vertexData
  21774. * @returns VertexData
  21775. */
  21776. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21777. /**
  21778. * Updates the associated mesh
  21779. * @param mesh the mesh to be updated
  21780. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21781. * @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
  21782. * @returns VertexData
  21783. */
  21784. updateMesh(mesh: Mesh): VertexData;
  21785. /**
  21786. * Updates the associated geometry
  21787. * @param geometry the geometry to be updated
  21788. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21789. * @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
  21790. * @returns VertexData.
  21791. */
  21792. updateGeometry(geometry: Geometry): VertexData;
  21793. private _applyTo;
  21794. private _update;
  21795. /**
  21796. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21797. * @param matrix the transforming matrix
  21798. * @returns the VertexData
  21799. */
  21800. transform(matrix: Matrix): VertexData;
  21801. /**
  21802. * Merges the passed VertexData into the current one
  21803. * @param other the VertexData to be merged into the current one
  21804. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21805. * @returns the modified VertexData
  21806. */
  21807. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21808. private _mergeElement;
  21809. private _validate;
  21810. /**
  21811. * Serializes the VertexData
  21812. * @returns a serialized object
  21813. */
  21814. serialize(): any;
  21815. /**
  21816. * Extracts the vertexData from a mesh
  21817. * @param mesh the mesh from which to extract the VertexData
  21818. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21819. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21820. * @returns the object VertexData associated to the passed mesh
  21821. */
  21822. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21823. /**
  21824. * Extracts the vertexData from the geometry
  21825. * @param geometry the geometry from which to extract the VertexData
  21826. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21827. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21828. * @returns the object VertexData associated to the passed mesh
  21829. */
  21830. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21831. private static _ExtractFrom;
  21832. /**
  21833. * Creates the VertexData for a Ribbon
  21834. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21835. * * pathArray array of paths, each of which an array of successive Vector3
  21836. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21837. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21838. * * 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
  21839. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21840. * * 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)
  21841. * * 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)
  21842. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21843. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21844. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21845. * @returns the VertexData of the ribbon
  21846. */
  21847. static CreateRibbon(options: {
  21848. pathArray: Vector3[][];
  21849. closeArray?: boolean;
  21850. closePath?: boolean;
  21851. offset?: number;
  21852. sideOrientation?: number;
  21853. frontUVs?: Vector4;
  21854. backUVs?: Vector4;
  21855. invertUV?: boolean;
  21856. uvs?: Vector2[];
  21857. colors?: Color4[];
  21858. }): VertexData;
  21859. /**
  21860. * Creates the VertexData for a box
  21861. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21862. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21863. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21864. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21865. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21866. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21867. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21868. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21869. * * 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)
  21870. * * 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)
  21871. * @returns the VertexData of the box
  21872. */
  21873. static CreateBox(options: {
  21874. size?: number;
  21875. width?: number;
  21876. height?: number;
  21877. depth?: number;
  21878. faceUV?: Vector4[];
  21879. faceColors?: Color4[];
  21880. sideOrientation?: number;
  21881. frontUVs?: Vector4;
  21882. backUVs?: Vector4;
  21883. }): VertexData;
  21884. /**
  21885. * Creates the VertexData for a tiled box
  21886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21887. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21888. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21889. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21891. * @returns the VertexData of the box
  21892. */
  21893. static CreateTiledBox(options: {
  21894. pattern?: number;
  21895. width?: number;
  21896. height?: number;
  21897. depth?: number;
  21898. tileSize?: number;
  21899. tileWidth?: number;
  21900. tileHeight?: number;
  21901. alignHorizontal?: number;
  21902. alignVertical?: number;
  21903. faceUV?: Vector4[];
  21904. faceColors?: Color4[];
  21905. sideOrientation?: number;
  21906. }): VertexData;
  21907. /**
  21908. * Creates the VertexData for a tiled plane
  21909. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21910. * * pattern a limited pattern arrangement depending on the number
  21911. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21912. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21913. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21915. * * 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)
  21916. * * 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)
  21917. * @returns the VertexData of the tiled plane
  21918. */
  21919. static CreateTiledPlane(options: {
  21920. pattern?: number;
  21921. tileSize?: number;
  21922. tileWidth?: number;
  21923. tileHeight?: number;
  21924. size?: number;
  21925. width?: number;
  21926. height?: number;
  21927. alignHorizontal?: number;
  21928. alignVertical?: number;
  21929. sideOrientation?: number;
  21930. frontUVs?: Vector4;
  21931. backUVs?: Vector4;
  21932. }): VertexData;
  21933. /**
  21934. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21935. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21936. * * segments sets the number of horizontal strips optional, default 32
  21937. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21938. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21939. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21940. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21941. * * 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
  21942. * * 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
  21943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21944. * * 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)
  21945. * * 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)
  21946. * @returns the VertexData of the ellipsoid
  21947. */
  21948. static CreateSphere(options: {
  21949. segments?: number;
  21950. diameter?: number;
  21951. diameterX?: number;
  21952. diameterY?: number;
  21953. diameterZ?: number;
  21954. arc?: number;
  21955. slice?: number;
  21956. sideOrientation?: number;
  21957. frontUVs?: Vector4;
  21958. backUVs?: Vector4;
  21959. }): VertexData;
  21960. /**
  21961. * Creates the VertexData for a cylinder, cone or prism
  21962. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21963. * * height sets the height (y direction) of the cylinder, optional, default 2
  21964. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21965. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21966. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21967. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21968. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21969. * * 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
  21970. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21971. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21972. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21973. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21975. * * 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)
  21976. * * 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)
  21977. * @returns the VertexData of the cylinder, cone or prism
  21978. */
  21979. static CreateCylinder(options: {
  21980. height?: number;
  21981. diameterTop?: number;
  21982. diameterBottom?: number;
  21983. diameter?: number;
  21984. tessellation?: number;
  21985. subdivisions?: number;
  21986. arc?: number;
  21987. faceColors?: Color4[];
  21988. faceUV?: Vector4[];
  21989. hasRings?: boolean;
  21990. enclose?: boolean;
  21991. sideOrientation?: number;
  21992. frontUVs?: Vector4;
  21993. backUVs?: Vector4;
  21994. }): VertexData;
  21995. /**
  21996. * Creates the VertexData for a torus
  21997. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21998. * * diameter the diameter of the torus, optional default 1
  21999. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22000. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22002. * * 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)
  22003. * * 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)
  22004. * @returns the VertexData of the torus
  22005. */
  22006. static CreateTorus(options: {
  22007. diameter?: number;
  22008. thickness?: number;
  22009. tessellation?: number;
  22010. sideOrientation?: number;
  22011. frontUVs?: Vector4;
  22012. backUVs?: Vector4;
  22013. }): VertexData;
  22014. /**
  22015. * Creates the VertexData of the LineSystem
  22016. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22017. * - lines an array of lines, each line being an array of successive Vector3
  22018. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22019. * @returns the VertexData of the LineSystem
  22020. */
  22021. static CreateLineSystem(options: {
  22022. lines: Vector3[][];
  22023. colors?: Nullable<Color4[][]>;
  22024. }): VertexData;
  22025. /**
  22026. * Create the VertexData for a DashedLines
  22027. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22028. * - points an array successive Vector3
  22029. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22030. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22031. * - dashNb the intended total number of dashes, optional, default 200
  22032. * @returns the VertexData for the DashedLines
  22033. */
  22034. static CreateDashedLines(options: {
  22035. points: Vector3[];
  22036. dashSize?: number;
  22037. gapSize?: number;
  22038. dashNb?: number;
  22039. }): VertexData;
  22040. /**
  22041. * Creates the VertexData for a Ground
  22042. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22043. * - width the width (x direction) of the ground, optional, default 1
  22044. * - height the height (z direction) of the ground, optional, default 1
  22045. * - subdivisions the number of subdivisions per side, optional, default 1
  22046. * @returns the VertexData of the Ground
  22047. */
  22048. static CreateGround(options: {
  22049. width?: number;
  22050. height?: number;
  22051. subdivisions?: number;
  22052. subdivisionsX?: number;
  22053. subdivisionsY?: number;
  22054. }): VertexData;
  22055. /**
  22056. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22057. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22058. * * xmin the ground minimum X coordinate, optional, default -1
  22059. * * zmin the ground minimum Z coordinate, optional, default -1
  22060. * * xmax the ground maximum X coordinate, optional, default 1
  22061. * * zmax the ground maximum Z coordinate, optional, default 1
  22062. * * 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}
  22063. * * 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}
  22064. * @returns the VertexData of the TiledGround
  22065. */
  22066. static CreateTiledGround(options: {
  22067. xmin: number;
  22068. zmin: number;
  22069. xmax: number;
  22070. zmax: number;
  22071. subdivisions?: {
  22072. w: number;
  22073. h: number;
  22074. };
  22075. precision?: {
  22076. w: number;
  22077. h: number;
  22078. };
  22079. }): VertexData;
  22080. /**
  22081. * Creates the VertexData of the Ground designed from a heightmap
  22082. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22083. * * width the width (x direction) of the ground
  22084. * * height the height (z direction) of the ground
  22085. * * subdivisions the number of subdivisions per side
  22086. * * minHeight the minimum altitude on the ground, optional, default 0
  22087. * * maxHeight the maximum altitude on the ground, optional default 1
  22088. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22089. * * buffer the array holding the image color data
  22090. * * bufferWidth the width of image
  22091. * * bufferHeight the height of image
  22092. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22093. * @returns the VertexData of the Ground designed from a heightmap
  22094. */
  22095. static CreateGroundFromHeightMap(options: {
  22096. width: number;
  22097. height: number;
  22098. subdivisions: number;
  22099. minHeight: number;
  22100. maxHeight: number;
  22101. colorFilter: Color3;
  22102. buffer: Uint8Array;
  22103. bufferWidth: number;
  22104. bufferHeight: number;
  22105. alphaFilter: number;
  22106. }): VertexData;
  22107. /**
  22108. * Creates the VertexData for a Plane
  22109. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22110. * * size sets the width and height of the plane to the value of size, optional default 1
  22111. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22112. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22114. * * 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)
  22115. * * 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)
  22116. * @returns the VertexData of the box
  22117. */
  22118. static CreatePlane(options: {
  22119. size?: number;
  22120. width?: number;
  22121. height?: number;
  22122. sideOrientation?: number;
  22123. frontUVs?: Vector4;
  22124. backUVs?: Vector4;
  22125. }): VertexData;
  22126. /**
  22127. * Creates the VertexData of the Disc or regular Polygon
  22128. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22129. * * radius the radius of the disc, optional default 0.5
  22130. * * tessellation the number of polygon sides, optional, default 64
  22131. * * 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
  22132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22133. * * 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)
  22134. * * 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)
  22135. * @returns the VertexData of the box
  22136. */
  22137. static CreateDisc(options: {
  22138. radius?: number;
  22139. tessellation?: number;
  22140. arc?: number;
  22141. sideOrientation?: number;
  22142. frontUVs?: Vector4;
  22143. backUVs?: Vector4;
  22144. }): VertexData;
  22145. /**
  22146. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22147. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22148. * @param polygon a mesh built from polygonTriangulation.build()
  22149. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22150. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22151. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22152. * @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)
  22153. * @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)
  22154. * @returns the VertexData of the Polygon
  22155. */
  22156. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22157. /**
  22158. * Creates the VertexData of the IcoSphere
  22159. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22160. * * radius the radius of the IcoSphere, optional default 1
  22161. * * radiusX allows stretching in the x direction, optional, default radius
  22162. * * radiusY allows stretching in the y direction, optional, default radius
  22163. * * radiusZ allows stretching in the z direction, optional, default radius
  22164. * * flat when true creates a flat shaded mesh, optional, default true
  22165. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22167. * * 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)
  22168. * * 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)
  22169. * @returns the VertexData of the IcoSphere
  22170. */
  22171. static CreateIcoSphere(options: {
  22172. radius?: number;
  22173. radiusX?: number;
  22174. radiusY?: number;
  22175. radiusZ?: number;
  22176. flat?: boolean;
  22177. subdivisions?: number;
  22178. sideOrientation?: number;
  22179. frontUVs?: Vector4;
  22180. backUVs?: Vector4;
  22181. }): VertexData;
  22182. /**
  22183. * Creates the VertexData for a Polyhedron
  22184. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22185. * * type provided types are:
  22186. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22187. * * 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)
  22188. * * size the size of the IcoSphere, optional default 1
  22189. * * sizeX allows stretching in the x direction, optional, default size
  22190. * * sizeY allows stretching in the y direction, optional, default size
  22191. * * sizeZ allows stretching in the z direction, optional, default size
  22192. * * 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
  22193. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22194. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22195. * * flat when true creates a flat shaded mesh, optional, default true
  22196. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22198. * * 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)
  22199. * * 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)
  22200. * @returns the VertexData of the Polyhedron
  22201. */
  22202. static CreatePolyhedron(options: {
  22203. type?: number;
  22204. size?: number;
  22205. sizeX?: number;
  22206. sizeY?: number;
  22207. sizeZ?: number;
  22208. custom?: any;
  22209. faceUV?: Vector4[];
  22210. faceColors?: Color4[];
  22211. flat?: boolean;
  22212. sideOrientation?: number;
  22213. frontUVs?: Vector4;
  22214. backUVs?: Vector4;
  22215. }): VertexData;
  22216. /**
  22217. * Creates the VertexData for a TorusKnot
  22218. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22219. * * radius the radius of the torus knot, optional, default 2
  22220. * * tube the thickness of the tube, optional, default 0.5
  22221. * * radialSegments the number of sides on each tube segments, optional, default 32
  22222. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22223. * * p the number of windings around the z axis, optional, default 2
  22224. * * q the number of windings around the x axis, optional, default 3
  22225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22226. * * 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)
  22227. * * 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)
  22228. * @returns the VertexData of the Torus Knot
  22229. */
  22230. static CreateTorusKnot(options: {
  22231. radius?: number;
  22232. tube?: number;
  22233. radialSegments?: number;
  22234. tubularSegments?: number;
  22235. p?: number;
  22236. q?: number;
  22237. sideOrientation?: number;
  22238. frontUVs?: Vector4;
  22239. backUVs?: Vector4;
  22240. }): VertexData;
  22241. /**
  22242. * Compute normals for given positions and indices
  22243. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22244. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22245. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22246. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22247. * * facetNormals : optional array of facet normals (vector3)
  22248. * * facetPositions : optional array of facet positions (vector3)
  22249. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22250. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22251. * * bInfo : optional bounding info, required for facetPartitioning computation
  22252. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22253. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22254. * * useRightHandedSystem: optional boolean to for right handed system computation
  22255. * * depthSort : optional boolean to enable the facet depth sort computation
  22256. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22257. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22258. */
  22259. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22260. facetNormals?: any;
  22261. facetPositions?: any;
  22262. facetPartitioning?: any;
  22263. ratio?: number;
  22264. bInfo?: any;
  22265. bbSize?: Vector3;
  22266. subDiv?: any;
  22267. useRightHandedSystem?: boolean;
  22268. depthSort?: boolean;
  22269. distanceTo?: Vector3;
  22270. depthSortedFacets?: any;
  22271. }): void;
  22272. /** @hidden */
  22273. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22274. /**
  22275. * Applies VertexData created from the imported parameters to the geometry
  22276. * @param parsedVertexData the parsed data from an imported file
  22277. * @param geometry the geometry to apply the VertexData to
  22278. */
  22279. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22280. }
  22281. }
  22282. declare module BABYLON {
  22283. /**
  22284. * Defines a target to use with MorphTargetManager
  22285. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22286. */
  22287. export class MorphTarget implements IAnimatable {
  22288. /** defines the name of the target */
  22289. name: string;
  22290. /**
  22291. * Gets or sets the list of animations
  22292. */
  22293. animations: Animation[];
  22294. private _scene;
  22295. private _positions;
  22296. private _normals;
  22297. private _tangents;
  22298. private _uvs;
  22299. private _influence;
  22300. private _uniqueId;
  22301. /**
  22302. * Observable raised when the influence changes
  22303. */
  22304. onInfluenceChanged: Observable<boolean>;
  22305. /** @hidden */
  22306. _onDataLayoutChanged: Observable<void>;
  22307. /**
  22308. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22309. */
  22310. influence: number;
  22311. /**
  22312. * Gets or sets the id of the morph Target
  22313. */
  22314. id: string;
  22315. private _animationPropertiesOverride;
  22316. /**
  22317. * Gets or sets the animation properties override
  22318. */
  22319. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22320. /**
  22321. * Creates a new MorphTarget
  22322. * @param name defines the name of the target
  22323. * @param influence defines the influence to use
  22324. * @param scene defines the scene the morphtarget belongs to
  22325. */
  22326. constructor(
  22327. /** defines the name of the target */
  22328. name: string, influence?: number, scene?: Nullable<Scene>);
  22329. /**
  22330. * Gets the unique ID of this manager
  22331. */
  22332. readonly uniqueId: number;
  22333. /**
  22334. * Gets a boolean defining if the target contains position data
  22335. */
  22336. readonly hasPositions: boolean;
  22337. /**
  22338. * Gets a boolean defining if the target contains normal data
  22339. */
  22340. readonly hasNormals: boolean;
  22341. /**
  22342. * Gets a boolean defining if the target contains tangent data
  22343. */
  22344. readonly hasTangents: boolean;
  22345. /**
  22346. * Gets a boolean defining if the target contains texture coordinates data
  22347. */
  22348. readonly hasUVs: boolean;
  22349. /**
  22350. * Affects position data to this target
  22351. * @param data defines the position data to use
  22352. */
  22353. setPositions(data: Nullable<FloatArray>): void;
  22354. /**
  22355. * Gets the position data stored in this target
  22356. * @returns a FloatArray containing the position data (or null if not present)
  22357. */
  22358. getPositions(): Nullable<FloatArray>;
  22359. /**
  22360. * Affects normal data to this target
  22361. * @param data defines the normal data to use
  22362. */
  22363. setNormals(data: Nullable<FloatArray>): void;
  22364. /**
  22365. * Gets the normal data stored in this target
  22366. * @returns a FloatArray containing the normal data (or null if not present)
  22367. */
  22368. getNormals(): Nullable<FloatArray>;
  22369. /**
  22370. * Affects tangent data to this target
  22371. * @param data defines the tangent data to use
  22372. */
  22373. setTangents(data: Nullable<FloatArray>): void;
  22374. /**
  22375. * Gets the tangent data stored in this target
  22376. * @returns a FloatArray containing the tangent data (or null if not present)
  22377. */
  22378. getTangents(): Nullable<FloatArray>;
  22379. /**
  22380. * Affects texture coordinates data to this target
  22381. * @param data defines the texture coordinates data to use
  22382. */
  22383. setUVs(data: Nullable<FloatArray>): void;
  22384. /**
  22385. * Gets the texture coordinates data stored in this target
  22386. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22387. */
  22388. getUVs(): Nullable<FloatArray>;
  22389. /**
  22390. * Clone the current target
  22391. * @returns a new MorphTarget
  22392. */
  22393. clone(): MorphTarget;
  22394. /**
  22395. * Serializes the current target into a Serialization object
  22396. * @returns the serialized object
  22397. */
  22398. serialize(): any;
  22399. /**
  22400. * Returns the string "MorphTarget"
  22401. * @returns "MorphTarget"
  22402. */
  22403. getClassName(): string;
  22404. /**
  22405. * Creates a new target from serialized data
  22406. * @param serializationObject defines the serialized data to use
  22407. * @returns a new MorphTarget
  22408. */
  22409. static Parse(serializationObject: any): MorphTarget;
  22410. /**
  22411. * Creates a MorphTarget from mesh data
  22412. * @param mesh defines the source mesh
  22413. * @param name defines the name to use for the new target
  22414. * @param influence defines the influence to attach to the target
  22415. * @returns a new MorphTarget
  22416. */
  22417. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22418. }
  22419. }
  22420. declare module BABYLON {
  22421. /**
  22422. * This class is used to deform meshes using morphing between different targets
  22423. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22424. */
  22425. export class MorphTargetManager {
  22426. private _targets;
  22427. private _targetInfluenceChangedObservers;
  22428. private _targetDataLayoutChangedObservers;
  22429. private _activeTargets;
  22430. private _scene;
  22431. private _influences;
  22432. private _supportsNormals;
  22433. private _supportsTangents;
  22434. private _supportsUVs;
  22435. private _vertexCount;
  22436. private _uniqueId;
  22437. private _tempInfluences;
  22438. /**
  22439. * Gets or sets a boolean indicating if normals must be morphed
  22440. */
  22441. enableNormalMorphing: boolean;
  22442. /**
  22443. * Gets or sets a boolean indicating if tangents must be morphed
  22444. */
  22445. enableTangentMorphing: boolean;
  22446. /**
  22447. * Gets or sets a boolean indicating if UV must be morphed
  22448. */
  22449. enableUVMorphing: boolean;
  22450. /**
  22451. * Creates a new MorphTargetManager
  22452. * @param scene defines the current scene
  22453. */
  22454. constructor(scene?: Nullable<Scene>);
  22455. /**
  22456. * Gets the unique ID of this manager
  22457. */
  22458. readonly uniqueId: number;
  22459. /**
  22460. * Gets the number of vertices handled by this manager
  22461. */
  22462. readonly vertexCount: number;
  22463. /**
  22464. * Gets a boolean indicating if this manager supports morphing of normals
  22465. */
  22466. readonly supportsNormals: boolean;
  22467. /**
  22468. * Gets a boolean indicating if this manager supports morphing of tangents
  22469. */
  22470. readonly supportsTangents: boolean;
  22471. /**
  22472. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22473. */
  22474. readonly supportsUVs: boolean;
  22475. /**
  22476. * Gets the number of targets stored in this manager
  22477. */
  22478. readonly numTargets: number;
  22479. /**
  22480. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22481. */
  22482. readonly numInfluencers: number;
  22483. /**
  22484. * Gets the list of influences (one per target)
  22485. */
  22486. readonly influences: Float32Array;
  22487. /**
  22488. * Gets the active target at specified index. An active target is a target with an influence > 0
  22489. * @param index defines the index to check
  22490. * @returns the requested target
  22491. */
  22492. getActiveTarget(index: number): MorphTarget;
  22493. /**
  22494. * Gets the target at specified index
  22495. * @param index defines the index to check
  22496. * @returns the requested target
  22497. */
  22498. getTarget(index: number): MorphTarget;
  22499. /**
  22500. * Add a new target to this manager
  22501. * @param target defines the target to add
  22502. */
  22503. addTarget(target: MorphTarget): void;
  22504. /**
  22505. * Removes a target from the manager
  22506. * @param target defines the target to remove
  22507. */
  22508. removeTarget(target: MorphTarget): void;
  22509. /**
  22510. * Clone the current manager
  22511. * @returns a new MorphTargetManager
  22512. */
  22513. clone(): MorphTargetManager;
  22514. /**
  22515. * Serializes the current manager into a Serialization object
  22516. * @returns the serialized object
  22517. */
  22518. serialize(): any;
  22519. private _syncActiveTargets;
  22520. /**
  22521. * Syncrhonize the targets with all the meshes using this morph target manager
  22522. */
  22523. synchronize(): void;
  22524. /**
  22525. * Creates a new MorphTargetManager from serialized data
  22526. * @param serializationObject defines the serialized data
  22527. * @param scene defines the hosting scene
  22528. * @returns the new MorphTargetManager
  22529. */
  22530. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22531. }
  22532. }
  22533. declare module BABYLON {
  22534. /**
  22535. * Class used to represent a specific level of detail of a mesh
  22536. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22537. */
  22538. export class MeshLODLevel {
  22539. /** Defines the distance where this level should start being displayed */
  22540. distance: number;
  22541. /** Defines the mesh to use to render this level */
  22542. mesh: Nullable<Mesh>;
  22543. /**
  22544. * Creates a new LOD level
  22545. * @param distance defines the distance where this level should star being displayed
  22546. * @param mesh defines the mesh to use to render this level
  22547. */
  22548. constructor(
  22549. /** Defines the distance where this level should start being displayed */
  22550. distance: number,
  22551. /** Defines the mesh to use to render this level */
  22552. mesh: Nullable<Mesh>);
  22553. }
  22554. }
  22555. declare module BABYLON {
  22556. /**
  22557. * Mesh representing the gorund
  22558. */
  22559. export class GroundMesh extends Mesh {
  22560. /** If octree should be generated */
  22561. generateOctree: boolean;
  22562. private _heightQuads;
  22563. /** @hidden */
  22564. _subdivisionsX: number;
  22565. /** @hidden */
  22566. _subdivisionsY: number;
  22567. /** @hidden */
  22568. _width: number;
  22569. /** @hidden */
  22570. _height: number;
  22571. /** @hidden */
  22572. _minX: number;
  22573. /** @hidden */
  22574. _maxX: number;
  22575. /** @hidden */
  22576. _minZ: number;
  22577. /** @hidden */
  22578. _maxZ: number;
  22579. constructor(name: string, scene: Scene);
  22580. /**
  22581. * "GroundMesh"
  22582. * @returns "GroundMesh"
  22583. */
  22584. getClassName(): string;
  22585. /**
  22586. * The minimum of x and y subdivisions
  22587. */
  22588. readonly subdivisions: number;
  22589. /**
  22590. * X subdivisions
  22591. */
  22592. readonly subdivisionsX: number;
  22593. /**
  22594. * Y subdivisions
  22595. */
  22596. readonly subdivisionsY: number;
  22597. /**
  22598. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22599. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22600. * @param chunksCount the number of subdivisions for x and y
  22601. * @param octreeBlocksSize (Default: 32)
  22602. */
  22603. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22604. /**
  22605. * Returns a height (y) value in the Worl system :
  22606. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22607. * @param x x coordinate
  22608. * @param z z coordinate
  22609. * @returns the ground y position if (x, z) are outside the ground surface.
  22610. */
  22611. getHeightAtCoordinates(x: number, z: number): number;
  22612. /**
  22613. * Returns a normalized vector (Vector3) orthogonal to the ground
  22614. * at the ground coordinates (x, z) expressed in the World system.
  22615. * @param x x coordinate
  22616. * @param z z coordinate
  22617. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22618. */
  22619. getNormalAtCoordinates(x: number, z: number): Vector3;
  22620. /**
  22621. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22622. * at the ground coordinates (x, z) expressed in the World system.
  22623. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22624. * @param x x coordinate
  22625. * @param z z coordinate
  22626. * @param ref vector to store the result
  22627. * @returns the GroundMesh.
  22628. */
  22629. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22630. /**
  22631. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22632. * if the ground has been updated.
  22633. * This can be used in the render loop.
  22634. * @returns the GroundMesh.
  22635. */
  22636. updateCoordinateHeights(): GroundMesh;
  22637. private _getFacetAt;
  22638. private _initHeightQuads;
  22639. private _computeHeightQuads;
  22640. /**
  22641. * Serializes this ground mesh
  22642. * @param serializationObject object to write serialization to
  22643. */
  22644. serialize(serializationObject: any): void;
  22645. /**
  22646. * Parses a serialized ground mesh
  22647. * @param parsedMesh the serialized mesh
  22648. * @param scene the scene to create the ground mesh in
  22649. * @returns the created ground mesh
  22650. */
  22651. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22652. }
  22653. }
  22654. declare module BABYLON {
  22655. /**
  22656. * Interface for Physics-Joint data
  22657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22658. */
  22659. export interface PhysicsJointData {
  22660. /**
  22661. * The main pivot of the joint
  22662. */
  22663. mainPivot?: Vector3;
  22664. /**
  22665. * The connected pivot of the joint
  22666. */
  22667. connectedPivot?: Vector3;
  22668. /**
  22669. * The main axis of the joint
  22670. */
  22671. mainAxis?: Vector3;
  22672. /**
  22673. * The connected axis of the joint
  22674. */
  22675. connectedAxis?: Vector3;
  22676. /**
  22677. * The collision of the joint
  22678. */
  22679. collision?: boolean;
  22680. /**
  22681. * Native Oimo/Cannon/Energy data
  22682. */
  22683. nativeParams?: any;
  22684. }
  22685. /**
  22686. * This is a holder class for the physics joint created by the physics plugin
  22687. * It holds a set of functions to control the underlying joint
  22688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22689. */
  22690. export class PhysicsJoint {
  22691. /**
  22692. * The type of the physics joint
  22693. */
  22694. type: number;
  22695. /**
  22696. * The data for the physics joint
  22697. */
  22698. jointData: PhysicsJointData;
  22699. private _physicsJoint;
  22700. protected _physicsPlugin: IPhysicsEnginePlugin;
  22701. /**
  22702. * Initializes the physics joint
  22703. * @param type The type of the physics joint
  22704. * @param jointData The data for the physics joint
  22705. */
  22706. constructor(
  22707. /**
  22708. * The type of the physics joint
  22709. */
  22710. type: number,
  22711. /**
  22712. * The data for the physics joint
  22713. */
  22714. jointData: PhysicsJointData);
  22715. /**
  22716. * Gets the physics joint
  22717. */
  22718. /**
  22719. * Sets the physics joint
  22720. */
  22721. physicsJoint: any;
  22722. /**
  22723. * Sets the physics plugin
  22724. */
  22725. physicsPlugin: IPhysicsEnginePlugin;
  22726. /**
  22727. * Execute a function that is physics-plugin specific.
  22728. * @param {Function} func the function that will be executed.
  22729. * It accepts two parameters: the physics world and the physics joint
  22730. */
  22731. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22732. /**
  22733. * Distance-Joint type
  22734. */
  22735. static DistanceJoint: number;
  22736. /**
  22737. * Hinge-Joint type
  22738. */
  22739. static HingeJoint: number;
  22740. /**
  22741. * Ball-and-Socket joint type
  22742. */
  22743. static BallAndSocketJoint: number;
  22744. /**
  22745. * Wheel-Joint type
  22746. */
  22747. static WheelJoint: number;
  22748. /**
  22749. * Slider-Joint type
  22750. */
  22751. static SliderJoint: number;
  22752. /**
  22753. * Prismatic-Joint type
  22754. */
  22755. static PrismaticJoint: number;
  22756. /**
  22757. * Universal-Joint type
  22758. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22759. */
  22760. static UniversalJoint: number;
  22761. /**
  22762. * Hinge-Joint 2 type
  22763. */
  22764. static Hinge2Joint: number;
  22765. /**
  22766. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22767. */
  22768. static PointToPointJoint: number;
  22769. /**
  22770. * Spring-Joint type
  22771. */
  22772. static SpringJoint: number;
  22773. /**
  22774. * Lock-Joint type
  22775. */
  22776. static LockJoint: number;
  22777. }
  22778. /**
  22779. * A class representing a physics distance joint
  22780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22781. */
  22782. export class DistanceJoint extends PhysicsJoint {
  22783. /**
  22784. *
  22785. * @param jointData The data for the Distance-Joint
  22786. */
  22787. constructor(jointData: DistanceJointData);
  22788. /**
  22789. * Update the predefined distance.
  22790. * @param maxDistance The maximum preferred distance
  22791. * @param minDistance The minimum preferred distance
  22792. */
  22793. updateDistance(maxDistance: number, minDistance?: number): void;
  22794. }
  22795. /**
  22796. * Represents a Motor-Enabled Joint
  22797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22798. */
  22799. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22800. /**
  22801. * Initializes the Motor-Enabled Joint
  22802. * @param type The type of the joint
  22803. * @param jointData The physica joint data for the joint
  22804. */
  22805. constructor(type: number, jointData: PhysicsJointData);
  22806. /**
  22807. * Set the motor values.
  22808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22809. * @param force the force to apply
  22810. * @param maxForce max force for this motor.
  22811. */
  22812. setMotor(force?: number, maxForce?: number): void;
  22813. /**
  22814. * Set the motor's limits.
  22815. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22816. * @param upperLimit The upper limit of the motor
  22817. * @param lowerLimit The lower limit of the motor
  22818. */
  22819. setLimit(upperLimit: number, lowerLimit?: number): void;
  22820. }
  22821. /**
  22822. * This class represents a single physics Hinge-Joint
  22823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22824. */
  22825. export class HingeJoint extends MotorEnabledJoint {
  22826. /**
  22827. * Initializes the Hinge-Joint
  22828. * @param jointData The joint data for the Hinge-Joint
  22829. */
  22830. constructor(jointData: PhysicsJointData);
  22831. /**
  22832. * Set the motor values.
  22833. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22834. * @param {number} force the force to apply
  22835. * @param {number} maxForce max force for this motor.
  22836. */
  22837. setMotor(force?: number, maxForce?: number): void;
  22838. /**
  22839. * Set the motor's limits.
  22840. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22841. * @param upperLimit The upper limit of the motor
  22842. * @param lowerLimit The lower limit of the motor
  22843. */
  22844. setLimit(upperLimit: number, lowerLimit?: number): void;
  22845. }
  22846. /**
  22847. * This class represents a dual hinge physics joint (same as wheel joint)
  22848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22849. */
  22850. export class Hinge2Joint extends MotorEnabledJoint {
  22851. /**
  22852. * Initializes the Hinge2-Joint
  22853. * @param jointData The joint data for the Hinge2-Joint
  22854. */
  22855. constructor(jointData: PhysicsJointData);
  22856. /**
  22857. * Set the motor values.
  22858. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22859. * @param {number} targetSpeed the speed the motor is to reach
  22860. * @param {number} maxForce max force for this motor.
  22861. * @param {motorIndex} the motor's index, 0 or 1.
  22862. */
  22863. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22864. /**
  22865. * Set the motor limits.
  22866. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22867. * @param {number} upperLimit the upper limit
  22868. * @param {number} lowerLimit lower limit
  22869. * @param {motorIndex} the motor's index, 0 or 1.
  22870. */
  22871. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22872. }
  22873. /**
  22874. * Interface for a motor enabled joint
  22875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22876. */
  22877. export interface IMotorEnabledJoint {
  22878. /**
  22879. * Physics joint
  22880. */
  22881. physicsJoint: any;
  22882. /**
  22883. * Sets the motor of the motor-enabled joint
  22884. * @param force The force of the motor
  22885. * @param maxForce The maximum force of the motor
  22886. * @param motorIndex The index of the motor
  22887. */
  22888. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22889. /**
  22890. * Sets the limit of the motor
  22891. * @param upperLimit The upper limit of the motor
  22892. * @param lowerLimit The lower limit of the motor
  22893. * @param motorIndex The index of the motor
  22894. */
  22895. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22896. }
  22897. /**
  22898. * Joint data for a Distance-Joint
  22899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22900. */
  22901. export interface DistanceJointData extends PhysicsJointData {
  22902. /**
  22903. * Max distance the 2 joint objects can be apart
  22904. */
  22905. maxDistance: number;
  22906. }
  22907. /**
  22908. * Joint data from a spring joint
  22909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22910. */
  22911. export interface SpringJointData extends PhysicsJointData {
  22912. /**
  22913. * Length of the spring
  22914. */
  22915. length: number;
  22916. /**
  22917. * Stiffness of the spring
  22918. */
  22919. stiffness: number;
  22920. /**
  22921. * Damping of the spring
  22922. */
  22923. damping: number;
  22924. /** this callback will be called when applying the force to the impostors. */
  22925. forceApplicationCallback: () => void;
  22926. }
  22927. }
  22928. declare module BABYLON {
  22929. /**
  22930. * Holds the data for the raycast result
  22931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22932. */
  22933. export class PhysicsRaycastResult {
  22934. private _hasHit;
  22935. private _hitDistance;
  22936. private _hitNormalWorld;
  22937. private _hitPointWorld;
  22938. private _rayFromWorld;
  22939. private _rayToWorld;
  22940. /**
  22941. * Gets if there was a hit
  22942. */
  22943. readonly hasHit: boolean;
  22944. /**
  22945. * Gets the distance from the hit
  22946. */
  22947. readonly hitDistance: number;
  22948. /**
  22949. * Gets the hit normal/direction in the world
  22950. */
  22951. readonly hitNormalWorld: Vector3;
  22952. /**
  22953. * Gets the hit point in the world
  22954. */
  22955. readonly hitPointWorld: Vector3;
  22956. /**
  22957. * Gets the ray "start point" of the ray in the world
  22958. */
  22959. readonly rayFromWorld: Vector3;
  22960. /**
  22961. * Gets the ray "end point" of the ray in the world
  22962. */
  22963. readonly rayToWorld: Vector3;
  22964. /**
  22965. * Sets the hit data (normal & point in world space)
  22966. * @param hitNormalWorld defines the normal in world space
  22967. * @param hitPointWorld defines the point in world space
  22968. */
  22969. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22970. /**
  22971. * Sets the distance from the start point to the hit point
  22972. * @param distance
  22973. */
  22974. setHitDistance(distance: number): void;
  22975. /**
  22976. * Calculates the distance manually
  22977. */
  22978. calculateHitDistance(): void;
  22979. /**
  22980. * Resets all the values to default
  22981. * @param from The from point on world space
  22982. * @param to The to point on world space
  22983. */
  22984. reset(from?: Vector3, to?: Vector3): void;
  22985. }
  22986. /**
  22987. * Interface for the size containing width and height
  22988. */
  22989. interface IXYZ {
  22990. /**
  22991. * X
  22992. */
  22993. x: number;
  22994. /**
  22995. * Y
  22996. */
  22997. y: number;
  22998. /**
  22999. * Z
  23000. */
  23001. z: number;
  23002. }
  23003. }
  23004. declare module BABYLON {
  23005. /**
  23006. * Interface used to describe a physics joint
  23007. */
  23008. export interface PhysicsImpostorJoint {
  23009. /** Defines the main impostor to which the joint is linked */
  23010. mainImpostor: PhysicsImpostor;
  23011. /** Defines the impostor that is connected to the main impostor using this joint */
  23012. connectedImpostor: PhysicsImpostor;
  23013. /** Defines the joint itself */
  23014. joint: PhysicsJoint;
  23015. }
  23016. /** @hidden */
  23017. export interface IPhysicsEnginePlugin {
  23018. world: any;
  23019. name: string;
  23020. setGravity(gravity: Vector3): void;
  23021. setTimeStep(timeStep: number): void;
  23022. getTimeStep(): number;
  23023. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23024. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23025. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23026. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23027. removePhysicsBody(impostor: PhysicsImpostor): void;
  23028. generateJoint(joint: PhysicsImpostorJoint): void;
  23029. removeJoint(joint: PhysicsImpostorJoint): void;
  23030. isSupported(): boolean;
  23031. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23032. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23033. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23034. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23035. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23036. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23037. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23038. getBodyMass(impostor: PhysicsImpostor): number;
  23039. getBodyFriction(impostor: PhysicsImpostor): number;
  23040. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23041. getBodyRestitution(impostor: PhysicsImpostor): number;
  23042. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23043. getBodyPressure?(impostor: PhysicsImpostor): number;
  23044. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23045. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23046. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23047. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23048. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23049. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23050. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23051. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23052. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23053. sleepBody(impostor: PhysicsImpostor): void;
  23054. wakeUpBody(impostor: PhysicsImpostor): void;
  23055. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23056. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23057. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23058. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23059. getRadius(impostor: PhysicsImpostor): number;
  23060. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23061. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23062. dispose(): void;
  23063. }
  23064. /**
  23065. * Interface used to define a physics engine
  23066. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23067. */
  23068. export interface IPhysicsEngine {
  23069. /**
  23070. * Gets the gravity vector used by the simulation
  23071. */
  23072. gravity: Vector3;
  23073. /**
  23074. * Sets the gravity vector used by the simulation
  23075. * @param gravity defines the gravity vector to use
  23076. */
  23077. setGravity(gravity: Vector3): void;
  23078. /**
  23079. * Set the time step of the physics engine.
  23080. * Default is 1/60.
  23081. * To slow it down, enter 1/600 for example.
  23082. * To speed it up, 1/30
  23083. * @param newTimeStep the new timestep to apply to this world.
  23084. */
  23085. setTimeStep(newTimeStep: number): void;
  23086. /**
  23087. * Get the time step of the physics engine.
  23088. * @returns the current time step
  23089. */
  23090. getTimeStep(): number;
  23091. /**
  23092. * Set the sub time step of the physics engine.
  23093. * Default is 0 meaning there is no sub steps
  23094. * To increase physics resolution precision, set a small value (like 1 ms)
  23095. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23096. */
  23097. setSubTimeStep(subTimeStep: number): void;
  23098. /**
  23099. * Get the sub time step of the physics engine.
  23100. * @returns the current sub time step
  23101. */
  23102. getSubTimeStep(): number;
  23103. /**
  23104. * Release all resources
  23105. */
  23106. dispose(): void;
  23107. /**
  23108. * Gets the name of the current physics plugin
  23109. * @returns the name of the plugin
  23110. */
  23111. getPhysicsPluginName(): string;
  23112. /**
  23113. * Adding a new impostor for the impostor tracking.
  23114. * This will be done by the impostor itself.
  23115. * @param impostor the impostor to add
  23116. */
  23117. addImpostor(impostor: PhysicsImpostor): void;
  23118. /**
  23119. * Remove an impostor from the engine.
  23120. * This impostor and its mesh will not longer be updated by the physics engine.
  23121. * @param impostor the impostor to remove
  23122. */
  23123. removeImpostor(impostor: PhysicsImpostor): void;
  23124. /**
  23125. * Add a joint to the physics engine
  23126. * @param mainImpostor defines the main impostor to which the joint is added.
  23127. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23128. * @param joint defines the joint that will connect both impostors.
  23129. */
  23130. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23131. /**
  23132. * Removes a joint from the simulation
  23133. * @param mainImpostor defines the impostor used with the joint
  23134. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23135. * @param joint defines the joint to remove
  23136. */
  23137. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23138. /**
  23139. * Gets the current plugin used to run the simulation
  23140. * @returns current plugin
  23141. */
  23142. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23143. /**
  23144. * Gets the list of physic impostors
  23145. * @returns an array of PhysicsImpostor
  23146. */
  23147. getImpostors(): Array<PhysicsImpostor>;
  23148. /**
  23149. * Gets the impostor for a physics enabled object
  23150. * @param object defines the object impersonated by the impostor
  23151. * @returns the PhysicsImpostor or null if not found
  23152. */
  23153. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23154. /**
  23155. * Gets the impostor for a physics body object
  23156. * @param body defines physics body used by the impostor
  23157. * @returns the PhysicsImpostor or null if not found
  23158. */
  23159. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23160. /**
  23161. * Does a raycast in the physics world
  23162. * @param from when should the ray start?
  23163. * @param to when should the ray end?
  23164. * @returns PhysicsRaycastResult
  23165. */
  23166. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23167. /**
  23168. * Called by the scene. No need to call it.
  23169. * @param delta defines the timespam between frames
  23170. */
  23171. _step(delta: number): void;
  23172. }
  23173. }
  23174. declare module BABYLON {
  23175. /**
  23176. * The interface for the physics imposter parameters
  23177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23178. */
  23179. export interface PhysicsImpostorParameters {
  23180. /**
  23181. * The mass of the physics imposter
  23182. */
  23183. mass: number;
  23184. /**
  23185. * The friction of the physics imposter
  23186. */
  23187. friction?: number;
  23188. /**
  23189. * The coefficient of restitution of the physics imposter
  23190. */
  23191. restitution?: number;
  23192. /**
  23193. * The native options of the physics imposter
  23194. */
  23195. nativeOptions?: any;
  23196. /**
  23197. * Specifies if the parent should be ignored
  23198. */
  23199. ignoreParent?: boolean;
  23200. /**
  23201. * Specifies if bi-directional transformations should be disabled
  23202. */
  23203. disableBidirectionalTransformation?: boolean;
  23204. /**
  23205. * The pressure inside the physics imposter, soft object only
  23206. */
  23207. pressure?: number;
  23208. /**
  23209. * The stiffness the physics imposter, soft object only
  23210. */
  23211. stiffness?: number;
  23212. /**
  23213. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23214. */
  23215. velocityIterations?: number;
  23216. /**
  23217. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23218. */
  23219. positionIterations?: number;
  23220. /**
  23221. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23222. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23223. * Add to fix multiple points
  23224. */
  23225. fixedPoints?: number;
  23226. /**
  23227. * The collision margin around a soft object
  23228. */
  23229. margin?: number;
  23230. /**
  23231. * The collision margin around a soft object
  23232. */
  23233. damping?: number;
  23234. /**
  23235. * The path for a rope based on an extrusion
  23236. */
  23237. path?: any;
  23238. /**
  23239. * The shape of an extrusion used for a rope based on an extrusion
  23240. */
  23241. shape?: any;
  23242. }
  23243. /**
  23244. * Interface for a physics-enabled object
  23245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23246. */
  23247. export interface IPhysicsEnabledObject {
  23248. /**
  23249. * The position of the physics-enabled object
  23250. */
  23251. position: Vector3;
  23252. /**
  23253. * The rotation of the physics-enabled object
  23254. */
  23255. rotationQuaternion: Nullable<Quaternion>;
  23256. /**
  23257. * The scale of the physics-enabled object
  23258. */
  23259. scaling: Vector3;
  23260. /**
  23261. * The rotation of the physics-enabled object
  23262. */
  23263. rotation?: Vector3;
  23264. /**
  23265. * The parent of the physics-enabled object
  23266. */
  23267. parent?: any;
  23268. /**
  23269. * The bounding info of the physics-enabled object
  23270. * @returns The bounding info of the physics-enabled object
  23271. */
  23272. getBoundingInfo(): BoundingInfo;
  23273. /**
  23274. * Computes the world matrix
  23275. * @param force Specifies if the world matrix should be computed by force
  23276. * @returns A world matrix
  23277. */
  23278. computeWorldMatrix(force: boolean): Matrix;
  23279. /**
  23280. * Gets the world matrix
  23281. * @returns A world matrix
  23282. */
  23283. getWorldMatrix?(): Matrix;
  23284. /**
  23285. * Gets the child meshes
  23286. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23287. * @returns An array of abstract meshes
  23288. */
  23289. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23290. /**
  23291. * Gets the vertex data
  23292. * @param kind The type of vertex data
  23293. * @returns A nullable array of numbers, or a float32 array
  23294. */
  23295. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23296. /**
  23297. * Gets the indices from the mesh
  23298. * @returns A nullable array of index arrays
  23299. */
  23300. getIndices?(): Nullable<IndicesArray>;
  23301. /**
  23302. * Gets the scene from the mesh
  23303. * @returns the indices array or null
  23304. */
  23305. getScene?(): Scene;
  23306. /**
  23307. * Gets the absolute position from the mesh
  23308. * @returns the absolute position
  23309. */
  23310. getAbsolutePosition(): Vector3;
  23311. /**
  23312. * Gets the absolute pivot point from the mesh
  23313. * @returns the absolute pivot point
  23314. */
  23315. getAbsolutePivotPoint(): Vector3;
  23316. /**
  23317. * Rotates the mesh
  23318. * @param axis The axis of rotation
  23319. * @param amount The amount of rotation
  23320. * @param space The space of the rotation
  23321. * @returns The rotation transform node
  23322. */
  23323. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23324. /**
  23325. * Translates the mesh
  23326. * @param axis The axis of translation
  23327. * @param distance The distance of translation
  23328. * @param space The space of the translation
  23329. * @returns The transform node
  23330. */
  23331. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23332. /**
  23333. * Sets the absolute position of the mesh
  23334. * @param absolutePosition The absolute position of the mesh
  23335. * @returns The transform node
  23336. */
  23337. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23338. /**
  23339. * Gets the class name of the mesh
  23340. * @returns The class name
  23341. */
  23342. getClassName(): string;
  23343. }
  23344. /**
  23345. * Represents a physics imposter
  23346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23347. */
  23348. export class PhysicsImpostor {
  23349. /**
  23350. * The physics-enabled object used as the physics imposter
  23351. */
  23352. object: IPhysicsEnabledObject;
  23353. /**
  23354. * The type of the physics imposter
  23355. */
  23356. type: number;
  23357. private _options;
  23358. private _scene?;
  23359. /**
  23360. * The default object size of the imposter
  23361. */
  23362. static DEFAULT_OBJECT_SIZE: Vector3;
  23363. /**
  23364. * The identity quaternion of the imposter
  23365. */
  23366. static IDENTITY_QUATERNION: Quaternion;
  23367. /** @hidden */
  23368. _pluginData: any;
  23369. private _physicsEngine;
  23370. private _physicsBody;
  23371. private _bodyUpdateRequired;
  23372. private _onBeforePhysicsStepCallbacks;
  23373. private _onAfterPhysicsStepCallbacks;
  23374. /** @hidden */
  23375. _onPhysicsCollideCallbacks: Array<{
  23376. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23377. otherImpostors: Array<PhysicsImpostor>;
  23378. }>;
  23379. private _deltaPosition;
  23380. private _deltaRotation;
  23381. private _deltaRotationConjugated;
  23382. /** @hidden */
  23383. _isFromLine: boolean;
  23384. private _parent;
  23385. private _isDisposed;
  23386. private static _tmpVecs;
  23387. private static _tmpQuat;
  23388. /**
  23389. * Specifies if the physics imposter is disposed
  23390. */
  23391. readonly isDisposed: boolean;
  23392. /**
  23393. * Gets the mass of the physics imposter
  23394. */
  23395. mass: number;
  23396. /**
  23397. * Gets the coefficient of friction
  23398. */
  23399. /**
  23400. * Sets the coefficient of friction
  23401. */
  23402. friction: number;
  23403. /**
  23404. * Gets the coefficient of restitution
  23405. */
  23406. /**
  23407. * Sets the coefficient of restitution
  23408. */
  23409. restitution: number;
  23410. /**
  23411. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23412. */
  23413. /**
  23414. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23415. */
  23416. pressure: number;
  23417. /**
  23418. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23419. */
  23420. /**
  23421. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23422. */
  23423. stiffness: number;
  23424. /**
  23425. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23426. */
  23427. /**
  23428. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23429. */
  23430. velocityIterations: number;
  23431. /**
  23432. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23433. */
  23434. /**
  23435. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23436. */
  23437. positionIterations: number;
  23438. /**
  23439. * The unique id of the physics imposter
  23440. * set by the physics engine when adding this impostor to the array
  23441. */
  23442. uniqueId: number;
  23443. /**
  23444. * @hidden
  23445. */
  23446. soft: boolean;
  23447. /**
  23448. * @hidden
  23449. */
  23450. segments: number;
  23451. private _joints;
  23452. /**
  23453. * Initializes the physics imposter
  23454. * @param object The physics-enabled object used as the physics imposter
  23455. * @param type The type of the physics imposter
  23456. * @param _options The options for the physics imposter
  23457. * @param _scene The Babylon scene
  23458. */
  23459. constructor(
  23460. /**
  23461. * The physics-enabled object used as the physics imposter
  23462. */
  23463. object: IPhysicsEnabledObject,
  23464. /**
  23465. * The type of the physics imposter
  23466. */
  23467. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23468. /**
  23469. * This function will completly initialize this impostor.
  23470. * It will create a new body - but only if this mesh has no parent.
  23471. * If it has, this impostor will not be used other than to define the impostor
  23472. * of the child mesh.
  23473. * @hidden
  23474. */
  23475. _init(): void;
  23476. private _getPhysicsParent;
  23477. /**
  23478. * Should a new body be generated.
  23479. * @returns boolean specifying if body initialization is required
  23480. */
  23481. isBodyInitRequired(): boolean;
  23482. /**
  23483. * Sets the updated scaling
  23484. * @param updated Specifies if the scaling is updated
  23485. */
  23486. setScalingUpdated(): void;
  23487. /**
  23488. * Force a regeneration of this or the parent's impostor's body.
  23489. * Use under cautious - This will remove all joints already implemented.
  23490. */
  23491. forceUpdate(): void;
  23492. /**
  23493. * Gets the body that holds this impostor. Either its own, or its parent.
  23494. */
  23495. /**
  23496. * Set the physics body. Used mainly by the physics engine/plugin
  23497. */
  23498. physicsBody: any;
  23499. /**
  23500. * Get the parent of the physics imposter
  23501. * @returns Physics imposter or null
  23502. */
  23503. /**
  23504. * Sets the parent of the physics imposter
  23505. */
  23506. parent: Nullable<PhysicsImpostor>;
  23507. /**
  23508. * Resets the update flags
  23509. */
  23510. resetUpdateFlags(): void;
  23511. /**
  23512. * Gets the object extend size
  23513. * @returns the object extend size
  23514. */
  23515. getObjectExtendSize(): Vector3;
  23516. /**
  23517. * Gets the object center
  23518. * @returns The object center
  23519. */
  23520. getObjectCenter(): Vector3;
  23521. /**
  23522. * Get a specific parametes from the options parameter
  23523. * @param paramName The object parameter name
  23524. * @returns The object parameter
  23525. */
  23526. getParam(paramName: string): any;
  23527. /**
  23528. * Sets a specific parameter in the options given to the physics plugin
  23529. * @param paramName The parameter name
  23530. * @param value The value of the parameter
  23531. */
  23532. setParam(paramName: string, value: number): void;
  23533. /**
  23534. * Specifically change the body's mass option. Won't recreate the physics body object
  23535. * @param mass The mass of the physics imposter
  23536. */
  23537. setMass(mass: number): void;
  23538. /**
  23539. * Gets the linear velocity
  23540. * @returns linear velocity or null
  23541. */
  23542. getLinearVelocity(): Nullable<Vector3>;
  23543. /**
  23544. * Sets the linear velocity
  23545. * @param velocity linear velocity or null
  23546. */
  23547. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23548. /**
  23549. * Gets the angular velocity
  23550. * @returns angular velocity or null
  23551. */
  23552. getAngularVelocity(): Nullable<Vector3>;
  23553. /**
  23554. * Sets the angular velocity
  23555. * @param velocity The velocity or null
  23556. */
  23557. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23558. /**
  23559. * Execute a function with the physics plugin native code
  23560. * Provide a function the will have two variables - the world object and the physics body object
  23561. * @param func The function to execute with the physics plugin native code
  23562. */
  23563. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23564. /**
  23565. * Register a function that will be executed before the physics world is stepping forward
  23566. * @param func The function to execute before the physics world is stepped forward
  23567. */
  23568. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23569. /**
  23570. * Unregister a function that will be executed before the physics world is stepping forward
  23571. * @param func The function to execute before the physics world is stepped forward
  23572. */
  23573. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23574. /**
  23575. * Register a function that will be executed after the physics step
  23576. * @param func The function to execute after physics step
  23577. */
  23578. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23579. /**
  23580. * Unregisters a function that will be executed after the physics step
  23581. * @param func The function to execute after physics step
  23582. */
  23583. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23584. /**
  23585. * register a function that will be executed when this impostor collides against a different body
  23586. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23587. * @param func Callback that is executed on collision
  23588. */
  23589. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23590. /**
  23591. * Unregisters the physics imposter on contact
  23592. * @param collideAgainst The physics object to collide against
  23593. * @param func Callback to execute on collision
  23594. */
  23595. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23596. private _tmpQuat;
  23597. private _tmpQuat2;
  23598. /**
  23599. * Get the parent rotation
  23600. * @returns The parent rotation
  23601. */
  23602. getParentsRotation(): Quaternion;
  23603. /**
  23604. * this function is executed by the physics engine.
  23605. */
  23606. beforeStep: () => void;
  23607. /**
  23608. * this function is executed by the physics engine
  23609. */
  23610. afterStep: () => void;
  23611. /**
  23612. * Legacy collision detection event support
  23613. */
  23614. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23615. /**
  23616. * event and body object due to cannon's event-based architecture.
  23617. */
  23618. onCollide: (e: {
  23619. body: any;
  23620. }) => void;
  23621. /**
  23622. * Apply a force
  23623. * @param force The force to apply
  23624. * @param contactPoint The contact point for the force
  23625. * @returns The physics imposter
  23626. */
  23627. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23628. /**
  23629. * Apply an impulse
  23630. * @param force The impulse force
  23631. * @param contactPoint The contact point for the impulse force
  23632. * @returns The physics imposter
  23633. */
  23634. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23635. /**
  23636. * A help function to create a joint
  23637. * @param otherImpostor A physics imposter used to create a joint
  23638. * @param jointType The type of joint
  23639. * @param jointData The data for the joint
  23640. * @returns The physics imposter
  23641. */
  23642. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23643. /**
  23644. * Add a joint to this impostor with a different impostor
  23645. * @param otherImpostor A physics imposter used to add a joint
  23646. * @param joint The joint to add
  23647. * @returns The physics imposter
  23648. */
  23649. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23650. /**
  23651. * Add an anchor to a cloth impostor
  23652. * @param otherImpostor rigid impostor to anchor to
  23653. * @param width ratio across width from 0 to 1
  23654. * @param height ratio up height from 0 to 1
  23655. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23656. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23657. * @returns impostor the soft imposter
  23658. */
  23659. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23660. /**
  23661. * Add a hook to a rope impostor
  23662. * @param otherImpostor rigid impostor to anchor to
  23663. * @param length ratio across rope from 0 to 1
  23664. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23665. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23666. * @returns impostor the rope imposter
  23667. */
  23668. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23669. /**
  23670. * Will keep this body still, in a sleep mode.
  23671. * @returns the physics imposter
  23672. */
  23673. sleep(): PhysicsImpostor;
  23674. /**
  23675. * Wake the body up.
  23676. * @returns The physics imposter
  23677. */
  23678. wakeUp(): PhysicsImpostor;
  23679. /**
  23680. * Clones the physics imposter
  23681. * @param newObject The physics imposter clones to this physics-enabled object
  23682. * @returns A nullable physics imposter
  23683. */
  23684. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23685. /**
  23686. * Disposes the physics imposter
  23687. */
  23688. dispose(): void;
  23689. /**
  23690. * Sets the delta position
  23691. * @param position The delta position amount
  23692. */
  23693. setDeltaPosition(position: Vector3): void;
  23694. /**
  23695. * Sets the delta rotation
  23696. * @param rotation The delta rotation amount
  23697. */
  23698. setDeltaRotation(rotation: Quaternion): void;
  23699. /**
  23700. * Gets the box size of the physics imposter and stores the result in the input parameter
  23701. * @param result Stores the box size
  23702. * @returns The physics imposter
  23703. */
  23704. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23705. /**
  23706. * Gets the radius of the physics imposter
  23707. * @returns Radius of the physics imposter
  23708. */
  23709. getRadius(): number;
  23710. /**
  23711. * Sync a bone with this impostor
  23712. * @param bone The bone to sync to the impostor.
  23713. * @param boneMesh The mesh that the bone is influencing.
  23714. * @param jointPivot The pivot of the joint / bone in local space.
  23715. * @param distToJoint Optional distance from the impostor to the joint.
  23716. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23717. */
  23718. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23719. /**
  23720. * Sync impostor to a bone
  23721. * @param bone The bone that the impostor will be synced to.
  23722. * @param boneMesh The mesh that the bone is influencing.
  23723. * @param jointPivot The pivot of the joint / bone in local space.
  23724. * @param distToJoint Optional distance from the impostor to the joint.
  23725. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23726. * @param boneAxis Optional vector3 axis the bone is aligned with
  23727. */
  23728. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23729. /**
  23730. * No-Imposter type
  23731. */
  23732. static NoImpostor: number;
  23733. /**
  23734. * Sphere-Imposter type
  23735. */
  23736. static SphereImpostor: number;
  23737. /**
  23738. * Box-Imposter type
  23739. */
  23740. static BoxImpostor: number;
  23741. /**
  23742. * Plane-Imposter type
  23743. */
  23744. static PlaneImpostor: number;
  23745. /**
  23746. * Mesh-imposter type
  23747. */
  23748. static MeshImpostor: number;
  23749. /**
  23750. * Capsule-Impostor type (Ammo.js plugin only)
  23751. */
  23752. static CapsuleImpostor: number;
  23753. /**
  23754. * Cylinder-Imposter type
  23755. */
  23756. static CylinderImpostor: number;
  23757. /**
  23758. * Particle-Imposter type
  23759. */
  23760. static ParticleImpostor: number;
  23761. /**
  23762. * Heightmap-Imposter type
  23763. */
  23764. static HeightmapImpostor: number;
  23765. /**
  23766. * ConvexHull-Impostor type (Ammo.js plugin only)
  23767. */
  23768. static ConvexHullImpostor: number;
  23769. /**
  23770. * Custom-Imposter type (Ammo.js plugin only)
  23771. */
  23772. static CustomImpostor: number;
  23773. /**
  23774. * Rope-Imposter type
  23775. */
  23776. static RopeImpostor: number;
  23777. /**
  23778. * Cloth-Imposter type
  23779. */
  23780. static ClothImpostor: number;
  23781. /**
  23782. * Softbody-Imposter type
  23783. */
  23784. static SoftbodyImpostor: number;
  23785. }
  23786. }
  23787. declare module BABYLON {
  23788. /**
  23789. * @hidden
  23790. **/
  23791. export class _CreationDataStorage {
  23792. closePath?: boolean;
  23793. closeArray?: boolean;
  23794. idx: number[];
  23795. dashSize: number;
  23796. gapSize: number;
  23797. path3D: Path3D;
  23798. pathArray: Vector3[][];
  23799. arc: number;
  23800. radius: number;
  23801. cap: number;
  23802. tessellation: number;
  23803. }
  23804. /**
  23805. * @hidden
  23806. **/
  23807. class _InstanceDataStorage {
  23808. visibleInstances: any;
  23809. batchCache: _InstancesBatch;
  23810. instancesBufferSize: number;
  23811. instancesBuffer: Nullable<Buffer>;
  23812. instancesData: Float32Array;
  23813. overridenInstanceCount: number;
  23814. isFrozen: boolean;
  23815. previousBatch: Nullable<_InstancesBatch>;
  23816. hardwareInstancedRendering: boolean;
  23817. sideOrientation: number;
  23818. manualUpdate: boolean;
  23819. }
  23820. /**
  23821. * @hidden
  23822. **/
  23823. export class _InstancesBatch {
  23824. mustReturn: boolean;
  23825. visibleInstances: Nullable<InstancedMesh[]>[];
  23826. renderSelf: boolean[];
  23827. hardwareInstancedRendering: boolean[];
  23828. }
  23829. /**
  23830. * Class used to represent renderable models
  23831. */
  23832. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23833. /**
  23834. * Mesh side orientation : usually the external or front surface
  23835. */
  23836. static readonly FRONTSIDE: number;
  23837. /**
  23838. * Mesh side orientation : usually the internal or back surface
  23839. */
  23840. static readonly BACKSIDE: number;
  23841. /**
  23842. * Mesh side orientation : both internal and external or front and back surfaces
  23843. */
  23844. static readonly DOUBLESIDE: number;
  23845. /**
  23846. * Mesh side orientation : by default, `FRONTSIDE`
  23847. */
  23848. static readonly DEFAULTSIDE: number;
  23849. /**
  23850. * Mesh cap setting : no cap
  23851. */
  23852. static readonly NO_CAP: number;
  23853. /**
  23854. * Mesh cap setting : one cap at the beginning of the mesh
  23855. */
  23856. static readonly CAP_START: number;
  23857. /**
  23858. * Mesh cap setting : one cap at the end of the mesh
  23859. */
  23860. static readonly CAP_END: number;
  23861. /**
  23862. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23863. */
  23864. static readonly CAP_ALL: number;
  23865. /**
  23866. * Mesh pattern setting : no flip or rotate
  23867. */
  23868. static readonly NO_FLIP: number;
  23869. /**
  23870. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23871. */
  23872. static readonly FLIP_TILE: number;
  23873. /**
  23874. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23875. */
  23876. static readonly ROTATE_TILE: number;
  23877. /**
  23878. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23879. */
  23880. static readonly FLIP_ROW: number;
  23881. /**
  23882. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23883. */
  23884. static readonly ROTATE_ROW: number;
  23885. /**
  23886. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23887. */
  23888. static readonly FLIP_N_ROTATE_TILE: number;
  23889. /**
  23890. * Mesh pattern setting : rotate pattern and rotate
  23891. */
  23892. static readonly FLIP_N_ROTATE_ROW: number;
  23893. /**
  23894. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23895. */
  23896. static readonly CENTER: number;
  23897. /**
  23898. * Mesh tile positioning : part tiles on left
  23899. */
  23900. static readonly LEFT: number;
  23901. /**
  23902. * Mesh tile positioning : part tiles on right
  23903. */
  23904. static readonly RIGHT: number;
  23905. /**
  23906. * Mesh tile positioning : part tiles on top
  23907. */
  23908. static readonly TOP: number;
  23909. /**
  23910. * Mesh tile positioning : part tiles on bottom
  23911. */
  23912. static readonly BOTTOM: number;
  23913. /**
  23914. * Gets the default side orientation.
  23915. * @param orientation the orientation to value to attempt to get
  23916. * @returns the default orientation
  23917. * @hidden
  23918. */
  23919. static _GetDefaultSideOrientation(orientation?: number): number;
  23920. private _internalMeshDataInfo;
  23921. /**
  23922. * An event triggered before rendering the mesh
  23923. */
  23924. readonly onBeforeRenderObservable: Observable<Mesh>;
  23925. /**
  23926. * An event triggered before binding the mesh
  23927. */
  23928. readonly onBeforeBindObservable: Observable<Mesh>;
  23929. /**
  23930. * An event triggered after rendering the mesh
  23931. */
  23932. readonly onAfterRenderObservable: Observable<Mesh>;
  23933. /**
  23934. * An event triggered before drawing the mesh
  23935. */
  23936. readonly onBeforeDrawObservable: Observable<Mesh>;
  23937. private _onBeforeDrawObserver;
  23938. /**
  23939. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23940. */
  23941. onBeforeDraw: () => void;
  23942. readonly hasInstances: boolean;
  23943. /**
  23944. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23945. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23946. */
  23947. delayLoadState: number;
  23948. /**
  23949. * Gets the list of instances created from this mesh
  23950. * it is not supposed to be modified manually.
  23951. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23952. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23953. */
  23954. instances: InstancedMesh[];
  23955. /**
  23956. * Gets the file containing delay loading data for this mesh
  23957. */
  23958. delayLoadingFile: string;
  23959. /** @hidden */
  23960. _binaryInfo: any;
  23961. /**
  23962. * User defined function used to change how LOD level selection is done
  23963. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23964. */
  23965. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23966. /**
  23967. * Gets or sets the morph target manager
  23968. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23969. */
  23970. morphTargetManager: Nullable<MorphTargetManager>;
  23971. /** @hidden */
  23972. _creationDataStorage: Nullable<_CreationDataStorage>;
  23973. /** @hidden */
  23974. _geometry: Nullable<Geometry>;
  23975. /** @hidden */
  23976. _delayInfo: Array<string>;
  23977. /** @hidden */
  23978. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23979. /** @hidden */
  23980. _instanceDataStorage: _InstanceDataStorage;
  23981. private _effectiveMaterial;
  23982. /** @hidden */
  23983. _shouldGenerateFlatShading: boolean;
  23984. /** @hidden */
  23985. _originalBuilderSideOrientation: number;
  23986. /**
  23987. * Use this property to change the original side orientation defined at construction time
  23988. */
  23989. overrideMaterialSideOrientation: Nullable<number>;
  23990. /**
  23991. * Gets the source mesh (the one used to clone this one from)
  23992. */
  23993. readonly source: Nullable<Mesh>;
  23994. /**
  23995. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23996. */
  23997. isUnIndexed: boolean;
  23998. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  23999. readonly worldMatrixInstancedBuffer: Float32Array;
  24000. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24001. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24002. /**
  24003. * @constructor
  24004. * @param name The value used by scene.getMeshByName() to do a lookup.
  24005. * @param scene The scene to add this mesh to.
  24006. * @param parent The parent of this mesh, if it has one
  24007. * @param source An optional Mesh from which geometry is shared, cloned.
  24008. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24009. * When false, achieved by calling a clone(), also passing False.
  24010. * This will make creation of children, recursive.
  24011. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24012. */
  24013. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24014. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24015. doNotInstantiate: boolean;
  24016. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24017. /**
  24018. * Gets the class name
  24019. * @returns the string "Mesh".
  24020. */
  24021. getClassName(): string;
  24022. /** @hidden */
  24023. readonly _isMesh: boolean;
  24024. /**
  24025. * Returns a description of this mesh
  24026. * @param fullDetails define if full details about this mesh must be used
  24027. * @returns a descriptive string representing this mesh
  24028. */
  24029. toString(fullDetails?: boolean): string;
  24030. /** @hidden */
  24031. _unBindEffect(): void;
  24032. /**
  24033. * Gets a boolean indicating if this mesh has LOD
  24034. */
  24035. readonly hasLODLevels: boolean;
  24036. /**
  24037. * Gets the list of MeshLODLevel associated with the current mesh
  24038. * @returns an array of MeshLODLevel
  24039. */
  24040. getLODLevels(): MeshLODLevel[];
  24041. private _sortLODLevels;
  24042. /**
  24043. * Add a mesh as LOD level triggered at the given distance.
  24044. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24045. * @param distance The distance from the center of the object to show this level
  24046. * @param mesh The mesh to be added as LOD level (can be null)
  24047. * @return This mesh (for chaining)
  24048. */
  24049. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24050. /**
  24051. * Returns the LOD level mesh at the passed distance or null if not found.
  24052. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24053. * @param distance The distance from the center of the object to show this level
  24054. * @returns a Mesh or `null`
  24055. */
  24056. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24057. /**
  24058. * Remove a mesh from the LOD array
  24059. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24060. * @param mesh defines the mesh to be removed
  24061. * @return This mesh (for chaining)
  24062. */
  24063. removeLODLevel(mesh: Mesh): Mesh;
  24064. /**
  24065. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24066. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24067. * @param camera defines the camera to use to compute distance
  24068. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24069. * @return This mesh (for chaining)
  24070. */
  24071. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24072. /**
  24073. * Gets the mesh internal Geometry object
  24074. */
  24075. readonly geometry: Nullable<Geometry>;
  24076. /**
  24077. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24078. * @returns the total number of vertices
  24079. */
  24080. getTotalVertices(): number;
  24081. /**
  24082. * Returns the content of an associated vertex buffer
  24083. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24084. * - VertexBuffer.PositionKind
  24085. * - VertexBuffer.UVKind
  24086. * - VertexBuffer.UV2Kind
  24087. * - VertexBuffer.UV3Kind
  24088. * - VertexBuffer.UV4Kind
  24089. * - VertexBuffer.UV5Kind
  24090. * - VertexBuffer.UV6Kind
  24091. * - VertexBuffer.ColorKind
  24092. * - VertexBuffer.MatricesIndicesKind
  24093. * - VertexBuffer.MatricesIndicesExtraKind
  24094. * - VertexBuffer.MatricesWeightsKind
  24095. * - VertexBuffer.MatricesWeightsExtraKind
  24096. * @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
  24097. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24098. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24099. */
  24100. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24101. /**
  24102. * Returns the mesh VertexBuffer object from the requested `kind`
  24103. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24104. * - VertexBuffer.PositionKind
  24105. * - VertexBuffer.NormalKind
  24106. * - VertexBuffer.UVKind
  24107. * - VertexBuffer.UV2Kind
  24108. * - VertexBuffer.UV3Kind
  24109. * - VertexBuffer.UV4Kind
  24110. * - VertexBuffer.UV5Kind
  24111. * - VertexBuffer.UV6Kind
  24112. * - VertexBuffer.ColorKind
  24113. * - VertexBuffer.MatricesIndicesKind
  24114. * - VertexBuffer.MatricesIndicesExtraKind
  24115. * - VertexBuffer.MatricesWeightsKind
  24116. * - VertexBuffer.MatricesWeightsExtraKind
  24117. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24118. */
  24119. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24120. /**
  24121. * Tests if a specific vertex buffer is associated with this mesh
  24122. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24123. * - VertexBuffer.PositionKind
  24124. * - VertexBuffer.NormalKind
  24125. * - VertexBuffer.UVKind
  24126. * - VertexBuffer.UV2Kind
  24127. * - VertexBuffer.UV3Kind
  24128. * - VertexBuffer.UV4Kind
  24129. * - VertexBuffer.UV5Kind
  24130. * - VertexBuffer.UV6Kind
  24131. * - VertexBuffer.ColorKind
  24132. * - VertexBuffer.MatricesIndicesKind
  24133. * - VertexBuffer.MatricesIndicesExtraKind
  24134. * - VertexBuffer.MatricesWeightsKind
  24135. * - VertexBuffer.MatricesWeightsExtraKind
  24136. * @returns a boolean
  24137. */
  24138. isVerticesDataPresent(kind: string): boolean;
  24139. /**
  24140. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24141. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24142. * - VertexBuffer.PositionKind
  24143. * - VertexBuffer.UVKind
  24144. * - VertexBuffer.UV2Kind
  24145. * - VertexBuffer.UV3Kind
  24146. * - VertexBuffer.UV4Kind
  24147. * - VertexBuffer.UV5Kind
  24148. * - VertexBuffer.UV6Kind
  24149. * - VertexBuffer.ColorKind
  24150. * - VertexBuffer.MatricesIndicesKind
  24151. * - VertexBuffer.MatricesIndicesExtraKind
  24152. * - VertexBuffer.MatricesWeightsKind
  24153. * - VertexBuffer.MatricesWeightsExtraKind
  24154. * @returns a boolean
  24155. */
  24156. isVertexBufferUpdatable(kind: string): boolean;
  24157. /**
  24158. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24159. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24160. * - VertexBuffer.PositionKind
  24161. * - VertexBuffer.NormalKind
  24162. * - VertexBuffer.UVKind
  24163. * - VertexBuffer.UV2Kind
  24164. * - VertexBuffer.UV3Kind
  24165. * - VertexBuffer.UV4Kind
  24166. * - VertexBuffer.UV5Kind
  24167. * - VertexBuffer.UV6Kind
  24168. * - VertexBuffer.ColorKind
  24169. * - VertexBuffer.MatricesIndicesKind
  24170. * - VertexBuffer.MatricesIndicesExtraKind
  24171. * - VertexBuffer.MatricesWeightsKind
  24172. * - VertexBuffer.MatricesWeightsExtraKind
  24173. * @returns an array of strings
  24174. */
  24175. getVerticesDataKinds(): string[];
  24176. /**
  24177. * Returns a positive integer : the total number of indices in this mesh geometry.
  24178. * @returns the numner of indices or zero if the mesh has no geometry.
  24179. */
  24180. getTotalIndices(): number;
  24181. /**
  24182. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24183. * @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.
  24184. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24185. * @returns the indices array or an empty array if the mesh has no geometry
  24186. */
  24187. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24188. readonly isBlocked: boolean;
  24189. /**
  24190. * Determine if the current mesh is ready to be rendered
  24191. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24192. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24193. * @returns true if all associated assets are ready (material, textures, shaders)
  24194. */
  24195. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24196. /**
  24197. * 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.
  24198. */
  24199. readonly areNormalsFrozen: boolean;
  24200. /**
  24201. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24202. * @returns the current mesh
  24203. */
  24204. freezeNormals(): Mesh;
  24205. /**
  24206. * 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
  24207. * @returns the current mesh
  24208. */
  24209. unfreezeNormals(): Mesh;
  24210. /**
  24211. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24212. */
  24213. overridenInstanceCount: number;
  24214. /** @hidden */
  24215. _preActivate(): Mesh;
  24216. /** @hidden */
  24217. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24218. /** @hidden */
  24219. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24220. /**
  24221. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24222. * This means the mesh underlying bounding box and sphere are recomputed.
  24223. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24224. * @returns the current mesh
  24225. */
  24226. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24227. /** @hidden */
  24228. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24229. /**
  24230. * This function will subdivide the mesh into multiple submeshes
  24231. * @param count defines the expected number of submeshes
  24232. */
  24233. subdivide(count: number): void;
  24234. /**
  24235. * Copy a FloatArray into a specific associated vertex buffer
  24236. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24237. * - VertexBuffer.PositionKind
  24238. * - VertexBuffer.UVKind
  24239. * - VertexBuffer.UV2Kind
  24240. * - VertexBuffer.UV3Kind
  24241. * - VertexBuffer.UV4Kind
  24242. * - VertexBuffer.UV5Kind
  24243. * - VertexBuffer.UV6Kind
  24244. * - VertexBuffer.ColorKind
  24245. * - VertexBuffer.MatricesIndicesKind
  24246. * - VertexBuffer.MatricesIndicesExtraKind
  24247. * - VertexBuffer.MatricesWeightsKind
  24248. * - VertexBuffer.MatricesWeightsExtraKind
  24249. * @param data defines the data source
  24250. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24251. * @param stride defines the data stride size (can be null)
  24252. * @returns the current mesh
  24253. */
  24254. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24255. /**
  24256. * Delete a vertex buffer associated with this mesh
  24257. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24258. * - VertexBuffer.PositionKind
  24259. * - VertexBuffer.UVKind
  24260. * - VertexBuffer.UV2Kind
  24261. * - VertexBuffer.UV3Kind
  24262. * - VertexBuffer.UV4Kind
  24263. * - VertexBuffer.UV5Kind
  24264. * - VertexBuffer.UV6Kind
  24265. * - VertexBuffer.ColorKind
  24266. * - VertexBuffer.MatricesIndicesKind
  24267. * - VertexBuffer.MatricesIndicesExtraKind
  24268. * - VertexBuffer.MatricesWeightsKind
  24269. * - VertexBuffer.MatricesWeightsExtraKind
  24270. */
  24271. removeVerticesData(kind: string): void;
  24272. /**
  24273. * Flags an associated vertex buffer as updatable
  24274. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24275. * - VertexBuffer.PositionKind
  24276. * - VertexBuffer.UVKind
  24277. * - VertexBuffer.UV2Kind
  24278. * - VertexBuffer.UV3Kind
  24279. * - VertexBuffer.UV4Kind
  24280. * - VertexBuffer.UV5Kind
  24281. * - VertexBuffer.UV6Kind
  24282. * - VertexBuffer.ColorKind
  24283. * - VertexBuffer.MatricesIndicesKind
  24284. * - VertexBuffer.MatricesIndicesExtraKind
  24285. * - VertexBuffer.MatricesWeightsKind
  24286. * - VertexBuffer.MatricesWeightsExtraKind
  24287. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24288. */
  24289. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24290. /**
  24291. * Sets the mesh global Vertex Buffer
  24292. * @param buffer defines the buffer to use
  24293. * @returns the current mesh
  24294. */
  24295. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24296. /**
  24297. * Update a specific associated vertex buffer
  24298. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24299. * - VertexBuffer.PositionKind
  24300. * - VertexBuffer.UVKind
  24301. * - VertexBuffer.UV2Kind
  24302. * - VertexBuffer.UV3Kind
  24303. * - VertexBuffer.UV4Kind
  24304. * - VertexBuffer.UV5Kind
  24305. * - VertexBuffer.UV6Kind
  24306. * - VertexBuffer.ColorKind
  24307. * - VertexBuffer.MatricesIndicesKind
  24308. * - VertexBuffer.MatricesIndicesExtraKind
  24309. * - VertexBuffer.MatricesWeightsKind
  24310. * - VertexBuffer.MatricesWeightsExtraKind
  24311. * @param data defines the data source
  24312. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24313. * @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)
  24314. * @returns the current mesh
  24315. */
  24316. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24317. /**
  24318. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24319. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24320. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24321. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24322. * @returns the current mesh
  24323. */
  24324. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24325. /**
  24326. * Creates a un-shared specific occurence of the geometry for the mesh.
  24327. * @returns the current mesh
  24328. */
  24329. makeGeometryUnique(): Mesh;
  24330. /**
  24331. * Set the index buffer of this mesh
  24332. * @param indices defines the source data
  24333. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24334. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24335. * @returns the current mesh
  24336. */
  24337. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24338. /**
  24339. * Update the current index buffer
  24340. * @param indices defines the source data
  24341. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24342. * @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)
  24343. * @returns the current mesh
  24344. */
  24345. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24346. /**
  24347. * Invert the geometry to move from a right handed system to a left handed one.
  24348. * @returns the current mesh
  24349. */
  24350. toLeftHanded(): Mesh;
  24351. /** @hidden */
  24352. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24353. /** @hidden */
  24354. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24355. /**
  24356. * Registers for this mesh a javascript function called just before the rendering process
  24357. * @param func defines the function to call before rendering this mesh
  24358. * @returns the current mesh
  24359. */
  24360. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24361. /**
  24362. * Disposes a previously registered javascript function called before the rendering
  24363. * @param func defines the function to remove
  24364. * @returns the current mesh
  24365. */
  24366. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24367. /**
  24368. * Registers for this mesh a javascript function called just after the rendering is complete
  24369. * @param func defines the function to call after rendering this mesh
  24370. * @returns the current mesh
  24371. */
  24372. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24373. /**
  24374. * Disposes a previously registered javascript function called after the rendering.
  24375. * @param func defines the function to remove
  24376. * @returns the current mesh
  24377. */
  24378. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24379. /** @hidden */
  24380. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24381. /** @hidden */
  24382. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24383. /** @hidden */
  24384. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24385. /** @hidden */
  24386. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24387. /** @hidden */
  24388. _rebuild(): void;
  24389. /** @hidden */
  24390. _freeze(): void;
  24391. /** @hidden */
  24392. _unFreeze(): void;
  24393. /**
  24394. * 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
  24395. * @param subMesh defines the subMesh to render
  24396. * @param enableAlphaMode defines if alpha mode can be changed
  24397. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24398. * @returns the current mesh
  24399. */
  24400. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24401. private _onBeforeDraw;
  24402. /**
  24403. * Renormalize the mesh and patch it up if there are no weights
  24404. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24405. * However in the case of zero weights then we set just a single influence to 1.
  24406. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24407. */
  24408. cleanMatrixWeights(): void;
  24409. private normalizeSkinFourWeights;
  24410. private normalizeSkinWeightsAndExtra;
  24411. /**
  24412. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24413. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24414. * the user know there was an issue with importing the mesh
  24415. * @returns a validation object with skinned, valid and report string
  24416. */
  24417. validateSkinning(): {
  24418. skinned: boolean;
  24419. valid: boolean;
  24420. report: string;
  24421. };
  24422. /** @hidden */
  24423. _checkDelayState(): Mesh;
  24424. private _queueLoad;
  24425. /**
  24426. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24427. * A mesh is in the frustum if its bounding box intersects the frustum
  24428. * @param frustumPlanes defines the frustum to test
  24429. * @returns true if the mesh is in the frustum planes
  24430. */
  24431. isInFrustum(frustumPlanes: Plane[]): boolean;
  24432. /**
  24433. * Sets the mesh material by the material or multiMaterial `id` property
  24434. * @param id is a string identifying the material or the multiMaterial
  24435. * @returns the current mesh
  24436. */
  24437. setMaterialByID(id: string): Mesh;
  24438. /**
  24439. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24440. * @returns an array of IAnimatable
  24441. */
  24442. getAnimatables(): IAnimatable[];
  24443. /**
  24444. * Modifies the mesh geometry according to the passed transformation matrix.
  24445. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24446. * The mesh normals are modified using the same transformation.
  24447. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24448. * @param transform defines the transform matrix to use
  24449. * @see http://doc.babylonjs.com/resources/baking_transformations
  24450. * @returns the current mesh
  24451. */
  24452. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24453. /**
  24454. * Modifies the mesh geometry according to its own current World Matrix.
  24455. * The mesh World Matrix is then reset.
  24456. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24457. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24458. * @see http://doc.babylonjs.com/resources/baking_transformations
  24459. * @returns the current mesh
  24460. */
  24461. bakeCurrentTransformIntoVertices(): Mesh;
  24462. /** @hidden */
  24463. readonly _positions: Nullable<Vector3[]>;
  24464. /** @hidden */
  24465. _resetPointsArrayCache(): Mesh;
  24466. /** @hidden */
  24467. _generatePointsArray(): boolean;
  24468. /**
  24469. * Returns a new Mesh object generated from the current mesh properties.
  24470. * This method must not get confused with createInstance()
  24471. * @param name is a string, the name given to the new mesh
  24472. * @param newParent can be any Node object (default `null`)
  24473. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24474. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24475. * @returns a new mesh
  24476. */
  24477. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24478. /**
  24479. * Releases resources associated with this mesh.
  24480. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24481. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24482. */
  24483. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24484. /** @hidden */
  24485. _disposeInstanceSpecificData(): void;
  24486. /**
  24487. * Modifies the mesh geometry according to a displacement map.
  24488. * 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.
  24489. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24490. * @param url is a string, the URL from the image file is to be downloaded.
  24491. * @param minHeight is the lower limit of the displacement.
  24492. * @param maxHeight is the upper limit of the displacement.
  24493. * @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.
  24494. * @param uvOffset is an optional vector2 used to offset UV.
  24495. * @param uvScale is an optional vector2 used to scale UV.
  24496. * @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.
  24497. * @returns the Mesh.
  24498. */
  24499. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24500. /**
  24501. * Modifies the mesh geometry according to a displacementMap buffer.
  24502. * 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.
  24503. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24504. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24505. * @param heightMapWidth is the width of the buffer image.
  24506. * @param heightMapHeight is the height of the buffer image.
  24507. * @param minHeight is the lower limit of the displacement.
  24508. * @param maxHeight is the upper limit of the displacement.
  24509. * @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.
  24510. * @param uvOffset is an optional vector2 used to offset UV.
  24511. * @param uvScale is an optional vector2 used to scale UV.
  24512. * @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.
  24513. * @returns the Mesh.
  24514. */
  24515. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24516. /**
  24517. * Modify the mesh to get a flat shading rendering.
  24518. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24519. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24520. * @returns current mesh
  24521. */
  24522. convertToFlatShadedMesh(): Mesh;
  24523. /**
  24524. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24525. * In other words, more vertices, no more indices and a single bigger VBO.
  24526. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24527. * @returns current mesh
  24528. */
  24529. convertToUnIndexedMesh(): Mesh;
  24530. /**
  24531. * Inverses facet orientations.
  24532. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24533. * @param flipNormals will also inverts the normals
  24534. * @returns current mesh
  24535. */
  24536. flipFaces(flipNormals?: boolean): Mesh;
  24537. /**
  24538. * Increase the number of facets and hence vertices in a mesh
  24539. * Vertex normals are interpolated from existing vertex normals
  24540. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24541. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24542. */
  24543. increaseVertices(numberPerEdge: number): void;
  24544. /**
  24545. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24546. * This will undo any application of covertToFlatShadedMesh
  24547. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24548. */
  24549. forceSharedVertices(): void;
  24550. /** @hidden */
  24551. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24552. /** @hidden */
  24553. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24554. /**
  24555. * Creates a new InstancedMesh object from the mesh model.
  24556. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24557. * @param name defines the name of the new instance
  24558. * @returns a new InstancedMesh
  24559. */
  24560. createInstance(name: string): InstancedMesh;
  24561. /**
  24562. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24563. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24564. * @returns the current mesh
  24565. */
  24566. synchronizeInstances(): Mesh;
  24567. /**
  24568. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24569. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24570. * This should be used together with the simplification to avoid disappearing triangles.
  24571. * @param successCallback an optional success callback to be called after the optimization finished.
  24572. * @returns the current mesh
  24573. */
  24574. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24575. /**
  24576. * Serialize current mesh
  24577. * @param serializationObject defines the object which will receive the serialization data
  24578. */
  24579. serialize(serializationObject: any): void;
  24580. /** @hidden */
  24581. _syncGeometryWithMorphTargetManager(): void;
  24582. /** @hidden */
  24583. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24584. /**
  24585. * Returns a new Mesh object parsed from the source provided.
  24586. * @param parsedMesh is the source
  24587. * @param scene defines the hosting scene
  24588. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24589. * @returns a new Mesh
  24590. */
  24591. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24592. /**
  24593. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24594. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24595. * @param name defines the name of the mesh to create
  24596. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24597. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24598. * @param closePath creates a seam between the first and the last points of each path of the path array
  24599. * @param offset is taken in account only if the `pathArray` is containing a single path
  24600. * @param scene defines the hosting scene
  24601. * @param updatable defines if the mesh must be flagged as updatable
  24602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24603. * @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)
  24604. * @returns a new Mesh
  24605. */
  24606. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24607. /**
  24608. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24609. * @param name defines the name of the mesh to create
  24610. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24611. * @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
  24612. * @param scene defines the hosting scene
  24613. * @param updatable defines if the mesh must be flagged as updatable
  24614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24615. * @returns a new Mesh
  24616. */
  24617. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24618. /**
  24619. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24620. * @param name defines the name of the mesh to create
  24621. * @param size sets the size (float) of each box side (default 1)
  24622. * @param scene defines the hosting scene
  24623. * @param updatable defines if the mesh must be flagged as updatable
  24624. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24625. * @returns a new Mesh
  24626. */
  24627. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24628. /**
  24629. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24630. * @param name defines the name of the mesh to create
  24631. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24632. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24633. * @param scene defines the hosting scene
  24634. * @param updatable defines if the mesh must be flagged as updatable
  24635. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24636. * @returns a new Mesh
  24637. */
  24638. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24639. /**
  24640. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24641. * @param name defines the name of the mesh to create
  24642. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24643. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24644. * @param scene defines the hosting scene
  24645. * @returns a new Mesh
  24646. */
  24647. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24648. /**
  24649. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24650. * @param name defines the name of the mesh to create
  24651. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24652. * @param diameterTop set the top cap diameter (floats, default 1)
  24653. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24654. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24655. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24656. * @param scene defines the hosting scene
  24657. * @param updatable defines if the mesh must be flagged as updatable
  24658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24659. * @returns a new Mesh
  24660. */
  24661. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24662. /**
  24663. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24664. * @param name defines the name of the mesh to create
  24665. * @param diameter sets the diameter size (float) of the torus (default 1)
  24666. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24667. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24668. * @param scene defines the hosting scene
  24669. * @param updatable defines if the mesh must be flagged as updatable
  24670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24671. * @returns a new Mesh
  24672. */
  24673. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24674. /**
  24675. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24676. * @param name defines the name of the mesh to create
  24677. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24678. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24679. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24680. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24681. * @param p the number of windings on X axis (positive integers, default 2)
  24682. * @param q the number of windings on Y axis (positive integers, default 3)
  24683. * @param scene defines the hosting scene
  24684. * @param updatable defines if the mesh must be flagged as updatable
  24685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24686. * @returns a new Mesh
  24687. */
  24688. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24689. /**
  24690. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24691. * @param name defines the name of the mesh to create
  24692. * @param points is an array successive Vector3
  24693. * @param scene defines the hosting scene
  24694. * @param updatable defines if the mesh must be flagged as updatable
  24695. * @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).
  24696. * @returns a new Mesh
  24697. */
  24698. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24699. /**
  24700. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24701. * @param name defines the name of the mesh to create
  24702. * @param points is an array successive Vector3
  24703. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24704. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24705. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24706. * @param scene defines the hosting scene
  24707. * @param updatable defines if the mesh must be flagged as updatable
  24708. * @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)
  24709. * @returns a new Mesh
  24710. */
  24711. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24712. /**
  24713. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24714. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24715. * 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.
  24716. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24717. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24718. * Remember you can only change the shape positions, not their number when updating a polygon.
  24719. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24720. * @param name defines the name of the mesh to create
  24721. * @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
  24722. * @param scene defines the hosting scene
  24723. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24724. * @param updatable defines if the mesh must be flagged as updatable
  24725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24726. * @param earcutInjection can be used to inject your own earcut reference
  24727. * @returns a new Mesh
  24728. */
  24729. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24730. /**
  24731. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24732. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24733. * @param name defines the name of the mesh to create
  24734. * @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
  24735. * @param depth defines the height of extrusion
  24736. * @param scene defines the hosting scene
  24737. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24738. * @param updatable defines if the mesh must be flagged as updatable
  24739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24740. * @param earcutInjection can be used to inject your own earcut reference
  24741. * @returns a new Mesh
  24742. */
  24743. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24744. /**
  24745. * Creates an extruded shape mesh.
  24746. * 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
  24747. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24748. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24749. * @param name defines the name of the mesh to create
  24750. * @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
  24751. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24752. * @param scale is the value to scale the shape
  24753. * @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
  24754. * @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
  24755. * @param scene defines the hosting scene
  24756. * @param updatable defines if the mesh must be flagged as updatable
  24757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24758. * @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)
  24759. * @returns a new Mesh
  24760. */
  24761. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24762. /**
  24763. * Creates an custom extruded shape mesh.
  24764. * The custom extrusion is a parametric shape.
  24765. * It has no predefined shape. Its final shape will depend on the input parameters.
  24766. * Please consider using the same method from the MeshBuilder class instead
  24767. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24768. * @param name defines the name of the mesh to create
  24769. * @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
  24770. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24771. * @param scaleFunction is a custom Javascript function called on each path point
  24772. * @param rotationFunction is a custom Javascript function called on each path point
  24773. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24774. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24775. * @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
  24776. * @param scene defines the hosting scene
  24777. * @param updatable defines if the mesh must be flagged as updatable
  24778. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24779. * @param instance 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)
  24780. * @returns a new Mesh
  24781. */
  24782. 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;
  24783. /**
  24784. * Creates lathe mesh.
  24785. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24786. * Please consider using the same method from the MeshBuilder class instead
  24787. * @param name defines the name of the mesh to create
  24788. * @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
  24789. * @param radius is the radius value of the lathe
  24790. * @param tessellation is the side number of the lathe.
  24791. * @param scene defines the hosting scene
  24792. * @param updatable defines if the mesh must be flagged as updatable
  24793. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24794. * @returns a new Mesh
  24795. */
  24796. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24797. /**
  24798. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24799. * @param name defines the name of the mesh to create
  24800. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24801. * @param scene defines the hosting scene
  24802. * @param updatable defines if the mesh must be flagged as updatable
  24803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24804. * @returns a new Mesh
  24805. */
  24806. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24807. /**
  24808. * Creates a ground mesh.
  24809. * Please consider using the same method from the MeshBuilder class instead
  24810. * @param name defines the name of the mesh to create
  24811. * @param width set the width of the ground
  24812. * @param height set the height of the ground
  24813. * @param subdivisions sets the number of subdivisions per side
  24814. * @param scene defines the hosting scene
  24815. * @param updatable defines if the mesh must be flagged as updatable
  24816. * @returns a new Mesh
  24817. */
  24818. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24819. /**
  24820. * Creates a tiled ground mesh.
  24821. * Please consider using the same method from the MeshBuilder class instead
  24822. * @param name defines the name of the mesh to create
  24823. * @param xmin set the ground minimum X coordinate
  24824. * @param zmin set the ground minimum Y coordinate
  24825. * @param xmax set the ground maximum X coordinate
  24826. * @param zmax set the ground maximum Z coordinate
  24827. * @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
  24828. * @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
  24829. * @param scene defines the hosting scene
  24830. * @param updatable defines if the mesh must be flagged as updatable
  24831. * @returns a new Mesh
  24832. */
  24833. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24834. w: number;
  24835. h: number;
  24836. }, precision: {
  24837. w: number;
  24838. h: number;
  24839. }, scene: Scene, updatable?: boolean): Mesh;
  24840. /**
  24841. * Creates a ground mesh from a height map.
  24842. * Please consider using the same method from the MeshBuilder class instead
  24843. * @see http://doc.babylonjs.com/babylon101/height_map
  24844. * @param name defines the name of the mesh to create
  24845. * @param url sets the URL of the height map image resource
  24846. * @param width set the ground width size
  24847. * @param height set the ground height size
  24848. * @param subdivisions sets the number of subdivision per side
  24849. * @param minHeight is the minimum altitude on the ground
  24850. * @param maxHeight is the maximum altitude on the ground
  24851. * @param scene defines the hosting scene
  24852. * @param updatable defines if the mesh must be flagged as updatable
  24853. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24854. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24855. * @returns a new Mesh
  24856. */
  24857. 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;
  24858. /**
  24859. * Creates a tube mesh.
  24860. * The tube is a parametric shape.
  24861. * It has no predefined shape. Its final shape will depend on the input parameters.
  24862. * Please consider using the same method from the MeshBuilder class instead
  24863. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24864. * @param name defines the name of the mesh to create
  24865. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24866. * @param radius sets the tube radius size
  24867. * @param tessellation is the number of sides on the tubular surface
  24868. * @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
  24869. * @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
  24870. * @param scene defines the hosting scene
  24871. * @param updatable defines if the mesh must be flagged as updatable
  24872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24873. * @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)
  24874. * @returns a new Mesh
  24875. */
  24876. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24877. (i: number, distance: number): number;
  24878. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24879. /**
  24880. * Creates a polyhedron mesh.
  24881. * Please consider using the same method from the MeshBuilder class instead.
  24882. * * 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
  24883. * * The parameter `size` (positive float, default 1) sets the polygon size
  24884. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24885. * * 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`
  24886. * * 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
  24887. * * 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)`)
  24888. * * 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
  24889. * * 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
  24890. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24891. * * 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
  24892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24893. * @param name defines the name of the mesh to create
  24894. * @param options defines the options used to create the mesh
  24895. * @param scene defines the hosting scene
  24896. * @returns a new Mesh
  24897. */
  24898. static CreatePolyhedron(name: string, options: {
  24899. type?: number;
  24900. size?: number;
  24901. sizeX?: number;
  24902. sizeY?: number;
  24903. sizeZ?: number;
  24904. custom?: any;
  24905. faceUV?: Vector4[];
  24906. faceColors?: Color4[];
  24907. updatable?: boolean;
  24908. sideOrientation?: number;
  24909. }, scene: Scene): Mesh;
  24910. /**
  24911. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24912. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24913. * * 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`)
  24914. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24915. * * 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
  24916. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24917. * * 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
  24918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24919. * @param name defines the name of the mesh
  24920. * @param options defines the options used to create the mesh
  24921. * @param scene defines the hosting scene
  24922. * @returns a new Mesh
  24923. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24924. */
  24925. static CreateIcoSphere(name: string, options: {
  24926. radius?: number;
  24927. flat?: boolean;
  24928. subdivisions?: number;
  24929. sideOrientation?: number;
  24930. updatable?: boolean;
  24931. }, scene: Scene): Mesh;
  24932. /**
  24933. * Creates a decal mesh.
  24934. * Please consider using the same method from the MeshBuilder class instead.
  24935. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24936. * @param name defines the name of the mesh
  24937. * @param sourceMesh defines the mesh receiving the decal
  24938. * @param position sets the position of the decal in world coordinates
  24939. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24940. * @param size sets the decal scaling
  24941. * @param angle sets the angle to rotate the decal
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24945. /**
  24946. * Prepare internal position array for software CPU skinning
  24947. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24948. */
  24949. setPositionsForCPUSkinning(): Float32Array;
  24950. /**
  24951. * Prepare internal normal array for software CPU skinning
  24952. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24953. */
  24954. setNormalsForCPUSkinning(): Float32Array;
  24955. /**
  24956. * Updates the vertex buffer by applying transformation from the bones
  24957. * @param skeleton defines the skeleton to apply to current mesh
  24958. * @returns the current mesh
  24959. */
  24960. applySkeleton(skeleton: Skeleton): Mesh;
  24961. /**
  24962. * 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
  24963. * @param meshes defines the list of meshes to scan
  24964. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24965. */
  24966. static MinMax(meshes: AbstractMesh[]): {
  24967. min: Vector3;
  24968. max: Vector3;
  24969. };
  24970. /**
  24971. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24972. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24973. * @returns a vector3
  24974. */
  24975. static Center(meshesOrMinMaxVector: {
  24976. min: Vector3;
  24977. max: Vector3;
  24978. } | AbstractMesh[]): Vector3;
  24979. /**
  24980. * Merge the array of meshes into a single mesh for performance reasons.
  24981. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24982. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24983. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24984. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24985. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24986. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24987. * @returns a new mesh
  24988. */
  24989. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24990. /** @hidden */
  24991. addInstance(instance: InstancedMesh): void;
  24992. /** @hidden */
  24993. removeInstance(instance: InstancedMesh): void;
  24994. }
  24995. }
  24996. declare module BABYLON {
  24997. /**
  24998. * This is the base class of all the camera used in the application.
  24999. * @see http://doc.babylonjs.com/features/cameras
  25000. */
  25001. export class Camera extends Node {
  25002. /** @hidden */
  25003. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25004. /**
  25005. * This is the default projection mode used by the cameras.
  25006. * It helps recreating a feeling of perspective and better appreciate depth.
  25007. * This is the best way to simulate real life cameras.
  25008. */
  25009. static readonly PERSPECTIVE_CAMERA: number;
  25010. /**
  25011. * This helps creating camera with an orthographic mode.
  25012. * 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.
  25013. */
  25014. static readonly ORTHOGRAPHIC_CAMERA: number;
  25015. /**
  25016. * This is the default FOV mode for perspective cameras.
  25017. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25018. */
  25019. static readonly FOVMODE_VERTICAL_FIXED: number;
  25020. /**
  25021. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25022. */
  25023. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25024. /**
  25025. * This specifies ther is no need for a camera rig.
  25026. * Basically only one eye is rendered corresponding to the camera.
  25027. */
  25028. static readonly RIG_MODE_NONE: number;
  25029. /**
  25030. * Simulates a camera Rig with one blue eye and one red eye.
  25031. * This can be use with 3d blue and red glasses.
  25032. */
  25033. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25034. /**
  25035. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25036. */
  25037. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25038. /**
  25039. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25040. */
  25041. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25042. /**
  25043. * Defines that both eyes of the camera will be rendered over under each other.
  25044. */
  25045. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25046. /**
  25047. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25048. */
  25049. static readonly RIG_MODE_VR: number;
  25050. /**
  25051. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25052. */
  25053. static readonly RIG_MODE_WEBVR: number;
  25054. /**
  25055. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25056. */
  25057. static readonly RIG_MODE_CUSTOM: number;
  25058. /**
  25059. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25060. */
  25061. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25062. /**
  25063. * Define the input manager associated with the camera.
  25064. */
  25065. inputs: CameraInputsManager<Camera>;
  25066. /** @hidden */
  25067. _position: Vector3;
  25068. /**
  25069. * Define the current local position of the camera in the scene
  25070. */
  25071. position: Vector3;
  25072. /**
  25073. * The vector the camera should consider as up.
  25074. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25075. */
  25076. upVector: Vector3;
  25077. /**
  25078. * Define the current limit on the left side for an orthographic camera
  25079. * In scene unit
  25080. */
  25081. orthoLeft: Nullable<number>;
  25082. /**
  25083. * Define the current limit on the right side for an orthographic camera
  25084. * In scene unit
  25085. */
  25086. orthoRight: Nullable<number>;
  25087. /**
  25088. * Define the current limit on the bottom side for an orthographic camera
  25089. * In scene unit
  25090. */
  25091. orthoBottom: Nullable<number>;
  25092. /**
  25093. * Define the current limit on the top side for an orthographic camera
  25094. * In scene unit
  25095. */
  25096. orthoTop: Nullable<number>;
  25097. /**
  25098. * Field Of View is set in Radians. (default is 0.8)
  25099. */
  25100. fov: number;
  25101. /**
  25102. * Define the minimum distance the camera can see from.
  25103. * This is important to note that the depth buffer are not infinite and the closer it starts
  25104. * the more your scene might encounter depth fighting issue.
  25105. */
  25106. minZ: number;
  25107. /**
  25108. * Define the maximum distance the camera can see to.
  25109. * This is important to note that the depth buffer are not infinite and the further it end
  25110. * the more your scene might encounter depth fighting issue.
  25111. */
  25112. maxZ: number;
  25113. /**
  25114. * Define the default inertia of the camera.
  25115. * This helps giving a smooth feeling to the camera movement.
  25116. */
  25117. inertia: number;
  25118. /**
  25119. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25120. */
  25121. mode: number;
  25122. /**
  25123. * Define wether the camera is intermediate.
  25124. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25125. */
  25126. isIntermediate: boolean;
  25127. /**
  25128. * Define the viewport of the camera.
  25129. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25130. */
  25131. viewport: Viewport;
  25132. /**
  25133. * Restricts the camera to viewing objects with the same layerMask.
  25134. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25135. */
  25136. layerMask: number;
  25137. /**
  25138. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25139. */
  25140. fovMode: number;
  25141. /**
  25142. * Rig mode of the camera.
  25143. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25144. * This is normally controlled byt the camera themselves as internal use.
  25145. */
  25146. cameraRigMode: number;
  25147. /**
  25148. * Defines the distance between both "eyes" in case of a RIG
  25149. */
  25150. interaxialDistance: number;
  25151. /**
  25152. * Defines if stereoscopic rendering is done side by side or over under.
  25153. */
  25154. isStereoscopicSideBySide: boolean;
  25155. /**
  25156. * 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
  25157. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25158. * else in the scene. (Eg. security camera)
  25159. *
  25160. * 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)
  25161. */
  25162. customRenderTargets: RenderTargetTexture[];
  25163. /**
  25164. * When set, the camera will render to this render target instead of the default canvas
  25165. *
  25166. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25167. */
  25168. outputRenderTarget: Nullable<RenderTargetTexture>;
  25169. /**
  25170. * Observable triggered when the camera view matrix has changed.
  25171. */
  25172. onViewMatrixChangedObservable: Observable<Camera>;
  25173. /**
  25174. * Observable triggered when the camera Projection matrix has changed.
  25175. */
  25176. onProjectionMatrixChangedObservable: Observable<Camera>;
  25177. /**
  25178. * Observable triggered when the inputs have been processed.
  25179. */
  25180. onAfterCheckInputsObservable: Observable<Camera>;
  25181. /**
  25182. * Observable triggered when reset has been called and applied to the camera.
  25183. */
  25184. onRestoreStateObservable: Observable<Camera>;
  25185. /** @hidden */
  25186. _cameraRigParams: any;
  25187. /** @hidden */
  25188. _rigCameras: Camera[];
  25189. /** @hidden */
  25190. _rigPostProcess: Nullable<PostProcess>;
  25191. protected _webvrViewMatrix: Matrix;
  25192. /** @hidden */
  25193. _skipRendering: boolean;
  25194. /** @hidden */
  25195. _projectionMatrix: Matrix;
  25196. /** @hidden */
  25197. _postProcesses: Nullable<PostProcess>[];
  25198. /** @hidden */
  25199. _activeMeshes: SmartArray<AbstractMesh>;
  25200. protected _globalPosition: Vector3;
  25201. /** @hidden */
  25202. _computedViewMatrix: Matrix;
  25203. private _doNotComputeProjectionMatrix;
  25204. private _transformMatrix;
  25205. private _frustumPlanes;
  25206. private _refreshFrustumPlanes;
  25207. private _storedFov;
  25208. private _stateStored;
  25209. /**
  25210. * Instantiates a new camera object.
  25211. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25212. * @see http://doc.babylonjs.com/features/cameras
  25213. * @param name Defines the name of the camera in the scene
  25214. * @param position Defines the position of the camera
  25215. * @param scene Defines the scene the camera belongs too
  25216. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25217. */
  25218. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25219. /**
  25220. * Store current camera state (fov, position, etc..)
  25221. * @returns the camera
  25222. */
  25223. storeState(): Camera;
  25224. /**
  25225. * Restores the camera state values if it has been stored. You must call storeState() first
  25226. */
  25227. protected _restoreStateValues(): boolean;
  25228. /**
  25229. * Restored camera state. You must call storeState() first.
  25230. * @returns true if restored and false otherwise
  25231. */
  25232. restoreState(): boolean;
  25233. /**
  25234. * Gets the class name of the camera.
  25235. * @returns the class name
  25236. */
  25237. getClassName(): string;
  25238. /** @hidden */
  25239. readonly _isCamera: boolean;
  25240. /**
  25241. * Gets a string representation of the camera useful for debug purpose.
  25242. * @param fullDetails Defines that a more verboe level of logging is required
  25243. * @returns the string representation
  25244. */
  25245. toString(fullDetails?: boolean): string;
  25246. /**
  25247. * Gets the current world space position of the camera.
  25248. */
  25249. readonly globalPosition: Vector3;
  25250. /**
  25251. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25252. * @returns the active meshe list
  25253. */
  25254. getActiveMeshes(): SmartArray<AbstractMesh>;
  25255. /**
  25256. * Check wether a mesh is part of the current active mesh list of the camera
  25257. * @param mesh Defines the mesh to check
  25258. * @returns true if active, false otherwise
  25259. */
  25260. isActiveMesh(mesh: Mesh): boolean;
  25261. /**
  25262. * Is this camera ready to be used/rendered
  25263. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25264. * @return true if the camera is ready
  25265. */
  25266. isReady(completeCheck?: boolean): boolean;
  25267. /** @hidden */
  25268. _initCache(): void;
  25269. /** @hidden */
  25270. _updateCache(ignoreParentClass?: boolean): void;
  25271. /** @hidden */
  25272. _isSynchronized(): boolean;
  25273. /** @hidden */
  25274. _isSynchronizedViewMatrix(): boolean;
  25275. /** @hidden */
  25276. _isSynchronizedProjectionMatrix(): boolean;
  25277. /**
  25278. * Attach the input controls to a specific dom element to get the input from.
  25279. * @param element Defines the element the controls should be listened from
  25280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25281. */
  25282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25283. /**
  25284. * Detach the current controls from the specified dom element.
  25285. * @param element Defines the element to stop listening the inputs from
  25286. */
  25287. detachControl(element: HTMLElement): void;
  25288. /**
  25289. * Update the camera state according to the different inputs gathered during the frame.
  25290. */
  25291. update(): void;
  25292. /** @hidden */
  25293. _checkInputs(): void;
  25294. /** @hidden */
  25295. readonly rigCameras: Camera[];
  25296. /**
  25297. * Gets the post process used by the rig cameras
  25298. */
  25299. readonly rigPostProcess: Nullable<PostProcess>;
  25300. /**
  25301. * Internal, gets the first post proces.
  25302. * @returns the first post process to be run on this camera.
  25303. */
  25304. _getFirstPostProcess(): Nullable<PostProcess>;
  25305. private _cascadePostProcessesToRigCams;
  25306. /**
  25307. * Attach a post process to the camera.
  25308. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25309. * @param postProcess The post process to attach to the camera
  25310. * @param insertAt The position of the post process in case several of them are in use in the scene
  25311. * @returns the position the post process has been inserted at
  25312. */
  25313. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25314. /**
  25315. * Detach a post process to the camera.
  25316. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25317. * @param postProcess The post process to detach from the camera
  25318. */
  25319. detachPostProcess(postProcess: PostProcess): void;
  25320. /**
  25321. * Gets the current world matrix of the camera
  25322. */
  25323. getWorldMatrix(): Matrix;
  25324. /** @hidden */
  25325. _getViewMatrix(): Matrix;
  25326. /**
  25327. * Gets the current view matrix of the camera.
  25328. * @param force forces the camera to recompute the matrix without looking at the cached state
  25329. * @returns the view matrix
  25330. */
  25331. getViewMatrix(force?: boolean): Matrix;
  25332. /**
  25333. * Freeze the projection matrix.
  25334. * It will prevent the cache check of the camera projection compute and can speed up perf
  25335. * if no parameter of the camera are meant to change
  25336. * @param projection Defines manually a projection if necessary
  25337. */
  25338. freezeProjectionMatrix(projection?: Matrix): void;
  25339. /**
  25340. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25341. */
  25342. unfreezeProjectionMatrix(): void;
  25343. /**
  25344. * Gets the current projection matrix of the camera.
  25345. * @param force forces the camera to recompute the matrix without looking at the cached state
  25346. * @returns the projection matrix
  25347. */
  25348. getProjectionMatrix(force?: boolean): Matrix;
  25349. /**
  25350. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25351. * @returns a Matrix
  25352. */
  25353. getTransformationMatrix(): Matrix;
  25354. private _updateFrustumPlanes;
  25355. /**
  25356. * Checks if a cullable object (mesh...) is in the camera frustum
  25357. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25358. * @param target The object to check
  25359. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25360. * @returns true if the object is in frustum otherwise false
  25361. */
  25362. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25363. /**
  25364. * Checks if a cullable object (mesh...) is in the camera frustum
  25365. * Unlike isInFrustum this cheks the full bounding box
  25366. * @param target The object to check
  25367. * @returns true if the object is in frustum otherwise false
  25368. */
  25369. isCompletelyInFrustum(target: ICullable): boolean;
  25370. /**
  25371. * Gets a ray in the forward direction from the camera.
  25372. * @param length Defines the length of the ray to create
  25373. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25374. * @param origin Defines the start point of the ray which defaults to the camera position
  25375. * @returns the forward ray
  25376. */
  25377. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25378. /**
  25379. * Releases resources associated with this node.
  25380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25382. */
  25383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25384. /** @hidden */
  25385. _isLeftCamera: boolean;
  25386. /**
  25387. * Gets the left camera of a rig setup in case of Rigged Camera
  25388. */
  25389. readonly isLeftCamera: boolean;
  25390. /** @hidden */
  25391. _isRightCamera: boolean;
  25392. /**
  25393. * Gets the right camera of a rig setup in case of Rigged Camera
  25394. */
  25395. readonly isRightCamera: boolean;
  25396. /**
  25397. * Gets the left camera of a rig setup in case of Rigged Camera
  25398. */
  25399. readonly leftCamera: Nullable<FreeCamera>;
  25400. /**
  25401. * Gets the right camera of a rig setup in case of Rigged Camera
  25402. */
  25403. readonly rightCamera: Nullable<FreeCamera>;
  25404. /**
  25405. * Gets the left camera target of a rig setup in case of Rigged Camera
  25406. * @returns the target position
  25407. */
  25408. getLeftTarget(): Nullable<Vector3>;
  25409. /**
  25410. * Gets the right camera target of a rig setup in case of Rigged Camera
  25411. * @returns the target position
  25412. */
  25413. getRightTarget(): Nullable<Vector3>;
  25414. /**
  25415. * @hidden
  25416. */
  25417. setCameraRigMode(mode: number, rigParams: any): void;
  25418. /** @hidden */
  25419. static _setStereoscopicRigMode(camera: Camera): void;
  25420. /** @hidden */
  25421. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25422. /** @hidden */
  25423. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25424. /** @hidden */
  25425. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25426. /** @hidden */
  25427. _getVRProjectionMatrix(): Matrix;
  25428. protected _updateCameraRotationMatrix(): void;
  25429. protected _updateWebVRCameraRotationMatrix(): void;
  25430. /**
  25431. * This function MUST be overwritten by the different WebVR cameras available.
  25432. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25433. * @hidden
  25434. */
  25435. _getWebVRProjectionMatrix(): Matrix;
  25436. /**
  25437. * This function MUST be overwritten by the different WebVR cameras available.
  25438. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25439. * @hidden
  25440. */
  25441. _getWebVRViewMatrix(): Matrix;
  25442. /** @hidden */
  25443. setCameraRigParameter(name: string, value: any): void;
  25444. /**
  25445. * needs to be overridden by children so sub has required properties to be copied
  25446. * @hidden
  25447. */
  25448. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25449. /**
  25450. * May need to be overridden by children
  25451. * @hidden
  25452. */
  25453. _updateRigCameras(): void;
  25454. /** @hidden */
  25455. _setupInputs(): void;
  25456. /**
  25457. * Serialiaze the camera setup to a json represention
  25458. * @returns the JSON representation
  25459. */
  25460. serialize(): any;
  25461. /**
  25462. * Clones the current camera.
  25463. * @param name The cloned camera name
  25464. * @returns the cloned camera
  25465. */
  25466. clone(name: string): Camera;
  25467. /**
  25468. * Gets the direction of the camera relative to a given local axis.
  25469. * @param localAxis Defines the reference axis to provide a relative direction.
  25470. * @return the direction
  25471. */
  25472. getDirection(localAxis: Vector3): Vector3;
  25473. /**
  25474. * Returns the current camera absolute rotation
  25475. */
  25476. readonly absoluteRotation: Quaternion;
  25477. /**
  25478. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25479. * @param localAxis Defines the reference axis to provide a relative direction.
  25480. * @param result Defines the vector to store the result in
  25481. */
  25482. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25483. /**
  25484. * Gets a camera constructor for a given camera type
  25485. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25486. * @param name The name of the camera the result will be able to instantiate
  25487. * @param scene The scene the result will construct the camera in
  25488. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25489. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25490. * @returns a factory method to construc the camera
  25491. */
  25492. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25493. /**
  25494. * Compute the world matrix of the camera.
  25495. * @returns the camera world matrix
  25496. */
  25497. computeWorldMatrix(): Matrix;
  25498. /**
  25499. * Parse a JSON and creates the camera from the parsed information
  25500. * @param parsedCamera The JSON to parse
  25501. * @param scene The scene to instantiate the camera in
  25502. * @returns the newly constructed camera
  25503. */
  25504. static Parse(parsedCamera: any, scene: Scene): Camera;
  25505. }
  25506. }
  25507. declare module BABYLON {
  25508. /**
  25509. * Class containing static functions to help procedurally build meshes
  25510. */
  25511. export class DiscBuilder {
  25512. /**
  25513. * Creates a plane polygonal mesh. By default, this is a disc
  25514. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25515. * * 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
  25516. * * 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
  25517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25518. * * 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
  25519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25520. * @param name defines the name of the mesh
  25521. * @param options defines the options used to create the mesh
  25522. * @param scene defines the hosting scene
  25523. * @returns the plane polygonal mesh
  25524. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25525. */
  25526. static CreateDisc(name: string, options: {
  25527. radius?: number;
  25528. tessellation?: number;
  25529. arc?: number;
  25530. updatable?: boolean;
  25531. sideOrientation?: number;
  25532. frontUVs?: Vector4;
  25533. backUVs?: Vector4;
  25534. }, scene?: Nullable<Scene>): Mesh;
  25535. }
  25536. }
  25537. declare module BABYLON {
  25538. /**
  25539. * This represents all the required information to add a fresnel effect on a material:
  25540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25541. */
  25542. export class FresnelParameters {
  25543. private _isEnabled;
  25544. /**
  25545. * Define if the fresnel effect is enable or not.
  25546. */
  25547. isEnabled: boolean;
  25548. /**
  25549. * Define the color used on edges (grazing angle)
  25550. */
  25551. leftColor: Color3;
  25552. /**
  25553. * Define the color used on center
  25554. */
  25555. rightColor: Color3;
  25556. /**
  25557. * Define bias applied to computed fresnel term
  25558. */
  25559. bias: number;
  25560. /**
  25561. * Defined the power exponent applied to fresnel term
  25562. */
  25563. power: number;
  25564. /**
  25565. * Clones the current fresnel and its valuues
  25566. * @returns a clone fresnel configuration
  25567. */
  25568. clone(): FresnelParameters;
  25569. /**
  25570. * Serializes the current fresnel parameters to a JSON representation.
  25571. * @return the JSON serialization
  25572. */
  25573. serialize(): any;
  25574. /**
  25575. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25576. * @param parsedFresnelParameters Define the JSON representation
  25577. * @returns the parsed parameters
  25578. */
  25579. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25580. }
  25581. }
  25582. declare module BABYLON {
  25583. /**
  25584. * Base class of materials working in push mode in babylon JS
  25585. * @hidden
  25586. */
  25587. export class PushMaterial extends Material {
  25588. protected _activeEffect: Effect;
  25589. protected _normalMatrix: Matrix;
  25590. /**
  25591. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25592. * This means that the material can keep using a previous shader while a new one is being compiled.
  25593. * This is mostly used when shader parallel compilation is supported (true by default)
  25594. */
  25595. allowShaderHotSwapping: boolean;
  25596. constructor(name: string, scene: Scene);
  25597. getEffect(): Effect;
  25598. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25599. /**
  25600. * Binds the given world matrix to the active effect
  25601. *
  25602. * @param world the matrix to bind
  25603. */
  25604. bindOnlyWorldMatrix(world: Matrix): void;
  25605. /**
  25606. * Binds the given normal matrix to the active effect
  25607. *
  25608. * @param normalMatrix the matrix to bind
  25609. */
  25610. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25611. bind(world: Matrix, mesh?: Mesh): void;
  25612. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25613. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25614. }
  25615. }
  25616. declare module BABYLON {
  25617. /**
  25618. * This groups all the flags used to control the materials channel.
  25619. */
  25620. export class MaterialFlags {
  25621. private static _DiffuseTextureEnabled;
  25622. /**
  25623. * Are diffuse textures enabled in the application.
  25624. */
  25625. static DiffuseTextureEnabled: boolean;
  25626. private static _AmbientTextureEnabled;
  25627. /**
  25628. * Are ambient textures enabled in the application.
  25629. */
  25630. static AmbientTextureEnabled: boolean;
  25631. private static _OpacityTextureEnabled;
  25632. /**
  25633. * Are opacity textures enabled in the application.
  25634. */
  25635. static OpacityTextureEnabled: boolean;
  25636. private static _ReflectionTextureEnabled;
  25637. /**
  25638. * Are reflection textures enabled in the application.
  25639. */
  25640. static ReflectionTextureEnabled: boolean;
  25641. private static _EmissiveTextureEnabled;
  25642. /**
  25643. * Are emissive textures enabled in the application.
  25644. */
  25645. static EmissiveTextureEnabled: boolean;
  25646. private static _SpecularTextureEnabled;
  25647. /**
  25648. * Are specular textures enabled in the application.
  25649. */
  25650. static SpecularTextureEnabled: boolean;
  25651. private static _BumpTextureEnabled;
  25652. /**
  25653. * Are bump textures enabled in the application.
  25654. */
  25655. static BumpTextureEnabled: boolean;
  25656. private static _LightmapTextureEnabled;
  25657. /**
  25658. * Are lightmap textures enabled in the application.
  25659. */
  25660. static LightmapTextureEnabled: boolean;
  25661. private static _RefractionTextureEnabled;
  25662. /**
  25663. * Are refraction textures enabled in the application.
  25664. */
  25665. static RefractionTextureEnabled: boolean;
  25666. private static _ColorGradingTextureEnabled;
  25667. /**
  25668. * Are color grading textures enabled in the application.
  25669. */
  25670. static ColorGradingTextureEnabled: boolean;
  25671. private static _FresnelEnabled;
  25672. /**
  25673. * Are fresnels enabled in the application.
  25674. */
  25675. static FresnelEnabled: boolean;
  25676. private static _ClearCoatTextureEnabled;
  25677. /**
  25678. * Are clear coat textures enabled in the application.
  25679. */
  25680. static ClearCoatTextureEnabled: boolean;
  25681. private static _ClearCoatBumpTextureEnabled;
  25682. /**
  25683. * Are clear coat bump textures enabled in the application.
  25684. */
  25685. static ClearCoatBumpTextureEnabled: boolean;
  25686. private static _ClearCoatTintTextureEnabled;
  25687. /**
  25688. * Are clear coat tint textures enabled in the application.
  25689. */
  25690. static ClearCoatTintTextureEnabled: boolean;
  25691. private static _SheenTextureEnabled;
  25692. /**
  25693. * Are sheen textures enabled in the application.
  25694. */
  25695. static SheenTextureEnabled: boolean;
  25696. private static _AnisotropicTextureEnabled;
  25697. /**
  25698. * Are anisotropic textures enabled in the application.
  25699. */
  25700. static AnisotropicTextureEnabled: boolean;
  25701. private static _ThicknessTextureEnabled;
  25702. /**
  25703. * Are thickness textures enabled in the application.
  25704. */
  25705. static ThicknessTextureEnabled: boolean;
  25706. }
  25707. }
  25708. declare module BABYLON {
  25709. /** @hidden */
  25710. export var defaultFragmentDeclaration: {
  25711. name: string;
  25712. shader: string;
  25713. };
  25714. }
  25715. declare module BABYLON {
  25716. /** @hidden */
  25717. export var defaultUboDeclaration: {
  25718. name: string;
  25719. shader: string;
  25720. };
  25721. }
  25722. declare module BABYLON {
  25723. /** @hidden */
  25724. export var lightFragmentDeclaration: {
  25725. name: string;
  25726. shader: string;
  25727. };
  25728. }
  25729. declare module BABYLON {
  25730. /** @hidden */
  25731. export var lightUboDeclaration: {
  25732. name: string;
  25733. shader: string;
  25734. };
  25735. }
  25736. declare module BABYLON {
  25737. /** @hidden */
  25738. export var lightsFragmentFunctions: {
  25739. name: string;
  25740. shader: string;
  25741. };
  25742. }
  25743. declare module BABYLON {
  25744. /** @hidden */
  25745. export var shadowsFragmentFunctions: {
  25746. name: string;
  25747. shader: string;
  25748. };
  25749. }
  25750. declare module BABYLON {
  25751. /** @hidden */
  25752. export var fresnelFunction: {
  25753. name: string;
  25754. shader: string;
  25755. };
  25756. }
  25757. declare module BABYLON {
  25758. /** @hidden */
  25759. export var reflectionFunction: {
  25760. name: string;
  25761. shader: string;
  25762. };
  25763. }
  25764. declare module BABYLON {
  25765. /** @hidden */
  25766. export var bumpFragmentFunctions: {
  25767. name: string;
  25768. shader: string;
  25769. };
  25770. }
  25771. declare module BABYLON {
  25772. /** @hidden */
  25773. export var logDepthDeclaration: {
  25774. name: string;
  25775. shader: string;
  25776. };
  25777. }
  25778. declare module BABYLON {
  25779. /** @hidden */
  25780. export var bumpFragment: {
  25781. name: string;
  25782. shader: string;
  25783. };
  25784. }
  25785. declare module BABYLON {
  25786. /** @hidden */
  25787. export var depthPrePass: {
  25788. name: string;
  25789. shader: string;
  25790. };
  25791. }
  25792. declare module BABYLON {
  25793. /** @hidden */
  25794. export var lightFragment: {
  25795. name: string;
  25796. shader: string;
  25797. };
  25798. }
  25799. declare module BABYLON {
  25800. /** @hidden */
  25801. export var logDepthFragment: {
  25802. name: string;
  25803. shader: string;
  25804. };
  25805. }
  25806. declare module BABYLON {
  25807. /** @hidden */
  25808. export var defaultPixelShader: {
  25809. name: string;
  25810. shader: string;
  25811. };
  25812. }
  25813. declare module BABYLON {
  25814. /** @hidden */
  25815. export var defaultVertexDeclaration: {
  25816. name: string;
  25817. shader: string;
  25818. };
  25819. }
  25820. declare module BABYLON {
  25821. /** @hidden */
  25822. export var bumpVertexDeclaration: {
  25823. name: string;
  25824. shader: string;
  25825. };
  25826. }
  25827. declare module BABYLON {
  25828. /** @hidden */
  25829. export var bumpVertex: {
  25830. name: string;
  25831. shader: string;
  25832. };
  25833. }
  25834. declare module BABYLON {
  25835. /** @hidden */
  25836. export var fogVertex: {
  25837. name: string;
  25838. shader: string;
  25839. };
  25840. }
  25841. declare module BABYLON {
  25842. /** @hidden */
  25843. export var shadowsVertex: {
  25844. name: string;
  25845. shader: string;
  25846. };
  25847. }
  25848. declare module BABYLON {
  25849. /** @hidden */
  25850. export var pointCloudVertex: {
  25851. name: string;
  25852. shader: string;
  25853. };
  25854. }
  25855. declare module BABYLON {
  25856. /** @hidden */
  25857. export var logDepthVertex: {
  25858. name: string;
  25859. shader: string;
  25860. };
  25861. }
  25862. declare module BABYLON {
  25863. /** @hidden */
  25864. export var defaultVertexShader: {
  25865. name: string;
  25866. shader: string;
  25867. };
  25868. }
  25869. declare module BABYLON {
  25870. /** @hidden */
  25871. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  25872. MAINUV1: boolean;
  25873. MAINUV2: boolean;
  25874. DIFFUSE: boolean;
  25875. DIFFUSEDIRECTUV: number;
  25876. AMBIENT: boolean;
  25877. AMBIENTDIRECTUV: number;
  25878. OPACITY: boolean;
  25879. OPACITYDIRECTUV: number;
  25880. OPACITYRGB: boolean;
  25881. REFLECTION: boolean;
  25882. EMISSIVE: boolean;
  25883. EMISSIVEDIRECTUV: number;
  25884. SPECULAR: boolean;
  25885. SPECULARDIRECTUV: number;
  25886. BUMP: boolean;
  25887. BUMPDIRECTUV: number;
  25888. PARALLAX: boolean;
  25889. PARALLAXOCCLUSION: boolean;
  25890. SPECULAROVERALPHA: boolean;
  25891. CLIPPLANE: boolean;
  25892. CLIPPLANE2: boolean;
  25893. CLIPPLANE3: boolean;
  25894. CLIPPLANE4: boolean;
  25895. ALPHATEST: boolean;
  25896. DEPTHPREPASS: boolean;
  25897. ALPHAFROMDIFFUSE: boolean;
  25898. POINTSIZE: boolean;
  25899. FOG: boolean;
  25900. SPECULARTERM: boolean;
  25901. DIFFUSEFRESNEL: boolean;
  25902. OPACITYFRESNEL: boolean;
  25903. REFLECTIONFRESNEL: boolean;
  25904. REFRACTIONFRESNEL: boolean;
  25905. EMISSIVEFRESNEL: boolean;
  25906. FRESNEL: boolean;
  25907. NORMAL: boolean;
  25908. UV1: boolean;
  25909. UV2: boolean;
  25910. VERTEXCOLOR: boolean;
  25911. VERTEXALPHA: boolean;
  25912. NUM_BONE_INFLUENCERS: number;
  25913. BonesPerMesh: number;
  25914. BONETEXTURE: boolean;
  25915. INSTANCES: boolean;
  25916. GLOSSINESS: boolean;
  25917. ROUGHNESS: boolean;
  25918. EMISSIVEASILLUMINATION: boolean;
  25919. LINKEMISSIVEWITHDIFFUSE: boolean;
  25920. REFLECTIONFRESNELFROMSPECULAR: boolean;
  25921. LIGHTMAP: boolean;
  25922. LIGHTMAPDIRECTUV: number;
  25923. OBJECTSPACE_NORMALMAP: boolean;
  25924. USELIGHTMAPASSHADOWMAP: boolean;
  25925. REFLECTIONMAP_3D: boolean;
  25926. REFLECTIONMAP_SPHERICAL: boolean;
  25927. REFLECTIONMAP_PLANAR: boolean;
  25928. REFLECTIONMAP_CUBIC: boolean;
  25929. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25930. REFLECTIONMAP_PROJECTION: boolean;
  25931. REFLECTIONMAP_SKYBOX: boolean;
  25932. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  25933. REFLECTIONMAP_EXPLICIT: boolean;
  25934. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25935. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25936. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25937. INVERTCUBICMAP: boolean;
  25938. LOGARITHMICDEPTH: boolean;
  25939. REFRACTION: boolean;
  25940. REFRACTIONMAP_3D: boolean;
  25941. REFLECTIONOVERALPHA: boolean;
  25942. TWOSIDEDLIGHTING: boolean;
  25943. SHADOWFLOAT: boolean;
  25944. MORPHTARGETS: boolean;
  25945. MORPHTARGETS_NORMAL: boolean;
  25946. MORPHTARGETS_TANGENT: boolean;
  25947. MORPHTARGETS_UV: boolean;
  25948. NUM_MORPH_INFLUENCERS: number;
  25949. NONUNIFORMSCALING: boolean;
  25950. PREMULTIPLYALPHA: boolean;
  25951. IMAGEPROCESSING: boolean;
  25952. VIGNETTE: boolean;
  25953. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25954. VIGNETTEBLENDMODEOPAQUE: boolean;
  25955. TONEMAPPING: boolean;
  25956. TONEMAPPING_ACES: boolean;
  25957. CONTRAST: boolean;
  25958. COLORCURVES: boolean;
  25959. COLORGRADING: boolean;
  25960. COLORGRADING3D: boolean;
  25961. SAMPLER3DGREENDEPTH: boolean;
  25962. SAMPLER3DBGRMAP: boolean;
  25963. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25964. MULTIVIEW: boolean;
  25965. /**
  25966. * If the reflection texture on this material is in linear color space
  25967. * @hidden
  25968. */
  25969. IS_REFLECTION_LINEAR: boolean;
  25970. /**
  25971. * If the refraction texture on this material is in linear color space
  25972. * @hidden
  25973. */
  25974. IS_REFRACTION_LINEAR: boolean;
  25975. EXPOSURE: boolean;
  25976. constructor();
  25977. setReflectionMode(modeToEnable: string): void;
  25978. }
  25979. /**
  25980. * This is the default material used in Babylon. It is the best trade off between quality
  25981. * and performances.
  25982. * @see http://doc.babylonjs.com/babylon101/materials
  25983. */
  25984. export class StandardMaterial extends PushMaterial {
  25985. private _diffuseTexture;
  25986. /**
  25987. * The basic texture of the material as viewed under a light.
  25988. */
  25989. diffuseTexture: Nullable<BaseTexture>;
  25990. private _ambientTexture;
  25991. /**
  25992. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  25993. */
  25994. ambientTexture: Nullable<BaseTexture>;
  25995. private _opacityTexture;
  25996. /**
  25997. * Define the transparency of the material from a texture.
  25998. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  25999. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26000. */
  26001. opacityTexture: Nullable<BaseTexture>;
  26002. private _reflectionTexture;
  26003. /**
  26004. * Define the texture used to display the reflection.
  26005. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26006. */
  26007. reflectionTexture: Nullable<BaseTexture>;
  26008. private _emissiveTexture;
  26009. /**
  26010. * Define texture of the material as if self lit.
  26011. * This will be mixed in the final result even in the absence of light.
  26012. */
  26013. emissiveTexture: Nullable<BaseTexture>;
  26014. private _specularTexture;
  26015. /**
  26016. * Define how the color and intensity of the highlight given by the light in the material.
  26017. */
  26018. specularTexture: Nullable<BaseTexture>;
  26019. private _bumpTexture;
  26020. /**
  26021. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26022. * 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.
  26023. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26024. */
  26025. bumpTexture: Nullable<BaseTexture>;
  26026. private _lightmapTexture;
  26027. /**
  26028. * Complex lighting can be computationally expensive to compute at runtime.
  26029. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26030. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26031. */
  26032. lightmapTexture: Nullable<BaseTexture>;
  26033. private _refractionTexture;
  26034. /**
  26035. * Define the texture used to display the refraction.
  26036. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26037. */
  26038. refractionTexture: Nullable<BaseTexture>;
  26039. /**
  26040. * The color of the material lit by the environmental background lighting.
  26041. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26042. */
  26043. ambientColor: Color3;
  26044. /**
  26045. * The basic color of the material as viewed under a light.
  26046. */
  26047. diffuseColor: Color3;
  26048. /**
  26049. * Define how the color and intensity of the highlight given by the light in the material.
  26050. */
  26051. specularColor: Color3;
  26052. /**
  26053. * Define the color of the material as if self lit.
  26054. * This will be mixed in the final result even in the absence of light.
  26055. */
  26056. emissiveColor: Color3;
  26057. /**
  26058. * Defines how sharp are the highlights in the material.
  26059. * The bigger the value the sharper giving a more glossy feeling to the result.
  26060. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26061. */
  26062. specularPower: number;
  26063. private _useAlphaFromDiffuseTexture;
  26064. /**
  26065. * Does the transparency come from the diffuse texture alpha channel.
  26066. */
  26067. useAlphaFromDiffuseTexture: boolean;
  26068. private _useEmissiveAsIllumination;
  26069. /**
  26070. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26071. */
  26072. useEmissiveAsIllumination: boolean;
  26073. private _linkEmissiveWithDiffuse;
  26074. /**
  26075. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26076. * the emissive level when the final color is close to one.
  26077. */
  26078. linkEmissiveWithDiffuse: boolean;
  26079. private _useSpecularOverAlpha;
  26080. /**
  26081. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26082. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26083. */
  26084. useSpecularOverAlpha: boolean;
  26085. private _useReflectionOverAlpha;
  26086. /**
  26087. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26088. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26089. */
  26090. useReflectionOverAlpha: boolean;
  26091. private _disableLighting;
  26092. /**
  26093. * Does lights from the scene impacts this material.
  26094. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26095. */
  26096. disableLighting: boolean;
  26097. private _useObjectSpaceNormalMap;
  26098. /**
  26099. * Allows using an object space normal map (instead of tangent space).
  26100. */
  26101. useObjectSpaceNormalMap: boolean;
  26102. private _useParallax;
  26103. /**
  26104. * Is parallax enabled or not.
  26105. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26106. */
  26107. useParallax: boolean;
  26108. private _useParallaxOcclusion;
  26109. /**
  26110. * Is parallax occlusion enabled or not.
  26111. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26112. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26113. */
  26114. useParallaxOcclusion: boolean;
  26115. /**
  26116. * 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.
  26117. */
  26118. parallaxScaleBias: number;
  26119. private _roughness;
  26120. /**
  26121. * Helps to define how blurry the reflections should appears in the material.
  26122. */
  26123. roughness: number;
  26124. /**
  26125. * In case of refraction, define the value of the index of refraction.
  26126. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26127. */
  26128. indexOfRefraction: number;
  26129. /**
  26130. * Invert the refraction texture alongside the y axis.
  26131. * It can be useful with procedural textures or probe for instance.
  26132. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26133. */
  26134. invertRefractionY: boolean;
  26135. /**
  26136. * Defines the alpha limits in alpha test mode.
  26137. */
  26138. alphaCutOff: number;
  26139. private _useLightmapAsShadowmap;
  26140. /**
  26141. * In case of light mapping, define whether the map contains light or shadow informations.
  26142. */
  26143. useLightmapAsShadowmap: boolean;
  26144. private _diffuseFresnelParameters;
  26145. /**
  26146. * Define the diffuse fresnel parameters of the material.
  26147. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26148. */
  26149. diffuseFresnelParameters: FresnelParameters;
  26150. private _opacityFresnelParameters;
  26151. /**
  26152. * Define the opacity fresnel parameters of the material.
  26153. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26154. */
  26155. opacityFresnelParameters: FresnelParameters;
  26156. private _reflectionFresnelParameters;
  26157. /**
  26158. * Define the reflection fresnel parameters of the material.
  26159. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26160. */
  26161. reflectionFresnelParameters: FresnelParameters;
  26162. private _refractionFresnelParameters;
  26163. /**
  26164. * Define the refraction fresnel parameters of the material.
  26165. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26166. */
  26167. refractionFresnelParameters: FresnelParameters;
  26168. private _emissiveFresnelParameters;
  26169. /**
  26170. * Define the emissive fresnel parameters of the material.
  26171. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26172. */
  26173. emissiveFresnelParameters: FresnelParameters;
  26174. private _useReflectionFresnelFromSpecular;
  26175. /**
  26176. * If true automatically deducts the fresnels values from the material specularity.
  26177. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26178. */
  26179. useReflectionFresnelFromSpecular: boolean;
  26180. private _useGlossinessFromSpecularMapAlpha;
  26181. /**
  26182. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26183. */
  26184. useGlossinessFromSpecularMapAlpha: boolean;
  26185. private _maxSimultaneousLights;
  26186. /**
  26187. * Defines the maximum number of lights that can be used in the material
  26188. */
  26189. maxSimultaneousLights: number;
  26190. private _invertNormalMapX;
  26191. /**
  26192. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26193. */
  26194. invertNormalMapX: boolean;
  26195. private _invertNormalMapY;
  26196. /**
  26197. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26198. */
  26199. invertNormalMapY: boolean;
  26200. private _twoSidedLighting;
  26201. /**
  26202. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26203. */
  26204. twoSidedLighting: boolean;
  26205. /**
  26206. * Default configuration related to image processing available in the standard Material.
  26207. */
  26208. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26209. /**
  26210. * Gets the image processing configuration used either in this material.
  26211. */
  26212. /**
  26213. * Sets the Default image processing configuration used either in the this material.
  26214. *
  26215. * If sets to null, the scene one is in use.
  26216. */
  26217. imageProcessingConfiguration: ImageProcessingConfiguration;
  26218. /**
  26219. * Keep track of the image processing observer to allow dispose and replace.
  26220. */
  26221. private _imageProcessingObserver;
  26222. /**
  26223. * Attaches a new image processing configuration to the Standard Material.
  26224. * @param configuration
  26225. */
  26226. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26227. /**
  26228. * Gets wether the color curves effect is enabled.
  26229. */
  26230. /**
  26231. * Sets wether the color curves effect is enabled.
  26232. */
  26233. cameraColorCurvesEnabled: boolean;
  26234. /**
  26235. * Gets wether the color grading effect is enabled.
  26236. */
  26237. /**
  26238. * Gets wether the color grading effect is enabled.
  26239. */
  26240. cameraColorGradingEnabled: boolean;
  26241. /**
  26242. * Gets wether tonemapping is enabled or not.
  26243. */
  26244. /**
  26245. * Sets wether tonemapping is enabled or not
  26246. */
  26247. cameraToneMappingEnabled: boolean;
  26248. /**
  26249. * The camera exposure used on this material.
  26250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26251. * This corresponds to a photographic exposure.
  26252. */
  26253. /**
  26254. * The camera exposure used on this material.
  26255. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26256. * This corresponds to a photographic exposure.
  26257. */
  26258. cameraExposure: number;
  26259. /**
  26260. * Gets The camera contrast used on this material.
  26261. */
  26262. /**
  26263. * Sets The camera contrast used on this material.
  26264. */
  26265. cameraContrast: number;
  26266. /**
  26267. * Gets the Color Grading 2D Lookup Texture.
  26268. */
  26269. /**
  26270. * Sets the Color Grading 2D Lookup Texture.
  26271. */
  26272. cameraColorGradingTexture: Nullable<BaseTexture>;
  26273. /**
  26274. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26275. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26276. * 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;
  26277. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26278. */
  26279. /**
  26280. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26281. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26282. * 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;
  26283. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26284. */
  26285. cameraColorCurves: Nullable<ColorCurves>;
  26286. /**
  26287. * Custom callback helping to override the default shader used in the material.
  26288. */
  26289. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26290. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26291. protected _worldViewProjectionMatrix: Matrix;
  26292. protected _globalAmbientColor: Color3;
  26293. protected _useLogarithmicDepth: boolean;
  26294. protected _rebuildInParallel: boolean;
  26295. /**
  26296. * Instantiates a new standard material.
  26297. * This is the default material used in Babylon. It is the best trade off between quality
  26298. * and performances.
  26299. * @see http://doc.babylonjs.com/babylon101/materials
  26300. * @param name Define the name of the material in the scene
  26301. * @param scene Define the scene the material belong to
  26302. */
  26303. constructor(name: string, scene: Scene);
  26304. /**
  26305. * Gets a boolean indicating that current material needs to register RTT
  26306. */
  26307. readonly hasRenderTargetTextures: boolean;
  26308. /**
  26309. * Gets the current class name of the material e.g. "StandardMaterial"
  26310. * Mainly use in serialization.
  26311. * @returns the class name
  26312. */
  26313. getClassName(): string;
  26314. /**
  26315. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26316. * You can try switching to logarithmic depth.
  26317. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26318. */
  26319. useLogarithmicDepth: boolean;
  26320. /**
  26321. * Specifies if the material will require alpha blending
  26322. * @returns a boolean specifying if alpha blending is needed
  26323. */
  26324. needAlphaBlending(): boolean;
  26325. /**
  26326. * Specifies if this material should be rendered in alpha test mode
  26327. * @returns a boolean specifying if an alpha test is needed.
  26328. */
  26329. needAlphaTesting(): boolean;
  26330. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26331. /**
  26332. * Get the texture used for alpha test purpose.
  26333. * @returns the diffuse texture in case of the standard material.
  26334. */
  26335. getAlphaTestTexture(): Nullable<BaseTexture>;
  26336. /**
  26337. * Get if the submesh is ready to be used and all its information available.
  26338. * Child classes can use it to update shaders
  26339. * @param mesh defines the mesh to check
  26340. * @param subMesh defines which submesh to check
  26341. * @param useInstances specifies that instances should be used
  26342. * @returns a boolean indicating that the submesh is ready or not
  26343. */
  26344. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26345. /**
  26346. * Builds the material UBO layouts.
  26347. * Used internally during the effect preparation.
  26348. */
  26349. buildUniformLayout(): void;
  26350. /**
  26351. * Unbinds the material from the mesh
  26352. */
  26353. unbind(): void;
  26354. /**
  26355. * Binds the submesh to this material by preparing the effect and shader to draw
  26356. * @param world defines the world transformation matrix
  26357. * @param mesh defines the mesh containing the submesh
  26358. * @param subMesh defines the submesh to bind the material to
  26359. */
  26360. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26361. /**
  26362. * Get the list of animatables in the material.
  26363. * @returns the list of animatables object used in the material
  26364. */
  26365. getAnimatables(): IAnimatable[];
  26366. /**
  26367. * Gets the active textures from the material
  26368. * @returns an array of textures
  26369. */
  26370. getActiveTextures(): BaseTexture[];
  26371. /**
  26372. * Specifies if the material uses a texture
  26373. * @param texture defines the texture to check against the material
  26374. * @returns a boolean specifying if the material uses the texture
  26375. */
  26376. hasTexture(texture: BaseTexture): boolean;
  26377. /**
  26378. * Disposes the material
  26379. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26380. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26381. */
  26382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26383. /**
  26384. * Makes a duplicate of the material, and gives it a new name
  26385. * @param name defines the new name for the duplicated material
  26386. * @returns the cloned material
  26387. */
  26388. clone(name: string): StandardMaterial;
  26389. /**
  26390. * Serializes this material in a JSON representation
  26391. * @returns the serialized material object
  26392. */
  26393. serialize(): any;
  26394. /**
  26395. * Creates a standard material from parsed material data
  26396. * @param source defines the JSON representation of the material
  26397. * @param scene defines the hosting scene
  26398. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26399. * @returns a new standard material
  26400. */
  26401. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26402. /**
  26403. * Are diffuse textures enabled in the application.
  26404. */
  26405. static DiffuseTextureEnabled: boolean;
  26406. /**
  26407. * Are ambient textures enabled in the application.
  26408. */
  26409. static AmbientTextureEnabled: boolean;
  26410. /**
  26411. * Are opacity textures enabled in the application.
  26412. */
  26413. static OpacityTextureEnabled: boolean;
  26414. /**
  26415. * Are reflection textures enabled in the application.
  26416. */
  26417. static ReflectionTextureEnabled: boolean;
  26418. /**
  26419. * Are emissive textures enabled in the application.
  26420. */
  26421. static EmissiveTextureEnabled: boolean;
  26422. /**
  26423. * Are specular textures enabled in the application.
  26424. */
  26425. static SpecularTextureEnabled: boolean;
  26426. /**
  26427. * Are bump textures enabled in the application.
  26428. */
  26429. static BumpTextureEnabled: boolean;
  26430. /**
  26431. * Are lightmap textures enabled in the application.
  26432. */
  26433. static LightmapTextureEnabled: boolean;
  26434. /**
  26435. * Are refraction textures enabled in the application.
  26436. */
  26437. static RefractionTextureEnabled: boolean;
  26438. /**
  26439. * Are color grading textures enabled in the application.
  26440. */
  26441. static ColorGradingTextureEnabled: boolean;
  26442. /**
  26443. * Are fresnels enabled in the application.
  26444. */
  26445. static FresnelEnabled: boolean;
  26446. }
  26447. }
  26448. declare module BABYLON {
  26449. /**
  26450. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26451. *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.
  26452. * The SPS is also a particle system. It provides some methods to manage the particles.
  26453. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26454. *
  26455. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26456. */
  26457. export class SolidParticleSystem implements IDisposable {
  26458. /**
  26459. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26460. * Example : var p = SPS.particles[i];
  26461. */
  26462. particles: SolidParticle[];
  26463. /**
  26464. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26465. */
  26466. nbParticles: number;
  26467. /**
  26468. * If the particles must ever face the camera (default false). Useful for planar particles.
  26469. */
  26470. billboard: boolean;
  26471. /**
  26472. * Recompute normals when adding a shape
  26473. */
  26474. recomputeNormals: boolean;
  26475. /**
  26476. * This a counter ofr your own usage. It's not set by any SPS functions.
  26477. */
  26478. counter: number;
  26479. /**
  26480. * The SPS name. This name is also given to the underlying mesh.
  26481. */
  26482. name: string;
  26483. /**
  26484. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26485. */
  26486. mesh: Mesh;
  26487. /**
  26488. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26489. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26490. */
  26491. vars: any;
  26492. /**
  26493. * This array is populated when the SPS is set as 'pickable'.
  26494. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26495. * Each element of this array is an object `{idx: int, faceId: int}`.
  26496. * `idx` is the picked particle index in the `SPS.particles` array
  26497. * `faceId` is the picked face index counted within this particle.
  26498. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26499. */
  26500. pickedParticles: {
  26501. idx: number;
  26502. faceId: number;
  26503. }[];
  26504. /**
  26505. * This array is populated when `enableDepthSort` is set to true.
  26506. * Each element of this array is an instance of the class DepthSortedParticle.
  26507. */
  26508. depthSortedParticles: DepthSortedParticle[];
  26509. /**
  26510. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26511. * @hidden
  26512. */
  26513. _bSphereOnly: boolean;
  26514. /**
  26515. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26516. * @hidden
  26517. */
  26518. _bSphereRadiusFactor: number;
  26519. private _scene;
  26520. private _positions;
  26521. private _indices;
  26522. private _normals;
  26523. private _colors;
  26524. private _uvs;
  26525. private _indices32;
  26526. private _positions32;
  26527. private _normals32;
  26528. private _fixedNormal32;
  26529. private _colors32;
  26530. private _uvs32;
  26531. private _index;
  26532. private _updatable;
  26533. private _pickable;
  26534. private _isVisibilityBoxLocked;
  26535. private _alwaysVisible;
  26536. private _depthSort;
  26537. private _expandable;
  26538. private _shapeCounter;
  26539. private _copy;
  26540. private _color;
  26541. private _computeParticleColor;
  26542. private _computeParticleTexture;
  26543. private _computeParticleRotation;
  26544. private _computeParticleVertex;
  26545. private _computeBoundingBox;
  26546. private _depthSortParticles;
  26547. private _camera;
  26548. private _mustUnrotateFixedNormals;
  26549. private _particlesIntersect;
  26550. private _needs32Bits;
  26551. private _isNotBuilt;
  26552. private _lastParticleId;
  26553. private _idxOfId;
  26554. private _multimaterialEnabled;
  26555. private _useModelMaterial;
  26556. private _indicesByMaterial;
  26557. private _materialIndexes;
  26558. private _depthSortFunction;
  26559. private _materialSortFunction;
  26560. private _materials;
  26561. private _multimaterial;
  26562. private _materialIndexesById;
  26563. private _defaultMaterial;
  26564. private _autoUpdateSubMeshes;
  26565. /**
  26566. * Creates a SPS (Solid Particle System) object.
  26567. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26568. * @param scene (Scene) is the scene in which the SPS is added.
  26569. * @param options defines the options of the sps e.g.
  26570. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26571. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26572. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26573. * * 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.
  26574. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26575. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26576. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26577. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26578. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26579. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26580. */
  26581. constructor(name: string, scene: Scene, options?: {
  26582. updatable?: boolean;
  26583. isPickable?: boolean;
  26584. enableDepthSort?: boolean;
  26585. particleIntersection?: boolean;
  26586. boundingSphereOnly?: boolean;
  26587. bSphereRadiusFactor?: number;
  26588. expandable?: boolean;
  26589. useModelMaterial?: boolean;
  26590. enableMultiMaterial?: boolean;
  26591. });
  26592. /**
  26593. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26594. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26595. * @returns the created mesh
  26596. */
  26597. buildMesh(): Mesh;
  26598. /**
  26599. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26600. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26601. * Thus the particles generated from `digest()` have their property `position` set yet.
  26602. * @param mesh ( Mesh ) is the mesh to be digested
  26603. * @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
  26604. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26605. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26606. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26607. * @returns the current SPS
  26608. */
  26609. digest(mesh: Mesh, options?: {
  26610. facetNb?: number;
  26611. number?: number;
  26612. delta?: number;
  26613. storage?: [];
  26614. }): SolidParticleSystem;
  26615. /**
  26616. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26617. * @hidden
  26618. */
  26619. private _unrotateFixedNormals;
  26620. /**
  26621. * Resets the temporary working copy particle
  26622. * @hidden
  26623. */
  26624. private _resetCopy;
  26625. /**
  26626. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26627. * @param p the current index in the positions array to be updated
  26628. * @param ind the current index in the indices array
  26629. * @param shape a Vector3 array, the shape geometry
  26630. * @param positions the positions array to be updated
  26631. * @param meshInd the shape indices array
  26632. * @param indices the indices array to be updated
  26633. * @param meshUV the shape uv array
  26634. * @param uvs the uv array to be updated
  26635. * @param meshCol the shape color array
  26636. * @param colors the color array to be updated
  26637. * @param meshNor the shape normals array
  26638. * @param normals the normals array to be updated
  26639. * @param idx the particle index
  26640. * @param idxInShape the particle index in its shape
  26641. * @param options the addShape() method passed options
  26642. * @model the particle model
  26643. * @hidden
  26644. */
  26645. private _meshBuilder;
  26646. /**
  26647. * Returns a shape Vector3 array from positions float array
  26648. * @param positions float array
  26649. * @returns a vector3 array
  26650. * @hidden
  26651. */
  26652. private _posToShape;
  26653. /**
  26654. * Returns a shapeUV array from a float uvs (array deep copy)
  26655. * @param uvs as a float array
  26656. * @returns a shapeUV array
  26657. * @hidden
  26658. */
  26659. private _uvsToShapeUV;
  26660. /**
  26661. * Adds a new particle object in the particles array
  26662. * @param idx particle index in particles array
  26663. * @param id particle id
  26664. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26665. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26666. * @param model particle ModelShape object
  26667. * @param shapeId model shape identifier
  26668. * @param idxInShape index of the particle in the current model
  26669. * @param bInfo model bounding info object
  26670. * @param storage target storage array, if any
  26671. * @hidden
  26672. */
  26673. private _addParticle;
  26674. /**
  26675. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26676. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26677. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26678. * @param nb (positive integer) the number of particles to be created from this model
  26679. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26680. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26681. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26682. * @returns the number of shapes in the system
  26683. */
  26684. addShape(mesh: Mesh, nb: number, options?: {
  26685. positionFunction?: any;
  26686. vertexFunction?: any;
  26687. storage?: [];
  26688. }): number;
  26689. /**
  26690. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26691. * @hidden
  26692. */
  26693. private _rebuildParticle;
  26694. /**
  26695. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26696. * @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.
  26697. * @returns the SPS.
  26698. */
  26699. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26700. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26701. * Returns an array with the removed particles.
  26702. * 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.
  26703. * The SPS can't be empty so at least one particle needs to remain in place.
  26704. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26705. * @param start index of the first particle to remove
  26706. * @param end index of the last particle to remove (included)
  26707. * @returns an array populated with the removed particles
  26708. */
  26709. removeParticles(start: number, end: number): SolidParticle[];
  26710. /**
  26711. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26712. * @param solidParticleArray an array populated with Solid Particles objects
  26713. * @returns the SPS
  26714. */
  26715. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26716. /**
  26717. * Creates a new particle and modifies the SPS mesh geometry :
  26718. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26719. * - calls _addParticle() to populate the particle array
  26720. * factorized code from addShape() and insertParticlesFromArray()
  26721. * @param idx particle index in the particles array
  26722. * @param i particle index in its shape
  26723. * @param modelShape particle ModelShape object
  26724. * @param shape shape vertex array
  26725. * @param meshInd shape indices array
  26726. * @param meshUV shape uv array
  26727. * @param meshCol shape color array
  26728. * @param meshNor shape normals array
  26729. * @param bbInfo shape bounding info
  26730. * @param storage target particle storage
  26731. * @options addShape() passed options
  26732. * @hidden
  26733. */
  26734. private _insertNewParticle;
  26735. /**
  26736. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26737. * This method calls `updateParticle()` for each particle of the SPS.
  26738. * For an animated SPS, it is usually called within the render loop.
  26739. * 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.
  26740. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26741. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26742. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26743. * @returns the SPS.
  26744. */
  26745. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26746. /**
  26747. * Disposes the SPS.
  26748. */
  26749. dispose(): void;
  26750. /**
  26751. * Returns a SolidParticle object from its identifier : particle.id
  26752. * @param id (integer) the particle Id
  26753. * @returns the searched particle or null if not found in the SPS.
  26754. */
  26755. getParticleById(id: number): Nullable<SolidParticle>;
  26756. /**
  26757. * Returns a new array populated with the particles having the passed shapeId.
  26758. * @param shapeId (integer) the shape identifier
  26759. * @returns a new solid particle array
  26760. */
  26761. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26762. /**
  26763. * Populates the passed array "ref" with the particles having the passed shapeId.
  26764. * @param shapeId the shape identifier
  26765. * @returns the SPS
  26766. * @param ref
  26767. */
  26768. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26769. /**
  26770. * Computes the required SubMeshes according the materials assigned to the particles.
  26771. * @returns the solid particle system.
  26772. * Does nothing if called before the SPS mesh is built.
  26773. */
  26774. computeSubMeshes(): SolidParticleSystem;
  26775. /**
  26776. * Sorts the solid particles by material when MultiMaterial is enabled.
  26777. * Updates the indices32 array.
  26778. * Updates the indicesByMaterial array.
  26779. * Updates the mesh indices array.
  26780. * @returns the SPS
  26781. * @hidden
  26782. */
  26783. private _sortParticlesByMaterial;
  26784. /**
  26785. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  26786. * @hidden
  26787. */
  26788. private _setMaterialIndexesById;
  26789. /**
  26790. * Returns an array with unique values of Materials from the passed array
  26791. * @param array the material array to be checked and filtered
  26792. * @hidden
  26793. */
  26794. private _filterUniqueMaterialId;
  26795. /**
  26796. * Sets a new Standard Material as _defaultMaterial if not already set.
  26797. * @hidden
  26798. */
  26799. private _setDefaultMaterial;
  26800. /**
  26801. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26802. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26803. * @returns the SPS.
  26804. */
  26805. refreshVisibleSize(): SolidParticleSystem;
  26806. /**
  26807. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26808. * @param size the size (float) of the visibility box
  26809. * note : this doesn't lock the SPS mesh bounding box.
  26810. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26811. */
  26812. setVisibilityBox(size: number): void;
  26813. /**
  26814. * Gets whether the SPS as always visible or not
  26815. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26816. */
  26817. /**
  26818. * Sets the SPS as always visible or not
  26819. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26820. */
  26821. isAlwaysVisible: boolean;
  26822. /**
  26823. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26824. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26825. */
  26826. /**
  26827. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26828. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26829. */
  26830. isVisibilityBoxLocked: boolean;
  26831. /**
  26832. * Tells to `setParticles()` to compute the particle rotations or not.
  26833. * Default value : true. The SPS is faster when it's set to false.
  26834. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26835. */
  26836. /**
  26837. * Gets if `setParticles()` computes the particle rotations or not.
  26838. * Default value : true. The SPS is faster when it's set to false.
  26839. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26840. */
  26841. computeParticleRotation: boolean;
  26842. /**
  26843. * Tells to `setParticles()` to compute the particle colors or not.
  26844. * Default value : true. The SPS is faster when it's set to false.
  26845. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26846. */
  26847. /**
  26848. * Gets if `setParticles()` computes the particle colors or not.
  26849. * Default value : true. The SPS is faster when it's set to false.
  26850. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26851. */
  26852. computeParticleColor: boolean;
  26853. /**
  26854. * Gets if `setParticles()` computes the particle textures or not.
  26855. * Default value : true. The SPS is faster when it's set to false.
  26856. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26857. */
  26858. computeParticleTexture: boolean;
  26859. /**
  26860. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26861. * Default value : false. The SPS is faster when it's set to false.
  26862. * Note : the particle custom vertex positions aren't stored values.
  26863. */
  26864. /**
  26865. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26866. * Default value : false. The SPS is faster when it's set to false.
  26867. * Note : the particle custom vertex positions aren't stored values.
  26868. */
  26869. computeParticleVertex: boolean;
  26870. /**
  26871. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26872. */
  26873. /**
  26874. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26875. */
  26876. computeBoundingBox: boolean;
  26877. /**
  26878. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26879. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26880. * Default : `true`
  26881. */
  26882. /**
  26883. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26884. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26885. * Default : `true`
  26886. */
  26887. depthSortParticles: boolean;
  26888. /**
  26889. * Gets if the SPS is created as expandable at construction time.
  26890. * Default : `false`
  26891. */
  26892. readonly expandable: boolean;
  26893. /**
  26894. * Gets if the SPS supports the Multi Materials
  26895. */
  26896. readonly multimaterialEnabled: boolean;
  26897. /**
  26898. * Gets if the SPS uses the model materials for its own multimaterial.
  26899. */
  26900. readonly useModelMaterial: boolean;
  26901. /**
  26902. * The SPS used material array.
  26903. */
  26904. readonly materials: Material[];
  26905. /**
  26906. * Sets the SPS MultiMaterial from the passed materials.
  26907. * Note : the passed array is internally copied and not used then by reference.
  26908. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  26909. */
  26910. setMultiMaterial(materials: Material[]): void;
  26911. /**
  26912. * The SPS computed multimaterial object
  26913. */
  26914. multimaterial: MultiMaterial;
  26915. /**
  26916. * If the subMeshes must be updated on the next call to setParticles()
  26917. */
  26918. autoUpdateSubMeshes: boolean;
  26919. /**
  26920. * This function does nothing. It may be overwritten to set all the particle first values.
  26921. * The SPS doesn't call this function, you may have to call it by your own.
  26922. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26923. */
  26924. initParticles(): void;
  26925. /**
  26926. * This function does nothing. It may be overwritten to recycle a particle.
  26927. * The SPS doesn't call this function, you may have to call it by your own.
  26928. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26929. * @param particle The particle to recycle
  26930. * @returns the recycled particle
  26931. */
  26932. recycleParticle(particle: SolidParticle): SolidParticle;
  26933. /**
  26934. * Updates a particle : this function should be overwritten by the user.
  26935. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26936. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26937. * @example : just set a particle position or velocity and recycle conditions
  26938. * @param particle The particle to update
  26939. * @returns the updated particle
  26940. */
  26941. updateParticle(particle: SolidParticle): SolidParticle;
  26942. /**
  26943. * Updates a vertex of a particle : it can be overwritten by the user.
  26944. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26945. * @param particle the current particle
  26946. * @param vertex the current index of the current particle
  26947. * @param pt the index of the current vertex in the particle shape
  26948. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26949. * @example : just set a vertex particle position
  26950. * @returns the updated vertex
  26951. */
  26952. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26953. /**
  26954. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26955. * This does nothing and may be overwritten by the user.
  26956. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26957. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26958. * @param update the boolean update value actually passed to setParticles()
  26959. */
  26960. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26961. /**
  26962. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26963. * This will be passed three parameters.
  26964. * This does nothing and may be overwritten by the user.
  26965. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26966. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26967. * @param update the boolean update value actually passed to setParticles()
  26968. */
  26969. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26970. }
  26971. }
  26972. declare module BABYLON {
  26973. /**
  26974. * Represents one particle of a solid particle system.
  26975. */
  26976. export class SolidParticle {
  26977. /**
  26978. * particle global index
  26979. */
  26980. idx: number;
  26981. /**
  26982. * particle identifier
  26983. */
  26984. id: number;
  26985. /**
  26986. * The color of the particle
  26987. */
  26988. color: Nullable<Color4>;
  26989. /**
  26990. * The world space position of the particle.
  26991. */
  26992. position: Vector3;
  26993. /**
  26994. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26995. */
  26996. rotation: Vector3;
  26997. /**
  26998. * The world space rotation quaternion of the particle.
  26999. */
  27000. rotationQuaternion: Nullable<Quaternion>;
  27001. /**
  27002. * The scaling of the particle.
  27003. */
  27004. scaling: Vector3;
  27005. /**
  27006. * The uvs of the particle.
  27007. */
  27008. uvs: Vector4;
  27009. /**
  27010. * The current speed of the particle.
  27011. */
  27012. velocity: Vector3;
  27013. /**
  27014. * The pivot point in the particle local space.
  27015. */
  27016. pivot: Vector3;
  27017. /**
  27018. * Must the particle be translated from its pivot point in its local space ?
  27019. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27020. * Default : false
  27021. */
  27022. translateFromPivot: boolean;
  27023. /**
  27024. * Is the particle active or not ?
  27025. */
  27026. alive: boolean;
  27027. /**
  27028. * Is the particle visible or not ?
  27029. */
  27030. isVisible: boolean;
  27031. /**
  27032. * Index of this particle in the global "positions" array (Internal use)
  27033. * @hidden
  27034. */
  27035. _pos: number;
  27036. /**
  27037. * @hidden Index of this particle in the global "indices" array (Internal use)
  27038. */
  27039. _ind: number;
  27040. /**
  27041. * @hidden ModelShape of this particle (Internal use)
  27042. */
  27043. _model: ModelShape;
  27044. /**
  27045. * ModelShape id of this particle
  27046. */
  27047. shapeId: number;
  27048. /**
  27049. * Index of the particle in its shape id
  27050. */
  27051. idxInShape: number;
  27052. /**
  27053. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27054. */
  27055. _modelBoundingInfo: BoundingInfo;
  27056. /**
  27057. * @hidden Particle BoundingInfo object (Internal use)
  27058. */
  27059. _boundingInfo: BoundingInfo;
  27060. /**
  27061. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27062. */
  27063. _sps: SolidParticleSystem;
  27064. /**
  27065. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27066. */
  27067. _stillInvisible: boolean;
  27068. /**
  27069. * @hidden Last computed particle rotation matrix
  27070. */
  27071. _rotationMatrix: number[];
  27072. /**
  27073. * Parent particle Id, if any.
  27074. * Default null.
  27075. */
  27076. parentId: Nullable<number>;
  27077. /**
  27078. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27079. */
  27080. materialIndex: Nullable<number>;
  27081. /**
  27082. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27083. * The possible values are :
  27084. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27085. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27086. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27087. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27088. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27089. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27090. * */
  27091. cullingStrategy: number;
  27092. /**
  27093. * @hidden Internal global position in the SPS.
  27094. */
  27095. _globalPosition: Vector3;
  27096. /**
  27097. * Creates a Solid Particle object.
  27098. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27099. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27100. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27101. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27102. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27103. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27104. * @param shapeId (integer) is the model shape identifier in the SPS.
  27105. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27106. * @param sps defines the sps it is associated to
  27107. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27108. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27109. */
  27110. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27111. /**
  27112. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27113. * @param target the particle target
  27114. * @returns the current particle
  27115. */
  27116. copyToRef(target: SolidParticle): SolidParticle;
  27117. /**
  27118. * Legacy support, changed scale to scaling
  27119. */
  27120. /**
  27121. * Legacy support, changed scale to scaling
  27122. */
  27123. scale: Vector3;
  27124. /**
  27125. * Legacy support, changed quaternion to rotationQuaternion
  27126. */
  27127. /**
  27128. * Legacy support, changed quaternion to rotationQuaternion
  27129. */
  27130. quaternion: Nullable<Quaternion>;
  27131. /**
  27132. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27133. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27134. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27135. * @returns true if it intersects
  27136. */
  27137. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27138. /**
  27139. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27140. * A particle is in the frustum if its bounding box intersects the frustum
  27141. * @param frustumPlanes defines the frustum to test
  27142. * @returns true if the particle is in the frustum planes
  27143. */
  27144. isInFrustum(frustumPlanes: Plane[]): boolean;
  27145. /**
  27146. * get the rotation matrix of the particle
  27147. * @hidden
  27148. */
  27149. getRotationMatrix(m: Matrix): void;
  27150. }
  27151. /**
  27152. * Represents the shape of the model used by one particle of a solid particle system.
  27153. * SPS internal tool, don't use it manually.
  27154. */
  27155. export class ModelShape {
  27156. /**
  27157. * The shape id
  27158. * @hidden
  27159. */
  27160. shapeID: number;
  27161. /**
  27162. * flat array of model positions (internal use)
  27163. * @hidden
  27164. */
  27165. _shape: Vector3[];
  27166. /**
  27167. * flat array of model UVs (internal use)
  27168. * @hidden
  27169. */
  27170. _shapeUV: number[];
  27171. /**
  27172. * color array of the model
  27173. * @hidden
  27174. */
  27175. _shapeColors: number[];
  27176. /**
  27177. * indices array of the model
  27178. * @hidden
  27179. */
  27180. _indices: number[];
  27181. /**
  27182. * normals array of the model
  27183. * @hidden
  27184. */
  27185. _normals: number[];
  27186. /**
  27187. * length of the shape in the model indices array (internal use)
  27188. * @hidden
  27189. */
  27190. _indicesLength: number;
  27191. /**
  27192. * Custom position function (internal use)
  27193. * @hidden
  27194. */
  27195. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27196. /**
  27197. * Custom vertex function (internal use)
  27198. * @hidden
  27199. */
  27200. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27201. /**
  27202. * Model material (internal use)
  27203. * @hidden
  27204. */
  27205. _material: Nullable<Material>;
  27206. /**
  27207. * 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.
  27208. * SPS internal tool, don't use it manually.
  27209. * @hidden
  27210. */
  27211. 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>);
  27212. }
  27213. /**
  27214. * Represents a Depth Sorted Particle in the solid particle system.
  27215. * @hidden
  27216. */
  27217. export class DepthSortedParticle {
  27218. /**
  27219. * Index of the particle in the "indices" array
  27220. */
  27221. ind: number;
  27222. /**
  27223. * Length of the particle shape in the "indices" array
  27224. */
  27225. indicesLength: number;
  27226. /**
  27227. * Squared distance from the particle to the camera
  27228. */
  27229. sqDistance: number;
  27230. /**
  27231. * Material index when used with MultiMaterials
  27232. */
  27233. materialIndex: number;
  27234. /**
  27235. * Creates a new sorted particle
  27236. * @param materialIndex
  27237. */
  27238. constructor(ind: number, indLength: number, materialIndex: number);
  27239. }
  27240. }
  27241. declare module BABYLON {
  27242. /**
  27243. * @hidden
  27244. */
  27245. export class _MeshCollisionData {
  27246. _checkCollisions: boolean;
  27247. _collisionMask: number;
  27248. _collisionGroup: number;
  27249. _collider: Nullable<Collider>;
  27250. _oldPositionForCollisions: Vector3;
  27251. _diffPositionForCollisions: Vector3;
  27252. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27253. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27254. }
  27255. }
  27256. declare module BABYLON {
  27257. /** @hidden */
  27258. class _FacetDataStorage {
  27259. facetPositions: Vector3[];
  27260. facetNormals: Vector3[];
  27261. facetPartitioning: number[][];
  27262. facetNb: number;
  27263. partitioningSubdivisions: number;
  27264. partitioningBBoxRatio: number;
  27265. facetDataEnabled: boolean;
  27266. facetParameters: any;
  27267. bbSize: Vector3;
  27268. subDiv: {
  27269. max: number;
  27270. X: number;
  27271. Y: number;
  27272. Z: number;
  27273. };
  27274. facetDepthSort: boolean;
  27275. facetDepthSortEnabled: boolean;
  27276. depthSortedIndices: IndicesArray;
  27277. depthSortedFacets: {
  27278. ind: number;
  27279. sqDistance: number;
  27280. }[];
  27281. facetDepthSortFunction: (f1: {
  27282. ind: number;
  27283. sqDistance: number;
  27284. }, f2: {
  27285. ind: number;
  27286. sqDistance: number;
  27287. }) => number;
  27288. facetDepthSortFrom: Vector3;
  27289. facetDepthSortOrigin: Vector3;
  27290. invertedMatrix: Matrix;
  27291. }
  27292. /**
  27293. * @hidden
  27294. **/
  27295. class _InternalAbstractMeshDataInfo {
  27296. _hasVertexAlpha: boolean;
  27297. _useVertexColors: boolean;
  27298. _numBoneInfluencers: number;
  27299. _applyFog: boolean;
  27300. _receiveShadows: boolean;
  27301. _facetData: _FacetDataStorage;
  27302. _visibility: number;
  27303. _skeleton: Nullable<Skeleton>;
  27304. _layerMask: number;
  27305. _computeBonesUsingShaders: boolean;
  27306. _isActive: boolean;
  27307. _onlyForInstances: boolean;
  27308. _isActiveIntermediate: boolean;
  27309. _onlyForInstancesIntermediate: boolean;
  27310. _actAsRegularMesh: boolean;
  27311. }
  27312. /**
  27313. * Class used to store all common mesh properties
  27314. */
  27315. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27316. /** No occlusion */
  27317. static OCCLUSION_TYPE_NONE: number;
  27318. /** Occlusion set to optimisitic */
  27319. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27320. /** Occlusion set to strict */
  27321. static OCCLUSION_TYPE_STRICT: number;
  27322. /** Use an accurante occlusion algorithm */
  27323. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27324. /** Use a conservative occlusion algorithm */
  27325. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27326. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27327. * Test order :
  27328. * Is the bounding sphere outside the frustum ?
  27329. * If not, are the bounding box vertices outside the frustum ?
  27330. * It not, then the cullable object is in the frustum.
  27331. */
  27332. static readonly CULLINGSTRATEGY_STANDARD: number;
  27333. /** Culling strategy : Bounding Sphere Only.
  27334. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27335. * It's also less accurate than the standard because some not visible objects can still be selected.
  27336. * Test : is the bounding sphere outside the frustum ?
  27337. * If not, then the cullable object is in the frustum.
  27338. */
  27339. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27340. /** Culling strategy : Optimistic Inclusion.
  27341. * This in an inclusion test first, then the standard exclusion test.
  27342. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27343. * 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.
  27344. * Anyway, it's as accurate as the standard strategy.
  27345. * Test :
  27346. * Is the cullable object bounding sphere center in the frustum ?
  27347. * If not, apply the default culling strategy.
  27348. */
  27349. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27350. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27351. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27352. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27353. * 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.
  27354. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27355. * Test :
  27356. * Is the cullable object bounding sphere center in the frustum ?
  27357. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27358. */
  27359. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27360. /**
  27361. * No billboard
  27362. */
  27363. static readonly BILLBOARDMODE_NONE: number;
  27364. /** Billboard on X axis */
  27365. static readonly BILLBOARDMODE_X: number;
  27366. /** Billboard on Y axis */
  27367. static readonly BILLBOARDMODE_Y: number;
  27368. /** Billboard on Z axis */
  27369. static readonly BILLBOARDMODE_Z: number;
  27370. /** Billboard on all axes */
  27371. static readonly BILLBOARDMODE_ALL: number;
  27372. /** Billboard on using position instead of orientation */
  27373. static readonly BILLBOARDMODE_USE_POSITION: number;
  27374. /** @hidden */
  27375. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27376. /**
  27377. * The culling strategy to use to check whether the mesh must be rendered or not.
  27378. * This value can be changed at any time and will be used on the next render mesh selection.
  27379. * The possible values are :
  27380. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27381. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27382. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27383. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27384. * Please read each static variable documentation to get details about the culling process.
  27385. * */
  27386. cullingStrategy: number;
  27387. /**
  27388. * Gets the number of facets in the mesh
  27389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27390. */
  27391. readonly facetNb: number;
  27392. /**
  27393. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27394. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27395. */
  27396. partitioningSubdivisions: number;
  27397. /**
  27398. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27399. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27400. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27401. */
  27402. partitioningBBoxRatio: number;
  27403. /**
  27404. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27405. * Works only for updatable meshes.
  27406. * Doesn't work with multi-materials
  27407. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27408. */
  27409. mustDepthSortFacets: boolean;
  27410. /**
  27411. * The location (Vector3) where the facet depth sort must be computed from.
  27412. * By default, the active camera position.
  27413. * Used only when facet depth sort is enabled
  27414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27415. */
  27416. facetDepthSortFrom: Vector3;
  27417. /**
  27418. * gets a boolean indicating if facetData is enabled
  27419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27420. */
  27421. readonly isFacetDataEnabled: boolean;
  27422. /** @hidden */
  27423. _updateNonUniformScalingState(value: boolean): boolean;
  27424. /**
  27425. * An event triggered when this mesh collides with another one
  27426. */
  27427. onCollideObservable: Observable<AbstractMesh>;
  27428. /** Set a function to call when this mesh collides with another one */
  27429. onCollide: () => void;
  27430. /**
  27431. * An event triggered when the collision's position changes
  27432. */
  27433. onCollisionPositionChangeObservable: Observable<Vector3>;
  27434. /** Set a function to call when the collision's position changes */
  27435. onCollisionPositionChange: () => void;
  27436. /**
  27437. * An event triggered when material is changed
  27438. */
  27439. onMaterialChangedObservable: Observable<AbstractMesh>;
  27440. /**
  27441. * Gets or sets the orientation for POV movement & rotation
  27442. */
  27443. definedFacingForward: boolean;
  27444. /** @hidden */
  27445. _occlusionQuery: Nullable<WebGLQuery>;
  27446. /** @hidden */
  27447. _renderingGroup: Nullable<RenderingGroup>;
  27448. /**
  27449. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27450. */
  27451. /**
  27452. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27453. */
  27454. visibility: number;
  27455. /** Gets or sets the alpha index used to sort transparent meshes
  27456. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27457. */
  27458. alphaIndex: number;
  27459. /**
  27460. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27461. */
  27462. isVisible: boolean;
  27463. /**
  27464. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27465. */
  27466. isPickable: boolean;
  27467. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27468. showSubMeshesBoundingBox: boolean;
  27469. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27470. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27471. */
  27472. isBlocker: boolean;
  27473. /**
  27474. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27475. */
  27476. enablePointerMoveEvents: boolean;
  27477. /**
  27478. * Specifies the rendering group id for this mesh (0 by default)
  27479. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27480. */
  27481. renderingGroupId: number;
  27482. private _material;
  27483. /** Gets or sets current material */
  27484. material: Nullable<Material>;
  27485. /**
  27486. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27487. * @see http://doc.babylonjs.com/babylon101/shadows
  27488. */
  27489. receiveShadows: boolean;
  27490. /** Defines color to use when rendering outline */
  27491. outlineColor: Color3;
  27492. /** Define width to use when rendering outline */
  27493. outlineWidth: number;
  27494. /** Defines color to use when rendering overlay */
  27495. overlayColor: Color3;
  27496. /** Defines alpha to use when rendering overlay */
  27497. overlayAlpha: number;
  27498. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27499. hasVertexAlpha: boolean;
  27500. /** 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) */
  27501. useVertexColors: boolean;
  27502. /**
  27503. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27504. */
  27505. computeBonesUsingShaders: boolean;
  27506. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27507. numBoneInfluencers: number;
  27508. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27509. applyFog: boolean;
  27510. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27511. useOctreeForRenderingSelection: boolean;
  27512. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27513. useOctreeForPicking: boolean;
  27514. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27515. useOctreeForCollisions: boolean;
  27516. /**
  27517. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27518. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27519. */
  27520. layerMask: number;
  27521. /**
  27522. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27523. */
  27524. alwaysSelectAsActiveMesh: boolean;
  27525. /**
  27526. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27527. */
  27528. doNotSyncBoundingInfo: boolean;
  27529. /**
  27530. * Gets or sets the current action manager
  27531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27532. */
  27533. actionManager: Nullable<AbstractActionManager>;
  27534. private _meshCollisionData;
  27535. /**
  27536. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27537. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27538. */
  27539. ellipsoid: Vector3;
  27540. /**
  27541. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27542. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27543. */
  27544. ellipsoidOffset: Vector3;
  27545. /**
  27546. * Gets or sets a collision mask used to mask collisions (default is -1).
  27547. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27548. */
  27549. collisionMask: number;
  27550. /**
  27551. * Gets or sets the current collision group mask (-1 by default).
  27552. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27553. */
  27554. collisionGroup: number;
  27555. /**
  27556. * Defines edge width used when edgesRenderer is enabled
  27557. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27558. */
  27559. edgesWidth: number;
  27560. /**
  27561. * Defines edge color used when edgesRenderer is enabled
  27562. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27563. */
  27564. edgesColor: Color4;
  27565. /** @hidden */
  27566. _edgesRenderer: Nullable<IEdgesRenderer>;
  27567. /** @hidden */
  27568. _masterMesh: Nullable<AbstractMesh>;
  27569. /** @hidden */
  27570. _boundingInfo: Nullable<BoundingInfo>;
  27571. /** @hidden */
  27572. _renderId: number;
  27573. /**
  27574. * Gets or sets the list of subMeshes
  27575. * @see http://doc.babylonjs.com/how_to/multi_materials
  27576. */
  27577. subMeshes: SubMesh[];
  27578. /** @hidden */
  27579. _intersectionsInProgress: AbstractMesh[];
  27580. /** @hidden */
  27581. _unIndexed: boolean;
  27582. /** @hidden */
  27583. _lightSources: Light[];
  27584. /** Gets the list of lights affecting that mesh */
  27585. readonly lightSources: Light[];
  27586. /** @hidden */
  27587. readonly _positions: Nullable<Vector3[]>;
  27588. /** @hidden */
  27589. _waitingData: {
  27590. lods: Nullable<any>;
  27591. actions: Nullable<any>;
  27592. freezeWorldMatrix: Nullable<boolean>;
  27593. };
  27594. /** @hidden */
  27595. _bonesTransformMatrices: Nullable<Float32Array>;
  27596. /** @hidden */
  27597. _transformMatrixTexture: Nullable<RawTexture>;
  27598. /**
  27599. * Gets or sets a skeleton to apply skining transformations
  27600. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27601. */
  27602. skeleton: Nullable<Skeleton>;
  27603. /**
  27604. * An event triggered when the mesh is rebuilt.
  27605. */
  27606. onRebuildObservable: Observable<AbstractMesh>;
  27607. /**
  27608. * Creates a new AbstractMesh
  27609. * @param name defines the name of the mesh
  27610. * @param scene defines the hosting scene
  27611. */
  27612. constructor(name: string, scene?: Nullable<Scene>);
  27613. /**
  27614. * Returns the string "AbstractMesh"
  27615. * @returns "AbstractMesh"
  27616. */
  27617. getClassName(): string;
  27618. /**
  27619. * Gets a string representation of the current mesh
  27620. * @param fullDetails defines a boolean indicating if full details must be included
  27621. * @returns a string representation of the current mesh
  27622. */
  27623. toString(fullDetails?: boolean): string;
  27624. /**
  27625. * @hidden
  27626. */
  27627. protected _getEffectiveParent(): Nullable<Node>;
  27628. /** @hidden */
  27629. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27630. /** @hidden */
  27631. _rebuild(): void;
  27632. /** @hidden */
  27633. _resyncLightSources(): void;
  27634. /** @hidden */
  27635. _resyncLightSource(light: Light): void;
  27636. /** @hidden */
  27637. _unBindEffect(): void;
  27638. /** @hidden */
  27639. _removeLightSource(light: Light, dispose: boolean): void;
  27640. private _markSubMeshesAsDirty;
  27641. /** @hidden */
  27642. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27643. /** @hidden */
  27644. _markSubMeshesAsAttributesDirty(): void;
  27645. /** @hidden */
  27646. _markSubMeshesAsMiscDirty(): void;
  27647. /**
  27648. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27649. */
  27650. scaling: Vector3;
  27651. /**
  27652. * Returns true if the mesh is blocked. Implemented by child classes
  27653. */
  27654. readonly isBlocked: boolean;
  27655. /**
  27656. * Returns the mesh itself by default. Implemented by child classes
  27657. * @param camera defines the camera to use to pick the right LOD level
  27658. * @returns the currentAbstractMesh
  27659. */
  27660. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27661. /**
  27662. * Returns 0 by default. Implemented by child classes
  27663. * @returns an integer
  27664. */
  27665. getTotalVertices(): number;
  27666. /**
  27667. * Returns a positive integer : the total number of indices in this mesh geometry.
  27668. * @returns the numner of indices or zero if the mesh has no geometry.
  27669. */
  27670. getTotalIndices(): number;
  27671. /**
  27672. * Returns null by default. Implemented by child classes
  27673. * @returns null
  27674. */
  27675. getIndices(): Nullable<IndicesArray>;
  27676. /**
  27677. * Returns the array of the requested vertex data kind. Implemented by child classes
  27678. * @param kind defines the vertex data kind to use
  27679. * @returns null
  27680. */
  27681. getVerticesData(kind: string): Nullable<FloatArray>;
  27682. /**
  27683. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27684. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27685. * Note that a new underlying VertexBuffer object is created each call.
  27686. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27687. * @param kind defines vertex data kind:
  27688. * * VertexBuffer.PositionKind
  27689. * * VertexBuffer.UVKind
  27690. * * VertexBuffer.UV2Kind
  27691. * * VertexBuffer.UV3Kind
  27692. * * VertexBuffer.UV4Kind
  27693. * * VertexBuffer.UV5Kind
  27694. * * VertexBuffer.UV6Kind
  27695. * * VertexBuffer.ColorKind
  27696. * * VertexBuffer.MatricesIndicesKind
  27697. * * VertexBuffer.MatricesIndicesExtraKind
  27698. * * VertexBuffer.MatricesWeightsKind
  27699. * * VertexBuffer.MatricesWeightsExtraKind
  27700. * @param data defines the data source
  27701. * @param updatable defines if the data must be flagged as updatable (or static)
  27702. * @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
  27703. * @returns the current mesh
  27704. */
  27705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27706. /**
  27707. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27708. * If the mesh has no geometry, it is simply returned as it is.
  27709. * @param kind defines vertex data kind:
  27710. * * VertexBuffer.PositionKind
  27711. * * VertexBuffer.UVKind
  27712. * * VertexBuffer.UV2Kind
  27713. * * VertexBuffer.UV3Kind
  27714. * * VertexBuffer.UV4Kind
  27715. * * VertexBuffer.UV5Kind
  27716. * * VertexBuffer.UV6Kind
  27717. * * VertexBuffer.ColorKind
  27718. * * VertexBuffer.MatricesIndicesKind
  27719. * * VertexBuffer.MatricesIndicesExtraKind
  27720. * * VertexBuffer.MatricesWeightsKind
  27721. * * VertexBuffer.MatricesWeightsExtraKind
  27722. * @param data defines the data source
  27723. * @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
  27724. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27725. * @returns the current mesh
  27726. */
  27727. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27728. /**
  27729. * Sets the mesh indices,
  27730. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27731. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27732. * @param totalVertices Defines the total number of vertices
  27733. * @returns the current mesh
  27734. */
  27735. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27736. /**
  27737. * Gets a boolean indicating if specific vertex data is present
  27738. * @param kind defines the vertex data kind to use
  27739. * @returns true is data kind is present
  27740. */
  27741. isVerticesDataPresent(kind: string): boolean;
  27742. /**
  27743. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27744. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27745. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27746. * @returns a BoundingInfo
  27747. */
  27748. getBoundingInfo(): BoundingInfo;
  27749. /**
  27750. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27751. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27752. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27753. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27754. * @returns the current mesh
  27755. */
  27756. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27757. /**
  27758. * Overwrite the current bounding info
  27759. * @param boundingInfo defines the new bounding info
  27760. * @returns the current mesh
  27761. */
  27762. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27763. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27764. readonly useBones: boolean;
  27765. /** @hidden */
  27766. _preActivate(): void;
  27767. /** @hidden */
  27768. _preActivateForIntermediateRendering(renderId: number): void;
  27769. /** @hidden */
  27770. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27771. /** @hidden */
  27772. _postActivate(): void;
  27773. /** @hidden */
  27774. _freeze(): void;
  27775. /** @hidden */
  27776. _unFreeze(): void;
  27777. /**
  27778. * Gets the current world matrix
  27779. * @returns a Matrix
  27780. */
  27781. getWorldMatrix(): Matrix;
  27782. /** @hidden */
  27783. _getWorldMatrixDeterminant(): number;
  27784. /**
  27785. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27786. */
  27787. readonly isAnInstance: boolean;
  27788. /**
  27789. * Gets a boolean indicating if this mesh has instances
  27790. */
  27791. readonly hasInstances: boolean;
  27792. /**
  27793. * Perform relative position change from the point of view of behind the front of the mesh.
  27794. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27795. * Supports definition of mesh facing forward or backward
  27796. * @param amountRight defines the distance on the right axis
  27797. * @param amountUp defines the distance on the up axis
  27798. * @param amountForward defines the distance on the forward axis
  27799. * @returns the current mesh
  27800. */
  27801. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27802. /**
  27803. * Calculate relative position change from the point of view of behind the front of the mesh.
  27804. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27805. * Supports definition of mesh facing forward or backward
  27806. * @param amountRight defines the distance on the right axis
  27807. * @param amountUp defines the distance on the up axis
  27808. * @param amountForward defines the distance on the forward axis
  27809. * @returns the new displacement vector
  27810. */
  27811. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27812. /**
  27813. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27814. * Supports definition of mesh facing forward or backward
  27815. * @param flipBack defines the flip
  27816. * @param twirlClockwise defines the twirl
  27817. * @param tiltRight defines the tilt
  27818. * @returns the current mesh
  27819. */
  27820. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27821. /**
  27822. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27823. * Supports definition of mesh facing forward or backward.
  27824. * @param flipBack defines the flip
  27825. * @param twirlClockwise defines the twirl
  27826. * @param tiltRight defines the tilt
  27827. * @returns the new rotation vector
  27828. */
  27829. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27830. /**
  27831. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27832. * This means the mesh underlying bounding box and sphere are recomputed.
  27833. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27834. * @returns the current mesh
  27835. */
  27836. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27837. /** @hidden */
  27838. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27839. /** @hidden */
  27840. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27841. /** @hidden */
  27842. _updateBoundingInfo(): AbstractMesh;
  27843. /** @hidden */
  27844. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27845. /** @hidden */
  27846. protected _afterComputeWorldMatrix(): void;
  27847. /** @hidden */
  27848. readonly _effectiveMesh: AbstractMesh;
  27849. /**
  27850. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27851. * A mesh is in the frustum if its bounding box intersects the frustum
  27852. * @param frustumPlanes defines the frustum to test
  27853. * @returns true if the mesh is in the frustum planes
  27854. */
  27855. isInFrustum(frustumPlanes: Plane[]): boolean;
  27856. /**
  27857. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27858. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27859. * @param frustumPlanes defines the frustum to test
  27860. * @returns true if the mesh is completely in the frustum planes
  27861. */
  27862. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27863. /**
  27864. * True if the mesh intersects another mesh or a SolidParticle object
  27865. * @param mesh defines a target mesh or SolidParticle to test
  27866. * @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)
  27867. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27868. * @returns true if there is an intersection
  27869. */
  27870. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27871. /**
  27872. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27873. * @param point defines the point to test
  27874. * @returns true if there is an intersection
  27875. */
  27876. intersectsPoint(point: Vector3): boolean;
  27877. /**
  27878. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27880. */
  27881. checkCollisions: boolean;
  27882. /**
  27883. * Gets Collider object used to compute collisions (not physics)
  27884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27885. */
  27886. readonly collider: Nullable<Collider>;
  27887. /**
  27888. * Move the mesh using collision engine
  27889. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27890. * @param displacement defines the requested displacement vector
  27891. * @returns the current mesh
  27892. */
  27893. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27894. private _onCollisionPositionChange;
  27895. /** @hidden */
  27896. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27897. /** @hidden */
  27898. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27899. /** @hidden */
  27900. _checkCollision(collider: Collider): AbstractMesh;
  27901. /** @hidden */
  27902. _generatePointsArray(): boolean;
  27903. /**
  27904. * Checks if the passed Ray intersects with the mesh
  27905. * @param ray defines the ray to use
  27906. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27907. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27908. * @returns the picking info
  27909. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27910. */
  27911. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27912. /**
  27913. * Clones the current mesh
  27914. * @param name defines the mesh name
  27915. * @param newParent defines the new mesh parent
  27916. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27917. * @returns the new mesh
  27918. */
  27919. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27920. /**
  27921. * Disposes all the submeshes of the current meshnp
  27922. * @returns the current mesh
  27923. */
  27924. releaseSubMeshes(): AbstractMesh;
  27925. /**
  27926. * Releases resources associated with this abstract mesh.
  27927. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27928. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27929. */
  27930. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27931. /**
  27932. * Adds the passed mesh as a child to the current mesh
  27933. * @param mesh defines the child mesh
  27934. * @returns the current mesh
  27935. */
  27936. addChild(mesh: AbstractMesh): AbstractMesh;
  27937. /**
  27938. * Removes the passed mesh from the current mesh children list
  27939. * @param mesh defines the child mesh
  27940. * @returns the current mesh
  27941. */
  27942. removeChild(mesh: AbstractMesh): AbstractMesh;
  27943. /** @hidden */
  27944. private _initFacetData;
  27945. /**
  27946. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27947. * This method can be called within the render loop.
  27948. * 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
  27949. * @returns the current mesh
  27950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27951. */
  27952. updateFacetData(): AbstractMesh;
  27953. /**
  27954. * Returns the facetLocalNormals array.
  27955. * The normals are expressed in the mesh local spac
  27956. * @returns an array of Vector3
  27957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27958. */
  27959. getFacetLocalNormals(): Vector3[];
  27960. /**
  27961. * Returns the facetLocalPositions array.
  27962. * The facet positions are expressed in the mesh local space
  27963. * @returns an array of Vector3
  27964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27965. */
  27966. getFacetLocalPositions(): Vector3[];
  27967. /**
  27968. * Returns the facetLocalPartioning array
  27969. * @returns an array of array of numbers
  27970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27971. */
  27972. getFacetLocalPartitioning(): number[][];
  27973. /**
  27974. * Returns the i-th facet position in the world system.
  27975. * This method allocates a new Vector3 per call
  27976. * @param i defines the facet index
  27977. * @returns a new Vector3
  27978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27979. */
  27980. getFacetPosition(i: number): Vector3;
  27981. /**
  27982. * Sets the reference Vector3 with the i-th facet position in the world system
  27983. * @param i defines the facet index
  27984. * @param ref defines the target vector
  27985. * @returns the current mesh
  27986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27987. */
  27988. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27989. /**
  27990. * Returns the i-th facet normal in the world system.
  27991. * This method allocates a new Vector3 per call
  27992. * @param i defines the facet index
  27993. * @returns a new Vector3
  27994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27995. */
  27996. getFacetNormal(i: number): Vector3;
  27997. /**
  27998. * Sets the reference Vector3 with the i-th facet normal in the world system
  27999. * @param i defines the facet index
  28000. * @param ref defines the target vector
  28001. * @returns the current mesh
  28002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28003. */
  28004. getFacetNormalToRef(i: number, ref: Vector3): this;
  28005. /**
  28006. * 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)
  28007. * @param x defines x coordinate
  28008. * @param y defines y coordinate
  28009. * @param z defines z coordinate
  28010. * @returns the array of facet indexes
  28011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28012. */
  28013. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28014. /**
  28015. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28016. * @param projected sets as the (x,y,z) world projection on the facet
  28017. * @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
  28018. * @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
  28019. * @param x defines x coordinate
  28020. * @param y defines y coordinate
  28021. * @param z defines z coordinate
  28022. * @returns the face index if found (or null instead)
  28023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28024. */
  28025. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28026. /**
  28027. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28028. * @param projected sets as the (x,y,z) local projection on the facet
  28029. * @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
  28030. * @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
  28031. * @param x defines x coordinate
  28032. * @param y defines y coordinate
  28033. * @param z defines z coordinate
  28034. * @returns the face index if found (or null instead)
  28035. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28036. */
  28037. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28038. /**
  28039. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28040. * @returns the parameters
  28041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28042. */
  28043. getFacetDataParameters(): any;
  28044. /**
  28045. * Disables the feature FacetData and frees the related memory
  28046. * @returns the current mesh
  28047. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28048. */
  28049. disableFacetData(): AbstractMesh;
  28050. /**
  28051. * Updates the AbstractMesh indices array
  28052. * @param indices defines the data source
  28053. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28054. * @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)
  28055. * @returns the current mesh
  28056. */
  28057. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28058. /**
  28059. * Creates new normals data for the mesh
  28060. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28061. * @returns the current mesh
  28062. */
  28063. createNormals(updatable: boolean): AbstractMesh;
  28064. /**
  28065. * Align the mesh with a normal
  28066. * @param normal defines the normal to use
  28067. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28068. * @returns the current mesh
  28069. */
  28070. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28071. /** @hidden */
  28072. _checkOcclusionQuery(): boolean;
  28073. /**
  28074. * Disables the mesh edge rendering mode
  28075. * @returns the currentAbstractMesh
  28076. */
  28077. disableEdgesRendering(): AbstractMesh;
  28078. /**
  28079. * Enables the edge rendering mode on the mesh.
  28080. * This mode makes the mesh edges visible
  28081. * @param epsilon defines the maximal distance between two angles to detect a face
  28082. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28083. * @returns the currentAbstractMesh
  28084. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28085. */
  28086. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28087. }
  28088. }
  28089. declare module BABYLON {
  28090. /**
  28091. * Interface used to define ActionEvent
  28092. */
  28093. export interface IActionEvent {
  28094. /** The mesh or sprite that triggered the action */
  28095. source: any;
  28096. /** The X mouse cursor position at the time of the event */
  28097. pointerX: number;
  28098. /** The Y mouse cursor position at the time of the event */
  28099. pointerY: number;
  28100. /** The mesh that is currently pointed at (can be null) */
  28101. meshUnderPointer: Nullable<AbstractMesh>;
  28102. /** the original (browser) event that triggered the ActionEvent */
  28103. sourceEvent?: any;
  28104. /** additional data for the event */
  28105. additionalData?: any;
  28106. }
  28107. /**
  28108. * ActionEvent is the event being sent when an action is triggered.
  28109. */
  28110. export class ActionEvent implements IActionEvent {
  28111. /** The mesh or sprite that triggered the action */
  28112. source: any;
  28113. /** The X mouse cursor position at the time of the event */
  28114. pointerX: number;
  28115. /** The Y mouse cursor position at the time of the event */
  28116. pointerY: number;
  28117. /** The mesh that is currently pointed at (can be null) */
  28118. meshUnderPointer: Nullable<AbstractMesh>;
  28119. /** the original (browser) event that triggered the ActionEvent */
  28120. sourceEvent?: any;
  28121. /** additional data for the event */
  28122. additionalData?: any;
  28123. /**
  28124. * Creates a new ActionEvent
  28125. * @param source The mesh or sprite that triggered the action
  28126. * @param pointerX The X mouse cursor position at the time of the event
  28127. * @param pointerY The Y mouse cursor position at the time of the event
  28128. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28129. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28130. * @param additionalData additional data for the event
  28131. */
  28132. constructor(
  28133. /** The mesh or sprite that triggered the action */
  28134. source: any,
  28135. /** The X mouse cursor position at the time of the event */
  28136. pointerX: number,
  28137. /** The Y mouse cursor position at the time of the event */
  28138. pointerY: number,
  28139. /** The mesh that is currently pointed at (can be null) */
  28140. meshUnderPointer: Nullable<AbstractMesh>,
  28141. /** the original (browser) event that triggered the ActionEvent */
  28142. sourceEvent?: any,
  28143. /** additional data for the event */
  28144. additionalData?: any);
  28145. /**
  28146. * Helper function to auto-create an ActionEvent from a source mesh.
  28147. * @param source The source mesh that triggered the event
  28148. * @param evt The original (browser) event
  28149. * @param additionalData additional data for the event
  28150. * @returns the new ActionEvent
  28151. */
  28152. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28153. /**
  28154. * Helper function to auto-create an ActionEvent from a source sprite
  28155. * @param source The source sprite that triggered the event
  28156. * @param scene Scene associated with the sprite
  28157. * @param evt The original (browser) event
  28158. * @param additionalData additional data for the event
  28159. * @returns the new ActionEvent
  28160. */
  28161. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28162. /**
  28163. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28164. * @param scene the scene where the event occurred
  28165. * @param evt The original (browser) event
  28166. * @returns the new ActionEvent
  28167. */
  28168. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28169. /**
  28170. * Helper function to auto-create an ActionEvent from a primitive
  28171. * @param prim defines the target primitive
  28172. * @param pointerPos defines the pointer position
  28173. * @param evt The original (browser) event
  28174. * @param additionalData additional data for the event
  28175. * @returns the new ActionEvent
  28176. */
  28177. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28178. }
  28179. }
  28180. declare module BABYLON {
  28181. /**
  28182. * Abstract class used to decouple action Manager from scene and meshes.
  28183. * Do not instantiate.
  28184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28185. */
  28186. export abstract class AbstractActionManager implements IDisposable {
  28187. /** Gets the list of active triggers */
  28188. static Triggers: {
  28189. [key: string]: number;
  28190. };
  28191. /** Gets the cursor to use when hovering items */
  28192. hoverCursor: string;
  28193. /** Gets the list of actions */
  28194. actions: IAction[];
  28195. /**
  28196. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28197. */
  28198. isRecursive: boolean;
  28199. /**
  28200. * Releases all associated resources
  28201. */
  28202. abstract dispose(): void;
  28203. /**
  28204. * Does this action manager has pointer triggers
  28205. */
  28206. abstract readonly hasPointerTriggers: boolean;
  28207. /**
  28208. * Does this action manager has pick triggers
  28209. */
  28210. abstract readonly hasPickTriggers: boolean;
  28211. /**
  28212. * Process a specific trigger
  28213. * @param trigger defines the trigger to process
  28214. * @param evt defines the event details to be processed
  28215. */
  28216. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28217. /**
  28218. * Does this action manager handles actions of any of the given triggers
  28219. * @param triggers defines the triggers to be tested
  28220. * @return a boolean indicating whether one (or more) of the triggers is handled
  28221. */
  28222. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28223. /**
  28224. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28225. * speed.
  28226. * @param triggerA defines the trigger to be tested
  28227. * @param triggerB defines the trigger to be tested
  28228. * @return a boolean indicating whether one (or more) of the triggers is handled
  28229. */
  28230. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28231. /**
  28232. * Does this action manager handles actions of a given trigger
  28233. * @param trigger defines the trigger to be tested
  28234. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28235. * @return whether the trigger is handled
  28236. */
  28237. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28238. /**
  28239. * Serialize this manager to a JSON object
  28240. * @param name defines the property name to store this manager
  28241. * @returns a JSON representation of this manager
  28242. */
  28243. abstract serialize(name: string): any;
  28244. /**
  28245. * Registers an action to this action manager
  28246. * @param action defines the action to be registered
  28247. * @return the action amended (prepared) after registration
  28248. */
  28249. abstract registerAction(action: IAction): Nullable<IAction>;
  28250. /**
  28251. * Unregisters an action to this action manager
  28252. * @param action defines the action to be unregistered
  28253. * @return a boolean indicating whether the action has been unregistered
  28254. */
  28255. abstract unregisterAction(action: IAction): Boolean;
  28256. /**
  28257. * Does exist one action manager with at least one trigger
  28258. **/
  28259. static readonly HasTriggers: boolean;
  28260. /**
  28261. * Does exist one action manager with at least one pick trigger
  28262. **/
  28263. static readonly HasPickTriggers: boolean;
  28264. /**
  28265. * Does exist one action manager that handles actions of a given trigger
  28266. * @param trigger defines the trigger to be tested
  28267. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28268. **/
  28269. static HasSpecificTrigger(trigger: number): boolean;
  28270. }
  28271. }
  28272. declare module BABYLON {
  28273. /**
  28274. * Defines how a node can be built from a string name.
  28275. */
  28276. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28277. /**
  28278. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28279. */
  28280. export class Node implements IBehaviorAware<Node> {
  28281. /** @hidden */
  28282. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28283. private static _NodeConstructors;
  28284. /**
  28285. * Add a new node constructor
  28286. * @param type defines the type name of the node to construct
  28287. * @param constructorFunc defines the constructor function
  28288. */
  28289. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28290. /**
  28291. * Returns a node constructor based on type name
  28292. * @param type defines the type name
  28293. * @param name defines the new node name
  28294. * @param scene defines the hosting scene
  28295. * @param options defines optional options to transmit to constructors
  28296. * @returns the new constructor or null
  28297. */
  28298. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28299. /**
  28300. * Gets or sets the name of the node
  28301. */
  28302. name: string;
  28303. /**
  28304. * Gets or sets the id of the node
  28305. */
  28306. id: string;
  28307. /**
  28308. * Gets or sets the unique id of the node
  28309. */
  28310. uniqueId: number;
  28311. /**
  28312. * Gets or sets a string used to store user defined state for the node
  28313. */
  28314. state: string;
  28315. /**
  28316. * Gets or sets an object used to store user defined information for the node
  28317. */
  28318. metadata: any;
  28319. /**
  28320. * For internal use only. Please do not use.
  28321. */
  28322. reservedDataStore: any;
  28323. /**
  28324. * List of inspectable custom properties (used by the Inspector)
  28325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28326. */
  28327. inspectableCustomProperties: IInspectable[];
  28328. private _doNotSerialize;
  28329. /**
  28330. * Gets or sets a boolean used to define if the node must be serialized
  28331. */
  28332. doNotSerialize: boolean;
  28333. /** @hidden */
  28334. _isDisposed: boolean;
  28335. /**
  28336. * Gets a list of Animations associated with the node
  28337. */
  28338. animations: Animation[];
  28339. protected _ranges: {
  28340. [name: string]: Nullable<AnimationRange>;
  28341. };
  28342. /**
  28343. * Callback raised when the node is ready to be used
  28344. */
  28345. onReady: Nullable<(node: Node) => void>;
  28346. private _isEnabled;
  28347. private _isParentEnabled;
  28348. private _isReady;
  28349. /** @hidden */
  28350. _currentRenderId: number;
  28351. private _parentUpdateId;
  28352. /** @hidden */
  28353. _childUpdateId: number;
  28354. /** @hidden */
  28355. _waitingParentId: Nullable<string>;
  28356. /** @hidden */
  28357. _scene: Scene;
  28358. /** @hidden */
  28359. _cache: any;
  28360. private _parentNode;
  28361. private _children;
  28362. /** @hidden */
  28363. _worldMatrix: Matrix;
  28364. /** @hidden */
  28365. _worldMatrixDeterminant: number;
  28366. /** @hidden */
  28367. _worldMatrixDeterminantIsDirty: boolean;
  28368. /** @hidden */
  28369. private _sceneRootNodesIndex;
  28370. /**
  28371. * Gets a boolean indicating if the node has been disposed
  28372. * @returns true if the node was disposed
  28373. */
  28374. isDisposed(): boolean;
  28375. /**
  28376. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28377. * @see https://doc.babylonjs.com/how_to/parenting
  28378. */
  28379. parent: Nullable<Node>;
  28380. /** @hidden */
  28381. _addToSceneRootNodes(): void;
  28382. /** @hidden */
  28383. _removeFromSceneRootNodes(): void;
  28384. private _animationPropertiesOverride;
  28385. /**
  28386. * Gets or sets the animation properties override
  28387. */
  28388. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28389. /**
  28390. * Gets a string idenfifying the name of the class
  28391. * @returns "Node" string
  28392. */
  28393. getClassName(): string;
  28394. /** @hidden */
  28395. readonly _isNode: boolean;
  28396. /**
  28397. * An event triggered when the mesh is disposed
  28398. */
  28399. onDisposeObservable: Observable<Node>;
  28400. private _onDisposeObserver;
  28401. /**
  28402. * Sets a callback that will be raised when the node will be disposed
  28403. */
  28404. onDispose: () => void;
  28405. /**
  28406. * Creates a new Node
  28407. * @param name the name and id to be given to this node
  28408. * @param scene the scene this node will be added to
  28409. */
  28410. constructor(name: string, scene?: Nullable<Scene>);
  28411. /**
  28412. * Gets the scene of the node
  28413. * @returns a scene
  28414. */
  28415. getScene(): Scene;
  28416. /**
  28417. * Gets the engine of the node
  28418. * @returns a Engine
  28419. */
  28420. getEngine(): Engine;
  28421. private _behaviors;
  28422. /**
  28423. * Attach a behavior to the node
  28424. * @see http://doc.babylonjs.com/features/behaviour
  28425. * @param behavior defines the behavior to attach
  28426. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28427. * @returns the current Node
  28428. */
  28429. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28430. /**
  28431. * Remove an attached behavior
  28432. * @see http://doc.babylonjs.com/features/behaviour
  28433. * @param behavior defines the behavior to attach
  28434. * @returns the current Node
  28435. */
  28436. removeBehavior(behavior: Behavior<Node>): Node;
  28437. /**
  28438. * Gets the list of attached behaviors
  28439. * @see http://doc.babylonjs.com/features/behaviour
  28440. */
  28441. readonly behaviors: Behavior<Node>[];
  28442. /**
  28443. * Gets an attached behavior by name
  28444. * @param name defines the name of the behavior to look for
  28445. * @see http://doc.babylonjs.com/features/behaviour
  28446. * @returns null if behavior was not found else the requested behavior
  28447. */
  28448. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28449. /**
  28450. * Returns the latest update of the World matrix
  28451. * @returns a Matrix
  28452. */
  28453. getWorldMatrix(): Matrix;
  28454. /** @hidden */
  28455. _getWorldMatrixDeterminant(): number;
  28456. /**
  28457. * Returns directly the latest state of the mesh World matrix.
  28458. * A Matrix is returned.
  28459. */
  28460. readonly worldMatrixFromCache: Matrix;
  28461. /** @hidden */
  28462. _initCache(): void;
  28463. /** @hidden */
  28464. updateCache(force?: boolean): void;
  28465. /** @hidden */
  28466. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28467. /** @hidden */
  28468. _updateCache(ignoreParentClass?: boolean): void;
  28469. /** @hidden */
  28470. _isSynchronized(): boolean;
  28471. /** @hidden */
  28472. _markSyncedWithParent(): void;
  28473. /** @hidden */
  28474. isSynchronizedWithParent(): boolean;
  28475. /** @hidden */
  28476. isSynchronized(): boolean;
  28477. /**
  28478. * Is this node ready to be used/rendered
  28479. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28480. * @return true if the node is ready
  28481. */
  28482. isReady(completeCheck?: boolean): boolean;
  28483. /**
  28484. * Is this node enabled?
  28485. * 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
  28486. * @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
  28487. * @return whether this node (and its parent) is enabled
  28488. */
  28489. isEnabled(checkAncestors?: boolean): boolean;
  28490. /** @hidden */
  28491. protected _syncParentEnabledState(): void;
  28492. /**
  28493. * Set the enabled state of this node
  28494. * @param value defines the new enabled state
  28495. */
  28496. setEnabled(value: boolean): void;
  28497. /**
  28498. * Is this node a descendant of the given node?
  28499. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28500. * @param ancestor defines the parent node to inspect
  28501. * @returns a boolean indicating if this node is a descendant of the given node
  28502. */
  28503. isDescendantOf(ancestor: Node): boolean;
  28504. /** @hidden */
  28505. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28506. /**
  28507. * Will return all nodes that have this node as ascendant
  28508. * @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
  28509. * @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
  28510. * @return all children nodes of all types
  28511. */
  28512. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28513. /**
  28514. * Get all child-meshes of this node
  28515. * @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)
  28516. * @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
  28517. * @returns an array of AbstractMesh
  28518. */
  28519. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28520. /**
  28521. * Get all direct children of this node
  28522. * @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
  28523. * @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)
  28524. * @returns an array of Node
  28525. */
  28526. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28527. /** @hidden */
  28528. _setReady(state: boolean): void;
  28529. /**
  28530. * Get an animation by name
  28531. * @param name defines the name of the animation to look for
  28532. * @returns null if not found else the requested animation
  28533. */
  28534. getAnimationByName(name: string): Nullable<Animation>;
  28535. /**
  28536. * Creates an animation range for this node
  28537. * @param name defines the name of the range
  28538. * @param from defines the starting key
  28539. * @param to defines the end key
  28540. */
  28541. createAnimationRange(name: string, from: number, to: number): void;
  28542. /**
  28543. * Delete a specific animation range
  28544. * @param name defines the name of the range to delete
  28545. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28546. */
  28547. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28548. /**
  28549. * Get an animation range by name
  28550. * @param name defines the name of the animation range to look for
  28551. * @returns null if not found else the requested animation range
  28552. */
  28553. getAnimationRange(name: string): Nullable<AnimationRange>;
  28554. /**
  28555. * Gets the list of all animation ranges defined on this node
  28556. * @returns an array
  28557. */
  28558. getAnimationRanges(): Nullable<AnimationRange>[];
  28559. /**
  28560. * Will start the animation sequence
  28561. * @param name defines the range frames for animation sequence
  28562. * @param loop defines if the animation should loop (false by default)
  28563. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28564. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28565. * @returns the object created for this animation. If range does not exist, it will return null
  28566. */
  28567. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28568. /**
  28569. * Serialize animation ranges into a JSON compatible object
  28570. * @returns serialization object
  28571. */
  28572. serializeAnimationRanges(): any;
  28573. /**
  28574. * Computes the world matrix of the node
  28575. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28576. * @returns the world matrix
  28577. */
  28578. computeWorldMatrix(force?: boolean): Matrix;
  28579. /**
  28580. * Releases resources associated with this node.
  28581. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28582. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28583. */
  28584. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28585. /**
  28586. * Parse animation range data from a serialization object and store them into a given node
  28587. * @param node defines where to store the animation ranges
  28588. * @param parsedNode defines the serialization object to read data from
  28589. * @param scene defines the hosting scene
  28590. */
  28591. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28592. /**
  28593. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28594. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28595. * @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
  28596. * @returns the new bounding vectors
  28597. */
  28598. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28599. min: Vector3;
  28600. max: Vector3;
  28601. };
  28602. }
  28603. }
  28604. declare module BABYLON {
  28605. /**
  28606. * @hidden
  28607. */
  28608. export class _IAnimationState {
  28609. key: number;
  28610. repeatCount: number;
  28611. workValue?: any;
  28612. loopMode?: number;
  28613. offsetValue?: any;
  28614. highLimitValue?: any;
  28615. }
  28616. /**
  28617. * Class used to store any kind of animation
  28618. */
  28619. export class Animation {
  28620. /**Name of the animation */
  28621. name: string;
  28622. /**Property to animate */
  28623. targetProperty: string;
  28624. /**The frames per second of the animation */
  28625. framePerSecond: number;
  28626. /**The data type of the animation */
  28627. dataType: number;
  28628. /**The loop mode of the animation */
  28629. loopMode?: number | undefined;
  28630. /**Specifies if blending should be enabled */
  28631. enableBlending?: boolean | undefined;
  28632. /**
  28633. * Use matrix interpolation instead of using direct key value when animating matrices
  28634. */
  28635. static AllowMatricesInterpolation: boolean;
  28636. /**
  28637. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28638. */
  28639. static AllowMatrixDecomposeForInterpolation: boolean;
  28640. /**
  28641. * Stores the key frames of the animation
  28642. */
  28643. private _keys;
  28644. /**
  28645. * Stores the easing function of the animation
  28646. */
  28647. private _easingFunction;
  28648. /**
  28649. * @hidden Internal use only
  28650. */
  28651. _runtimeAnimations: RuntimeAnimation[];
  28652. /**
  28653. * The set of event that will be linked to this animation
  28654. */
  28655. private _events;
  28656. /**
  28657. * Stores an array of target property paths
  28658. */
  28659. targetPropertyPath: string[];
  28660. /**
  28661. * Stores the blending speed of the animation
  28662. */
  28663. blendingSpeed: number;
  28664. /**
  28665. * Stores the animation ranges for the animation
  28666. */
  28667. private _ranges;
  28668. /**
  28669. * @hidden Internal use
  28670. */
  28671. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28672. /**
  28673. * Sets up an animation
  28674. * @param property The property to animate
  28675. * @param animationType The animation type to apply
  28676. * @param framePerSecond The frames per second of the animation
  28677. * @param easingFunction The easing function used in the animation
  28678. * @returns The created animation
  28679. */
  28680. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28681. /**
  28682. * Create and start an animation on a node
  28683. * @param name defines the name of the global animation that will be run on all nodes
  28684. * @param node defines the root node where the animation will take place
  28685. * @param targetProperty defines property to animate
  28686. * @param framePerSecond defines the number of frame per second yo use
  28687. * @param totalFrame defines the number of frames in total
  28688. * @param from defines the initial value
  28689. * @param to defines the final value
  28690. * @param loopMode defines which loop mode you want to use (off by default)
  28691. * @param easingFunction defines the easing function to use (linear by default)
  28692. * @param onAnimationEnd defines the callback to call when animation end
  28693. * @returns the animatable created for this animation
  28694. */
  28695. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28696. /**
  28697. * Create and start an animation on a node and its descendants
  28698. * @param name defines the name of the global animation that will be run on all nodes
  28699. * @param node defines the root node where the animation will take place
  28700. * @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
  28701. * @param targetProperty defines property to animate
  28702. * @param framePerSecond defines the number of frame per second to use
  28703. * @param totalFrame defines the number of frames in total
  28704. * @param from defines the initial value
  28705. * @param to defines the final value
  28706. * @param loopMode defines which loop mode you want to use (off by default)
  28707. * @param easingFunction defines the easing function to use (linear by default)
  28708. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28709. * @returns the list of animatables created for all nodes
  28710. * @example https://www.babylonjs-playground.com/#MH0VLI
  28711. */
  28712. 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[]>;
  28713. /**
  28714. * Creates a new animation, merges it with the existing animations and starts it
  28715. * @param name Name of the animation
  28716. * @param node Node which contains the scene that begins the animations
  28717. * @param targetProperty Specifies which property to animate
  28718. * @param framePerSecond The frames per second of the animation
  28719. * @param totalFrame The total number of frames
  28720. * @param from The frame at the beginning of the animation
  28721. * @param to The frame at the end of the animation
  28722. * @param loopMode Specifies the loop mode of the animation
  28723. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28724. * @param onAnimationEnd Callback to run once the animation is complete
  28725. * @returns Nullable animation
  28726. */
  28727. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28728. /**
  28729. * Transition property of an host to the target Value
  28730. * @param property The property to transition
  28731. * @param targetValue The target Value of the property
  28732. * @param host The object where the property to animate belongs
  28733. * @param scene Scene used to run the animation
  28734. * @param frameRate Framerate (in frame/s) to use
  28735. * @param transition The transition type we want to use
  28736. * @param duration The duration of the animation, in milliseconds
  28737. * @param onAnimationEnd Callback trigger at the end of the animation
  28738. * @returns Nullable animation
  28739. */
  28740. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28741. /**
  28742. * Return the array of runtime animations currently using this animation
  28743. */
  28744. readonly runtimeAnimations: RuntimeAnimation[];
  28745. /**
  28746. * Specifies if any of the runtime animations are currently running
  28747. */
  28748. readonly hasRunningRuntimeAnimations: boolean;
  28749. /**
  28750. * Initializes the animation
  28751. * @param name Name of the animation
  28752. * @param targetProperty Property to animate
  28753. * @param framePerSecond The frames per second of the animation
  28754. * @param dataType The data type of the animation
  28755. * @param loopMode The loop mode of the animation
  28756. * @param enableBlending Specifies if blending should be enabled
  28757. */
  28758. constructor(
  28759. /**Name of the animation */
  28760. name: string,
  28761. /**Property to animate */
  28762. targetProperty: string,
  28763. /**The frames per second of the animation */
  28764. framePerSecond: number,
  28765. /**The data type of the animation */
  28766. dataType: number,
  28767. /**The loop mode of the animation */
  28768. loopMode?: number | undefined,
  28769. /**Specifies if blending should be enabled */
  28770. enableBlending?: boolean | undefined);
  28771. /**
  28772. * Converts the animation to a string
  28773. * @param fullDetails support for multiple levels of logging within scene loading
  28774. * @returns String form of the animation
  28775. */
  28776. toString(fullDetails?: boolean): string;
  28777. /**
  28778. * Add an event to this animation
  28779. * @param event Event to add
  28780. */
  28781. addEvent(event: AnimationEvent): void;
  28782. /**
  28783. * Remove all events found at the given frame
  28784. * @param frame The frame to remove events from
  28785. */
  28786. removeEvents(frame: number): void;
  28787. /**
  28788. * Retrieves all the events from the animation
  28789. * @returns Events from the animation
  28790. */
  28791. getEvents(): AnimationEvent[];
  28792. /**
  28793. * Creates an animation range
  28794. * @param name Name of the animation range
  28795. * @param from Starting frame of the animation range
  28796. * @param to Ending frame of the animation
  28797. */
  28798. createRange(name: string, from: number, to: number): void;
  28799. /**
  28800. * Deletes an animation range by name
  28801. * @param name Name of the animation range to delete
  28802. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28803. */
  28804. deleteRange(name: string, deleteFrames?: boolean): void;
  28805. /**
  28806. * Gets the animation range by name, or null if not defined
  28807. * @param name Name of the animation range
  28808. * @returns Nullable animation range
  28809. */
  28810. getRange(name: string): Nullable<AnimationRange>;
  28811. /**
  28812. * Gets the key frames from the animation
  28813. * @returns The key frames of the animation
  28814. */
  28815. getKeys(): Array<IAnimationKey>;
  28816. /**
  28817. * Gets the highest frame rate of the animation
  28818. * @returns Highest frame rate of the animation
  28819. */
  28820. getHighestFrame(): number;
  28821. /**
  28822. * Gets the easing function of the animation
  28823. * @returns Easing function of the animation
  28824. */
  28825. getEasingFunction(): IEasingFunction;
  28826. /**
  28827. * Sets the easing function of the animation
  28828. * @param easingFunction A custom mathematical formula for animation
  28829. */
  28830. setEasingFunction(easingFunction: EasingFunction): void;
  28831. /**
  28832. * Interpolates a scalar linearly
  28833. * @param startValue Start value of the animation curve
  28834. * @param endValue End value of the animation curve
  28835. * @param gradient Scalar amount to interpolate
  28836. * @returns Interpolated scalar value
  28837. */
  28838. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28839. /**
  28840. * Interpolates a scalar cubically
  28841. * @param startValue Start value of the animation curve
  28842. * @param outTangent End tangent of the animation
  28843. * @param endValue End value of the animation curve
  28844. * @param inTangent Start tangent of the animation curve
  28845. * @param gradient Scalar amount to interpolate
  28846. * @returns Interpolated scalar value
  28847. */
  28848. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28849. /**
  28850. * Interpolates a quaternion using a spherical linear interpolation
  28851. * @param startValue Start value of the animation curve
  28852. * @param endValue End value of the animation curve
  28853. * @param gradient Scalar amount to interpolate
  28854. * @returns Interpolated quaternion value
  28855. */
  28856. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28857. /**
  28858. * Interpolates a quaternion cubically
  28859. * @param startValue Start value of the animation curve
  28860. * @param outTangent End tangent of the animation curve
  28861. * @param endValue End value of the animation curve
  28862. * @param inTangent Start tangent of the animation curve
  28863. * @param gradient Scalar amount to interpolate
  28864. * @returns Interpolated quaternion value
  28865. */
  28866. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28867. /**
  28868. * Interpolates a Vector3 linearl
  28869. * @param startValue Start value of the animation curve
  28870. * @param endValue End value of the animation curve
  28871. * @param gradient Scalar amount to interpolate
  28872. * @returns Interpolated scalar value
  28873. */
  28874. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28875. /**
  28876. * Interpolates a Vector3 cubically
  28877. * @param startValue Start value of the animation curve
  28878. * @param outTangent End tangent of the animation
  28879. * @param endValue End value of the animation curve
  28880. * @param inTangent Start tangent of the animation curve
  28881. * @param gradient Scalar amount to interpolate
  28882. * @returns InterpolatedVector3 value
  28883. */
  28884. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28885. /**
  28886. * Interpolates a Vector2 linearly
  28887. * @param startValue Start value of the animation curve
  28888. * @param endValue End value of the animation curve
  28889. * @param gradient Scalar amount to interpolate
  28890. * @returns Interpolated Vector2 value
  28891. */
  28892. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28893. /**
  28894. * Interpolates a Vector2 cubically
  28895. * @param startValue Start value of the animation curve
  28896. * @param outTangent End tangent of the animation
  28897. * @param endValue End value of the animation curve
  28898. * @param inTangent Start tangent of the animation curve
  28899. * @param gradient Scalar amount to interpolate
  28900. * @returns Interpolated Vector2 value
  28901. */
  28902. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28903. /**
  28904. * Interpolates a size linearly
  28905. * @param startValue Start value of the animation curve
  28906. * @param endValue End value of the animation curve
  28907. * @param gradient Scalar amount to interpolate
  28908. * @returns Interpolated Size value
  28909. */
  28910. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28911. /**
  28912. * Interpolates a Color3 linearly
  28913. * @param startValue Start value of the animation curve
  28914. * @param endValue End value of the animation curve
  28915. * @param gradient Scalar amount to interpolate
  28916. * @returns Interpolated Color3 value
  28917. */
  28918. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28919. /**
  28920. * Interpolates a Color4 linearly
  28921. * @param startValue Start value of the animation curve
  28922. * @param endValue End value of the animation curve
  28923. * @param gradient Scalar amount to interpolate
  28924. * @returns Interpolated Color3 value
  28925. */
  28926. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28927. /**
  28928. * @hidden Internal use only
  28929. */
  28930. _getKeyValue(value: any): any;
  28931. /**
  28932. * @hidden Internal use only
  28933. */
  28934. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28935. /**
  28936. * Defines the function to use to interpolate matrices
  28937. * @param startValue defines the start matrix
  28938. * @param endValue defines the end matrix
  28939. * @param gradient defines the gradient between both matrices
  28940. * @param result defines an optional target matrix where to store the interpolation
  28941. * @returns the interpolated matrix
  28942. */
  28943. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28944. /**
  28945. * Makes a copy of the animation
  28946. * @returns Cloned animation
  28947. */
  28948. clone(): Animation;
  28949. /**
  28950. * Sets the key frames of the animation
  28951. * @param values The animation key frames to set
  28952. */
  28953. setKeys(values: Array<IAnimationKey>): void;
  28954. /**
  28955. * Serializes the animation to an object
  28956. * @returns Serialized object
  28957. */
  28958. serialize(): any;
  28959. /**
  28960. * Float animation type
  28961. */
  28962. static readonly ANIMATIONTYPE_FLOAT: number;
  28963. /**
  28964. * Vector3 animation type
  28965. */
  28966. static readonly ANIMATIONTYPE_VECTOR3: number;
  28967. /**
  28968. * Quaternion animation type
  28969. */
  28970. static readonly ANIMATIONTYPE_QUATERNION: number;
  28971. /**
  28972. * Matrix animation type
  28973. */
  28974. static readonly ANIMATIONTYPE_MATRIX: number;
  28975. /**
  28976. * Color3 animation type
  28977. */
  28978. static readonly ANIMATIONTYPE_COLOR3: number;
  28979. /**
  28980. * Color3 animation type
  28981. */
  28982. static readonly ANIMATIONTYPE_COLOR4: number;
  28983. /**
  28984. * Vector2 animation type
  28985. */
  28986. static readonly ANIMATIONTYPE_VECTOR2: number;
  28987. /**
  28988. * Size animation type
  28989. */
  28990. static readonly ANIMATIONTYPE_SIZE: number;
  28991. /**
  28992. * Relative Loop Mode
  28993. */
  28994. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28995. /**
  28996. * Cycle Loop Mode
  28997. */
  28998. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28999. /**
  29000. * Constant Loop Mode
  29001. */
  29002. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29003. /** @hidden */
  29004. static _UniversalLerp(left: any, right: any, amount: number): any;
  29005. /**
  29006. * Parses an animation object and creates an animation
  29007. * @param parsedAnimation Parsed animation object
  29008. * @returns Animation object
  29009. */
  29010. static Parse(parsedAnimation: any): Animation;
  29011. /**
  29012. * Appends the serialized animations from the source animations
  29013. * @param source Source containing the animations
  29014. * @param destination Target to store the animations
  29015. */
  29016. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29017. }
  29018. }
  29019. declare module BABYLON {
  29020. /**
  29021. * Interface containing an array of animations
  29022. */
  29023. export interface IAnimatable {
  29024. /**
  29025. * Array of animations
  29026. */
  29027. animations: Nullable<Array<Animation>>;
  29028. }
  29029. }
  29030. declare module BABYLON {
  29031. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29032. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29033. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29034. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29035. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29036. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29037. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29038. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29039. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29040. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29041. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29042. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29043. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29044. /**
  29045. * Decorator used to define property that can be serialized as reference to a camera
  29046. * @param sourceName defines the name of the property to decorate
  29047. */
  29048. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29049. /**
  29050. * Class used to help serialization objects
  29051. */
  29052. export class SerializationHelper {
  29053. /** @hidden */
  29054. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29055. /** @hidden */
  29056. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29057. /** @hidden */
  29058. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29059. /** @hidden */
  29060. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29061. /**
  29062. * Appends the serialized animations from the source animations
  29063. * @param source Source containing the animations
  29064. * @param destination Target to store the animations
  29065. */
  29066. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29067. /**
  29068. * Static function used to serialized a specific entity
  29069. * @param entity defines the entity to serialize
  29070. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29071. * @returns a JSON compatible object representing the serialization of the entity
  29072. */
  29073. static Serialize<T>(entity: T, serializationObject?: any): any;
  29074. /**
  29075. * Creates a new entity from a serialization data object
  29076. * @param creationFunction defines a function used to instanciated the new entity
  29077. * @param source defines the source serialization data
  29078. * @param scene defines the hosting scene
  29079. * @param rootUrl defines the root url for resources
  29080. * @returns a new entity
  29081. */
  29082. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29083. /**
  29084. * Clones an object
  29085. * @param creationFunction defines the function used to instanciate the new object
  29086. * @param source defines the source object
  29087. * @returns the cloned object
  29088. */
  29089. static Clone<T>(creationFunction: () => T, source: T): T;
  29090. /**
  29091. * Instanciates a new object based on a source one (some data will be shared between both object)
  29092. * @param creationFunction defines the function used to instanciate the new object
  29093. * @param source defines the source object
  29094. * @returns the new object
  29095. */
  29096. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29097. }
  29098. }
  29099. declare module BABYLON {
  29100. /**
  29101. * Class used to manipulate GUIDs
  29102. */
  29103. export class GUID {
  29104. /**
  29105. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29106. * Be aware Math.random() could cause collisions, but:
  29107. * "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"
  29108. * @returns a pseudo random id
  29109. */
  29110. static RandomId(): string;
  29111. }
  29112. }
  29113. declare module BABYLON {
  29114. /**
  29115. * Base class of all the textures in babylon.
  29116. * It groups all the common properties the materials, post process, lights... might need
  29117. * in order to make a correct use of the texture.
  29118. */
  29119. export class BaseTexture implements IAnimatable {
  29120. /**
  29121. * Default anisotropic filtering level for the application.
  29122. * It is set to 4 as a good tradeoff between perf and quality.
  29123. */
  29124. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29125. /**
  29126. * Gets or sets the unique id of the texture
  29127. */
  29128. uniqueId: number;
  29129. /**
  29130. * Define the name of the texture.
  29131. */
  29132. name: string;
  29133. /**
  29134. * Gets or sets an object used to store user defined information.
  29135. */
  29136. metadata: any;
  29137. /**
  29138. * For internal use only. Please do not use.
  29139. */
  29140. reservedDataStore: any;
  29141. private _hasAlpha;
  29142. /**
  29143. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29144. */
  29145. hasAlpha: boolean;
  29146. /**
  29147. * Defines if the alpha value should be determined via the rgb values.
  29148. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29149. */
  29150. getAlphaFromRGB: boolean;
  29151. /**
  29152. * Intensity or strength of the texture.
  29153. * It is commonly used by materials to fine tune the intensity of the texture
  29154. */
  29155. level: number;
  29156. /**
  29157. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29158. * This is part of the texture as textures usually maps to one uv set.
  29159. */
  29160. coordinatesIndex: number;
  29161. private _coordinatesMode;
  29162. /**
  29163. * How a texture is mapped.
  29164. *
  29165. * | Value | Type | Description |
  29166. * | ----- | ----------------------------------- | ----------- |
  29167. * | 0 | EXPLICIT_MODE | |
  29168. * | 1 | SPHERICAL_MODE | |
  29169. * | 2 | PLANAR_MODE | |
  29170. * | 3 | CUBIC_MODE | |
  29171. * | 4 | PROJECTION_MODE | |
  29172. * | 5 | SKYBOX_MODE | |
  29173. * | 6 | INVCUBIC_MODE | |
  29174. * | 7 | EQUIRECTANGULAR_MODE | |
  29175. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29176. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29177. */
  29178. coordinatesMode: number;
  29179. /**
  29180. * | Value | Type | Description |
  29181. * | ----- | ------------------ | ----------- |
  29182. * | 0 | CLAMP_ADDRESSMODE | |
  29183. * | 1 | WRAP_ADDRESSMODE | |
  29184. * | 2 | MIRROR_ADDRESSMODE | |
  29185. */
  29186. wrapU: number;
  29187. /**
  29188. * | Value | Type | Description |
  29189. * | ----- | ------------------ | ----------- |
  29190. * | 0 | CLAMP_ADDRESSMODE | |
  29191. * | 1 | WRAP_ADDRESSMODE | |
  29192. * | 2 | MIRROR_ADDRESSMODE | |
  29193. */
  29194. wrapV: number;
  29195. /**
  29196. * | Value | Type | Description |
  29197. * | ----- | ------------------ | ----------- |
  29198. * | 0 | CLAMP_ADDRESSMODE | |
  29199. * | 1 | WRAP_ADDRESSMODE | |
  29200. * | 2 | MIRROR_ADDRESSMODE | |
  29201. */
  29202. wrapR: number;
  29203. /**
  29204. * With compliant hardware and browser (supporting anisotropic filtering)
  29205. * this defines the level of anisotropic filtering in the texture.
  29206. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29207. */
  29208. anisotropicFilteringLevel: number;
  29209. /**
  29210. * Define if the texture is a cube texture or if false a 2d texture.
  29211. */
  29212. isCube: boolean;
  29213. /**
  29214. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29215. */
  29216. is3D: boolean;
  29217. /**
  29218. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29219. */
  29220. is2DArray: boolean;
  29221. /**
  29222. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29223. * HDR texture are usually stored in linear space.
  29224. * This only impacts the PBR and Background materials
  29225. */
  29226. gammaSpace: boolean;
  29227. /**
  29228. * Gets or sets whether or not the texture contains RGBD data.
  29229. */
  29230. isRGBD: boolean;
  29231. /**
  29232. * Is Z inverted in the texture (useful in a cube texture).
  29233. */
  29234. invertZ: boolean;
  29235. /**
  29236. * Are mip maps generated for this texture or not.
  29237. */
  29238. readonly noMipmap: boolean;
  29239. /**
  29240. * @hidden
  29241. */
  29242. lodLevelInAlpha: boolean;
  29243. /**
  29244. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29245. */
  29246. lodGenerationOffset: number;
  29247. /**
  29248. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29249. */
  29250. lodGenerationScale: number;
  29251. /**
  29252. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29253. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29254. * average roughness values.
  29255. */
  29256. linearSpecularLOD: boolean;
  29257. /**
  29258. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29259. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29260. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29261. */
  29262. irradianceTexture: Nullable<BaseTexture>;
  29263. /**
  29264. * Define if the texture is a render target.
  29265. */
  29266. isRenderTarget: boolean;
  29267. /**
  29268. * Define the unique id of the texture in the scene.
  29269. */
  29270. readonly uid: string;
  29271. /**
  29272. * Return a string representation of the texture.
  29273. * @returns the texture as a string
  29274. */
  29275. toString(): string;
  29276. /**
  29277. * Get the class name of the texture.
  29278. * @returns "BaseTexture"
  29279. */
  29280. getClassName(): string;
  29281. /**
  29282. * Define the list of animation attached to the texture.
  29283. */
  29284. animations: Animation[];
  29285. /**
  29286. * An event triggered when the texture is disposed.
  29287. */
  29288. onDisposeObservable: Observable<BaseTexture>;
  29289. private _onDisposeObserver;
  29290. /**
  29291. * Callback triggered when the texture has been disposed.
  29292. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29293. */
  29294. onDispose: () => void;
  29295. /**
  29296. * Define the current state of the loading sequence when in delayed load mode.
  29297. */
  29298. delayLoadState: number;
  29299. private _scene;
  29300. /** @hidden */
  29301. _texture: Nullable<InternalTexture>;
  29302. private _uid;
  29303. /**
  29304. * Define if the texture is preventinga material to render or not.
  29305. * If not and the texture is not ready, the engine will use a default black texture instead.
  29306. */
  29307. readonly isBlocking: boolean;
  29308. /**
  29309. * Instantiates a new BaseTexture.
  29310. * Base class of all the textures in babylon.
  29311. * It groups all the common properties the materials, post process, lights... might need
  29312. * in order to make a correct use of the texture.
  29313. * @param scene Define the scene the texture blongs to
  29314. */
  29315. constructor(scene: Nullable<Scene>);
  29316. /**
  29317. * Get the scene the texture belongs to.
  29318. * @returns the scene or null if undefined
  29319. */
  29320. getScene(): Nullable<Scene>;
  29321. /**
  29322. * Get the texture transform matrix used to offset tile the texture for istance.
  29323. * @returns the transformation matrix
  29324. */
  29325. getTextureMatrix(): Matrix;
  29326. /**
  29327. * Get the texture reflection matrix used to rotate/transform the reflection.
  29328. * @returns the reflection matrix
  29329. */
  29330. getReflectionTextureMatrix(): Matrix;
  29331. /**
  29332. * Get the underlying lower level texture from Babylon.
  29333. * @returns the insternal texture
  29334. */
  29335. getInternalTexture(): Nullable<InternalTexture>;
  29336. /**
  29337. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29338. * @returns true if ready or not blocking
  29339. */
  29340. isReadyOrNotBlocking(): boolean;
  29341. /**
  29342. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29343. * @returns true if fully ready
  29344. */
  29345. isReady(): boolean;
  29346. private _cachedSize;
  29347. /**
  29348. * Get the size of the texture.
  29349. * @returns the texture size.
  29350. */
  29351. getSize(): ISize;
  29352. /**
  29353. * Get the base size of the texture.
  29354. * It can be different from the size if the texture has been resized for POT for instance
  29355. * @returns the base size
  29356. */
  29357. getBaseSize(): ISize;
  29358. /**
  29359. * Update the sampling mode of the texture.
  29360. * Default is Trilinear mode.
  29361. *
  29362. * | Value | Type | Description |
  29363. * | ----- | ------------------ | ----------- |
  29364. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29365. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29366. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29367. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29368. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29369. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29370. * | 7 | NEAREST_LINEAR | |
  29371. * | 8 | NEAREST_NEAREST | |
  29372. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29373. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29374. * | 11 | LINEAR_LINEAR | |
  29375. * | 12 | LINEAR_NEAREST | |
  29376. *
  29377. * > _mag_: magnification filter (close to the viewer)
  29378. * > _min_: minification filter (far from the viewer)
  29379. * > _mip_: filter used between mip map levels
  29380. *@param samplingMode Define the new sampling mode of the texture
  29381. */
  29382. updateSamplingMode(samplingMode: number): void;
  29383. /**
  29384. * Scales the texture if is `canRescale()`
  29385. * @param ratio the resize factor we want to use to rescale
  29386. */
  29387. scale(ratio: number): void;
  29388. /**
  29389. * Get if the texture can rescale.
  29390. */
  29391. readonly canRescale: boolean;
  29392. /** @hidden */
  29393. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29394. /** @hidden */
  29395. _rebuild(): void;
  29396. /**
  29397. * Triggers the load sequence in delayed load mode.
  29398. */
  29399. delayLoad(): void;
  29400. /**
  29401. * Clones the texture.
  29402. * @returns the cloned texture
  29403. */
  29404. clone(): Nullable<BaseTexture>;
  29405. /**
  29406. * Get the texture underlying type (INT, FLOAT...)
  29407. */
  29408. readonly textureType: number;
  29409. /**
  29410. * Get the texture underlying format (RGB, RGBA...)
  29411. */
  29412. readonly textureFormat: number;
  29413. /**
  29414. * Indicates that textures need to be re-calculated for all materials
  29415. */
  29416. protected _markAllSubMeshesAsTexturesDirty(): void;
  29417. /**
  29418. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29419. * This will returns an RGBA array buffer containing either in values (0-255) or
  29420. * float values (0-1) depending of the underlying buffer type.
  29421. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29422. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29423. * @param buffer defines a user defined buffer to fill with data (can be null)
  29424. * @returns The Array buffer containing the pixels data.
  29425. */
  29426. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29427. /**
  29428. * Release and destroy the underlying lower level texture aka internalTexture.
  29429. */
  29430. releaseInternalTexture(): void;
  29431. /** @hidden */
  29432. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29433. /** @hidden */
  29434. readonly _lodTextureMid: Nullable<BaseTexture>;
  29435. /** @hidden */
  29436. readonly _lodTextureLow: Nullable<BaseTexture>;
  29437. /**
  29438. * Dispose the texture and release its associated resources.
  29439. */
  29440. dispose(): void;
  29441. /**
  29442. * Serialize the texture into a JSON representation that can be parsed later on.
  29443. * @returns the JSON representation of the texture
  29444. */
  29445. serialize(): any;
  29446. /**
  29447. * Helper function to be called back once a list of texture contains only ready textures.
  29448. * @param textures Define the list of textures to wait for
  29449. * @param callback Define the callback triggered once the entire list will be ready
  29450. */
  29451. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29452. }
  29453. }
  29454. declare module BABYLON {
  29455. /**
  29456. * Options to be used when creating an effect.
  29457. */
  29458. export interface IEffectCreationOptions {
  29459. /**
  29460. * Atrributes that will be used in the shader.
  29461. */
  29462. attributes: string[];
  29463. /**
  29464. * Uniform varible names that will be set in the shader.
  29465. */
  29466. uniformsNames: string[];
  29467. /**
  29468. * Uniform buffer variable names that will be set in the shader.
  29469. */
  29470. uniformBuffersNames: string[];
  29471. /**
  29472. * Sampler texture variable names that will be set in the shader.
  29473. */
  29474. samplers: string[];
  29475. /**
  29476. * Define statements that will be set in the shader.
  29477. */
  29478. defines: any;
  29479. /**
  29480. * Possible fallbacks for this effect to improve performance when needed.
  29481. */
  29482. fallbacks: Nullable<IEffectFallbacks>;
  29483. /**
  29484. * Callback that will be called when the shader is compiled.
  29485. */
  29486. onCompiled: Nullable<(effect: Effect) => void>;
  29487. /**
  29488. * Callback that will be called if an error occurs during shader compilation.
  29489. */
  29490. onError: Nullable<(effect: Effect, errors: string) => void>;
  29491. /**
  29492. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29493. */
  29494. indexParameters?: any;
  29495. /**
  29496. * Max number of lights that can be used in the shader.
  29497. */
  29498. maxSimultaneousLights?: number;
  29499. /**
  29500. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29501. */
  29502. transformFeedbackVaryings?: Nullable<string[]>;
  29503. }
  29504. /**
  29505. * Effect containing vertex and fragment shader that can be executed on an object.
  29506. */
  29507. export class Effect implements IDisposable {
  29508. /**
  29509. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29510. */
  29511. static ShadersRepository: string;
  29512. /**
  29513. * Name of the effect.
  29514. */
  29515. name: any;
  29516. /**
  29517. * String container all the define statements that should be set on the shader.
  29518. */
  29519. defines: string;
  29520. /**
  29521. * Callback that will be called when the shader is compiled.
  29522. */
  29523. onCompiled: Nullable<(effect: Effect) => void>;
  29524. /**
  29525. * Callback that will be called if an error occurs during shader compilation.
  29526. */
  29527. onError: Nullable<(effect: Effect, errors: string) => void>;
  29528. /**
  29529. * Callback that will be called when effect is bound.
  29530. */
  29531. onBind: Nullable<(effect: Effect) => void>;
  29532. /**
  29533. * Unique ID of the effect.
  29534. */
  29535. uniqueId: number;
  29536. /**
  29537. * Observable that will be called when the shader is compiled.
  29538. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29539. */
  29540. onCompileObservable: Observable<Effect>;
  29541. /**
  29542. * Observable that will be called if an error occurs during shader compilation.
  29543. */
  29544. onErrorObservable: Observable<Effect>;
  29545. /** @hidden */
  29546. _onBindObservable: Nullable<Observable<Effect>>;
  29547. /**
  29548. * Observable that will be called when effect is bound.
  29549. */
  29550. readonly onBindObservable: Observable<Effect>;
  29551. /** @hidden */
  29552. _bonesComputationForcedToCPU: boolean;
  29553. private static _uniqueIdSeed;
  29554. private _engine;
  29555. private _uniformBuffersNames;
  29556. private _uniformsNames;
  29557. private _samplerList;
  29558. private _samplers;
  29559. private _isReady;
  29560. private _compilationError;
  29561. private _allFallbacksProcessed;
  29562. private _attributesNames;
  29563. private _attributes;
  29564. private _attributeLocationByName;
  29565. private _uniforms;
  29566. /**
  29567. * Key for the effect.
  29568. * @hidden
  29569. */
  29570. _key: string;
  29571. private _indexParameters;
  29572. private _fallbacks;
  29573. private _vertexSourceCode;
  29574. private _fragmentSourceCode;
  29575. private _vertexSourceCodeOverride;
  29576. private _fragmentSourceCodeOverride;
  29577. private _transformFeedbackVaryings;
  29578. /**
  29579. * Compiled shader to webGL program.
  29580. * @hidden
  29581. */
  29582. _pipelineContext: Nullable<IPipelineContext>;
  29583. private _valueCache;
  29584. private static _baseCache;
  29585. /**
  29586. * Instantiates an effect.
  29587. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29588. * @param baseName Name of the effect.
  29589. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29590. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29591. * @param samplers List of sampler variables that will be passed to the shader.
  29592. * @param engine Engine to be used to render the effect
  29593. * @param defines Define statements to be added to the shader.
  29594. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29595. * @param onCompiled Callback that will be called when the shader is compiled.
  29596. * @param onError Callback that will be called if an error occurs during shader compilation.
  29597. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29598. */
  29599. 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);
  29600. private _useFinalCode;
  29601. /**
  29602. * Unique key for this effect
  29603. */
  29604. readonly key: string;
  29605. /**
  29606. * If the effect has been compiled and prepared.
  29607. * @returns if the effect is compiled and prepared.
  29608. */
  29609. isReady(): boolean;
  29610. private _isReadyInternal;
  29611. /**
  29612. * The engine the effect was initialized with.
  29613. * @returns the engine.
  29614. */
  29615. getEngine(): Engine;
  29616. /**
  29617. * The pipeline context for this effect
  29618. * @returns the associated pipeline context
  29619. */
  29620. getPipelineContext(): Nullable<IPipelineContext>;
  29621. /**
  29622. * The set of names of attribute variables for the shader.
  29623. * @returns An array of attribute names.
  29624. */
  29625. getAttributesNames(): string[];
  29626. /**
  29627. * Returns the attribute at the given index.
  29628. * @param index The index of the attribute.
  29629. * @returns The location of the attribute.
  29630. */
  29631. getAttributeLocation(index: number): number;
  29632. /**
  29633. * Returns the attribute based on the name of the variable.
  29634. * @param name of the attribute to look up.
  29635. * @returns the attribute location.
  29636. */
  29637. getAttributeLocationByName(name: string): number;
  29638. /**
  29639. * The number of attributes.
  29640. * @returns the numnber of attributes.
  29641. */
  29642. getAttributesCount(): number;
  29643. /**
  29644. * Gets the index of a uniform variable.
  29645. * @param uniformName of the uniform to look up.
  29646. * @returns the index.
  29647. */
  29648. getUniformIndex(uniformName: string): number;
  29649. /**
  29650. * Returns the attribute based on the name of the variable.
  29651. * @param uniformName of the uniform to look up.
  29652. * @returns the location of the uniform.
  29653. */
  29654. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29655. /**
  29656. * Returns an array of sampler variable names
  29657. * @returns The array of sampler variable neames.
  29658. */
  29659. getSamplers(): string[];
  29660. /**
  29661. * The error from the last compilation.
  29662. * @returns the error string.
  29663. */
  29664. getCompilationError(): string;
  29665. /**
  29666. * Gets a boolean indicating that all fallbacks were used during compilation
  29667. * @returns true if all fallbacks were used
  29668. */
  29669. allFallbacksProcessed(): boolean;
  29670. /**
  29671. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29672. * @param func The callback to be used.
  29673. */
  29674. executeWhenCompiled(func: (effect: Effect) => void): void;
  29675. private _checkIsReady;
  29676. private _loadShader;
  29677. /**
  29678. * Recompiles the webGL program
  29679. * @param vertexSourceCode The source code for the vertex shader.
  29680. * @param fragmentSourceCode The source code for the fragment shader.
  29681. * @param onCompiled Callback called when completed.
  29682. * @param onError Callback called on error.
  29683. * @hidden
  29684. */
  29685. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29686. /**
  29687. * Prepares the effect
  29688. * @hidden
  29689. */
  29690. _prepareEffect(): void;
  29691. private _processCompilationErrors;
  29692. /**
  29693. * Checks if the effect is supported. (Must be called after compilation)
  29694. */
  29695. readonly isSupported: boolean;
  29696. /**
  29697. * Binds a texture to the engine to be used as output of the shader.
  29698. * @param channel Name of the output variable.
  29699. * @param texture Texture to bind.
  29700. * @hidden
  29701. */
  29702. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  29703. /**
  29704. * Sets a texture on the engine to be used in the shader.
  29705. * @param channel Name of the sampler variable.
  29706. * @param texture Texture to set.
  29707. */
  29708. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29709. /**
  29710. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29711. * @param channel Name of the sampler variable.
  29712. * @param texture Texture to set.
  29713. */
  29714. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29715. /**
  29716. * Sets an array of textures on the engine to be used in the shader.
  29717. * @param channel Name of the variable.
  29718. * @param textures Textures to set.
  29719. */
  29720. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29721. /**
  29722. * 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)
  29723. * @param channel Name of the sampler variable.
  29724. * @param postProcess Post process to get the input texture from.
  29725. */
  29726. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29727. /**
  29728. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29729. * 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)
  29730. * @param channel Name of the sampler variable.
  29731. * @param postProcess Post process to get the output texture from.
  29732. */
  29733. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29734. /** @hidden */
  29735. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29736. /** @hidden */
  29737. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29738. /** @hidden */
  29739. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29740. /** @hidden */
  29741. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29742. /**
  29743. * Binds a buffer to a uniform.
  29744. * @param buffer Buffer to bind.
  29745. * @param name Name of the uniform variable to bind to.
  29746. */
  29747. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29748. /**
  29749. * Binds block to a uniform.
  29750. * @param blockName Name of the block to bind.
  29751. * @param index Index to bind.
  29752. */
  29753. bindUniformBlock(blockName: string, index: number): void;
  29754. /**
  29755. * Sets an interger value on a uniform variable.
  29756. * @param uniformName Name of the variable.
  29757. * @param value Value to be set.
  29758. * @returns this effect.
  29759. */
  29760. setInt(uniformName: string, value: number): Effect;
  29761. /**
  29762. * Sets an int array on a uniform variable.
  29763. * @param uniformName Name of the variable.
  29764. * @param array array to be set.
  29765. * @returns this effect.
  29766. */
  29767. setIntArray(uniformName: string, array: Int32Array): Effect;
  29768. /**
  29769. * 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)
  29770. * @param uniformName Name of the variable.
  29771. * @param array array to be set.
  29772. * @returns this effect.
  29773. */
  29774. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29775. /**
  29776. * 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)
  29777. * @param uniformName Name of the variable.
  29778. * @param array array to be set.
  29779. * @returns this effect.
  29780. */
  29781. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29782. /**
  29783. * 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)
  29784. * @param uniformName Name of the variable.
  29785. * @param array array to be set.
  29786. * @returns this effect.
  29787. */
  29788. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29789. /**
  29790. * Sets an float array on a uniform variable.
  29791. * @param uniformName Name of the variable.
  29792. * @param array array to be set.
  29793. * @returns this effect.
  29794. */
  29795. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29796. /**
  29797. * 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)
  29798. * @param uniformName Name of the variable.
  29799. * @param array array to be set.
  29800. * @returns this effect.
  29801. */
  29802. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29803. /**
  29804. * 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)
  29805. * @param uniformName Name of the variable.
  29806. * @param array array to be set.
  29807. * @returns this effect.
  29808. */
  29809. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29810. /**
  29811. * 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)
  29812. * @param uniformName Name of the variable.
  29813. * @param array array to be set.
  29814. * @returns this effect.
  29815. */
  29816. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29817. /**
  29818. * Sets an array on a uniform variable.
  29819. * @param uniformName Name of the variable.
  29820. * @param array array to be set.
  29821. * @returns this effect.
  29822. */
  29823. setArray(uniformName: string, array: number[]): Effect;
  29824. /**
  29825. * 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)
  29826. * @param uniformName Name of the variable.
  29827. * @param array array to be set.
  29828. * @returns this effect.
  29829. */
  29830. setArray2(uniformName: string, array: number[]): Effect;
  29831. /**
  29832. * 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)
  29833. * @param uniformName Name of the variable.
  29834. * @param array array to be set.
  29835. * @returns this effect.
  29836. */
  29837. setArray3(uniformName: string, array: number[]): Effect;
  29838. /**
  29839. * 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)
  29840. * @param uniformName Name of the variable.
  29841. * @param array array to be set.
  29842. * @returns this effect.
  29843. */
  29844. setArray4(uniformName: string, array: number[]): Effect;
  29845. /**
  29846. * Sets matrices on a uniform variable.
  29847. * @param uniformName Name of the variable.
  29848. * @param matrices matrices to be set.
  29849. * @returns this effect.
  29850. */
  29851. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29852. /**
  29853. * Sets matrix on a uniform variable.
  29854. * @param uniformName Name of the variable.
  29855. * @param matrix matrix to be set.
  29856. * @returns this effect.
  29857. */
  29858. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29859. /**
  29860. * 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)
  29861. * @param uniformName Name of the variable.
  29862. * @param matrix matrix to be set.
  29863. * @returns this effect.
  29864. */
  29865. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29866. /**
  29867. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29868. * @param uniformName Name of the variable.
  29869. * @param matrix matrix to be set.
  29870. * @returns this effect.
  29871. */
  29872. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29873. /**
  29874. * Sets a float on a uniform variable.
  29875. * @param uniformName Name of the variable.
  29876. * @param value value to be set.
  29877. * @returns this effect.
  29878. */
  29879. setFloat(uniformName: string, value: number): Effect;
  29880. /**
  29881. * Sets a boolean on a uniform variable.
  29882. * @param uniformName Name of the variable.
  29883. * @param bool value to be set.
  29884. * @returns this effect.
  29885. */
  29886. setBool(uniformName: string, bool: boolean): Effect;
  29887. /**
  29888. * Sets a Vector2 on a uniform variable.
  29889. * @param uniformName Name of the variable.
  29890. * @param vector2 vector2 to be set.
  29891. * @returns this effect.
  29892. */
  29893. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29894. /**
  29895. * Sets a float2 on a uniform variable.
  29896. * @param uniformName Name of the variable.
  29897. * @param x First float in float2.
  29898. * @param y Second float in float2.
  29899. * @returns this effect.
  29900. */
  29901. setFloat2(uniformName: string, x: number, y: number): Effect;
  29902. /**
  29903. * Sets a Vector3 on a uniform variable.
  29904. * @param uniformName Name of the variable.
  29905. * @param vector3 Value to be set.
  29906. * @returns this effect.
  29907. */
  29908. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29909. /**
  29910. * Sets a float3 on a uniform variable.
  29911. * @param uniformName Name of the variable.
  29912. * @param x First float in float3.
  29913. * @param y Second float in float3.
  29914. * @param z Third float in float3.
  29915. * @returns this effect.
  29916. */
  29917. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29918. /**
  29919. * Sets a Vector4 on a uniform variable.
  29920. * @param uniformName Name of the variable.
  29921. * @param vector4 Value to be set.
  29922. * @returns this effect.
  29923. */
  29924. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29925. /**
  29926. * Sets a float4 on a uniform variable.
  29927. * @param uniformName Name of the variable.
  29928. * @param x First float in float4.
  29929. * @param y Second float in float4.
  29930. * @param z Third float in float4.
  29931. * @param w Fourth float in float4.
  29932. * @returns this effect.
  29933. */
  29934. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29935. /**
  29936. * Sets a Color3 on a uniform variable.
  29937. * @param uniformName Name of the variable.
  29938. * @param color3 Value to be set.
  29939. * @returns this effect.
  29940. */
  29941. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29942. /**
  29943. * Sets a Color4 on a uniform variable.
  29944. * @param uniformName Name of the variable.
  29945. * @param color3 Value to be set.
  29946. * @param alpha Alpha value to be set.
  29947. * @returns this effect.
  29948. */
  29949. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29950. /**
  29951. * Sets a Color4 on a uniform variable
  29952. * @param uniformName defines the name of the variable
  29953. * @param color4 defines the value to be set
  29954. * @returns this effect.
  29955. */
  29956. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29957. /** Release all associated resources */
  29958. dispose(): void;
  29959. /**
  29960. * This function will add a new shader to the shader store
  29961. * @param name the name of the shader
  29962. * @param pixelShader optional pixel shader content
  29963. * @param vertexShader optional vertex shader content
  29964. */
  29965. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29966. /**
  29967. * Store of each shader (The can be looked up using effect.key)
  29968. */
  29969. static ShadersStore: {
  29970. [key: string]: string;
  29971. };
  29972. /**
  29973. * Store of each included file for a shader (The can be looked up using effect.key)
  29974. */
  29975. static IncludesShadersStore: {
  29976. [key: string]: string;
  29977. };
  29978. /**
  29979. * Resets the cache of effects.
  29980. */
  29981. static ResetCache(): void;
  29982. }
  29983. }
  29984. declare module BABYLON {
  29985. /**
  29986. * Interface used to describe the capabilities of the engine relatively to the current browser
  29987. */
  29988. export interface EngineCapabilities {
  29989. /** Maximum textures units per fragment shader */
  29990. maxTexturesImageUnits: number;
  29991. /** Maximum texture units per vertex shader */
  29992. maxVertexTextureImageUnits: number;
  29993. /** Maximum textures units in the entire pipeline */
  29994. maxCombinedTexturesImageUnits: number;
  29995. /** Maximum texture size */
  29996. maxTextureSize: number;
  29997. /** Maximum texture samples */
  29998. maxSamples?: number;
  29999. /** Maximum cube texture size */
  30000. maxCubemapTextureSize: number;
  30001. /** Maximum render texture size */
  30002. maxRenderTextureSize: number;
  30003. /** Maximum number of vertex attributes */
  30004. maxVertexAttribs: number;
  30005. /** Maximum number of varyings */
  30006. maxVaryingVectors: number;
  30007. /** Maximum number of uniforms per vertex shader */
  30008. maxVertexUniformVectors: number;
  30009. /** Maximum number of uniforms per fragment shader */
  30010. maxFragmentUniformVectors: number;
  30011. /** Defines if standard derivates (dx/dy) are supported */
  30012. standardDerivatives: boolean;
  30013. /** Defines if s3tc texture compression is supported */
  30014. s3tc?: WEBGL_compressed_texture_s3tc;
  30015. /** Defines if pvrtc texture compression is supported */
  30016. pvrtc: any;
  30017. /** Defines if etc1 texture compression is supported */
  30018. etc1: any;
  30019. /** Defines if etc2 texture compression is supported */
  30020. etc2: any;
  30021. /** Defines if astc texture compression is supported */
  30022. astc: any;
  30023. /** Defines if float textures are supported */
  30024. textureFloat: boolean;
  30025. /** Defines if vertex array objects are supported */
  30026. vertexArrayObject: boolean;
  30027. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30028. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30029. /** Gets the maximum level of anisotropy supported */
  30030. maxAnisotropy: number;
  30031. /** Defines if instancing is supported */
  30032. instancedArrays: boolean;
  30033. /** Defines if 32 bits indices are supported */
  30034. uintIndices: boolean;
  30035. /** Defines if high precision shaders are supported */
  30036. highPrecisionShaderSupported: boolean;
  30037. /** Defines if depth reading in the fragment shader is supported */
  30038. fragmentDepthSupported: boolean;
  30039. /** Defines if float texture linear filtering is supported*/
  30040. textureFloatLinearFiltering: boolean;
  30041. /** Defines if rendering to float textures is supported */
  30042. textureFloatRender: boolean;
  30043. /** Defines if half float textures are supported*/
  30044. textureHalfFloat: boolean;
  30045. /** Defines if half float texture linear filtering is supported*/
  30046. textureHalfFloatLinearFiltering: boolean;
  30047. /** Defines if rendering to half float textures is supported */
  30048. textureHalfFloatRender: boolean;
  30049. /** Defines if textureLOD shader command is supported */
  30050. textureLOD: boolean;
  30051. /** Defines if draw buffers extension is supported */
  30052. drawBuffersExtension: boolean;
  30053. /** Defines if depth textures are supported */
  30054. depthTextureExtension: boolean;
  30055. /** Defines if float color buffer are supported */
  30056. colorBufferFloat: boolean;
  30057. /** Gets disjoint timer query extension (null if not supported) */
  30058. timerQuery?: EXT_disjoint_timer_query;
  30059. /** Defines if timestamp can be used with timer query */
  30060. canUseTimestampForTimerQuery: boolean;
  30061. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30062. multiview?: any;
  30063. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30064. oculusMultiview?: any;
  30065. /** Function used to let the system compiles shaders in background */
  30066. parallelShaderCompile?: {
  30067. COMPLETION_STATUS_KHR: number;
  30068. };
  30069. /** Max number of texture samples for MSAA */
  30070. maxMSAASamples: number;
  30071. /** Defines if the blend min max extension is supported */
  30072. blendMinMax: boolean;
  30073. }
  30074. }
  30075. declare module BABYLON {
  30076. /**
  30077. * @hidden
  30078. **/
  30079. export class DepthCullingState {
  30080. private _isDepthTestDirty;
  30081. private _isDepthMaskDirty;
  30082. private _isDepthFuncDirty;
  30083. private _isCullFaceDirty;
  30084. private _isCullDirty;
  30085. private _isZOffsetDirty;
  30086. private _isFrontFaceDirty;
  30087. private _depthTest;
  30088. private _depthMask;
  30089. private _depthFunc;
  30090. private _cull;
  30091. private _cullFace;
  30092. private _zOffset;
  30093. private _frontFace;
  30094. /**
  30095. * Initializes the state.
  30096. */
  30097. constructor();
  30098. readonly isDirty: boolean;
  30099. zOffset: number;
  30100. cullFace: Nullable<number>;
  30101. cull: Nullable<boolean>;
  30102. depthFunc: Nullable<number>;
  30103. depthMask: boolean;
  30104. depthTest: boolean;
  30105. frontFace: Nullable<number>;
  30106. reset(): void;
  30107. apply(gl: WebGLRenderingContext): void;
  30108. }
  30109. }
  30110. declare module BABYLON {
  30111. /**
  30112. * @hidden
  30113. **/
  30114. export class StencilState {
  30115. /** 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 */
  30116. static readonly ALWAYS: number;
  30117. /** Passed to stencilOperation to specify that stencil value must be kept */
  30118. static readonly KEEP: number;
  30119. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30120. static readonly REPLACE: number;
  30121. private _isStencilTestDirty;
  30122. private _isStencilMaskDirty;
  30123. private _isStencilFuncDirty;
  30124. private _isStencilOpDirty;
  30125. private _stencilTest;
  30126. private _stencilMask;
  30127. private _stencilFunc;
  30128. private _stencilFuncRef;
  30129. private _stencilFuncMask;
  30130. private _stencilOpStencilFail;
  30131. private _stencilOpDepthFail;
  30132. private _stencilOpStencilDepthPass;
  30133. readonly isDirty: boolean;
  30134. stencilFunc: number;
  30135. stencilFuncRef: number;
  30136. stencilFuncMask: number;
  30137. stencilOpStencilFail: number;
  30138. stencilOpDepthFail: number;
  30139. stencilOpStencilDepthPass: number;
  30140. stencilMask: number;
  30141. stencilTest: boolean;
  30142. constructor();
  30143. reset(): void;
  30144. apply(gl: WebGLRenderingContext): void;
  30145. }
  30146. }
  30147. declare module BABYLON {
  30148. /**
  30149. * @hidden
  30150. **/
  30151. export class AlphaState {
  30152. private _isAlphaBlendDirty;
  30153. private _isBlendFunctionParametersDirty;
  30154. private _isBlendEquationParametersDirty;
  30155. private _isBlendConstantsDirty;
  30156. private _alphaBlend;
  30157. private _blendFunctionParameters;
  30158. private _blendEquationParameters;
  30159. private _blendConstants;
  30160. /**
  30161. * Initializes the state.
  30162. */
  30163. constructor();
  30164. readonly isDirty: boolean;
  30165. alphaBlend: boolean;
  30166. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30167. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30168. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30169. reset(): void;
  30170. apply(gl: WebGLRenderingContext): void;
  30171. }
  30172. }
  30173. declare module BABYLON {
  30174. /** @hidden */
  30175. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30176. attributeProcessor(attribute: string): string;
  30177. varyingProcessor(varying: string, isFragment: boolean): string;
  30178. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30179. }
  30180. }
  30181. declare module BABYLON {
  30182. /**
  30183. * Interface for attribute information associated with buffer instanciation
  30184. */
  30185. export interface InstancingAttributeInfo {
  30186. /**
  30187. * Name of the GLSL attribute
  30188. * if attribute index is not specified, this is used to retrieve the index from the effect
  30189. */
  30190. attributeName: string;
  30191. /**
  30192. * Index/offset of the attribute in the vertex shader
  30193. * if not specified, this will be computes from the name.
  30194. */
  30195. index?: number;
  30196. /**
  30197. * size of the attribute, 1, 2, 3 or 4
  30198. */
  30199. attributeSize: number;
  30200. /**
  30201. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30202. */
  30203. offset: number;
  30204. /**
  30205. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30206. * default to 1
  30207. */
  30208. divisor?: number;
  30209. /**
  30210. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30211. * default is FLOAT
  30212. */
  30213. attributeType?: number;
  30214. /**
  30215. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30216. */
  30217. normalized?: boolean;
  30218. }
  30219. }
  30220. declare module BABYLON {
  30221. interface ThinEngine {
  30222. /**
  30223. * Update a video texture
  30224. * @param texture defines the texture to update
  30225. * @param video defines the video element to use
  30226. * @param invertY defines if data must be stored with Y axis inverted
  30227. */
  30228. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30229. }
  30230. }
  30231. declare module BABYLON {
  30232. /**
  30233. * Settings for finer control over video usage
  30234. */
  30235. export interface VideoTextureSettings {
  30236. /**
  30237. * Applies `autoplay` to video, if specified
  30238. */
  30239. autoPlay?: boolean;
  30240. /**
  30241. * Applies `loop` to video, if specified
  30242. */
  30243. loop?: boolean;
  30244. /**
  30245. * Automatically updates internal texture from video at every frame in the render loop
  30246. */
  30247. autoUpdateTexture: boolean;
  30248. /**
  30249. * Image src displayed during the video loading or until the user interacts with the video.
  30250. */
  30251. poster?: string;
  30252. }
  30253. /**
  30254. * If you want to display a video in your scene, this is the special texture for that.
  30255. * This special texture works similar to other textures, with the exception of a few parameters.
  30256. * @see https://doc.babylonjs.com/how_to/video_texture
  30257. */
  30258. export class VideoTexture extends Texture {
  30259. /**
  30260. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30261. */
  30262. readonly autoUpdateTexture: boolean;
  30263. /**
  30264. * The video instance used by the texture internally
  30265. */
  30266. readonly video: HTMLVideoElement;
  30267. private _onUserActionRequestedObservable;
  30268. /**
  30269. * Event triggerd when a dom action is required by the user to play the video.
  30270. * This happens due to recent changes in browser policies preventing video to auto start.
  30271. */
  30272. readonly onUserActionRequestedObservable: Observable<Texture>;
  30273. private _generateMipMaps;
  30274. private _engine;
  30275. private _stillImageCaptured;
  30276. private _displayingPosterTexture;
  30277. private _settings;
  30278. private _createInternalTextureOnEvent;
  30279. private _frameId;
  30280. /**
  30281. * Creates a video texture.
  30282. * If you want to display a video in your scene, this is the special texture for that.
  30283. * This special texture works similar to other textures, with the exception of a few parameters.
  30284. * @see https://doc.babylonjs.com/how_to/video_texture
  30285. * @param name optional name, will detect from video source, if not defined
  30286. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30287. * @param scene is obviously the current scene.
  30288. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30289. * @param invertY is false by default but can be used to invert video on Y axis
  30290. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30291. * @param settings allows finer control over video usage
  30292. */
  30293. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30294. private _getName;
  30295. private _getVideo;
  30296. private _createInternalTexture;
  30297. private reset;
  30298. /**
  30299. * @hidden Internal method to initiate `update`.
  30300. */
  30301. _rebuild(): void;
  30302. /**
  30303. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30304. */
  30305. update(): void;
  30306. /**
  30307. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30308. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30309. */
  30310. updateTexture(isVisible: boolean): void;
  30311. protected _updateInternalTexture: () => void;
  30312. /**
  30313. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30314. * @param url New url.
  30315. */
  30316. updateURL(url: string): void;
  30317. /**
  30318. * Dispose the texture and release its associated resources.
  30319. */
  30320. dispose(): void;
  30321. /**
  30322. * Creates a video texture straight from a stream.
  30323. * @param scene Define the scene the texture should be created in
  30324. * @param stream Define the stream the texture should be created from
  30325. * @returns The created video texture as a promise
  30326. */
  30327. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30328. /**
  30329. * Creates a video texture straight from your WebCam video feed.
  30330. * @param scene Define the scene the texture should be created in
  30331. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30332. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30333. * @returns The created video texture as a promise
  30334. */
  30335. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30336. minWidth: number;
  30337. maxWidth: number;
  30338. minHeight: number;
  30339. maxHeight: number;
  30340. deviceId: string;
  30341. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30342. /**
  30343. * Creates a video texture straight from your WebCam video feed.
  30344. * @param scene Define the scene the texture should be created in
  30345. * @param onReady Define a callback to triggered once the texture will be ready
  30346. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30347. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30348. */
  30349. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30350. minWidth: number;
  30351. maxWidth: number;
  30352. minHeight: number;
  30353. maxHeight: number;
  30354. deviceId: string;
  30355. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30356. }
  30357. }
  30358. declare module BABYLON {
  30359. /**
  30360. * Defines the interface used by objects working like Scene
  30361. * @hidden
  30362. */
  30363. interface ISceneLike {
  30364. _addPendingData(data: any): void;
  30365. _removePendingData(data: any): void;
  30366. offlineProvider: IOfflineProvider;
  30367. }
  30368. /** Interface defining initialization parameters for Engine class */
  30369. export interface EngineOptions extends WebGLContextAttributes {
  30370. /**
  30371. * Defines if the engine should no exceed a specified device ratio
  30372. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30373. */
  30374. limitDeviceRatio?: number;
  30375. /**
  30376. * Defines if webvr should be enabled automatically
  30377. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30378. */
  30379. autoEnableWebVR?: boolean;
  30380. /**
  30381. * Defines if webgl2 should be turned off even if supported
  30382. * @see http://doc.babylonjs.com/features/webgl2
  30383. */
  30384. disableWebGL2Support?: boolean;
  30385. /**
  30386. * Defines if webaudio should be initialized as well
  30387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30388. */
  30389. audioEngine?: boolean;
  30390. /**
  30391. * Defines if animations should run using a deterministic lock step
  30392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30393. */
  30394. deterministicLockstep?: boolean;
  30395. /** Defines the maximum steps to use with deterministic lock step mode */
  30396. lockstepMaxSteps?: number;
  30397. /** Defines the seconds between each deterministic lock step */
  30398. timeStep?: number;
  30399. /**
  30400. * Defines that engine should ignore context lost events
  30401. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30402. */
  30403. doNotHandleContextLost?: boolean;
  30404. /**
  30405. * Defines that engine should ignore modifying touch action attribute and style
  30406. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30407. */
  30408. doNotHandleTouchAction?: boolean;
  30409. /**
  30410. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30411. */
  30412. useHighPrecisionFloats?: boolean;
  30413. }
  30414. /**
  30415. * The base engine class (root of all engines)
  30416. */
  30417. export class ThinEngine {
  30418. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30419. static ExceptionList: ({
  30420. key: string;
  30421. capture: string;
  30422. captureConstraint: number;
  30423. targets: string[];
  30424. } | {
  30425. key: string;
  30426. capture: null;
  30427. captureConstraint: null;
  30428. targets: string[];
  30429. })[];
  30430. /** @hidden */
  30431. static _TextureLoaders: IInternalTextureLoader[];
  30432. /**
  30433. * Returns the current npm package of the sdk
  30434. */
  30435. static readonly NpmPackage: string;
  30436. /**
  30437. * Returns the current version of the framework
  30438. */
  30439. static readonly Version: string;
  30440. /**
  30441. * Returns a string describing the current engine
  30442. */
  30443. readonly description: string;
  30444. /**
  30445. * Gets or sets the epsilon value used by collision engine
  30446. */
  30447. static CollisionsEpsilon: number;
  30448. /**
  30449. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30450. */
  30451. static ShadersRepository: string;
  30452. /**
  30453. * Gets or sets the textures that the engine should not attempt to load as compressed
  30454. */
  30455. protected _excludedCompressedTextures: string[];
  30456. /**
  30457. * Filters the compressed texture formats to only include
  30458. * files that are not included in the skippable list
  30459. *
  30460. * @param url the current extension
  30461. * @param textureFormatInUse the current compressed texture format
  30462. * @returns "format" string
  30463. */
  30464. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30465. /** @hidden */
  30466. _shaderProcessor: IShaderProcessor;
  30467. /**
  30468. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30469. */
  30470. forcePOTTextures: boolean;
  30471. /**
  30472. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30473. */
  30474. isFullscreen: boolean;
  30475. /**
  30476. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30477. */
  30478. cullBackFaces: boolean;
  30479. /**
  30480. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30481. */
  30482. renderEvenInBackground: boolean;
  30483. /**
  30484. * Gets or sets a boolean indicating that cache can be kept between frames
  30485. */
  30486. preventCacheWipeBetweenFrames: boolean;
  30487. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30488. validateShaderPrograms: boolean;
  30489. /**
  30490. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30491. * This can provide greater z depth for distant objects.
  30492. */
  30493. useReverseDepthBuffer: boolean;
  30494. /**
  30495. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30496. */
  30497. disableUniformBuffers: boolean;
  30498. /** @hidden */
  30499. _uniformBuffers: UniformBuffer[];
  30500. /**
  30501. * Gets a boolean indicating that the engine supports uniform buffers
  30502. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30503. */
  30504. readonly supportsUniformBuffers: boolean;
  30505. /** @hidden */
  30506. _gl: WebGLRenderingContext;
  30507. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30508. protected _windowIsBackground: boolean;
  30509. protected _webGLVersion: number;
  30510. protected _creationOptions: EngineOptions;
  30511. protected _highPrecisionShadersAllowed: boolean;
  30512. /** @hidden */
  30513. readonly _shouldUseHighPrecisionShader: boolean;
  30514. /**
  30515. * Gets a boolean indicating that only power of 2 textures are supported
  30516. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30517. */
  30518. readonly needPOTTextures: boolean;
  30519. /** @hidden */
  30520. _badOS: boolean;
  30521. /** @hidden */
  30522. _badDesktopOS: boolean;
  30523. private _hardwareScalingLevel;
  30524. /** @hidden */
  30525. _caps: EngineCapabilities;
  30526. private _isStencilEnable;
  30527. private _glVersion;
  30528. private _glRenderer;
  30529. private _glVendor;
  30530. /** @hidden */
  30531. _videoTextureSupported: boolean;
  30532. protected _renderingQueueLaunched: boolean;
  30533. protected _activeRenderLoops: (() => void)[];
  30534. /**
  30535. * Observable signaled when a context lost event is raised
  30536. */
  30537. onContextLostObservable: Observable<ThinEngine>;
  30538. /**
  30539. * Observable signaled when a context restored event is raised
  30540. */
  30541. onContextRestoredObservable: Observable<ThinEngine>;
  30542. private _onContextLost;
  30543. private _onContextRestored;
  30544. protected _contextWasLost: boolean;
  30545. /** @hidden */
  30546. _doNotHandleContextLost: boolean;
  30547. /**
  30548. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30550. */
  30551. doNotHandleContextLost: boolean;
  30552. /**
  30553. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30554. */
  30555. disableVertexArrayObjects: boolean;
  30556. /** @hidden */
  30557. protected _colorWrite: boolean;
  30558. /** @hidden */
  30559. protected _colorWriteChanged: boolean;
  30560. /** @hidden */
  30561. protected _depthCullingState: DepthCullingState;
  30562. /** @hidden */
  30563. protected _stencilState: StencilState;
  30564. /** @hidden */
  30565. _alphaState: AlphaState;
  30566. /** @hidden */
  30567. _alphaMode: number;
  30568. /** @hidden */
  30569. _alphaEquation: number;
  30570. /** @hidden */
  30571. _internalTexturesCache: InternalTexture[];
  30572. /** @hidden */
  30573. protected _activeChannel: number;
  30574. private _currentTextureChannel;
  30575. /** @hidden */
  30576. protected _boundTexturesCache: {
  30577. [key: string]: Nullable<InternalTexture>;
  30578. };
  30579. /** @hidden */
  30580. protected _currentEffect: Nullable<Effect>;
  30581. /** @hidden */
  30582. protected _currentProgram: Nullable<WebGLProgram>;
  30583. private _compiledEffects;
  30584. private _vertexAttribArraysEnabled;
  30585. /** @hidden */
  30586. protected _cachedViewport: Nullable<IViewportLike>;
  30587. private _cachedVertexArrayObject;
  30588. /** @hidden */
  30589. protected _cachedVertexBuffers: any;
  30590. /** @hidden */
  30591. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30592. /** @hidden */
  30593. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30594. /** @hidden */
  30595. _currentRenderTarget: Nullable<InternalTexture>;
  30596. private _uintIndicesCurrentlySet;
  30597. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30598. /** @hidden */
  30599. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30600. private _currentBufferPointers;
  30601. private _currentInstanceLocations;
  30602. private _currentInstanceBuffers;
  30603. private _textureUnits;
  30604. /** @hidden */
  30605. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30606. /** @hidden */
  30607. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30608. /** @hidden */
  30609. _boundRenderFunction: any;
  30610. private _vaoRecordInProgress;
  30611. private _mustWipeVertexAttributes;
  30612. private _emptyTexture;
  30613. private _emptyCubeTexture;
  30614. private _emptyTexture3D;
  30615. private _emptyTexture2DArray;
  30616. /** @hidden */
  30617. _frameHandler: number;
  30618. private _nextFreeTextureSlots;
  30619. private _maxSimultaneousTextures;
  30620. private _activeRequests;
  30621. protected _texturesSupported: string[];
  30622. /** @hidden */
  30623. _textureFormatInUse: Nullable<string>;
  30624. protected readonly _supportsHardwareTextureRescaling: boolean;
  30625. /**
  30626. * Gets the list of texture formats supported
  30627. */
  30628. readonly texturesSupported: Array<string>;
  30629. /**
  30630. * Gets the list of texture formats in use
  30631. */
  30632. readonly textureFormatInUse: Nullable<string>;
  30633. /**
  30634. * Gets the current viewport
  30635. */
  30636. readonly currentViewport: Nullable<IViewportLike>;
  30637. /**
  30638. * Gets the default empty texture
  30639. */
  30640. readonly emptyTexture: InternalTexture;
  30641. /**
  30642. * Gets the default empty 3D texture
  30643. */
  30644. readonly emptyTexture3D: InternalTexture;
  30645. /**
  30646. * Gets the default empty 2D array texture
  30647. */
  30648. readonly emptyTexture2DArray: InternalTexture;
  30649. /**
  30650. * Gets the default empty cube texture
  30651. */
  30652. readonly emptyCubeTexture: InternalTexture;
  30653. /**
  30654. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30655. */
  30656. readonly premultipliedAlpha: boolean;
  30657. /**
  30658. * Observable event triggered before each texture is initialized
  30659. */
  30660. onBeforeTextureInitObservable: Observable<Texture>;
  30661. /**
  30662. * Creates a new engine
  30663. * @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
  30664. * @param antialias defines enable antialiasing (default: false)
  30665. * @param options defines further options to be sent to the getContext() function
  30666. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30667. */
  30668. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30669. private _rebuildInternalTextures;
  30670. private _rebuildEffects;
  30671. /**
  30672. * Gets a boolean indicating if all created effects are ready
  30673. * @returns true if all effects are ready
  30674. */
  30675. areAllEffectsReady(): boolean;
  30676. protected _rebuildBuffers(): void;
  30677. private _initGLContext;
  30678. /**
  30679. * Gets version of the current webGL context
  30680. */
  30681. readonly webGLVersion: number;
  30682. /**
  30683. * Gets a string idenfifying the name of the class
  30684. * @returns "Engine" string
  30685. */
  30686. getClassName(): string;
  30687. /**
  30688. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30689. */
  30690. readonly isStencilEnable: boolean;
  30691. /** @hidden */
  30692. _prepareWorkingCanvas(): void;
  30693. /**
  30694. * Reset the texture cache to empty state
  30695. */
  30696. resetTextureCache(): void;
  30697. /**
  30698. * Gets an object containing information about the current webGL context
  30699. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30700. */
  30701. getGlInfo(): {
  30702. vendor: string;
  30703. renderer: string;
  30704. version: string;
  30705. };
  30706. /**
  30707. * Defines the hardware scaling level.
  30708. * By default the hardware scaling level is computed from the window device ratio.
  30709. * 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.
  30710. * @param level defines the level to use
  30711. */
  30712. setHardwareScalingLevel(level: number): void;
  30713. /**
  30714. * Gets the current hardware scaling level.
  30715. * By default the hardware scaling level is computed from the window device ratio.
  30716. * 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.
  30717. * @returns a number indicating the current hardware scaling level
  30718. */
  30719. getHardwareScalingLevel(): number;
  30720. /**
  30721. * Gets the list of loaded textures
  30722. * @returns an array containing all loaded textures
  30723. */
  30724. getLoadedTexturesCache(): InternalTexture[];
  30725. /**
  30726. * Gets the object containing all engine capabilities
  30727. * @returns the EngineCapabilities object
  30728. */
  30729. getCaps(): EngineCapabilities;
  30730. /**
  30731. * stop executing a render loop function and remove it from the execution array
  30732. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30733. */
  30734. stopRenderLoop(renderFunction?: () => void): void;
  30735. /** @hidden */
  30736. _renderLoop(): void;
  30737. /**
  30738. * Gets the HTML canvas attached with the current webGL context
  30739. * @returns a HTML canvas
  30740. */
  30741. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30742. /**
  30743. * Gets host window
  30744. * @returns the host window object
  30745. */
  30746. getHostWindow(): Nullable<Window>;
  30747. /**
  30748. * Gets the current render width
  30749. * @param useScreen defines if screen size must be used (or the current render target if any)
  30750. * @returns a number defining the current render width
  30751. */
  30752. getRenderWidth(useScreen?: boolean): number;
  30753. /**
  30754. * Gets the current render height
  30755. * @param useScreen defines if screen size must be used (or the current render target if any)
  30756. * @returns a number defining the current render height
  30757. */
  30758. getRenderHeight(useScreen?: boolean): number;
  30759. /**
  30760. * Can be used to override the current requestAnimationFrame requester.
  30761. * @hidden
  30762. */
  30763. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30764. /**
  30765. * Register and execute a render loop. The engine can have more than one render function
  30766. * @param renderFunction defines the function to continuously execute
  30767. */
  30768. runRenderLoop(renderFunction: () => void): void;
  30769. /**
  30770. * Clear the current render buffer or the current render target (if any is set up)
  30771. * @param color defines the color to use
  30772. * @param backBuffer defines if the back buffer must be cleared
  30773. * @param depth defines if the depth buffer must be cleared
  30774. * @param stencil defines if the stencil buffer must be cleared
  30775. */
  30776. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30777. private _viewportCached;
  30778. /** @hidden */
  30779. _viewport(x: number, y: number, width: number, height: number): void;
  30780. /**
  30781. * Set the WebGL's viewport
  30782. * @param viewport defines the viewport element to be used
  30783. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30784. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30785. */
  30786. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30787. /**
  30788. * Begin a new frame
  30789. */
  30790. beginFrame(): void;
  30791. /**
  30792. * Enf the current frame
  30793. */
  30794. endFrame(): void;
  30795. /**
  30796. * Resize the view according to the canvas' size
  30797. */
  30798. resize(): void;
  30799. /**
  30800. * Force a specific size of the canvas
  30801. * @param width defines the new canvas' width
  30802. * @param height defines the new canvas' height
  30803. */
  30804. setSize(width: number, height: number): void;
  30805. /**
  30806. * Binds the frame buffer to the specified texture.
  30807. * @param texture The texture to render to or null for the default canvas
  30808. * @param faceIndex The face of the texture to render to in case of cube texture
  30809. * @param requiredWidth The width of the target to render to
  30810. * @param requiredHeight The height of the target to render to
  30811. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30812. * @param depthStencilTexture The depth stencil texture to use to render
  30813. * @param lodLevel defines le lod level to bind to the frame buffer
  30814. */
  30815. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30816. /** @hidden */
  30817. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30818. /**
  30819. * Unbind the current render target texture from the webGL context
  30820. * @param texture defines the render target texture to unbind
  30821. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30822. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30823. */
  30824. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30825. /**
  30826. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30827. */
  30828. flushFramebuffer(): void;
  30829. /**
  30830. * Unbind the current render target and bind the default framebuffer
  30831. */
  30832. restoreDefaultFramebuffer(): void;
  30833. /** @hidden */
  30834. protected _resetVertexBufferBinding(): void;
  30835. /**
  30836. * Creates a vertex buffer
  30837. * @param data the data for the vertex buffer
  30838. * @returns the new WebGL static buffer
  30839. */
  30840. createVertexBuffer(data: DataArray): DataBuffer;
  30841. private _createVertexBuffer;
  30842. /**
  30843. * Creates a dynamic vertex buffer
  30844. * @param data the data for the dynamic vertex buffer
  30845. * @returns the new WebGL dynamic buffer
  30846. */
  30847. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30848. protected _resetIndexBufferBinding(): void;
  30849. /**
  30850. * Creates a new index buffer
  30851. * @param indices defines the content of the index buffer
  30852. * @param updatable defines if the index buffer must be updatable
  30853. * @returns a new webGL buffer
  30854. */
  30855. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30856. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30857. /**
  30858. * Bind a webGL buffer to the webGL context
  30859. * @param buffer defines the buffer to bind
  30860. */
  30861. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30862. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30863. private bindBuffer;
  30864. /**
  30865. * update the bound buffer with the given data
  30866. * @param data defines the data to update
  30867. */
  30868. updateArrayBuffer(data: Float32Array): void;
  30869. private _vertexAttribPointer;
  30870. private _bindIndexBufferWithCache;
  30871. private _bindVertexBuffersAttributes;
  30872. /**
  30873. * Records a vertex array object
  30874. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30875. * @param vertexBuffers defines the list of vertex buffers to store
  30876. * @param indexBuffer defines the index buffer to store
  30877. * @param effect defines the effect to store
  30878. * @returns the new vertex array object
  30879. */
  30880. recordVertexArrayObject(vertexBuffers: {
  30881. [key: string]: VertexBuffer;
  30882. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30883. /**
  30884. * Bind a specific vertex array object
  30885. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30886. * @param vertexArrayObject defines the vertex array object to bind
  30887. * @param indexBuffer defines the index buffer to bind
  30888. */
  30889. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30890. /**
  30891. * Bind webGl buffers directly to the webGL context
  30892. * @param vertexBuffer defines the vertex buffer to bind
  30893. * @param indexBuffer defines the index buffer to bind
  30894. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30895. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30896. * @param effect defines the effect associated with the vertex buffer
  30897. */
  30898. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30899. private _unbindVertexArrayObject;
  30900. /**
  30901. * Bind a list of vertex buffers to the webGL context
  30902. * @param vertexBuffers defines the list of vertex buffers to bind
  30903. * @param indexBuffer defines the index buffer to bind
  30904. * @param effect defines the effect associated with the vertex buffers
  30905. */
  30906. bindBuffers(vertexBuffers: {
  30907. [key: string]: Nullable<VertexBuffer>;
  30908. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30909. /**
  30910. * Unbind all instance attributes
  30911. */
  30912. unbindInstanceAttributes(): void;
  30913. /**
  30914. * Release and free the memory of a vertex array object
  30915. * @param vao defines the vertex array object to delete
  30916. */
  30917. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30918. /** @hidden */
  30919. _releaseBuffer(buffer: DataBuffer): boolean;
  30920. protected _deleteBuffer(buffer: DataBuffer): void;
  30921. /**
  30922. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30923. * @param instancesBuffer defines the webGL buffer to update and bind
  30924. * @param data defines the data to store in the buffer
  30925. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30926. */
  30927. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30928. /**
  30929. * Bind the content of a webGL buffer used with instanciation
  30930. * @param instancesBuffer defines the webGL buffer to bind
  30931. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  30932. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  30933. */
  30934. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  30935. /**
  30936. * Disable the instance attribute corresponding to the name in parameter
  30937. * @param name defines the name of the attribute to disable
  30938. */
  30939. disableInstanceAttributeByName(name: string): void;
  30940. /**
  30941. * Disable the instance attribute corresponding to the location in parameter
  30942. * @param attributeLocation defines the attribute location of the attribute to disable
  30943. */
  30944. disableInstanceAttribute(attributeLocation: number): void;
  30945. /**
  30946. * Disable the attribute corresponding to the location in parameter
  30947. * @param attributeLocation defines the attribute location of the attribute to disable
  30948. */
  30949. disableAttributeByIndex(attributeLocation: number): void;
  30950. /**
  30951. * Send a draw order
  30952. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30953. * @param indexStart defines the starting index
  30954. * @param indexCount defines the number of index to draw
  30955. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30956. */
  30957. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30958. /**
  30959. * Draw a list of points
  30960. * @param verticesStart defines the index of first vertex to draw
  30961. * @param verticesCount defines the count of vertices to draw
  30962. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30963. */
  30964. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30965. /**
  30966. * Draw a list of unindexed primitives
  30967. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30968. * @param verticesStart defines the index of first vertex to draw
  30969. * @param verticesCount defines the count of vertices to draw
  30970. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30971. */
  30972. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30973. /**
  30974. * Draw a list of indexed primitives
  30975. * @param fillMode defines the primitive to use
  30976. * @param indexStart defines the starting index
  30977. * @param indexCount defines the number of index to draw
  30978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30979. */
  30980. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30981. /**
  30982. * Draw a list of unindexed primitives
  30983. * @param fillMode defines the primitive to use
  30984. * @param verticesStart defines the index of first vertex to draw
  30985. * @param verticesCount defines the count of vertices to draw
  30986. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30987. */
  30988. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30989. private _drawMode;
  30990. /** @hidden */
  30991. protected _reportDrawCall(): void;
  30992. /** @hidden */
  30993. _releaseEffect(effect: Effect): void;
  30994. /** @hidden */
  30995. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30996. /**
  30997. * Create a new effect (used to store vertex/fragment shaders)
  30998. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30999. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31000. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31001. * @param samplers defines an array of string used to represent textures
  31002. * @param defines defines the string containing the defines to use to compile the shaders
  31003. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31004. * @param onCompiled defines a function to call when the effect creation is successful
  31005. * @param onError defines a function to call when the effect creation has failed
  31006. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31007. * @returns the new Effect
  31008. */
  31009. 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;
  31010. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31011. private _compileShader;
  31012. private _compileRawShader;
  31013. /**
  31014. * Directly creates a webGL program
  31015. * @param pipelineContext defines the pipeline context to attach to
  31016. * @param vertexCode defines the vertex shader code to use
  31017. * @param fragmentCode defines the fragment shader code to use
  31018. * @param context defines the webGL context to use (if not set, the current one will be used)
  31019. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31020. * @returns the new webGL program
  31021. */
  31022. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31023. /**
  31024. * Creates a webGL program
  31025. * @param pipelineContext defines the pipeline context to attach to
  31026. * @param vertexCode defines the vertex shader code to use
  31027. * @param fragmentCode defines the fragment shader code to use
  31028. * @param defines defines the string containing the defines to use to compile the shaders
  31029. * @param context defines the webGL context to use (if not set, the current one will be used)
  31030. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31031. * @returns the new webGL program
  31032. */
  31033. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31034. /**
  31035. * Creates a new pipeline context
  31036. * @returns the new pipeline
  31037. */
  31038. createPipelineContext(): IPipelineContext;
  31039. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31040. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31041. /** @hidden */
  31042. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31043. /** @hidden */
  31044. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31045. /** @hidden */
  31046. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31047. /**
  31048. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31049. * @param pipelineContext defines the pipeline context to use
  31050. * @param uniformsNames defines the list of uniform names
  31051. * @returns an array of webGL uniform locations
  31052. */
  31053. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31054. /**
  31055. * Gets the lsit of active attributes for a given webGL program
  31056. * @param pipelineContext defines the pipeline context to use
  31057. * @param attributesNames defines the list of attribute names to get
  31058. * @returns an array of indices indicating the offset of each attribute
  31059. */
  31060. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31061. /**
  31062. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31063. * @param effect defines the effect to activate
  31064. */
  31065. enableEffect(effect: Nullable<Effect>): void;
  31066. /**
  31067. * Set the value of an uniform to a number (int)
  31068. * @param uniform defines the webGL uniform location where to store the value
  31069. * @param value defines the int number to store
  31070. */
  31071. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31072. /**
  31073. * Set the value of an uniform to an array of int32
  31074. * @param uniform defines the webGL uniform location where to store the value
  31075. * @param array defines the array of int32 to store
  31076. */
  31077. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31078. /**
  31079. * Set the value of an uniform to an array of int32 (stored as vec2)
  31080. * @param uniform defines the webGL uniform location where to store the value
  31081. * @param array defines the array of int32 to store
  31082. */
  31083. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31084. /**
  31085. * Set the value of an uniform to an array of int32 (stored as vec3)
  31086. * @param uniform defines the webGL uniform location where to store the value
  31087. * @param array defines the array of int32 to store
  31088. */
  31089. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31090. /**
  31091. * Set the value of an uniform to an array of int32 (stored as vec4)
  31092. * @param uniform defines the webGL uniform location where to store the value
  31093. * @param array defines the array of int32 to store
  31094. */
  31095. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31096. /**
  31097. * Set the value of an uniform to an array of number
  31098. * @param uniform defines the webGL uniform location where to store the value
  31099. * @param array defines the array of number to store
  31100. */
  31101. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31102. /**
  31103. * Set the value of an uniform to an array of number (stored as vec2)
  31104. * @param uniform defines the webGL uniform location where to store the value
  31105. * @param array defines the array of number to store
  31106. */
  31107. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31108. /**
  31109. * Set the value of an uniform to an array of number (stored as vec3)
  31110. * @param uniform defines the webGL uniform location where to store the value
  31111. * @param array defines the array of number to store
  31112. */
  31113. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31114. /**
  31115. * Set the value of an uniform to an array of number (stored as vec4)
  31116. * @param uniform defines the webGL uniform location where to store the value
  31117. * @param array defines the array of number to store
  31118. */
  31119. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31120. /**
  31121. * Set the value of an uniform to an array of float32 (stored as matrices)
  31122. * @param uniform defines the webGL uniform location where to store the value
  31123. * @param matrices defines the array of float32 to store
  31124. */
  31125. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31126. /**
  31127. * Set the value of an uniform to a matrix (3x3)
  31128. * @param uniform defines the webGL uniform location where to store the value
  31129. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31130. */
  31131. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31132. /**
  31133. * Set the value of an uniform to a matrix (2x2)
  31134. * @param uniform defines the webGL uniform location where to store the value
  31135. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31136. */
  31137. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31138. /**
  31139. * Set the value of an uniform to a number (float)
  31140. * @param uniform defines the webGL uniform location where to store the value
  31141. * @param value defines the float number to store
  31142. */
  31143. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31144. /**
  31145. * Set the value of an uniform to a vec2
  31146. * @param uniform defines the webGL uniform location where to store the value
  31147. * @param x defines the 1st component of the value
  31148. * @param y defines the 2nd component of the value
  31149. */
  31150. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31151. /**
  31152. * Set the value of an uniform to a vec3
  31153. * @param uniform defines the webGL uniform location where to store the value
  31154. * @param x defines the 1st component of the value
  31155. * @param y defines the 2nd component of the value
  31156. * @param z defines the 3rd component of the value
  31157. */
  31158. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31159. /**
  31160. * Set the value of an uniform to a vec4
  31161. * @param uniform defines the webGL uniform location where to store the value
  31162. * @param x defines the 1st component of the value
  31163. * @param y defines the 2nd component of the value
  31164. * @param z defines the 3rd component of the value
  31165. * @param w defines the 4th component of the value
  31166. */
  31167. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31168. /**
  31169. * Apply all cached states (depth, culling, stencil and alpha)
  31170. */
  31171. applyStates(): void;
  31172. /**
  31173. * Enable or disable color writing
  31174. * @param enable defines the state to set
  31175. */
  31176. setColorWrite(enable: boolean): void;
  31177. /**
  31178. * Gets a boolean indicating if color writing is enabled
  31179. * @returns the current color writing state
  31180. */
  31181. getColorWrite(): boolean;
  31182. /**
  31183. * Gets the depth culling state manager
  31184. */
  31185. readonly depthCullingState: DepthCullingState;
  31186. /**
  31187. * Gets the alpha state manager
  31188. */
  31189. readonly alphaState: AlphaState;
  31190. /**
  31191. * Gets the stencil state manager
  31192. */
  31193. readonly stencilState: StencilState;
  31194. /**
  31195. * Clears the list of texture accessible through engine.
  31196. * This can help preventing texture load conflict due to name collision.
  31197. */
  31198. clearInternalTexturesCache(): void;
  31199. /**
  31200. * Force the entire cache to be cleared
  31201. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31202. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31203. */
  31204. wipeCaches(bruteForce?: boolean): void;
  31205. /** @hidden */
  31206. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31207. min: number;
  31208. mag: number;
  31209. };
  31210. /** @hidden */
  31211. _createTexture(): WebGLTexture;
  31212. /**
  31213. * Usually called from Texture.ts.
  31214. * Passed information to create a WebGLTexture
  31215. * @param urlArg defines a value which contains one of the following:
  31216. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31217. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31218. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31219. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31220. * @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)
  31221. * @param scene needed for loading to the correct scene
  31222. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31223. * @param onLoad optional callback to be called upon successful completion
  31224. * @param onError optional callback to be called upon failure
  31225. * @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
  31226. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31227. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31228. * @param forcedExtension defines the extension to use to pick the right loader
  31229. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31230. * @param mimeType defines an optional mime type
  31231. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31232. */
  31233. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31234. /**
  31235. * @hidden
  31236. */
  31237. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31238. /**
  31239. * Creates a raw texture
  31240. * @param data defines the data to store in the texture
  31241. * @param width defines the width of the texture
  31242. * @param height defines the height of the texture
  31243. * @param format defines the format of the data
  31244. * @param generateMipMaps defines if the engine should generate the mip levels
  31245. * @param invertY defines if data must be stored with Y axis inverted
  31246. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31247. * @param compression defines the compression used (null by default)
  31248. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31249. * @returns the raw texture inside an InternalTexture
  31250. */
  31251. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31252. /**
  31253. * Creates a new raw cube texture
  31254. * @param data defines the array of data to use to create each face
  31255. * @param size defines the size of the textures
  31256. * @param format defines the format of the data
  31257. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31258. * @param generateMipMaps defines if the engine should generate the mip levels
  31259. * @param invertY defines if data must be stored with Y axis inverted
  31260. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31261. * @param compression defines the compression used (null by default)
  31262. * @returns the cube texture as an InternalTexture
  31263. */
  31264. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31265. /**
  31266. * Creates a new raw 3D texture
  31267. * @param data defines the data used to create the texture
  31268. * @param width defines the width of the texture
  31269. * @param height defines the height of the texture
  31270. * @param depth defines the depth of the texture
  31271. * @param format defines the format of the texture
  31272. * @param generateMipMaps defines if the engine must generate mip levels
  31273. * @param invertY defines if data must be stored with Y axis inverted
  31274. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31275. * @param compression defines the compressed used (can be null)
  31276. * @param textureType defines the compressed used (can be null)
  31277. * @returns a new raw 3D texture (stored in an InternalTexture)
  31278. */
  31279. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31280. /**
  31281. * Creates a new raw 2D array texture
  31282. * @param data defines the data used to create the texture
  31283. * @param width defines the width of the texture
  31284. * @param height defines the height of the texture
  31285. * @param depth defines the number of layers of the texture
  31286. * @param format defines the format of the texture
  31287. * @param generateMipMaps defines if the engine must generate mip levels
  31288. * @param invertY defines if data must be stored with Y axis inverted
  31289. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31290. * @param compression defines the compressed used (can be null)
  31291. * @param textureType defines the compressed used (can be null)
  31292. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31293. */
  31294. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31295. private _unpackFlipYCached;
  31296. /**
  31297. * In case you are sharing the context with other applications, it might
  31298. * be interested to not cache the unpack flip y state to ensure a consistent
  31299. * value would be set.
  31300. */
  31301. enableUnpackFlipYCached: boolean;
  31302. /** @hidden */
  31303. _unpackFlipY(value: boolean): void;
  31304. /** @hidden */
  31305. _getUnpackAlignement(): number;
  31306. private _getTextureTarget;
  31307. /**
  31308. * Update the sampling mode of a given texture
  31309. * @param samplingMode defines the required sampling mode
  31310. * @param texture defines the texture to update
  31311. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31312. */
  31313. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31314. /**
  31315. * Update the sampling mode of a given texture
  31316. * @param texture defines the texture to update
  31317. * @param wrapU defines the texture wrap mode of the u coordinates
  31318. * @param wrapV defines the texture wrap mode of the v coordinates
  31319. * @param wrapR defines the texture wrap mode of the r coordinates
  31320. */
  31321. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31322. /** @hidden */
  31323. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31324. width: number;
  31325. height: number;
  31326. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31327. /** @hidden */
  31328. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31329. /** @hidden */
  31330. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31331. /** @hidden */
  31332. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31333. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31334. private _prepareWebGLTexture;
  31335. /** @hidden */
  31336. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31337. private _getDepthStencilBuffer;
  31338. /** @hidden */
  31339. _releaseFramebufferObjects(texture: InternalTexture): void;
  31340. /** @hidden */
  31341. _releaseTexture(texture: InternalTexture): void;
  31342. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31343. protected _setProgram(program: WebGLProgram): void;
  31344. protected _boundUniforms: {
  31345. [key: number]: WebGLUniformLocation;
  31346. };
  31347. /**
  31348. * Binds an effect to the webGL context
  31349. * @param effect defines the effect to bind
  31350. */
  31351. bindSamplers(effect: Effect): void;
  31352. private _activateCurrentTexture;
  31353. /** @hidden */
  31354. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31355. /** @hidden */
  31356. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31357. /**
  31358. * Unbind all textures from the webGL context
  31359. */
  31360. unbindAllTextures(): void;
  31361. /**
  31362. * Sets a texture to the according uniform.
  31363. * @param channel The texture channel
  31364. * @param uniform The uniform to set
  31365. * @param texture The texture to apply
  31366. */
  31367. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31368. private _bindSamplerUniformToChannel;
  31369. private _getTextureWrapMode;
  31370. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31371. /**
  31372. * Sets an array of texture to the webGL context
  31373. * @param channel defines the channel where the texture array must be set
  31374. * @param uniform defines the associated uniform location
  31375. * @param textures defines the array of textures to bind
  31376. */
  31377. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31378. /** @hidden */
  31379. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31380. private _setTextureParameterFloat;
  31381. private _setTextureParameterInteger;
  31382. /**
  31383. * Unbind all vertex attributes from the webGL context
  31384. */
  31385. unbindAllAttributes(): void;
  31386. /**
  31387. * 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
  31388. */
  31389. releaseEffects(): void;
  31390. /**
  31391. * Dispose and release all associated resources
  31392. */
  31393. dispose(): void;
  31394. /**
  31395. * Attach a new callback raised when context lost event is fired
  31396. * @param callback defines the callback to call
  31397. */
  31398. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31399. /**
  31400. * Attach a new callback raised when context restored event is fired
  31401. * @param callback defines the callback to call
  31402. */
  31403. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31404. /**
  31405. * Get the current error code of the webGL context
  31406. * @returns the error code
  31407. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31408. */
  31409. getError(): number;
  31410. private _canRenderToFloatFramebuffer;
  31411. private _canRenderToHalfFloatFramebuffer;
  31412. private _canRenderToFramebuffer;
  31413. /** @hidden */
  31414. _getWebGLTextureType(type: number): number;
  31415. /** @hidden */
  31416. _getInternalFormat(format: number): number;
  31417. /** @hidden */
  31418. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31419. /** @hidden */
  31420. _getRGBAMultiSampleBufferFormat(type: number): number;
  31421. /** @hidden */
  31422. _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;
  31423. /**
  31424. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31425. * @param x defines the x coordinate of the rectangle where pixels must be read
  31426. * @param y defines the y coordinate of the rectangle where pixels must be read
  31427. * @param width defines the width of the rectangle where pixels must be read
  31428. * @param height defines the height of the rectangle where pixels must be read
  31429. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31430. * @returns a Uint8Array containing RGBA colors
  31431. */
  31432. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31433. /**
  31434. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31435. * @returns true if the engine can be created
  31436. * @ignorenaming
  31437. */
  31438. static isSupported(): boolean;
  31439. /**
  31440. * Find the next highest power of two.
  31441. * @param x Number to start search from.
  31442. * @return Next highest power of two.
  31443. */
  31444. static CeilingPOT(x: number): number;
  31445. /**
  31446. * Find the next lowest power of two.
  31447. * @param x Number to start search from.
  31448. * @return Next lowest power of two.
  31449. */
  31450. static FloorPOT(x: number): number;
  31451. /**
  31452. * Find the nearest power of two.
  31453. * @param x Number to start search from.
  31454. * @return Next nearest power of two.
  31455. */
  31456. static NearestPOT(x: number): number;
  31457. /**
  31458. * Get the closest exponent of two
  31459. * @param value defines the value to approximate
  31460. * @param max defines the maximum value to return
  31461. * @param mode defines how to define the closest value
  31462. * @returns closest exponent of two of the given value
  31463. */
  31464. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31465. /**
  31466. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31467. * @param func - the function to be called
  31468. * @param requester - the object that will request the next frame. Falls back to window.
  31469. * @returns frame number
  31470. */
  31471. static QueueNewFrame(func: () => void, requester?: any): number;
  31472. /**
  31473. * Gets host document
  31474. * @returns the host document object
  31475. */
  31476. getHostDocument(): Document;
  31477. }
  31478. }
  31479. declare module BABYLON {
  31480. /**
  31481. * Class representing spherical harmonics coefficients to the 3rd degree
  31482. */
  31483. export class SphericalHarmonics {
  31484. /**
  31485. * Defines whether or not the harmonics have been prescaled for rendering.
  31486. */
  31487. preScaled: boolean;
  31488. /**
  31489. * The l0,0 coefficients of the spherical harmonics
  31490. */
  31491. l00: Vector3;
  31492. /**
  31493. * The l1,-1 coefficients of the spherical harmonics
  31494. */
  31495. l1_1: Vector3;
  31496. /**
  31497. * The l1,0 coefficients of the spherical harmonics
  31498. */
  31499. l10: Vector3;
  31500. /**
  31501. * The l1,1 coefficients of the spherical harmonics
  31502. */
  31503. l11: Vector3;
  31504. /**
  31505. * The l2,-2 coefficients of the spherical harmonics
  31506. */
  31507. l2_2: Vector3;
  31508. /**
  31509. * The l2,-1 coefficients of the spherical harmonics
  31510. */
  31511. l2_1: Vector3;
  31512. /**
  31513. * The l2,0 coefficients of the spherical harmonics
  31514. */
  31515. l20: Vector3;
  31516. /**
  31517. * The l2,1 coefficients of the spherical harmonics
  31518. */
  31519. l21: Vector3;
  31520. /**
  31521. * The l2,2 coefficients of the spherical harmonics
  31522. */
  31523. l22: Vector3;
  31524. /**
  31525. * Adds a light to the spherical harmonics
  31526. * @param direction the direction of the light
  31527. * @param color the color of the light
  31528. * @param deltaSolidAngle the delta solid angle of the light
  31529. */
  31530. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31531. /**
  31532. * Scales the spherical harmonics by the given amount
  31533. * @param scale the amount to scale
  31534. */
  31535. scaleInPlace(scale: number): void;
  31536. /**
  31537. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31538. *
  31539. * ```
  31540. * E_lm = A_l * L_lm
  31541. * ```
  31542. *
  31543. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31544. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31545. * the scaling factors are given in equation 9.
  31546. */
  31547. convertIncidentRadianceToIrradiance(): void;
  31548. /**
  31549. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31550. *
  31551. * ```
  31552. * L = (1/pi) * E * rho
  31553. * ```
  31554. *
  31555. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31556. */
  31557. convertIrradianceToLambertianRadiance(): void;
  31558. /**
  31559. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31560. * required operations at run time.
  31561. *
  31562. * This is simply done by scaling back the SH with Ylm constants parameter.
  31563. * The trigonometric part being applied by the shader at run time.
  31564. */
  31565. preScaleForRendering(): void;
  31566. /**
  31567. * Constructs a spherical harmonics from an array.
  31568. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31569. * @returns the spherical harmonics
  31570. */
  31571. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31572. /**
  31573. * Gets the spherical harmonics from polynomial
  31574. * @param polynomial the spherical polynomial
  31575. * @returns the spherical harmonics
  31576. */
  31577. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31578. }
  31579. /**
  31580. * Class representing spherical polynomial coefficients to the 3rd degree
  31581. */
  31582. export class SphericalPolynomial {
  31583. private _harmonics;
  31584. /**
  31585. * The spherical harmonics used to create the polynomials.
  31586. */
  31587. readonly preScaledHarmonics: SphericalHarmonics;
  31588. /**
  31589. * The x coefficients of the spherical polynomial
  31590. */
  31591. x: Vector3;
  31592. /**
  31593. * The y coefficients of the spherical polynomial
  31594. */
  31595. y: Vector3;
  31596. /**
  31597. * The z coefficients of the spherical polynomial
  31598. */
  31599. z: Vector3;
  31600. /**
  31601. * The xx coefficients of the spherical polynomial
  31602. */
  31603. xx: Vector3;
  31604. /**
  31605. * The yy coefficients of the spherical polynomial
  31606. */
  31607. yy: Vector3;
  31608. /**
  31609. * The zz coefficients of the spherical polynomial
  31610. */
  31611. zz: Vector3;
  31612. /**
  31613. * The xy coefficients of the spherical polynomial
  31614. */
  31615. xy: Vector3;
  31616. /**
  31617. * The yz coefficients of the spherical polynomial
  31618. */
  31619. yz: Vector3;
  31620. /**
  31621. * The zx coefficients of the spherical polynomial
  31622. */
  31623. zx: Vector3;
  31624. /**
  31625. * Adds an ambient color to the spherical polynomial
  31626. * @param color the color to add
  31627. */
  31628. addAmbient(color: Color3): void;
  31629. /**
  31630. * Scales the spherical polynomial by the given amount
  31631. * @param scale the amount to scale
  31632. */
  31633. scaleInPlace(scale: number): void;
  31634. /**
  31635. * Gets the spherical polynomial from harmonics
  31636. * @param harmonics the spherical harmonics
  31637. * @returns the spherical polynomial
  31638. */
  31639. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31640. /**
  31641. * Constructs a spherical polynomial from an array.
  31642. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31643. * @returns the spherical polynomial
  31644. */
  31645. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31646. }
  31647. }
  31648. declare module BABYLON {
  31649. /**
  31650. * Defines the source of the internal texture
  31651. */
  31652. export enum InternalTextureSource {
  31653. /**
  31654. * The source of the texture data is unknown
  31655. */
  31656. Unknown = 0,
  31657. /**
  31658. * Texture data comes from an URL
  31659. */
  31660. Url = 1,
  31661. /**
  31662. * Texture data is only used for temporary storage
  31663. */
  31664. Temp = 2,
  31665. /**
  31666. * Texture data comes from raw data (ArrayBuffer)
  31667. */
  31668. Raw = 3,
  31669. /**
  31670. * Texture content is dynamic (video or dynamic texture)
  31671. */
  31672. Dynamic = 4,
  31673. /**
  31674. * Texture content is generated by rendering to it
  31675. */
  31676. RenderTarget = 5,
  31677. /**
  31678. * Texture content is part of a multi render target process
  31679. */
  31680. MultiRenderTarget = 6,
  31681. /**
  31682. * Texture data comes from a cube data file
  31683. */
  31684. Cube = 7,
  31685. /**
  31686. * Texture data comes from a raw cube data
  31687. */
  31688. CubeRaw = 8,
  31689. /**
  31690. * Texture data come from a prefiltered cube data file
  31691. */
  31692. CubePrefiltered = 9,
  31693. /**
  31694. * Texture content is raw 3D data
  31695. */
  31696. Raw3D = 10,
  31697. /**
  31698. * Texture content is raw 2D array data
  31699. */
  31700. Raw2DArray = 11,
  31701. /**
  31702. * Texture content is a depth texture
  31703. */
  31704. Depth = 12,
  31705. /**
  31706. * Texture data comes from a raw cube data encoded with RGBD
  31707. */
  31708. CubeRawRGBD = 13
  31709. }
  31710. /**
  31711. * Class used to store data associated with WebGL texture data for the engine
  31712. * This class should not be used directly
  31713. */
  31714. export class InternalTexture {
  31715. /** @hidden */
  31716. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31717. /**
  31718. * Defines if the texture is ready
  31719. */
  31720. isReady: boolean;
  31721. /**
  31722. * Defines if the texture is a cube texture
  31723. */
  31724. isCube: boolean;
  31725. /**
  31726. * Defines if the texture contains 3D data
  31727. */
  31728. is3D: boolean;
  31729. /**
  31730. * Defines if the texture contains 2D array data
  31731. */
  31732. is2DArray: boolean;
  31733. /**
  31734. * Defines if the texture contains multiview data
  31735. */
  31736. isMultiview: boolean;
  31737. /**
  31738. * Gets the URL used to load this texture
  31739. */
  31740. url: string;
  31741. /**
  31742. * Gets the sampling mode of the texture
  31743. */
  31744. samplingMode: number;
  31745. /**
  31746. * Gets a boolean indicating if the texture needs mipmaps generation
  31747. */
  31748. generateMipMaps: boolean;
  31749. /**
  31750. * Gets the number of samples used by the texture (WebGL2+ only)
  31751. */
  31752. samples: number;
  31753. /**
  31754. * Gets the type of the texture (int, float...)
  31755. */
  31756. type: number;
  31757. /**
  31758. * Gets the format of the texture (RGB, RGBA...)
  31759. */
  31760. format: number;
  31761. /**
  31762. * Observable called when the texture is loaded
  31763. */
  31764. onLoadedObservable: Observable<InternalTexture>;
  31765. /**
  31766. * Gets the width of the texture
  31767. */
  31768. width: number;
  31769. /**
  31770. * Gets the height of the texture
  31771. */
  31772. height: number;
  31773. /**
  31774. * Gets the depth of the texture
  31775. */
  31776. depth: number;
  31777. /**
  31778. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31779. */
  31780. baseWidth: number;
  31781. /**
  31782. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31783. */
  31784. baseHeight: number;
  31785. /**
  31786. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31787. */
  31788. baseDepth: number;
  31789. /**
  31790. * Gets a boolean indicating if the texture is inverted on Y axis
  31791. */
  31792. invertY: boolean;
  31793. /** @hidden */
  31794. _invertVScale: boolean;
  31795. /** @hidden */
  31796. _associatedChannel: number;
  31797. /** @hidden */
  31798. _source: InternalTextureSource;
  31799. /** @hidden */
  31800. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31801. /** @hidden */
  31802. _bufferView: Nullable<ArrayBufferView>;
  31803. /** @hidden */
  31804. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31805. /** @hidden */
  31806. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31807. /** @hidden */
  31808. _size: number;
  31809. /** @hidden */
  31810. _extension: string;
  31811. /** @hidden */
  31812. _files: Nullable<string[]>;
  31813. /** @hidden */
  31814. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31815. /** @hidden */
  31816. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31817. /** @hidden */
  31818. _framebuffer: Nullable<WebGLFramebuffer>;
  31819. /** @hidden */
  31820. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31821. /** @hidden */
  31822. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31823. /** @hidden */
  31824. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31825. /** @hidden */
  31826. _attachments: Nullable<number[]>;
  31827. /** @hidden */
  31828. _cachedCoordinatesMode: Nullable<number>;
  31829. /** @hidden */
  31830. _cachedWrapU: Nullable<number>;
  31831. /** @hidden */
  31832. _cachedWrapV: Nullable<number>;
  31833. /** @hidden */
  31834. _cachedWrapR: Nullable<number>;
  31835. /** @hidden */
  31836. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31837. /** @hidden */
  31838. _isDisabled: boolean;
  31839. /** @hidden */
  31840. _compression: Nullable<string>;
  31841. /** @hidden */
  31842. _generateStencilBuffer: boolean;
  31843. /** @hidden */
  31844. _generateDepthBuffer: boolean;
  31845. /** @hidden */
  31846. _comparisonFunction: number;
  31847. /** @hidden */
  31848. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31849. /** @hidden */
  31850. _lodGenerationScale: number;
  31851. /** @hidden */
  31852. _lodGenerationOffset: number;
  31853. /** @hidden */
  31854. _colorTextureArray: Nullable<WebGLTexture>;
  31855. /** @hidden */
  31856. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31857. /** @hidden */
  31858. _lodTextureHigh: Nullable<BaseTexture>;
  31859. /** @hidden */
  31860. _lodTextureMid: Nullable<BaseTexture>;
  31861. /** @hidden */
  31862. _lodTextureLow: Nullable<BaseTexture>;
  31863. /** @hidden */
  31864. _isRGBD: boolean;
  31865. /** @hidden */
  31866. _linearSpecularLOD: boolean;
  31867. /** @hidden */
  31868. _irradianceTexture: Nullable<BaseTexture>;
  31869. /** @hidden */
  31870. _webGLTexture: Nullable<WebGLTexture>;
  31871. /** @hidden */
  31872. _references: number;
  31873. private _engine;
  31874. /**
  31875. * Gets the Engine the texture belongs to.
  31876. * @returns The babylon engine
  31877. */
  31878. getEngine(): ThinEngine;
  31879. /**
  31880. * Gets the data source type of the texture
  31881. */
  31882. readonly source: InternalTextureSource;
  31883. /**
  31884. * Creates a new InternalTexture
  31885. * @param engine defines the engine to use
  31886. * @param source defines the type of data that will be used
  31887. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31888. */
  31889. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31890. /**
  31891. * Increments the number of references (ie. the number of Texture that point to it)
  31892. */
  31893. incrementReferences(): void;
  31894. /**
  31895. * Change the size of the texture (not the size of the content)
  31896. * @param width defines the new width
  31897. * @param height defines the new height
  31898. * @param depth defines the new depth (1 by default)
  31899. */
  31900. updateSize(width: int, height: int, depth?: int): void;
  31901. /** @hidden */
  31902. _rebuild(): void;
  31903. /** @hidden */
  31904. _swapAndDie(target: InternalTexture): void;
  31905. /**
  31906. * Dispose the current allocated resources
  31907. */
  31908. dispose(): void;
  31909. }
  31910. }
  31911. declare module BABYLON {
  31912. /**
  31913. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31915. */
  31916. export class Analyser {
  31917. /**
  31918. * Gets or sets the smoothing
  31919. * @ignorenaming
  31920. */
  31921. SMOOTHING: number;
  31922. /**
  31923. * Gets or sets the FFT table size
  31924. * @ignorenaming
  31925. */
  31926. FFT_SIZE: number;
  31927. /**
  31928. * Gets or sets the bar graph amplitude
  31929. * @ignorenaming
  31930. */
  31931. BARGRAPHAMPLITUDE: number;
  31932. /**
  31933. * Gets or sets the position of the debug canvas
  31934. * @ignorenaming
  31935. */
  31936. DEBUGCANVASPOS: {
  31937. x: number;
  31938. y: number;
  31939. };
  31940. /**
  31941. * Gets or sets the debug canvas size
  31942. * @ignorenaming
  31943. */
  31944. DEBUGCANVASSIZE: {
  31945. width: number;
  31946. height: number;
  31947. };
  31948. private _byteFreqs;
  31949. private _byteTime;
  31950. private _floatFreqs;
  31951. private _webAudioAnalyser;
  31952. private _debugCanvas;
  31953. private _debugCanvasContext;
  31954. private _scene;
  31955. private _registerFunc;
  31956. private _audioEngine;
  31957. /**
  31958. * Creates a new analyser
  31959. * @param scene defines hosting scene
  31960. */
  31961. constructor(scene: Scene);
  31962. /**
  31963. * Get the number of data values you will have to play with for the visualization
  31964. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31965. * @returns a number
  31966. */
  31967. getFrequencyBinCount(): number;
  31968. /**
  31969. * Gets the current frequency data as a byte array
  31970. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31971. * @returns a Uint8Array
  31972. */
  31973. getByteFrequencyData(): Uint8Array;
  31974. /**
  31975. * Gets the current waveform as a byte array
  31976. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31977. * @returns a Uint8Array
  31978. */
  31979. getByteTimeDomainData(): Uint8Array;
  31980. /**
  31981. * Gets the current frequency data as a float array
  31982. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31983. * @returns a Float32Array
  31984. */
  31985. getFloatFrequencyData(): Float32Array;
  31986. /**
  31987. * Renders the debug canvas
  31988. */
  31989. drawDebugCanvas(): void;
  31990. /**
  31991. * Stops rendering the debug canvas and removes it
  31992. */
  31993. stopDebugCanvas(): void;
  31994. /**
  31995. * Connects two audio nodes
  31996. * @param inputAudioNode defines first node to connect
  31997. * @param outputAudioNode defines second node to connect
  31998. */
  31999. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32000. /**
  32001. * Releases all associated resources
  32002. */
  32003. dispose(): void;
  32004. }
  32005. }
  32006. declare module BABYLON {
  32007. /**
  32008. * This represents an audio engine and it is responsible
  32009. * to play, synchronize and analyse sounds throughout the application.
  32010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32011. */
  32012. export interface IAudioEngine extends IDisposable {
  32013. /**
  32014. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32015. */
  32016. readonly canUseWebAudio: boolean;
  32017. /**
  32018. * Gets the current AudioContext if available.
  32019. */
  32020. readonly audioContext: Nullable<AudioContext>;
  32021. /**
  32022. * The master gain node defines the global audio volume of your audio engine.
  32023. */
  32024. readonly masterGain: GainNode;
  32025. /**
  32026. * Gets whether or not mp3 are supported by your browser.
  32027. */
  32028. readonly isMP3supported: boolean;
  32029. /**
  32030. * Gets whether or not ogg are supported by your browser.
  32031. */
  32032. readonly isOGGsupported: boolean;
  32033. /**
  32034. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32035. * @ignoreNaming
  32036. */
  32037. WarnedWebAudioUnsupported: boolean;
  32038. /**
  32039. * Defines if the audio engine relies on a custom unlocked button.
  32040. * In this case, the embedded button will not be displayed.
  32041. */
  32042. useCustomUnlockedButton: boolean;
  32043. /**
  32044. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32045. */
  32046. readonly unlocked: boolean;
  32047. /**
  32048. * Event raised when audio has been unlocked on the browser.
  32049. */
  32050. onAudioUnlockedObservable: Observable<AudioEngine>;
  32051. /**
  32052. * Event raised when audio has been locked on the browser.
  32053. */
  32054. onAudioLockedObservable: Observable<AudioEngine>;
  32055. /**
  32056. * Flags the audio engine in Locked state.
  32057. * This happens due to new browser policies preventing audio to autoplay.
  32058. */
  32059. lock(): void;
  32060. /**
  32061. * Unlocks the audio engine once a user action has been done on the dom.
  32062. * This is helpful to resume play once browser policies have been satisfied.
  32063. */
  32064. unlock(): void;
  32065. }
  32066. /**
  32067. * This represents the default audio engine used in babylon.
  32068. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32070. */
  32071. export class AudioEngine implements IAudioEngine {
  32072. private _audioContext;
  32073. private _audioContextInitialized;
  32074. private _muteButton;
  32075. private _hostElement;
  32076. /**
  32077. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32078. */
  32079. canUseWebAudio: boolean;
  32080. /**
  32081. * The master gain node defines the global audio volume of your audio engine.
  32082. */
  32083. masterGain: GainNode;
  32084. /**
  32085. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32086. * @ignoreNaming
  32087. */
  32088. WarnedWebAudioUnsupported: boolean;
  32089. /**
  32090. * Gets whether or not mp3 are supported by your browser.
  32091. */
  32092. isMP3supported: boolean;
  32093. /**
  32094. * Gets whether or not ogg are supported by your browser.
  32095. */
  32096. isOGGsupported: boolean;
  32097. /**
  32098. * Gets whether audio has been unlocked on the device.
  32099. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32100. * a user interaction has happened.
  32101. */
  32102. unlocked: boolean;
  32103. /**
  32104. * Defines if the audio engine relies on a custom unlocked button.
  32105. * In this case, the embedded button will not be displayed.
  32106. */
  32107. useCustomUnlockedButton: boolean;
  32108. /**
  32109. * Event raised when audio has been unlocked on the browser.
  32110. */
  32111. onAudioUnlockedObservable: Observable<AudioEngine>;
  32112. /**
  32113. * Event raised when audio has been locked on the browser.
  32114. */
  32115. onAudioLockedObservable: Observable<AudioEngine>;
  32116. /**
  32117. * Gets the current AudioContext if available.
  32118. */
  32119. readonly audioContext: Nullable<AudioContext>;
  32120. private _connectedAnalyser;
  32121. /**
  32122. * Instantiates a new audio engine.
  32123. *
  32124. * There should be only one per page as some browsers restrict the number
  32125. * of audio contexts you can create.
  32126. * @param hostElement defines the host element where to display the mute icon if necessary
  32127. */
  32128. constructor(hostElement?: Nullable<HTMLElement>);
  32129. /**
  32130. * Flags the audio engine in Locked state.
  32131. * This happens due to new browser policies preventing audio to autoplay.
  32132. */
  32133. lock(): void;
  32134. /**
  32135. * Unlocks the audio engine once a user action has been done on the dom.
  32136. * This is helpful to resume play once browser policies have been satisfied.
  32137. */
  32138. unlock(): void;
  32139. private _resumeAudioContext;
  32140. private _initializeAudioContext;
  32141. private _tryToRun;
  32142. private _triggerRunningState;
  32143. private _triggerSuspendedState;
  32144. private _displayMuteButton;
  32145. private _moveButtonToTopLeft;
  32146. private _onResize;
  32147. private _hideMuteButton;
  32148. /**
  32149. * Destroy and release the resources associated with the audio ccontext.
  32150. */
  32151. dispose(): void;
  32152. /**
  32153. * Gets the global volume sets on the master gain.
  32154. * @returns the global volume if set or -1 otherwise
  32155. */
  32156. getGlobalVolume(): number;
  32157. /**
  32158. * Sets the global volume of your experience (sets on the master gain).
  32159. * @param newVolume Defines the new global volume of the application
  32160. */
  32161. setGlobalVolume(newVolume: number): void;
  32162. /**
  32163. * Connect the audio engine to an audio analyser allowing some amazing
  32164. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32166. * @param analyser The analyser to connect to the engine
  32167. */
  32168. connectToAnalyser(analyser: Analyser): void;
  32169. }
  32170. }
  32171. declare module BABYLON {
  32172. /**
  32173. * Interface used to present a loading screen while loading a scene
  32174. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32175. */
  32176. export interface ILoadingScreen {
  32177. /**
  32178. * Function called to display the loading screen
  32179. */
  32180. displayLoadingUI: () => void;
  32181. /**
  32182. * Function called to hide the loading screen
  32183. */
  32184. hideLoadingUI: () => void;
  32185. /**
  32186. * Gets or sets the color to use for the background
  32187. */
  32188. loadingUIBackgroundColor: string;
  32189. /**
  32190. * Gets or sets the text to display while loading
  32191. */
  32192. loadingUIText: string;
  32193. }
  32194. /**
  32195. * Class used for the default loading screen
  32196. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32197. */
  32198. export class DefaultLoadingScreen implements ILoadingScreen {
  32199. private _renderingCanvas;
  32200. private _loadingText;
  32201. private _loadingDivBackgroundColor;
  32202. private _loadingDiv;
  32203. private _loadingTextDiv;
  32204. /** Gets or sets the logo url to use for the default loading screen */
  32205. static DefaultLogoUrl: string;
  32206. /** Gets or sets the spinner url to use for the default loading screen */
  32207. static DefaultSpinnerUrl: string;
  32208. /**
  32209. * Creates a new default loading screen
  32210. * @param _renderingCanvas defines the canvas used to render the scene
  32211. * @param _loadingText defines the default text to display
  32212. * @param _loadingDivBackgroundColor defines the default background color
  32213. */
  32214. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32215. /**
  32216. * Function called to display the loading screen
  32217. */
  32218. displayLoadingUI(): void;
  32219. /**
  32220. * Function called to hide the loading screen
  32221. */
  32222. hideLoadingUI(): void;
  32223. /**
  32224. * Gets or sets the text to display while loading
  32225. */
  32226. loadingUIText: string;
  32227. /**
  32228. * Gets or sets the color to use for the background
  32229. */
  32230. loadingUIBackgroundColor: string;
  32231. private _resizeLoadingUI;
  32232. }
  32233. }
  32234. declare module BABYLON {
  32235. /**
  32236. * Interface for any object that can request an animation frame
  32237. */
  32238. export interface ICustomAnimationFrameRequester {
  32239. /**
  32240. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32241. */
  32242. renderFunction?: Function;
  32243. /**
  32244. * Called to request the next frame to render to
  32245. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32246. */
  32247. requestAnimationFrame: Function;
  32248. /**
  32249. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32250. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32251. */
  32252. requestID?: number;
  32253. }
  32254. }
  32255. declare module BABYLON {
  32256. /**
  32257. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32258. */
  32259. export class PerformanceMonitor {
  32260. private _enabled;
  32261. private _rollingFrameTime;
  32262. private _lastFrameTimeMs;
  32263. /**
  32264. * constructor
  32265. * @param frameSampleSize The number of samples required to saturate the sliding window
  32266. */
  32267. constructor(frameSampleSize?: number);
  32268. /**
  32269. * Samples current frame
  32270. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32271. */
  32272. sampleFrame(timeMs?: number): void;
  32273. /**
  32274. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32275. */
  32276. readonly averageFrameTime: number;
  32277. /**
  32278. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32279. */
  32280. readonly averageFrameTimeVariance: number;
  32281. /**
  32282. * Returns the frame time of the most recent frame
  32283. */
  32284. readonly instantaneousFrameTime: number;
  32285. /**
  32286. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32287. */
  32288. readonly averageFPS: number;
  32289. /**
  32290. * Returns the average framerate in frames per second using the most recent frame time
  32291. */
  32292. readonly instantaneousFPS: number;
  32293. /**
  32294. * Returns true if enough samples have been taken to completely fill the sliding window
  32295. */
  32296. readonly isSaturated: boolean;
  32297. /**
  32298. * Enables contributions to the sliding window sample set
  32299. */
  32300. enable(): void;
  32301. /**
  32302. * Disables contributions to the sliding window sample set
  32303. * Samples will not be interpolated over the disabled period
  32304. */
  32305. disable(): void;
  32306. /**
  32307. * Returns true if sampling is enabled
  32308. */
  32309. readonly isEnabled: boolean;
  32310. /**
  32311. * Resets performance monitor
  32312. */
  32313. reset(): void;
  32314. }
  32315. /**
  32316. * RollingAverage
  32317. *
  32318. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32319. */
  32320. export class RollingAverage {
  32321. /**
  32322. * Current average
  32323. */
  32324. average: number;
  32325. /**
  32326. * Current variance
  32327. */
  32328. variance: number;
  32329. protected _samples: Array<number>;
  32330. protected _sampleCount: number;
  32331. protected _pos: number;
  32332. protected _m2: number;
  32333. /**
  32334. * constructor
  32335. * @param length The number of samples required to saturate the sliding window
  32336. */
  32337. constructor(length: number);
  32338. /**
  32339. * Adds a sample to the sample set
  32340. * @param v The sample value
  32341. */
  32342. add(v: number): void;
  32343. /**
  32344. * Returns previously added values or null if outside of history or outside the sliding window domain
  32345. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32346. * @return Value previously recorded with add() or null if outside of range
  32347. */
  32348. history(i: number): number;
  32349. /**
  32350. * Returns true if enough samples have been taken to completely fill the sliding window
  32351. * @return true if sample-set saturated
  32352. */
  32353. isSaturated(): boolean;
  32354. /**
  32355. * Resets the rolling average (equivalent to 0 samples taken so far)
  32356. */
  32357. reset(): void;
  32358. /**
  32359. * Wraps a value around the sample range boundaries
  32360. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32361. * @return Wrapped position in sample range
  32362. */
  32363. protected _wrapPosition(i: number): number;
  32364. }
  32365. }
  32366. declare module BABYLON {
  32367. /**
  32368. * This class is used to track a performance counter which is number based.
  32369. * The user has access to many properties which give statistics of different nature.
  32370. *
  32371. * The implementer can track two kinds of Performance Counter: time and count.
  32372. * 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.
  32373. * 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.
  32374. */
  32375. export class PerfCounter {
  32376. /**
  32377. * Gets or sets a global boolean to turn on and off all the counters
  32378. */
  32379. static Enabled: boolean;
  32380. /**
  32381. * Returns the smallest value ever
  32382. */
  32383. readonly min: number;
  32384. /**
  32385. * Returns the biggest value ever
  32386. */
  32387. readonly max: number;
  32388. /**
  32389. * Returns the average value since the performance counter is running
  32390. */
  32391. readonly average: number;
  32392. /**
  32393. * Returns the average value of the last second the counter was monitored
  32394. */
  32395. readonly lastSecAverage: number;
  32396. /**
  32397. * Returns the current value
  32398. */
  32399. readonly current: number;
  32400. /**
  32401. * Gets the accumulated total
  32402. */
  32403. readonly total: number;
  32404. /**
  32405. * Gets the total value count
  32406. */
  32407. readonly count: number;
  32408. /**
  32409. * Creates a new counter
  32410. */
  32411. constructor();
  32412. /**
  32413. * Call this method to start monitoring a new frame.
  32414. * 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.
  32415. */
  32416. fetchNewFrame(): void;
  32417. /**
  32418. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32419. * @param newCount the count value to add to the monitored count
  32420. * @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.
  32421. */
  32422. addCount(newCount: number, fetchResult: boolean): void;
  32423. /**
  32424. * Start monitoring this performance counter
  32425. */
  32426. beginMonitoring(): void;
  32427. /**
  32428. * Compute the time lapsed since the previous beginMonitoring() call.
  32429. * @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
  32430. */
  32431. endMonitoring(newFrame?: boolean): void;
  32432. private _fetchResult;
  32433. private _startMonitoringTime;
  32434. private _min;
  32435. private _max;
  32436. private _average;
  32437. private _current;
  32438. private _totalValueCount;
  32439. private _totalAccumulated;
  32440. private _lastSecAverage;
  32441. private _lastSecAccumulated;
  32442. private _lastSecTime;
  32443. private _lastSecValueCount;
  32444. }
  32445. }
  32446. declare module BABYLON {
  32447. interface ThinEngine {
  32448. /**
  32449. * Sets alpha constants used by some alpha blending modes
  32450. * @param r defines the red component
  32451. * @param g defines the green component
  32452. * @param b defines the blue component
  32453. * @param a defines the alpha component
  32454. */
  32455. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32456. /**
  32457. * Sets the current alpha mode
  32458. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32459. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32460. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32461. */
  32462. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32463. /**
  32464. * Gets the current alpha mode
  32465. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32466. * @returns the current alpha mode
  32467. */
  32468. getAlphaMode(): number;
  32469. /**
  32470. * Sets the current alpha equation
  32471. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32472. */
  32473. setAlphaEquation(equation: number): void;
  32474. /**
  32475. * Gets the current alpha equation.
  32476. * @returns the current alpha equation
  32477. */
  32478. getAlphaEquation(): number;
  32479. }
  32480. }
  32481. declare module BABYLON {
  32482. /**
  32483. * Defines the interface used by display changed events
  32484. */
  32485. export interface IDisplayChangedEventArgs {
  32486. /** Gets the vrDisplay object (if any) */
  32487. vrDisplay: Nullable<any>;
  32488. /** Gets a boolean indicating if webVR is supported */
  32489. vrSupported: boolean;
  32490. }
  32491. /**
  32492. * Defines the interface used by objects containing a viewport (like a camera)
  32493. */
  32494. interface IViewportOwnerLike {
  32495. /**
  32496. * Gets or sets the viewport
  32497. */
  32498. viewport: IViewportLike;
  32499. }
  32500. /**
  32501. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32502. */
  32503. export class Engine extends ThinEngine {
  32504. /** Defines that alpha blending is disabled */
  32505. static readonly ALPHA_DISABLE: number;
  32506. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32507. static readonly ALPHA_ADD: number;
  32508. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32509. static readonly ALPHA_COMBINE: number;
  32510. /** Defines that alpha blending to DEST - SRC * DEST */
  32511. static readonly ALPHA_SUBTRACT: number;
  32512. /** Defines that alpha blending to SRC * DEST */
  32513. static readonly ALPHA_MULTIPLY: number;
  32514. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32515. static readonly ALPHA_MAXIMIZED: number;
  32516. /** Defines that alpha blending to SRC + DEST */
  32517. static readonly ALPHA_ONEONE: number;
  32518. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32519. static readonly ALPHA_PREMULTIPLIED: number;
  32520. /**
  32521. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32522. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32523. */
  32524. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32525. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32526. static readonly ALPHA_INTERPOLATE: number;
  32527. /**
  32528. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32529. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32530. */
  32531. static readonly ALPHA_SCREENMODE: number;
  32532. /** Defines that the ressource is not delayed*/
  32533. static readonly DELAYLOADSTATE_NONE: number;
  32534. /** Defines that the ressource was successfully delay loaded */
  32535. static readonly DELAYLOADSTATE_LOADED: number;
  32536. /** Defines that the ressource is currently delay loading */
  32537. static readonly DELAYLOADSTATE_LOADING: number;
  32538. /** Defines that the ressource is delayed and has not started loading */
  32539. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32540. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32541. static readonly NEVER: number;
  32542. /** 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 */
  32543. static readonly ALWAYS: number;
  32544. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32545. static readonly LESS: number;
  32546. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32547. static readonly EQUAL: number;
  32548. /** 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 */
  32549. static readonly LEQUAL: number;
  32550. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32551. static readonly GREATER: number;
  32552. /** 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 */
  32553. static readonly GEQUAL: number;
  32554. /** 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 */
  32555. static readonly NOTEQUAL: number;
  32556. /** Passed to stencilOperation to specify that stencil value must be kept */
  32557. static readonly KEEP: number;
  32558. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32559. static readonly REPLACE: number;
  32560. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32561. static readonly INCR: number;
  32562. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32563. static readonly DECR: number;
  32564. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32565. static readonly INVERT: number;
  32566. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32567. static readonly INCR_WRAP: number;
  32568. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32569. static readonly DECR_WRAP: number;
  32570. /** Texture is not repeating outside of 0..1 UVs */
  32571. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32572. /** Texture is repeating outside of 0..1 UVs */
  32573. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32574. /** Texture is repeating and mirrored */
  32575. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32576. /** ALPHA */
  32577. static readonly TEXTUREFORMAT_ALPHA: number;
  32578. /** LUMINANCE */
  32579. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32580. /** LUMINANCE_ALPHA */
  32581. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32582. /** RGB */
  32583. static readonly TEXTUREFORMAT_RGB: number;
  32584. /** RGBA */
  32585. static readonly TEXTUREFORMAT_RGBA: number;
  32586. /** RED */
  32587. static readonly TEXTUREFORMAT_RED: number;
  32588. /** RED (2nd reference) */
  32589. static readonly TEXTUREFORMAT_R: number;
  32590. /** RG */
  32591. static readonly TEXTUREFORMAT_RG: number;
  32592. /** RED_INTEGER */
  32593. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32594. /** RED_INTEGER (2nd reference) */
  32595. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32596. /** RG_INTEGER */
  32597. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32598. /** RGB_INTEGER */
  32599. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32600. /** RGBA_INTEGER */
  32601. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32602. /** UNSIGNED_BYTE */
  32603. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32604. /** UNSIGNED_BYTE (2nd reference) */
  32605. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32606. /** FLOAT */
  32607. static readonly TEXTURETYPE_FLOAT: number;
  32608. /** HALF_FLOAT */
  32609. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32610. /** BYTE */
  32611. static readonly TEXTURETYPE_BYTE: number;
  32612. /** SHORT */
  32613. static readonly TEXTURETYPE_SHORT: number;
  32614. /** UNSIGNED_SHORT */
  32615. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32616. /** INT */
  32617. static readonly TEXTURETYPE_INT: number;
  32618. /** UNSIGNED_INT */
  32619. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32620. /** UNSIGNED_SHORT_4_4_4_4 */
  32621. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32622. /** UNSIGNED_SHORT_5_5_5_1 */
  32623. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32624. /** UNSIGNED_SHORT_5_6_5 */
  32625. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32626. /** UNSIGNED_INT_2_10_10_10_REV */
  32627. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32628. /** UNSIGNED_INT_24_8 */
  32629. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32630. /** UNSIGNED_INT_10F_11F_11F_REV */
  32631. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32632. /** UNSIGNED_INT_5_9_9_9_REV */
  32633. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32634. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32635. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32636. /** nearest is mag = nearest and min = nearest and mip = linear */
  32637. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32638. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32639. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32640. /** Trilinear is mag = linear and min = linear and mip = linear */
  32641. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32642. /** nearest is mag = nearest and min = nearest and mip = linear */
  32643. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32644. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32645. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32646. /** Trilinear is mag = linear and min = linear and mip = linear */
  32647. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32648. /** mag = nearest and min = nearest and mip = nearest */
  32649. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32650. /** mag = nearest and min = linear and mip = nearest */
  32651. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32652. /** mag = nearest and min = linear and mip = linear */
  32653. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32654. /** mag = nearest and min = linear and mip = none */
  32655. static readonly TEXTURE_NEAREST_LINEAR: number;
  32656. /** mag = nearest and min = nearest and mip = none */
  32657. static readonly TEXTURE_NEAREST_NEAREST: number;
  32658. /** mag = linear and min = nearest and mip = nearest */
  32659. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32660. /** mag = linear and min = nearest and mip = linear */
  32661. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32662. /** mag = linear and min = linear and mip = none */
  32663. static readonly TEXTURE_LINEAR_LINEAR: number;
  32664. /** mag = linear and min = nearest and mip = none */
  32665. static readonly TEXTURE_LINEAR_NEAREST: number;
  32666. /** Explicit coordinates mode */
  32667. static readonly TEXTURE_EXPLICIT_MODE: number;
  32668. /** Spherical coordinates mode */
  32669. static readonly TEXTURE_SPHERICAL_MODE: number;
  32670. /** Planar coordinates mode */
  32671. static readonly TEXTURE_PLANAR_MODE: number;
  32672. /** Cubic coordinates mode */
  32673. static readonly TEXTURE_CUBIC_MODE: number;
  32674. /** Projection coordinates mode */
  32675. static readonly TEXTURE_PROJECTION_MODE: number;
  32676. /** Skybox coordinates mode */
  32677. static readonly TEXTURE_SKYBOX_MODE: number;
  32678. /** Inverse Cubic coordinates mode */
  32679. static readonly TEXTURE_INVCUBIC_MODE: number;
  32680. /** Equirectangular coordinates mode */
  32681. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32682. /** Equirectangular Fixed coordinates mode */
  32683. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32684. /** Equirectangular Fixed Mirrored coordinates mode */
  32685. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32686. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32687. static readonly SCALEMODE_FLOOR: number;
  32688. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32689. static readonly SCALEMODE_NEAREST: number;
  32690. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32691. static readonly SCALEMODE_CEILING: number;
  32692. /**
  32693. * Returns the current npm package of the sdk
  32694. */
  32695. static readonly NpmPackage: string;
  32696. /**
  32697. * Returns the current version of the framework
  32698. */
  32699. static readonly Version: string;
  32700. /** Gets the list of created engines */
  32701. static readonly Instances: Engine[];
  32702. /**
  32703. * Gets the latest created engine
  32704. */
  32705. static readonly LastCreatedEngine: Nullable<Engine>;
  32706. /**
  32707. * Gets the latest created scene
  32708. */
  32709. static readonly LastCreatedScene: Nullable<Scene>;
  32710. /**
  32711. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32712. * @param flag defines which part of the materials must be marked as dirty
  32713. * @param predicate defines a predicate used to filter which materials should be affected
  32714. */
  32715. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32716. /**
  32717. * Method called to create the default loading screen.
  32718. * This can be overriden in your own app.
  32719. * @param canvas The rendering canvas element
  32720. * @returns The loading screen
  32721. */
  32722. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32723. /**
  32724. * Method called to create the default rescale post process on each engine.
  32725. */
  32726. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32727. /**
  32728. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32729. **/
  32730. enableOfflineSupport: boolean;
  32731. /**
  32732. * 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)
  32733. **/
  32734. disableManifestCheck: boolean;
  32735. /**
  32736. * Gets the list of created scenes
  32737. */
  32738. scenes: Scene[];
  32739. /**
  32740. * Event raised when a new scene is created
  32741. */
  32742. onNewSceneAddedObservable: Observable<Scene>;
  32743. /**
  32744. * Gets the list of created postprocesses
  32745. */
  32746. postProcesses: PostProcess[];
  32747. /**
  32748. * Gets a boolean indicating if the pointer is currently locked
  32749. */
  32750. isPointerLock: boolean;
  32751. /**
  32752. * Observable event triggered each time the rendering canvas is resized
  32753. */
  32754. onResizeObservable: Observable<Engine>;
  32755. /**
  32756. * Observable event triggered each time the canvas loses focus
  32757. */
  32758. onCanvasBlurObservable: Observable<Engine>;
  32759. /**
  32760. * Observable event triggered each time the canvas gains focus
  32761. */
  32762. onCanvasFocusObservable: Observable<Engine>;
  32763. /**
  32764. * Observable event triggered each time the canvas receives pointerout event
  32765. */
  32766. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32767. /**
  32768. * Observable raised when the engine begins a new frame
  32769. */
  32770. onBeginFrameObservable: Observable<Engine>;
  32771. /**
  32772. * If set, will be used to request the next animation frame for the render loop
  32773. */
  32774. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32775. /**
  32776. * Observable raised when the engine ends the current frame
  32777. */
  32778. onEndFrameObservable: Observable<Engine>;
  32779. /**
  32780. * Observable raised when the engine is about to compile a shader
  32781. */
  32782. onBeforeShaderCompilationObservable: Observable<Engine>;
  32783. /**
  32784. * Observable raised when the engine has jsut compiled a shader
  32785. */
  32786. onAfterShaderCompilationObservable: Observable<Engine>;
  32787. /**
  32788. * Gets the audio engine
  32789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32790. * @ignorenaming
  32791. */
  32792. static audioEngine: IAudioEngine;
  32793. /**
  32794. * Default AudioEngine factory responsible of creating the Audio Engine.
  32795. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32796. */
  32797. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32798. /**
  32799. * Default offline support factory responsible of creating a tool used to store data locally.
  32800. * By default, this will create a Database object if the workload has been embedded.
  32801. */
  32802. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32803. private _loadingScreen;
  32804. private _pointerLockRequested;
  32805. private _dummyFramebuffer;
  32806. private _rescalePostProcess;
  32807. private _deterministicLockstep;
  32808. private _lockstepMaxSteps;
  32809. private _timeStep;
  32810. protected readonly _supportsHardwareTextureRescaling: boolean;
  32811. private _fps;
  32812. private _deltaTime;
  32813. /** @hidden */
  32814. _drawCalls: PerfCounter;
  32815. /**
  32816. * Turn this value on if you want to pause FPS computation when in background
  32817. */
  32818. disablePerformanceMonitorInBackground: boolean;
  32819. private _performanceMonitor;
  32820. /**
  32821. * Gets the performance monitor attached to this engine
  32822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32823. */
  32824. readonly performanceMonitor: PerformanceMonitor;
  32825. private _onFocus;
  32826. private _onBlur;
  32827. private _onCanvasPointerOut;
  32828. private _onCanvasBlur;
  32829. private _onCanvasFocus;
  32830. private _onFullscreenChange;
  32831. private _onPointerLockChange;
  32832. /**
  32833. * Gets the HTML element used to attach event listeners
  32834. * @returns a HTML element
  32835. */
  32836. getInputElement(): Nullable<HTMLElement>;
  32837. /**
  32838. * Creates a new engine
  32839. * @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
  32840. * @param antialias defines enable antialiasing (default: false)
  32841. * @param options defines further options to be sent to the getContext() function
  32842. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32843. */
  32844. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32845. /**
  32846. * Gets current aspect ratio
  32847. * @param viewportOwner defines the camera to use to get the aspect ratio
  32848. * @param useScreen defines if screen size must be used (or the current render target if any)
  32849. * @returns a number defining the aspect ratio
  32850. */
  32851. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32852. /**
  32853. * Gets current screen aspect ratio
  32854. * @returns a number defining the aspect ratio
  32855. */
  32856. getScreenAspectRatio(): number;
  32857. /**
  32858. * Gets the client rect of the HTML canvas attached with the current webGL context
  32859. * @returns a client rectanglee
  32860. */
  32861. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32862. /**
  32863. * Gets the client rect of the HTML element used for events
  32864. * @returns a client rectanglee
  32865. */
  32866. getInputElementClientRect(): Nullable<ClientRect>;
  32867. /**
  32868. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32869. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32870. * @returns true if engine is in deterministic lock step mode
  32871. */
  32872. isDeterministicLockStep(): boolean;
  32873. /**
  32874. * Gets the max steps when engine is running in deterministic lock step
  32875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32876. * @returns the max steps
  32877. */
  32878. getLockstepMaxSteps(): number;
  32879. /**
  32880. * Returns the time in ms between steps when using deterministic lock step.
  32881. * @returns time step in (ms)
  32882. */
  32883. getTimeStep(): number;
  32884. /**
  32885. * Force the mipmap generation for the given render target texture
  32886. * @param texture defines the render target texture to use
  32887. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  32888. */
  32889. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  32890. /** States */
  32891. /**
  32892. * Set various states to the webGL context
  32893. * @param culling defines backface culling state
  32894. * @param zOffset defines the value to apply to zOffset (0 by default)
  32895. * @param force defines if states must be applied even if cache is up to date
  32896. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32897. */
  32898. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32899. /**
  32900. * Set the z offset to apply to current rendering
  32901. * @param value defines the offset to apply
  32902. */
  32903. setZOffset(value: number): void;
  32904. /**
  32905. * Gets the current value of the zOffset
  32906. * @returns the current zOffset state
  32907. */
  32908. getZOffset(): number;
  32909. /**
  32910. * Enable or disable depth buffering
  32911. * @param enable defines the state to set
  32912. */
  32913. setDepthBuffer(enable: boolean): void;
  32914. /**
  32915. * Gets a boolean indicating if depth writing is enabled
  32916. * @returns the current depth writing state
  32917. */
  32918. getDepthWrite(): boolean;
  32919. /**
  32920. * Enable or disable depth writing
  32921. * @param enable defines the state to set
  32922. */
  32923. setDepthWrite(enable: boolean): void;
  32924. /**
  32925. * Gets a boolean indicating if stencil buffer is enabled
  32926. * @returns the current stencil buffer state
  32927. */
  32928. getStencilBuffer(): boolean;
  32929. /**
  32930. * Enable or disable the stencil buffer
  32931. * @param enable defines if the stencil buffer must be enabled or disabled
  32932. */
  32933. setStencilBuffer(enable: boolean): void;
  32934. /**
  32935. * Gets the current stencil mask
  32936. * @returns a number defining the new stencil mask to use
  32937. */
  32938. getStencilMask(): number;
  32939. /**
  32940. * Sets the current stencil mask
  32941. * @param mask defines the new stencil mask to use
  32942. */
  32943. setStencilMask(mask: number): void;
  32944. /**
  32945. * Gets the current stencil function
  32946. * @returns a number defining the stencil function to use
  32947. */
  32948. getStencilFunction(): number;
  32949. /**
  32950. * Gets the current stencil reference value
  32951. * @returns a number defining the stencil reference value to use
  32952. */
  32953. getStencilFunctionReference(): number;
  32954. /**
  32955. * Gets the current stencil mask
  32956. * @returns a number defining the stencil mask to use
  32957. */
  32958. getStencilFunctionMask(): number;
  32959. /**
  32960. * Sets the current stencil function
  32961. * @param stencilFunc defines the new stencil function to use
  32962. */
  32963. setStencilFunction(stencilFunc: number): void;
  32964. /**
  32965. * Sets the current stencil reference
  32966. * @param reference defines the new stencil reference to use
  32967. */
  32968. setStencilFunctionReference(reference: number): void;
  32969. /**
  32970. * Sets the current stencil mask
  32971. * @param mask defines the new stencil mask to use
  32972. */
  32973. setStencilFunctionMask(mask: number): void;
  32974. /**
  32975. * Gets the current stencil operation when stencil fails
  32976. * @returns a number defining stencil operation to use when stencil fails
  32977. */
  32978. getStencilOperationFail(): number;
  32979. /**
  32980. * Gets the current stencil operation when depth fails
  32981. * @returns a number defining stencil operation to use when depth fails
  32982. */
  32983. getStencilOperationDepthFail(): number;
  32984. /**
  32985. * Gets the current stencil operation when stencil passes
  32986. * @returns a number defining stencil operation to use when stencil passes
  32987. */
  32988. getStencilOperationPass(): number;
  32989. /**
  32990. * Sets the stencil operation to use when stencil fails
  32991. * @param operation defines the stencil operation to use when stencil fails
  32992. */
  32993. setStencilOperationFail(operation: number): void;
  32994. /**
  32995. * Sets the stencil operation to use when depth fails
  32996. * @param operation defines the stencil operation to use when depth fails
  32997. */
  32998. setStencilOperationDepthFail(operation: number): void;
  32999. /**
  33000. * Sets the stencil operation to use when stencil passes
  33001. * @param operation defines the stencil operation to use when stencil passes
  33002. */
  33003. setStencilOperationPass(operation: number): void;
  33004. /**
  33005. * Sets a boolean indicating if the dithering state is enabled or disabled
  33006. * @param value defines the dithering state
  33007. */
  33008. setDitheringState(value: boolean): void;
  33009. /**
  33010. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33011. * @param value defines the rasterizer state
  33012. */
  33013. setRasterizerState(value: boolean): void;
  33014. /**
  33015. * Gets the current depth function
  33016. * @returns a number defining the depth function
  33017. */
  33018. getDepthFunction(): Nullable<number>;
  33019. /**
  33020. * Sets the current depth function
  33021. * @param depthFunc defines the function to use
  33022. */
  33023. setDepthFunction(depthFunc: number): void;
  33024. /**
  33025. * Sets the current depth function to GREATER
  33026. */
  33027. setDepthFunctionToGreater(): void;
  33028. /**
  33029. * Sets the current depth function to GEQUAL
  33030. */
  33031. setDepthFunctionToGreaterOrEqual(): void;
  33032. /**
  33033. * Sets the current depth function to LESS
  33034. */
  33035. setDepthFunctionToLess(): void;
  33036. /**
  33037. * Sets the current depth function to LEQUAL
  33038. */
  33039. setDepthFunctionToLessOrEqual(): void;
  33040. private _cachedStencilBuffer;
  33041. private _cachedStencilFunction;
  33042. private _cachedStencilMask;
  33043. private _cachedStencilOperationPass;
  33044. private _cachedStencilOperationFail;
  33045. private _cachedStencilOperationDepthFail;
  33046. private _cachedStencilReference;
  33047. /**
  33048. * Caches the the state of the stencil buffer
  33049. */
  33050. cacheStencilState(): void;
  33051. /**
  33052. * Restores the state of the stencil buffer
  33053. */
  33054. restoreStencilState(): void;
  33055. /**
  33056. * Directly set the WebGL Viewport
  33057. * @param x defines the x coordinate of the viewport (in screen space)
  33058. * @param y defines the y coordinate of the viewport (in screen space)
  33059. * @param width defines the width of the viewport (in screen space)
  33060. * @param height defines the height of the viewport (in screen space)
  33061. * @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
  33062. */
  33063. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33064. /**
  33065. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33066. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33067. * @param y defines the y-coordinate of the corner of the clear rectangle
  33068. * @param width defines the width of the clear rectangle
  33069. * @param height defines the height of the clear rectangle
  33070. * @param clearColor defines the clear color
  33071. */
  33072. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33073. /**
  33074. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33075. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33076. * @param y defines the y-coordinate of the corner of the clear rectangle
  33077. * @param width defines the width of the clear rectangle
  33078. * @param height defines the height of the clear rectangle
  33079. */
  33080. enableScissor(x: number, y: number, width: number, height: number): void;
  33081. /**
  33082. * Disable previously set scissor test rectangle
  33083. */
  33084. disableScissor(): void;
  33085. protected _reportDrawCall(): void;
  33086. /**
  33087. * Initializes a webVR display and starts listening to display change events
  33088. * The onVRDisplayChangedObservable will be notified upon these changes
  33089. * @returns The onVRDisplayChangedObservable
  33090. */
  33091. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33092. /** @hidden */
  33093. _prepareVRComponent(): void;
  33094. /** @hidden */
  33095. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33096. /** @hidden */
  33097. _submitVRFrame(): void;
  33098. /**
  33099. * Call this function to leave webVR mode
  33100. * Will do nothing if webVR is not supported or if there is no webVR device
  33101. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33102. */
  33103. disableVR(): void;
  33104. /**
  33105. * Gets a boolean indicating that the system is in VR mode and is presenting
  33106. * @returns true if VR mode is engaged
  33107. */
  33108. isVRPresenting(): boolean;
  33109. /** @hidden */
  33110. _requestVRFrame(): void;
  33111. /** @hidden */
  33112. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33113. /**
  33114. * Gets the source code of the vertex shader associated with a specific webGL program
  33115. * @param program defines the program to use
  33116. * @returns a string containing the source code of the vertex shader associated with the program
  33117. */
  33118. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33119. /**
  33120. * Gets the source code of the fragment shader associated with a specific webGL program
  33121. * @param program defines the program to use
  33122. * @returns a string containing the source code of the fragment shader associated with the program
  33123. */
  33124. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33125. /**
  33126. * Sets a depth stencil texture from a render target to the according uniform.
  33127. * @param channel The texture channel
  33128. * @param uniform The uniform to set
  33129. * @param texture The render target texture containing the depth stencil texture to apply
  33130. */
  33131. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33132. /**
  33133. * Sets a texture to the webGL context from a postprocess
  33134. * @param channel defines the channel to use
  33135. * @param postProcess defines the source postprocess
  33136. */
  33137. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33138. /**
  33139. * Binds the output of the passed in post process to the texture channel specified
  33140. * @param channel The channel the texture should be bound to
  33141. * @param postProcess The post process which's output should be bound
  33142. */
  33143. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33144. /** @hidden */
  33145. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33146. protected _rebuildBuffers(): void;
  33147. /** @hidden */
  33148. _renderFrame(): void;
  33149. _renderLoop(): void;
  33150. /** @hidden */
  33151. _renderViews(): boolean;
  33152. /**
  33153. * Toggle full screen mode
  33154. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33155. */
  33156. switchFullscreen(requestPointerLock: boolean): void;
  33157. /**
  33158. * Enters full screen mode
  33159. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33160. */
  33161. enterFullscreen(requestPointerLock: boolean): void;
  33162. /**
  33163. * Exits full screen mode
  33164. */
  33165. exitFullscreen(): void;
  33166. /**
  33167. * Enters Pointerlock mode
  33168. */
  33169. enterPointerlock(): void;
  33170. /**
  33171. * Exits Pointerlock mode
  33172. */
  33173. exitPointerlock(): void;
  33174. /**
  33175. * Begin a new frame
  33176. */
  33177. beginFrame(): void;
  33178. /**
  33179. * Enf the current frame
  33180. */
  33181. endFrame(): void;
  33182. resize(): void;
  33183. /**
  33184. * Set the compressed texture format to use, based on the formats you have, and the formats
  33185. * supported by the hardware / browser.
  33186. *
  33187. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33188. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33189. * to API arguments needed to compressed textures. This puts the burden on the container
  33190. * generator to house the arcane code for determining these for current & future formats.
  33191. *
  33192. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33193. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33194. *
  33195. * Note: The result of this call is not taken into account when a texture is base64.
  33196. *
  33197. * @param formatsAvailable defines the list of those format families you have created
  33198. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33199. *
  33200. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33201. * @returns The extension selected.
  33202. */
  33203. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33204. /**
  33205. * Set the compressed texture extensions or file names to skip.
  33206. *
  33207. * @param skippedFiles defines the list of those texture files you want to skip
  33208. * Example: [".dds", ".env", "myfile.png"]
  33209. */
  33210. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33211. /**
  33212. * Force a specific size of the canvas
  33213. * @param width defines the new canvas' width
  33214. * @param height defines the new canvas' height
  33215. */
  33216. setSize(width: number, height: number): void;
  33217. /**
  33218. * Updates a dynamic vertex buffer.
  33219. * @param vertexBuffer the vertex buffer to update
  33220. * @param data the data used to update the vertex buffer
  33221. * @param byteOffset the byte offset of the data
  33222. * @param byteLength the byte length of the data
  33223. */
  33224. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33225. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33226. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33227. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33228. _releaseTexture(texture: InternalTexture): void;
  33229. /**
  33230. * @hidden
  33231. * Rescales a texture
  33232. * @param source input texutre
  33233. * @param destination destination texture
  33234. * @param scene scene to use to render the resize
  33235. * @param internalFormat format to use when resizing
  33236. * @param onComplete callback to be called when resize has completed
  33237. */
  33238. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33239. /**
  33240. * Gets the current framerate
  33241. * @returns a number representing the framerate
  33242. */
  33243. getFps(): number;
  33244. /**
  33245. * Gets the time spent between current and previous frame
  33246. * @returns a number representing the delta time in ms
  33247. */
  33248. getDeltaTime(): number;
  33249. private _measureFps;
  33250. /** @hidden */
  33251. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33252. /**
  33253. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33254. * @param renderTarget The render target to set the frame buffer for
  33255. */
  33256. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33257. /**
  33258. * Update a dynamic index buffer
  33259. * @param indexBuffer defines the target index buffer
  33260. * @param indices defines the data to update
  33261. * @param offset defines the offset in the target index buffer where update should start
  33262. */
  33263. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33264. /**
  33265. * Updates the sample count of a render target texture
  33266. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33267. * @param texture defines the texture to update
  33268. * @param samples defines the sample count to set
  33269. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33270. */
  33271. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33272. /**
  33273. * Updates a depth texture Comparison Mode and Function.
  33274. * If the comparison Function is equal to 0, the mode will be set to none.
  33275. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33276. * @param texture The texture to set the comparison function for
  33277. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33278. */
  33279. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33280. /**
  33281. * Creates a webGL buffer to use with instanciation
  33282. * @param capacity defines the size of the buffer
  33283. * @returns the webGL buffer
  33284. */
  33285. createInstancesBuffer(capacity: number): DataBuffer;
  33286. /**
  33287. * Delete a webGL buffer used with instanciation
  33288. * @param buffer defines the webGL buffer to delete
  33289. */
  33290. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33291. /** @hidden */
  33292. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33293. dispose(): void;
  33294. private _disableTouchAction;
  33295. /**
  33296. * Display the loading screen
  33297. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33298. */
  33299. displayLoadingUI(): void;
  33300. /**
  33301. * Hide the loading screen
  33302. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33303. */
  33304. hideLoadingUI(): void;
  33305. /**
  33306. * Gets the current loading screen object
  33307. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33308. */
  33309. /**
  33310. * Sets the current loading screen object
  33311. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33312. */
  33313. loadingScreen: ILoadingScreen;
  33314. /**
  33315. * Sets the current loading screen text
  33316. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33317. */
  33318. loadingUIText: string;
  33319. /**
  33320. * Sets the current loading screen background color
  33321. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33322. */
  33323. loadingUIBackgroundColor: string;
  33324. /** Pointerlock and fullscreen */
  33325. /**
  33326. * Ask the browser to promote the current element to pointerlock mode
  33327. * @param element defines the DOM element to promote
  33328. */
  33329. static _RequestPointerlock(element: HTMLElement): void;
  33330. /**
  33331. * Asks the browser to exit pointerlock mode
  33332. */
  33333. static _ExitPointerlock(): void;
  33334. /**
  33335. * Ask the browser to promote the current element to fullscreen rendering mode
  33336. * @param element defines the DOM element to promote
  33337. */
  33338. static _RequestFullscreen(element: HTMLElement): void;
  33339. /**
  33340. * Asks the browser to exit fullscreen mode
  33341. */
  33342. static _ExitFullscreen(): void;
  33343. }
  33344. }
  33345. declare module BABYLON {
  33346. /**
  33347. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33348. * during the life time of the application.
  33349. */
  33350. export class EngineStore {
  33351. /** Gets the list of created engines */
  33352. static Instances: Engine[];
  33353. /** @hidden */
  33354. static _LastCreatedScene: Nullable<Scene>;
  33355. /**
  33356. * Gets the latest created engine
  33357. */
  33358. static readonly LastCreatedEngine: Nullable<Engine>;
  33359. /**
  33360. * Gets the latest created scene
  33361. */
  33362. static readonly LastCreatedScene: Nullable<Scene>;
  33363. /**
  33364. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33365. * @ignorenaming
  33366. */
  33367. static UseFallbackTexture: boolean;
  33368. /**
  33369. * Texture content used if a texture cannot loaded
  33370. * @ignorenaming
  33371. */
  33372. static FallbackTexture: string;
  33373. }
  33374. }
  33375. declare module BABYLON {
  33376. /**
  33377. * Helper class that provides a small promise polyfill
  33378. */
  33379. export class PromisePolyfill {
  33380. /**
  33381. * Static function used to check if the polyfill is required
  33382. * If this is the case then the function will inject the polyfill to window.Promise
  33383. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33384. */
  33385. static Apply(force?: boolean): void;
  33386. }
  33387. }
  33388. declare module BABYLON {
  33389. /**
  33390. * Interface for screenshot methods with describe argument called `size` as object with options
  33391. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33392. */
  33393. export interface IScreenshotSize {
  33394. /**
  33395. * number in pixels for canvas height
  33396. */
  33397. height?: number;
  33398. /**
  33399. * multiplier allowing render at a higher or lower resolution
  33400. * If value is defined then height and width will be ignored and taken from camera
  33401. */
  33402. precision?: number;
  33403. /**
  33404. * number in pixels for canvas width
  33405. */
  33406. width?: number;
  33407. }
  33408. }
  33409. declare module BABYLON {
  33410. interface IColor4Like {
  33411. r: float;
  33412. g: float;
  33413. b: float;
  33414. a: float;
  33415. }
  33416. /**
  33417. * Class containing a set of static utilities functions
  33418. */
  33419. export class Tools {
  33420. /**
  33421. * Gets or sets the base URL to use to load assets
  33422. */
  33423. static BaseUrl: string;
  33424. /**
  33425. * Enable/Disable Custom HTTP Request Headers globally.
  33426. * default = false
  33427. * @see CustomRequestHeaders
  33428. */
  33429. static UseCustomRequestHeaders: boolean;
  33430. /**
  33431. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33432. * i.e. when loading files, where the server/service expects an Authorization header
  33433. */
  33434. static CustomRequestHeaders: {
  33435. [key: string]: string;
  33436. };
  33437. /**
  33438. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33439. */
  33440. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33441. /**
  33442. * Default behaviour for cors in the application.
  33443. * It can be a string if the expected behavior is identical in the entire app.
  33444. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33445. */
  33446. static CorsBehavior: string | ((url: string | string[]) => string);
  33447. /**
  33448. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33449. * @ignorenaming
  33450. */
  33451. static UseFallbackTexture: boolean;
  33452. /**
  33453. * Use this object to register external classes like custom textures or material
  33454. * to allow the laoders to instantiate them
  33455. */
  33456. static RegisteredExternalClasses: {
  33457. [key: string]: Object;
  33458. };
  33459. /**
  33460. * Texture content used if a texture cannot loaded
  33461. * @ignorenaming
  33462. */
  33463. static fallbackTexture: string;
  33464. /**
  33465. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33466. * @param u defines the coordinate on X axis
  33467. * @param v defines the coordinate on Y axis
  33468. * @param width defines the width of the source data
  33469. * @param height defines the height of the source data
  33470. * @param pixels defines the source byte array
  33471. * @param color defines the output color
  33472. */
  33473. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33474. /**
  33475. * Interpolates between a and b via alpha
  33476. * @param a The lower value (returned when alpha = 0)
  33477. * @param b The upper value (returned when alpha = 1)
  33478. * @param alpha The interpolation-factor
  33479. * @return The mixed value
  33480. */
  33481. static Mix(a: number, b: number, alpha: number): number;
  33482. /**
  33483. * Tries to instantiate a new object from a given class name
  33484. * @param className defines the class name to instantiate
  33485. * @returns the new object or null if the system was not able to do the instantiation
  33486. */
  33487. static Instantiate(className: string): any;
  33488. /**
  33489. * Provides a slice function that will work even on IE
  33490. * @param data defines the array to slice
  33491. * @param start defines the start of the data (optional)
  33492. * @param end defines the end of the data (optional)
  33493. * @returns the new sliced array
  33494. */
  33495. static Slice<T>(data: T, start?: number, end?: number): T;
  33496. /**
  33497. * Polyfill for setImmediate
  33498. * @param action defines the action to execute after the current execution block
  33499. */
  33500. static SetImmediate(action: () => void): void;
  33501. /**
  33502. * Function indicating if a number is an exponent of 2
  33503. * @param value defines the value to test
  33504. * @returns true if the value is an exponent of 2
  33505. */
  33506. static IsExponentOfTwo(value: number): boolean;
  33507. private static _tmpFloatArray;
  33508. /**
  33509. * Returns the nearest 32-bit single precision float representation of a Number
  33510. * @param value A Number. If the parameter is of a different type, it will get converted
  33511. * to a number or to NaN if it cannot be converted
  33512. * @returns number
  33513. */
  33514. static FloatRound(value: number): number;
  33515. /**
  33516. * Extracts the filename from a path
  33517. * @param path defines the path to use
  33518. * @returns the filename
  33519. */
  33520. static GetFilename(path: string): string;
  33521. /**
  33522. * Extracts the "folder" part of a path (everything before the filename).
  33523. * @param uri The URI to extract the info from
  33524. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33525. * @returns The "folder" part of the path
  33526. */
  33527. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33528. /**
  33529. * Extracts text content from a DOM element hierarchy
  33530. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33531. */
  33532. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33533. /**
  33534. * Convert an angle in radians to degrees
  33535. * @param angle defines the angle to convert
  33536. * @returns the angle in degrees
  33537. */
  33538. static ToDegrees(angle: number): number;
  33539. /**
  33540. * Convert an angle in degrees to radians
  33541. * @param angle defines the angle to convert
  33542. * @returns the angle in radians
  33543. */
  33544. static ToRadians(angle: number): number;
  33545. /**
  33546. * Returns an array if obj is not an array
  33547. * @param obj defines the object to evaluate as an array
  33548. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33549. * @returns either obj directly if obj is an array or a new array containing obj
  33550. */
  33551. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33552. /**
  33553. * Gets the pointer prefix to use
  33554. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33555. */
  33556. static GetPointerPrefix(): string;
  33557. /**
  33558. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33559. * @param url define the url we are trying
  33560. * @param element define the dom element where to configure the cors policy
  33561. */
  33562. static SetCorsBehavior(url: string | string[], element: {
  33563. crossOrigin: string | null;
  33564. }): void;
  33565. /**
  33566. * Removes unwanted characters from an url
  33567. * @param url defines the url to clean
  33568. * @returns the cleaned url
  33569. */
  33570. static CleanUrl(url: string): string;
  33571. /**
  33572. * Gets or sets a function used to pre-process url before using them to load assets
  33573. */
  33574. static PreprocessUrl: (url: string) => string;
  33575. /**
  33576. * Loads an image as an HTMLImageElement.
  33577. * @param input url string, ArrayBuffer, or Blob to load
  33578. * @param onLoad callback called when the image successfully loads
  33579. * @param onError callback called when the image fails to load
  33580. * @param offlineProvider offline provider for caching
  33581. * @param mimeType optional mime type
  33582. * @returns the HTMLImageElement of the loaded image
  33583. */
  33584. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33585. /**
  33586. * Loads a file from a url
  33587. * @param url url string, ArrayBuffer, or Blob to load
  33588. * @param onSuccess callback called when the file successfully loads
  33589. * @param onProgress callback called while file is loading (if the server supports this mode)
  33590. * @param offlineProvider defines the offline provider for caching
  33591. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33592. * @param onError callback called when the file fails to load
  33593. * @returns a file request object
  33594. */
  33595. 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;
  33596. /**
  33597. * Loads a file from a url
  33598. * @param url the file url to load
  33599. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33600. */
  33601. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33602. /**
  33603. * Load a script (identified by an url). When the url returns, the
  33604. * content of this file is added into a new script element, attached to the DOM (body element)
  33605. * @param scriptUrl defines the url of the script to laod
  33606. * @param onSuccess defines the callback called when the script is loaded
  33607. * @param onError defines the callback to call if an error occurs
  33608. * @param scriptId defines the id of the script element
  33609. */
  33610. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33611. /**
  33612. * Load an asynchronous script (identified by an url). When the url returns, the
  33613. * content of this file is added into a new script element, attached to the DOM (body element)
  33614. * @param scriptUrl defines the url of the script to laod
  33615. * @param scriptId defines the id of the script element
  33616. * @returns a promise request object
  33617. */
  33618. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33619. /**
  33620. * Loads a file from a blob
  33621. * @param fileToLoad defines the blob to use
  33622. * @param callback defines the callback to call when data is loaded
  33623. * @param progressCallback defines the callback to call during loading process
  33624. * @returns a file request object
  33625. */
  33626. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33627. /**
  33628. * Reads a file from a File object
  33629. * @param file defines the file to load
  33630. * @param onSuccess defines the callback to call when data is loaded
  33631. * @param onProgress defines the callback to call during loading process
  33632. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33633. * @param onError defines the callback to call when an error occurs
  33634. * @returns a file request object
  33635. */
  33636. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33637. /**
  33638. * Creates a data url from a given string content
  33639. * @param content defines the content to convert
  33640. * @returns the new data url link
  33641. */
  33642. static FileAsURL(content: string): string;
  33643. /**
  33644. * Format the given number to a specific decimal format
  33645. * @param value defines the number to format
  33646. * @param decimals defines the number of decimals to use
  33647. * @returns the formatted string
  33648. */
  33649. static Format(value: number, decimals?: number): string;
  33650. /**
  33651. * Tries to copy an object by duplicating every property
  33652. * @param source defines the source object
  33653. * @param destination defines the target object
  33654. * @param doNotCopyList defines a list of properties to avoid
  33655. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33656. */
  33657. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33658. /**
  33659. * Gets a boolean indicating if the given object has no own property
  33660. * @param obj defines the object to test
  33661. * @returns true if object has no own property
  33662. */
  33663. static IsEmpty(obj: any): boolean;
  33664. /**
  33665. * Function used to register events at window level
  33666. * @param windowElement defines the Window object to use
  33667. * @param events defines the events to register
  33668. */
  33669. static RegisterTopRootEvents(windowElement: Window, events: {
  33670. name: string;
  33671. handler: Nullable<(e: FocusEvent) => any>;
  33672. }[]): void;
  33673. /**
  33674. * Function used to unregister events from window level
  33675. * @param windowElement defines the Window object to use
  33676. * @param events defines the events to unregister
  33677. */
  33678. static UnregisterTopRootEvents(windowElement: Window, events: {
  33679. name: string;
  33680. handler: Nullable<(e: FocusEvent) => any>;
  33681. }[]): void;
  33682. /**
  33683. * @ignore
  33684. */
  33685. static _ScreenshotCanvas: HTMLCanvasElement;
  33686. /**
  33687. * Dumps the current bound framebuffer
  33688. * @param width defines the rendering width
  33689. * @param height defines the rendering height
  33690. * @param engine defines the hosting engine
  33691. * @param successCallback defines the callback triggered once the data are available
  33692. * @param mimeType defines the mime type of the result
  33693. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33694. */
  33695. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33696. /**
  33697. * Converts the canvas data to blob.
  33698. * This acts as a polyfill for browsers not supporting the to blob function.
  33699. * @param canvas Defines the canvas to extract the data from
  33700. * @param successCallback Defines the callback triggered once the data are available
  33701. * @param mimeType Defines the mime type of the result
  33702. */
  33703. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33704. /**
  33705. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33706. * @param successCallback defines the callback triggered once the data are available
  33707. * @param mimeType defines the mime type of the result
  33708. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33709. */
  33710. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33711. /**
  33712. * Downloads a blob in the browser
  33713. * @param blob defines the blob to download
  33714. * @param fileName defines the name of the downloaded file
  33715. */
  33716. static Download(blob: Blob, fileName: string): void;
  33717. /**
  33718. * Captures a screenshot of the current rendering
  33719. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33720. * @param engine defines the rendering engine
  33721. * @param camera defines the source camera
  33722. * @param size This parameter can be set to a single number or to an object with the
  33723. * following (optional) properties: precision, width, height. If a single number is passed,
  33724. * it will be used for both width and height. If an object is passed, the screenshot size
  33725. * will be derived from the parameters. The precision property is a multiplier allowing
  33726. * rendering at a higher or lower resolution
  33727. * @param successCallback defines the callback receives a single parameter which contains the
  33728. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33729. * src parameter of an <img> to display it
  33730. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33731. * Check your browser for supported MIME types
  33732. */
  33733. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33734. /**
  33735. * Captures a screenshot of the current rendering
  33736. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33737. * @param engine defines the rendering engine
  33738. * @param camera defines the source camera
  33739. * @param size This parameter can be set to a single number or to an object with the
  33740. * following (optional) properties: precision, width, height. If a single number is passed,
  33741. * it will be used for both width and height. If an object is passed, the screenshot size
  33742. * will be derived from the parameters. The precision property is a multiplier allowing
  33743. * rendering at a higher or lower resolution
  33744. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33745. * Check your browser for supported MIME types
  33746. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33747. * to the src parameter of an <img> to display it
  33748. */
  33749. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33750. /**
  33751. * Generates an image screenshot from the specified camera.
  33752. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33753. * @param engine The engine to use for rendering
  33754. * @param camera The camera to use for rendering
  33755. * @param size This parameter can be set to a single number or to an object with the
  33756. * following (optional) properties: precision, width, height. If a single number is passed,
  33757. * it will be used for both width and height. If an object is passed, the screenshot size
  33758. * will be derived from the parameters. The precision property is a multiplier allowing
  33759. * rendering at a higher or lower resolution
  33760. * @param successCallback The callback receives a single parameter which contains the
  33761. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33762. * src parameter of an <img> to display it
  33763. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33764. * Check your browser for supported MIME types
  33765. * @param samples Texture samples (default: 1)
  33766. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33767. * @param fileName A name for for the downloaded file.
  33768. */
  33769. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33770. /**
  33771. * Generates an image screenshot from the specified camera.
  33772. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33773. * @param engine The engine to use for rendering
  33774. * @param camera The camera to use for rendering
  33775. * @param size This parameter can be set to a single number or to an object with the
  33776. * following (optional) properties: precision, width, height. If a single number is passed,
  33777. * it will be used for both width and height. If an object is passed, the screenshot size
  33778. * will be derived from the parameters. The precision property is a multiplier allowing
  33779. * rendering at a higher or lower resolution
  33780. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33781. * Check your browser for supported MIME types
  33782. * @param samples Texture samples (default: 1)
  33783. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33784. * @param fileName A name for for the downloaded file.
  33785. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33786. * to the src parameter of an <img> to display it
  33787. */
  33788. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33789. /**
  33790. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33791. * Be aware Math.random() could cause collisions, but:
  33792. * "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"
  33793. * @returns a pseudo random id
  33794. */
  33795. static RandomId(): string;
  33796. /**
  33797. * Test if the given uri is a base64 string
  33798. * @param uri The uri to test
  33799. * @return True if the uri is a base64 string or false otherwise
  33800. */
  33801. static IsBase64(uri: string): boolean;
  33802. /**
  33803. * Decode the given base64 uri.
  33804. * @param uri The uri to decode
  33805. * @return The decoded base64 data.
  33806. */
  33807. static DecodeBase64(uri: string): ArrayBuffer;
  33808. /**
  33809. * Gets the absolute url.
  33810. * @param url the input url
  33811. * @return the absolute url
  33812. */
  33813. static GetAbsoluteUrl(url: string): string;
  33814. /**
  33815. * No log
  33816. */
  33817. static readonly NoneLogLevel: number;
  33818. /**
  33819. * Only message logs
  33820. */
  33821. static readonly MessageLogLevel: number;
  33822. /**
  33823. * Only warning logs
  33824. */
  33825. static readonly WarningLogLevel: number;
  33826. /**
  33827. * Only error logs
  33828. */
  33829. static readonly ErrorLogLevel: number;
  33830. /**
  33831. * All logs
  33832. */
  33833. static readonly AllLogLevel: number;
  33834. /**
  33835. * Gets a value indicating the number of loading errors
  33836. * @ignorenaming
  33837. */
  33838. static readonly errorsCount: number;
  33839. /**
  33840. * Callback called when a new log is added
  33841. */
  33842. static OnNewCacheEntry: (entry: string) => void;
  33843. /**
  33844. * Log a message to the console
  33845. * @param message defines the message to log
  33846. */
  33847. static Log(message: string): void;
  33848. /**
  33849. * Write a warning message to the console
  33850. * @param message defines the message to log
  33851. */
  33852. static Warn(message: string): void;
  33853. /**
  33854. * Write an error message to the console
  33855. * @param message defines the message to log
  33856. */
  33857. static Error(message: string): void;
  33858. /**
  33859. * Gets current log cache (list of logs)
  33860. */
  33861. static readonly LogCache: string;
  33862. /**
  33863. * Clears the log cache
  33864. */
  33865. static ClearLogCache(): void;
  33866. /**
  33867. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33868. */
  33869. static LogLevels: number;
  33870. /**
  33871. * Checks if the window object exists
  33872. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33873. */
  33874. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33875. /**
  33876. * No performance log
  33877. */
  33878. static readonly PerformanceNoneLogLevel: number;
  33879. /**
  33880. * Use user marks to log performance
  33881. */
  33882. static readonly PerformanceUserMarkLogLevel: number;
  33883. /**
  33884. * Log performance to the console
  33885. */
  33886. static readonly PerformanceConsoleLogLevel: number;
  33887. private static _performance;
  33888. /**
  33889. * Sets the current performance log level
  33890. */
  33891. static PerformanceLogLevel: number;
  33892. private static _StartPerformanceCounterDisabled;
  33893. private static _EndPerformanceCounterDisabled;
  33894. private static _StartUserMark;
  33895. private static _EndUserMark;
  33896. private static _StartPerformanceConsole;
  33897. private static _EndPerformanceConsole;
  33898. /**
  33899. * Starts a performance counter
  33900. */
  33901. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33902. /**
  33903. * Ends a specific performance coutner
  33904. */
  33905. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33906. /**
  33907. * Gets either window.performance.now() if supported or Date.now() else
  33908. */
  33909. static readonly Now: number;
  33910. /**
  33911. * This method will return the name of the class used to create the instance of the given object.
  33912. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33913. * @param object the object to get the class name from
  33914. * @param isType defines if the object is actually a type
  33915. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33916. */
  33917. static GetClassName(object: any, isType?: boolean): string;
  33918. /**
  33919. * Gets the first element of an array satisfying a given predicate
  33920. * @param array defines the array to browse
  33921. * @param predicate defines the predicate to use
  33922. * @returns null if not found or the element
  33923. */
  33924. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33925. /**
  33926. * This method will return the name of the full name of the class, including its owning module (if any).
  33927. * 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).
  33928. * @param object the object to get the class name from
  33929. * @param isType defines if the object is actually a type
  33930. * @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.
  33931. * @ignorenaming
  33932. */
  33933. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33934. /**
  33935. * Returns a promise that resolves after the given amount of time.
  33936. * @param delay Number of milliseconds to delay
  33937. * @returns Promise that resolves after the given amount of time
  33938. */
  33939. static DelayAsync(delay: number): Promise<void>;
  33940. }
  33941. /**
  33942. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33943. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33944. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33945. * @param name The name of the class, case should be preserved
  33946. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33947. */
  33948. export function className(name: string, module?: string): (target: Object) => void;
  33949. /**
  33950. * An implementation of a loop for asynchronous functions.
  33951. */
  33952. export class AsyncLoop {
  33953. /**
  33954. * Defines the number of iterations for the loop
  33955. */
  33956. iterations: number;
  33957. /**
  33958. * Defines the current index of the loop.
  33959. */
  33960. index: number;
  33961. private _done;
  33962. private _fn;
  33963. private _successCallback;
  33964. /**
  33965. * Constructor.
  33966. * @param iterations the number of iterations.
  33967. * @param func the function to run each iteration
  33968. * @param successCallback the callback that will be called upon succesful execution
  33969. * @param offset starting offset.
  33970. */
  33971. constructor(
  33972. /**
  33973. * Defines the number of iterations for the loop
  33974. */
  33975. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33976. /**
  33977. * Execute the next iteration. Must be called after the last iteration was finished.
  33978. */
  33979. executeNext(): void;
  33980. /**
  33981. * Break the loop and run the success callback.
  33982. */
  33983. breakLoop(): void;
  33984. /**
  33985. * Create and run an async loop.
  33986. * @param iterations the number of iterations.
  33987. * @param fn the function to run each iteration
  33988. * @param successCallback the callback that will be called upon succesful execution
  33989. * @param offset starting offset.
  33990. * @returns the created async loop object
  33991. */
  33992. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33993. /**
  33994. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33995. * @param iterations total number of iterations
  33996. * @param syncedIterations number of synchronous iterations in each async iteration.
  33997. * @param fn the function to call each iteration.
  33998. * @param callback a success call back that will be called when iterating stops.
  33999. * @param breakFunction a break condition (optional)
  34000. * @param timeout timeout settings for the setTimeout function. default - 0.
  34001. * @returns the created async loop object
  34002. */
  34003. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34004. }
  34005. }
  34006. declare module BABYLON {
  34007. /**
  34008. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34009. * The underlying implementation relies on an associative array to ensure the best performances.
  34010. * The value can be anything including 'null' but except 'undefined'
  34011. */
  34012. export class StringDictionary<T> {
  34013. /**
  34014. * This will clear this dictionary and copy the content from the 'source' one.
  34015. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34016. * @param source the dictionary to take the content from and copy to this dictionary
  34017. */
  34018. copyFrom(source: StringDictionary<T>): void;
  34019. /**
  34020. * Get a value based from its key
  34021. * @param key the given key to get the matching value from
  34022. * @return the value if found, otherwise undefined is returned
  34023. */
  34024. get(key: string): T | undefined;
  34025. /**
  34026. * Get a value from its key or add it if it doesn't exist.
  34027. * This method will ensure you that a given key/data will be present in the dictionary.
  34028. * @param key the given key to get the matching value from
  34029. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34030. * The factory will only be invoked if there's no data for the given key.
  34031. * @return the value corresponding to the key.
  34032. */
  34033. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34034. /**
  34035. * Get a value from its key if present in the dictionary otherwise add it
  34036. * @param key the key to get the value from
  34037. * @param val if there's no such key/value pair in the dictionary add it with this value
  34038. * @return the value corresponding to the key
  34039. */
  34040. getOrAdd(key: string, val: T): T;
  34041. /**
  34042. * Check if there's a given key in the dictionary
  34043. * @param key the key to check for
  34044. * @return true if the key is present, false otherwise
  34045. */
  34046. contains(key: string): boolean;
  34047. /**
  34048. * Add a new key and its corresponding value
  34049. * @param key the key to add
  34050. * @param value the value corresponding to the key
  34051. * @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
  34052. */
  34053. add(key: string, value: T): boolean;
  34054. /**
  34055. * Update a specific value associated to a key
  34056. * @param key defines the key to use
  34057. * @param value defines the value to store
  34058. * @returns true if the value was updated (or false if the key was not found)
  34059. */
  34060. set(key: string, value: T): boolean;
  34061. /**
  34062. * Get the element of the given key and remove it from the dictionary
  34063. * @param key defines the key to search
  34064. * @returns the value associated with the key or null if not found
  34065. */
  34066. getAndRemove(key: string): Nullable<T>;
  34067. /**
  34068. * Remove a key/value from the dictionary.
  34069. * @param key the key to remove
  34070. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34071. */
  34072. remove(key: string): boolean;
  34073. /**
  34074. * Clear the whole content of the dictionary
  34075. */
  34076. clear(): void;
  34077. /**
  34078. * Gets the current count
  34079. */
  34080. readonly count: number;
  34081. /**
  34082. * Execute a callback on each key/val of the dictionary.
  34083. * Note that you can remove any element in this dictionary in the callback implementation
  34084. * @param callback the callback to execute on a given key/value pair
  34085. */
  34086. forEach(callback: (key: string, val: T) => void): void;
  34087. /**
  34088. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34089. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34090. * Note that you can remove any element in this dictionary in the callback implementation
  34091. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34092. * @returns the first item
  34093. */
  34094. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34095. private _count;
  34096. private _data;
  34097. }
  34098. }
  34099. declare module BABYLON {
  34100. /** @hidden */
  34101. export interface ICollisionCoordinator {
  34102. createCollider(): Collider;
  34103. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34104. init(scene: Scene): void;
  34105. }
  34106. /** @hidden */
  34107. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34108. private _scene;
  34109. private _scaledPosition;
  34110. private _scaledVelocity;
  34111. private _finalPosition;
  34112. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34113. createCollider(): Collider;
  34114. init(scene: Scene): void;
  34115. private _collideWithWorld;
  34116. }
  34117. }
  34118. declare module BABYLON {
  34119. /**
  34120. * Class used to manage all inputs for the scene.
  34121. */
  34122. export class InputManager {
  34123. /** The distance in pixel that you have to move to prevent some events */
  34124. static DragMovementThreshold: number;
  34125. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34126. static LongPressDelay: number;
  34127. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34128. static DoubleClickDelay: number;
  34129. /** If you need to check double click without raising a single click at first click, enable this flag */
  34130. static ExclusiveDoubleClickMode: boolean;
  34131. private _wheelEventName;
  34132. private _onPointerMove;
  34133. private _onPointerDown;
  34134. private _onPointerUp;
  34135. private _initClickEvent;
  34136. private _initActionManager;
  34137. private _delayedSimpleClick;
  34138. private _delayedSimpleClickTimeout;
  34139. private _previousDelayedSimpleClickTimeout;
  34140. private _meshPickProceed;
  34141. private _previousButtonPressed;
  34142. private _currentPickResult;
  34143. private _previousPickResult;
  34144. private _totalPointersPressed;
  34145. private _doubleClickOccured;
  34146. private _pointerOverMesh;
  34147. private _pickedDownMesh;
  34148. private _pickedUpMesh;
  34149. private _pointerX;
  34150. private _pointerY;
  34151. private _unTranslatedPointerX;
  34152. private _unTranslatedPointerY;
  34153. private _startingPointerPosition;
  34154. private _previousStartingPointerPosition;
  34155. private _startingPointerTime;
  34156. private _previousStartingPointerTime;
  34157. private _pointerCaptures;
  34158. private _onKeyDown;
  34159. private _onKeyUp;
  34160. private _onCanvasFocusObserver;
  34161. private _onCanvasBlurObserver;
  34162. private _scene;
  34163. /**
  34164. * Creates a new InputManager
  34165. * @param scene defines the hosting scene
  34166. */
  34167. constructor(scene: Scene);
  34168. /**
  34169. * Gets the mesh that is currently under the pointer
  34170. */
  34171. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34172. /**
  34173. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34174. */
  34175. readonly unTranslatedPointer: Vector2;
  34176. /**
  34177. * Gets or sets the current on-screen X position of the pointer
  34178. */
  34179. pointerX: number;
  34180. /**
  34181. * Gets or sets the current on-screen Y position of the pointer
  34182. */
  34183. pointerY: number;
  34184. private _updatePointerPosition;
  34185. private _processPointerMove;
  34186. private _setRayOnPointerInfo;
  34187. private _checkPrePointerObservable;
  34188. /**
  34189. * Use this method to simulate a pointer move on a mesh
  34190. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34191. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34192. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34193. */
  34194. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34195. /**
  34196. * Use this method to simulate a pointer down on a mesh
  34197. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34198. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34199. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34200. */
  34201. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34202. private _processPointerDown;
  34203. /** @hidden */
  34204. _isPointerSwiping(): boolean;
  34205. /**
  34206. * Use this method to simulate a pointer up on a mesh
  34207. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34208. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34209. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34210. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34211. */
  34212. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34213. private _processPointerUp;
  34214. /**
  34215. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34216. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34217. * @returns true if the pointer was captured
  34218. */
  34219. isPointerCaptured(pointerId?: number): boolean;
  34220. /**
  34221. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34222. * @param attachUp defines if you want to attach events to pointerup
  34223. * @param attachDown defines if you want to attach events to pointerdown
  34224. * @param attachMove defines if you want to attach events to pointermove
  34225. */
  34226. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34227. /**
  34228. * Detaches all event handlers
  34229. */
  34230. detachControl(): void;
  34231. /**
  34232. * Force the value of meshUnderPointer
  34233. * @param mesh defines the mesh to use
  34234. */
  34235. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34236. /**
  34237. * Gets the mesh under the pointer
  34238. * @returns a Mesh or null if no mesh is under the pointer
  34239. */
  34240. getPointerOverMesh(): Nullable<AbstractMesh>;
  34241. }
  34242. }
  34243. declare module BABYLON {
  34244. /**
  34245. * Helper class used to generate session unique ID
  34246. */
  34247. export class UniqueIdGenerator {
  34248. private static _UniqueIdCounter;
  34249. /**
  34250. * Gets an unique (relatively to the current scene) Id
  34251. */
  34252. static readonly UniqueId: number;
  34253. }
  34254. }
  34255. declare module BABYLON {
  34256. /**
  34257. * This class defines the direct association between an animation and a target
  34258. */
  34259. export class TargetedAnimation {
  34260. /**
  34261. * Animation to perform
  34262. */
  34263. animation: Animation;
  34264. /**
  34265. * Target to animate
  34266. */
  34267. target: any;
  34268. /**
  34269. * Serialize the object
  34270. * @returns the JSON object representing the current entity
  34271. */
  34272. serialize(): any;
  34273. }
  34274. /**
  34275. * Use this class to create coordinated animations on multiple targets
  34276. */
  34277. export class AnimationGroup implements IDisposable {
  34278. /** The name of the animation group */
  34279. name: string;
  34280. private _scene;
  34281. private _targetedAnimations;
  34282. private _animatables;
  34283. private _from;
  34284. private _to;
  34285. private _isStarted;
  34286. private _isPaused;
  34287. private _speedRatio;
  34288. private _loopAnimation;
  34289. /**
  34290. * Gets or sets the unique id of the node
  34291. */
  34292. uniqueId: number;
  34293. /**
  34294. * This observable will notify when one animation have ended
  34295. */
  34296. onAnimationEndObservable: Observable<TargetedAnimation>;
  34297. /**
  34298. * Observer raised when one animation loops
  34299. */
  34300. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34301. /**
  34302. * Observer raised when all animations have looped
  34303. */
  34304. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34305. /**
  34306. * This observable will notify when all animations have ended.
  34307. */
  34308. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34309. /**
  34310. * This observable will notify when all animations have paused.
  34311. */
  34312. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34313. /**
  34314. * This observable will notify when all animations are playing.
  34315. */
  34316. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34317. /**
  34318. * Gets the first frame
  34319. */
  34320. readonly from: number;
  34321. /**
  34322. * Gets the last frame
  34323. */
  34324. readonly to: number;
  34325. /**
  34326. * Define if the animations are started
  34327. */
  34328. readonly isStarted: boolean;
  34329. /**
  34330. * Gets a value indicating that the current group is playing
  34331. */
  34332. readonly isPlaying: boolean;
  34333. /**
  34334. * Gets or sets the speed ratio to use for all animations
  34335. */
  34336. /**
  34337. * Gets or sets the speed ratio to use for all animations
  34338. */
  34339. speedRatio: number;
  34340. /**
  34341. * Gets or sets if all animations should loop or not
  34342. */
  34343. loopAnimation: boolean;
  34344. /**
  34345. * Gets the targeted animations for this animation group
  34346. */
  34347. readonly targetedAnimations: Array<TargetedAnimation>;
  34348. /**
  34349. * returning the list of animatables controlled by this animation group.
  34350. */
  34351. readonly animatables: Array<Animatable>;
  34352. /**
  34353. * Instantiates a new Animation Group.
  34354. * This helps managing several animations at once.
  34355. * @see http://doc.babylonjs.com/how_to/group
  34356. * @param name Defines the name of the group
  34357. * @param scene Defines the scene the group belongs to
  34358. */
  34359. constructor(
  34360. /** The name of the animation group */
  34361. name: string, scene?: Nullable<Scene>);
  34362. /**
  34363. * Add an animation (with its target) in the group
  34364. * @param animation defines the animation we want to add
  34365. * @param target defines the target of the animation
  34366. * @returns the TargetedAnimation object
  34367. */
  34368. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34369. /**
  34370. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34371. * It can add constant keys at begin or end
  34372. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34373. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34374. * @returns the animation group
  34375. */
  34376. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34377. private _animationLoopCount;
  34378. private _animationLoopFlags;
  34379. private _processLoop;
  34380. /**
  34381. * Start all animations on given targets
  34382. * @param loop defines if animations must loop
  34383. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34384. * @param from defines the from key (optional)
  34385. * @param to defines the to key (optional)
  34386. * @returns the current animation group
  34387. */
  34388. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34389. /**
  34390. * Pause all animations
  34391. * @returns the animation group
  34392. */
  34393. pause(): AnimationGroup;
  34394. /**
  34395. * Play all animations to initial state
  34396. * This function will start() the animations if they were not started or will restart() them if they were paused
  34397. * @param loop defines if animations must loop
  34398. * @returns the animation group
  34399. */
  34400. play(loop?: boolean): AnimationGroup;
  34401. /**
  34402. * Reset all animations to initial state
  34403. * @returns the animation group
  34404. */
  34405. reset(): AnimationGroup;
  34406. /**
  34407. * Restart animations from key 0
  34408. * @returns the animation group
  34409. */
  34410. restart(): AnimationGroup;
  34411. /**
  34412. * Stop all animations
  34413. * @returns the animation group
  34414. */
  34415. stop(): AnimationGroup;
  34416. /**
  34417. * Set animation weight for all animatables
  34418. * @param weight defines the weight to use
  34419. * @return the animationGroup
  34420. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34421. */
  34422. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34423. /**
  34424. * Synchronize and normalize all animatables with a source animatable
  34425. * @param root defines the root animatable to synchronize with
  34426. * @return the animationGroup
  34427. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34428. */
  34429. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34430. /**
  34431. * Goes to a specific frame in this animation group
  34432. * @param frame the frame number to go to
  34433. * @return the animationGroup
  34434. */
  34435. goToFrame(frame: number): AnimationGroup;
  34436. /**
  34437. * Dispose all associated resources
  34438. */
  34439. dispose(): void;
  34440. private _checkAnimationGroupEnded;
  34441. /**
  34442. * Clone the current animation group and returns a copy
  34443. * @param newName defines the name of the new group
  34444. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34445. * @returns the new aniamtion group
  34446. */
  34447. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34448. /**
  34449. * Serializes the animationGroup to an object
  34450. * @returns Serialized object
  34451. */
  34452. serialize(): any;
  34453. /**
  34454. * Returns a new AnimationGroup object parsed from the source provided.
  34455. * @param parsedAnimationGroup defines the source
  34456. * @param scene defines the scene that will receive the animationGroup
  34457. * @returns a new AnimationGroup
  34458. */
  34459. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34460. /**
  34461. * Returns the string "AnimationGroup"
  34462. * @returns "AnimationGroup"
  34463. */
  34464. getClassName(): string;
  34465. /**
  34466. * Creates a detailled string about the object
  34467. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34468. * @returns a string representing the object
  34469. */
  34470. toString(fullDetails?: boolean): string;
  34471. }
  34472. }
  34473. declare module BABYLON {
  34474. /**
  34475. * Define an interface for all classes that will hold resources
  34476. */
  34477. export interface IDisposable {
  34478. /**
  34479. * Releases all held resources
  34480. */
  34481. dispose(): void;
  34482. }
  34483. /** Interface defining initialization parameters for Scene class */
  34484. export interface SceneOptions {
  34485. /**
  34486. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34487. * It will improve performance when the number of geometries becomes important.
  34488. */
  34489. useGeometryUniqueIdsMap?: boolean;
  34490. /**
  34491. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34492. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34493. */
  34494. useMaterialMeshMap?: boolean;
  34495. /**
  34496. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34497. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34498. */
  34499. useClonedMeshhMap?: boolean;
  34500. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34501. virtual?: boolean;
  34502. }
  34503. /**
  34504. * Represents a scene to be rendered by the engine.
  34505. * @see http://doc.babylonjs.com/features/scene
  34506. */
  34507. export class Scene extends AbstractScene implements IAnimatable {
  34508. /** The fog is deactivated */
  34509. static readonly FOGMODE_NONE: number;
  34510. /** The fog density is following an exponential function */
  34511. static readonly FOGMODE_EXP: number;
  34512. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34513. static readonly FOGMODE_EXP2: number;
  34514. /** The fog density is following a linear function. */
  34515. static readonly FOGMODE_LINEAR: number;
  34516. /**
  34517. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34518. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34519. */
  34520. static MinDeltaTime: number;
  34521. /**
  34522. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34523. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34524. */
  34525. static MaxDeltaTime: number;
  34526. /**
  34527. * Factory used to create the default material.
  34528. * @param name The name of the material to create
  34529. * @param scene The scene to create the material for
  34530. * @returns The default material
  34531. */
  34532. static DefaultMaterialFactory(scene: Scene): Material;
  34533. /**
  34534. * Factory used to create the a collision coordinator.
  34535. * @returns The collision coordinator
  34536. */
  34537. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34538. /** @hidden */
  34539. _inputManager: InputManager;
  34540. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34541. cameraToUseForPointers: Nullable<Camera>;
  34542. /** @hidden */
  34543. readonly _isScene: boolean;
  34544. /**
  34545. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34546. */
  34547. autoClear: boolean;
  34548. /**
  34549. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34550. */
  34551. autoClearDepthAndStencil: boolean;
  34552. /**
  34553. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34554. */
  34555. clearColor: Color4;
  34556. /**
  34557. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34558. */
  34559. ambientColor: Color3;
  34560. /**
  34561. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34562. * It should only be one of the following (if not the default embedded one):
  34563. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34564. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34565. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34566. * The material properties need to be setup according to the type of texture in use.
  34567. */
  34568. environmentBRDFTexture: BaseTexture;
  34569. /** @hidden */
  34570. protected _environmentTexture: Nullable<BaseTexture>;
  34571. /**
  34572. * Texture used in all pbr material as the reflection texture.
  34573. * As in the majority of the scene they are the same (exception for multi room and so on),
  34574. * this is easier to reference from here than from all the materials.
  34575. */
  34576. /**
  34577. * Texture used in all pbr material as the reflection texture.
  34578. * As in the majority of the scene they are the same (exception for multi room and so on),
  34579. * this is easier to set here than in all the materials.
  34580. */
  34581. environmentTexture: Nullable<BaseTexture>;
  34582. /** @hidden */
  34583. protected _environmentIntensity: number;
  34584. /**
  34585. * Intensity of the environment in all pbr material.
  34586. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34587. * As in the majority of the scene they are the same (exception for multi room and so on),
  34588. * this is easier to reference from here than from all the materials.
  34589. */
  34590. /**
  34591. * Intensity of the environment in all pbr material.
  34592. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34593. * As in the majority of the scene they are the same (exception for multi room and so on),
  34594. * this is easier to set here than in all the materials.
  34595. */
  34596. environmentIntensity: number;
  34597. /** @hidden */
  34598. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34599. /**
  34600. * Default image processing configuration used either in the rendering
  34601. * Forward main pass or through the imageProcessingPostProcess if present.
  34602. * As in the majority of the scene they are the same (exception for multi camera),
  34603. * this is easier to reference from here than from all the materials and post process.
  34604. *
  34605. * No setter as we it is a shared configuration, you can set the values instead.
  34606. */
  34607. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34608. private _forceWireframe;
  34609. /**
  34610. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34611. */
  34612. forceWireframe: boolean;
  34613. private _forcePointsCloud;
  34614. /**
  34615. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34616. */
  34617. forcePointsCloud: boolean;
  34618. /**
  34619. * Gets or sets the active clipplane 1
  34620. */
  34621. clipPlane: Nullable<Plane>;
  34622. /**
  34623. * Gets or sets the active clipplane 2
  34624. */
  34625. clipPlane2: Nullable<Plane>;
  34626. /**
  34627. * Gets or sets the active clipplane 3
  34628. */
  34629. clipPlane3: Nullable<Plane>;
  34630. /**
  34631. * Gets or sets the active clipplane 4
  34632. */
  34633. clipPlane4: Nullable<Plane>;
  34634. /**
  34635. * Gets or sets a boolean indicating if animations are enabled
  34636. */
  34637. animationsEnabled: boolean;
  34638. private _animationPropertiesOverride;
  34639. /**
  34640. * Gets or sets the animation properties override
  34641. */
  34642. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34643. /**
  34644. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34645. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34646. */
  34647. useConstantAnimationDeltaTime: boolean;
  34648. /**
  34649. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34650. * Please note that it requires to run a ray cast through the scene on every frame
  34651. */
  34652. constantlyUpdateMeshUnderPointer: boolean;
  34653. /**
  34654. * Defines the HTML cursor to use when hovering over interactive elements
  34655. */
  34656. hoverCursor: string;
  34657. /**
  34658. * Defines the HTML default cursor to use (empty by default)
  34659. */
  34660. defaultCursor: string;
  34661. /**
  34662. * Defines wether cursors are handled by the scene.
  34663. */
  34664. doNotHandleCursors: boolean;
  34665. /**
  34666. * This is used to call preventDefault() on pointer down
  34667. * in order to block unwanted artifacts like system double clicks
  34668. */
  34669. preventDefaultOnPointerDown: boolean;
  34670. /**
  34671. * This is used to call preventDefault() on pointer up
  34672. * in order to block unwanted artifacts like system double clicks
  34673. */
  34674. preventDefaultOnPointerUp: boolean;
  34675. /**
  34676. * Gets or sets user defined metadata
  34677. */
  34678. metadata: any;
  34679. /**
  34680. * For internal use only. Please do not use.
  34681. */
  34682. reservedDataStore: any;
  34683. /**
  34684. * Gets the name of the plugin used to load this scene (null by default)
  34685. */
  34686. loadingPluginName: string;
  34687. /**
  34688. * Use this array to add regular expressions used to disable offline support for specific urls
  34689. */
  34690. disableOfflineSupportExceptionRules: RegExp[];
  34691. /**
  34692. * An event triggered when the scene is disposed.
  34693. */
  34694. onDisposeObservable: Observable<Scene>;
  34695. private _onDisposeObserver;
  34696. /** Sets a function to be executed when this scene is disposed. */
  34697. onDispose: () => void;
  34698. /**
  34699. * An event triggered before rendering the scene (right after animations and physics)
  34700. */
  34701. onBeforeRenderObservable: Observable<Scene>;
  34702. private _onBeforeRenderObserver;
  34703. /** Sets a function to be executed before rendering this scene */
  34704. beforeRender: Nullable<() => void>;
  34705. /**
  34706. * An event triggered after rendering the scene
  34707. */
  34708. onAfterRenderObservable: Observable<Scene>;
  34709. /**
  34710. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34711. */
  34712. onAfterRenderCameraObservable: Observable<Camera>;
  34713. private _onAfterRenderObserver;
  34714. /** Sets a function to be executed after rendering this scene */
  34715. afterRender: Nullable<() => void>;
  34716. /**
  34717. * An event triggered before animating the scene
  34718. */
  34719. onBeforeAnimationsObservable: Observable<Scene>;
  34720. /**
  34721. * An event triggered after animations processing
  34722. */
  34723. onAfterAnimationsObservable: Observable<Scene>;
  34724. /**
  34725. * An event triggered before draw calls are ready to be sent
  34726. */
  34727. onBeforeDrawPhaseObservable: Observable<Scene>;
  34728. /**
  34729. * An event triggered after draw calls have been sent
  34730. */
  34731. onAfterDrawPhaseObservable: Observable<Scene>;
  34732. /**
  34733. * An event triggered when the scene is ready
  34734. */
  34735. onReadyObservable: Observable<Scene>;
  34736. /**
  34737. * An event triggered before rendering a camera
  34738. */
  34739. onBeforeCameraRenderObservable: Observable<Camera>;
  34740. private _onBeforeCameraRenderObserver;
  34741. /** Sets a function to be executed before rendering a camera*/
  34742. beforeCameraRender: () => void;
  34743. /**
  34744. * An event triggered after rendering a camera
  34745. */
  34746. onAfterCameraRenderObservable: Observable<Camera>;
  34747. private _onAfterCameraRenderObserver;
  34748. /** Sets a function to be executed after rendering a camera*/
  34749. afterCameraRender: () => void;
  34750. /**
  34751. * An event triggered when active meshes evaluation is about to start
  34752. */
  34753. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34754. /**
  34755. * An event triggered when active meshes evaluation is done
  34756. */
  34757. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34758. /**
  34759. * An event triggered when particles rendering is about to start
  34760. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34761. */
  34762. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34763. /**
  34764. * An event triggered when particles rendering is done
  34765. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34766. */
  34767. onAfterParticlesRenderingObservable: Observable<Scene>;
  34768. /**
  34769. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34770. */
  34771. onDataLoadedObservable: Observable<Scene>;
  34772. /**
  34773. * An event triggered when a camera is created
  34774. */
  34775. onNewCameraAddedObservable: Observable<Camera>;
  34776. /**
  34777. * An event triggered when a camera is removed
  34778. */
  34779. onCameraRemovedObservable: Observable<Camera>;
  34780. /**
  34781. * An event triggered when a light is created
  34782. */
  34783. onNewLightAddedObservable: Observable<Light>;
  34784. /**
  34785. * An event triggered when a light is removed
  34786. */
  34787. onLightRemovedObservable: Observable<Light>;
  34788. /**
  34789. * An event triggered when a geometry is created
  34790. */
  34791. onNewGeometryAddedObservable: Observable<Geometry>;
  34792. /**
  34793. * An event triggered when a geometry is removed
  34794. */
  34795. onGeometryRemovedObservable: Observable<Geometry>;
  34796. /**
  34797. * An event triggered when a transform node is created
  34798. */
  34799. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34800. /**
  34801. * An event triggered when a transform node is removed
  34802. */
  34803. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34804. /**
  34805. * An event triggered when a mesh is created
  34806. */
  34807. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34808. /**
  34809. * An event triggered when a mesh is removed
  34810. */
  34811. onMeshRemovedObservable: Observable<AbstractMesh>;
  34812. /**
  34813. * An event triggered when a skeleton is created
  34814. */
  34815. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34816. /**
  34817. * An event triggered when a skeleton is removed
  34818. */
  34819. onSkeletonRemovedObservable: Observable<Skeleton>;
  34820. /**
  34821. * An event triggered when a material is created
  34822. */
  34823. onNewMaterialAddedObservable: Observable<Material>;
  34824. /**
  34825. * An event triggered when a material is removed
  34826. */
  34827. onMaterialRemovedObservable: Observable<Material>;
  34828. /**
  34829. * An event triggered when a texture is created
  34830. */
  34831. onNewTextureAddedObservable: Observable<BaseTexture>;
  34832. /**
  34833. * An event triggered when a texture is removed
  34834. */
  34835. onTextureRemovedObservable: Observable<BaseTexture>;
  34836. /**
  34837. * An event triggered when render targets are about to be rendered
  34838. * Can happen multiple times per frame.
  34839. */
  34840. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34841. /**
  34842. * An event triggered when render targets were rendered.
  34843. * Can happen multiple times per frame.
  34844. */
  34845. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34846. /**
  34847. * An event triggered before calculating deterministic simulation step
  34848. */
  34849. onBeforeStepObservable: Observable<Scene>;
  34850. /**
  34851. * An event triggered after calculating deterministic simulation step
  34852. */
  34853. onAfterStepObservable: Observable<Scene>;
  34854. /**
  34855. * An event triggered when the activeCamera property is updated
  34856. */
  34857. onActiveCameraChanged: Observable<Scene>;
  34858. /**
  34859. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34860. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34861. * 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)
  34862. */
  34863. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34864. /**
  34865. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34866. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34867. * 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)
  34868. */
  34869. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34870. /**
  34871. * This Observable will when a mesh has been imported into the scene.
  34872. */
  34873. onMeshImportedObservable: Observable<AbstractMesh>;
  34874. /**
  34875. * This Observable will when an animation file has been imported into the scene.
  34876. */
  34877. onAnimationFileImportedObservable: Observable<Scene>;
  34878. /**
  34879. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34880. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34881. */
  34882. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34883. /** @hidden */
  34884. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34885. /**
  34886. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34887. */
  34888. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34889. /**
  34890. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34891. */
  34892. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34893. /**
  34894. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34895. */
  34896. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34897. /** Callback called when a pointer move is detected */
  34898. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34899. /** Callback called when a pointer down is detected */
  34900. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34901. /** Callback called when a pointer up is detected */
  34902. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34903. /** Callback called when a pointer pick is detected */
  34904. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34905. /**
  34906. * 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).
  34907. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34908. */
  34909. onPrePointerObservable: Observable<PointerInfoPre>;
  34910. /**
  34911. * Observable event triggered each time an input event is received from the rendering canvas
  34912. */
  34913. onPointerObservable: Observable<PointerInfo>;
  34914. /**
  34915. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34916. */
  34917. readonly unTranslatedPointer: Vector2;
  34918. /**
  34919. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34920. */
  34921. static DragMovementThreshold: number;
  34922. /**
  34923. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34924. */
  34925. static LongPressDelay: number;
  34926. /**
  34927. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34928. */
  34929. static DoubleClickDelay: number;
  34930. /** If you need to check double click without raising a single click at first click, enable this flag */
  34931. static ExclusiveDoubleClickMode: boolean;
  34932. /** @hidden */
  34933. _mirroredCameraPosition: Nullable<Vector3>;
  34934. /**
  34935. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34936. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34937. */
  34938. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34939. /**
  34940. * Observable event triggered each time an keyboard event is received from the hosting window
  34941. */
  34942. onKeyboardObservable: Observable<KeyboardInfo>;
  34943. private _useRightHandedSystem;
  34944. /**
  34945. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34946. */
  34947. useRightHandedSystem: boolean;
  34948. private _timeAccumulator;
  34949. private _currentStepId;
  34950. private _currentInternalStep;
  34951. /**
  34952. * Sets the step Id used by deterministic lock step
  34953. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34954. * @param newStepId defines the step Id
  34955. */
  34956. setStepId(newStepId: number): void;
  34957. /**
  34958. * Gets the step Id used by deterministic lock step
  34959. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34960. * @returns the step Id
  34961. */
  34962. getStepId(): number;
  34963. /**
  34964. * Gets the internal step used by deterministic lock step
  34965. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34966. * @returns the internal step
  34967. */
  34968. getInternalStep(): number;
  34969. private _fogEnabled;
  34970. /**
  34971. * Gets or sets a boolean indicating if fog is enabled on this scene
  34972. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34973. * (Default is true)
  34974. */
  34975. fogEnabled: boolean;
  34976. private _fogMode;
  34977. /**
  34978. * Gets or sets the fog mode to use
  34979. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34980. * | mode | value |
  34981. * | --- | --- |
  34982. * | FOGMODE_NONE | 0 |
  34983. * | FOGMODE_EXP | 1 |
  34984. * | FOGMODE_EXP2 | 2 |
  34985. * | FOGMODE_LINEAR | 3 |
  34986. */
  34987. fogMode: number;
  34988. /**
  34989. * Gets or sets the fog color to use
  34990. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34991. * (Default is Color3(0.2, 0.2, 0.3))
  34992. */
  34993. fogColor: Color3;
  34994. /**
  34995. * Gets or sets the fog density to use
  34996. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34997. * (Default is 0.1)
  34998. */
  34999. fogDensity: number;
  35000. /**
  35001. * Gets or sets the fog start distance to use
  35002. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35003. * (Default is 0)
  35004. */
  35005. fogStart: number;
  35006. /**
  35007. * Gets or sets the fog end distance to use
  35008. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35009. * (Default is 1000)
  35010. */
  35011. fogEnd: number;
  35012. private _shadowsEnabled;
  35013. /**
  35014. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35015. */
  35016. shadowsEnabled: boolean;
  35017. private _lightsEnabled;
  35018. /**
  35019. * Gets or sets a boolean indicating if lights are enabled on this scene
  35020. */
  35021. lightsEnabled: boolean;
  35022. /** All of the active cameras added to this scene. */
  35023. activeCameras: Camera[];
  35024. /** @hidden */
  35025. _activeCamera: Nullable<Camera>;
  35026. /** Gets or sets the current active camera */
  35027. activeCamera: Nullable<Camera>;
  35028. private _defaultMaterial;
  35029. /** The default material used on meshes when no material is affected */
  35030. /** The default material used on meshes when no material is affected */
  35031. defaultMaterial: Material;
  35032. private _texturesEnabled;
  35033. /**
  35034. * Gets or sets a boolean indicating if textures are enabled on this scene
  35035. */
  35036. texturesEnabled: boolean;
  35037. /**
  35038. * Gets or sets a boolean indicating if particles are enabled on this scene
  35039. */
  35040. particlesEnabled: boolean;
  35041. /**
  35042. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35043. */
  35044. spritesEnabled: boolean;
  35045. private _skeletonsEnabled;
  35046. /**
  35047. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35048. */
  35049. skeletonsEnabled: boolean;
  35050. /**
  35051. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35052. */
  35053. lensFlaresEnabled: boolean;
  35054. /**
  35055. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35056. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35057. */
  35058. collisionsEnabled: boolean;
  35059. private _collisionCoordinator;
  35060. /** @hidden */
  35061. readonly collisionCoordinator: ICollisionCoordinator;
  35062. /**
  35063. * Defines the gravity applied to this scene (used only for collisions)
  35064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35065. */
  35066. gravity: Vector3;
  35067. /**
  35068. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35069. */
  35070. postProcessesEnabled: boolean;
  35071. /**
  35072. * The list of postprocesses added to the scene
  35073. */
  35074. postProcesses: PostProcess[];
  35075. /**
  35076. * Gets the current postprocess manager
  35077. */
  35078. postProcessManager: PostProcessManager;
  35079. /**
  35080. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35081. */
  35082. renderTargetsEnabled: boolean;
  35083. /**
  35084. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35085. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35086. */
  35087. dumpNextRenderTargets: boolean;
  35088. /**
  35089. * The list of user defined render targets added to the scene
  35090. */
  35091. customRenderTargets: RenderTargetTexture[];
  35092. /**
  35093. * Defines if texture loading must be delayed
  35094. * If true, textures will only be loaded when they need to be rendered
  35095. */
  35096. useDelayedTextureLoading: boolean;
  35097. /**
  35098. * Gets the list of meshes imported to the scene through SceneLoader
  35099. */
  35100. importedMeshesFiles: String[];
  35101. /**
  35102. * Gets or sets a boolean indicating if probes are enabled on this scene
  35103. */
  35104. probesEnabled: boolean;
  35105. /**
  35106. * Gets or sets the current offline provider to use to store scene data
  35107. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35108. */
  35109. offlineProvider: IOfflineProvider;
  35110. /**
  35111. * Gets or sets the action manager associated with the scene
  35112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35113. */
  35114. actionManager: AbstractActionManager;
  35115. private _meshesForIntersections;
  35116. /**
  35117. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35118. */
  35119. proceduralTexturesEnabled: boolean;
  35120. private _engine;
  35121. private _totalVertices;
  35122. /** @hidden */
  35123. _activeIndices: PerfCounter;
  35124. /** @hidden */
  35125. _activeParticles: PerfCounter;
  35126. /** @hidden */
  35127. _activeBones: PerfCounter;
  35128. private _animationRatio;
  35129. /** @hidden */
  35130. _animationTimeLast: number;
  35131. /** @hidden */
  35132. _animationTime: number;
  35133. /**
  35134. * Gets or sets a general scale for animation speed
  35135. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35136. */
  35137. animationTimeScale: number;
  35138. /** @hidden */
  35139. _cachedMaterial: Nullable<Material>;
  35140. /** @hidden */
  35141. _cachedEffect: Nullable<Effect>;
  35142. /** @hidden */
  35143. _cachedVisibility: Nullable<number>;
  35144. private _renderId;
  35145. private _frameId;
  35146. private _executeWhenReadyTimeoutId;
  35147. private _intermediateRendering;
  35148. private _viewUpdateFlag;
  35149. private _projectionUpdateFlag;
  35150. /** @hidden */
  35151. _toBeDisposed: Nullable<IDisposable>[];
  35152. private _activeRequests;
  35153. /** @hidden */
  35154. _pendingData: any[];
  35155. private _isDisposed;
  35156. /**
  35157. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35158. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35159. */
  35160. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35161. private _activeMeshes;
  35162. private _processedMaterials;
  35163. private _renderTargets;
  35164. /** @hidden */
  35165. _activeParticleSystems: SmartArray<IParticleSystem>;
  35166. private _activeSkeletons;
  35167. private _softwareSkinnedMeshes;
  35168. private _renderingManager;
  35169. /** @hidden */
  35170. _activeAnimatables: Animatable[];
  35171. private _transformMatrix;
  35172. private _sceneUbo;
  35173. /** @hidden */
  35174. _viewMatrix: Matrix;
  35175. private _projectionMatrix;
  35176. /** @hidden */
  35177. _forcedViewPosition: Nullable<Vector3>;
  35178. /** @hidden */
  35179. _frustumPlanes: Plane[];
  35180. /**
  35181. * Gets the list of frustum planes (built from the active camera)
  35182. */
  35183. readonly frustumPlanes: Plane[];
  35184. /**
  35185. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35186. * This is useful if there are more lights that the maximum simulteanous authorized
  35187. */
  35188. requireLightSorting: boolean;
  35189. /** @hidden */
  35190. readonly useMaterialMeshMap: boolean;
  35191. /** @hidden */
  35192. readonly useClonedMeshhMap: boolean;
  35193. private _externalData;
  35194. private _uid;
  35195. /**
  35196. * @hidden
  35197. * Backing store of defined scene components.
  35198. */
  35199. _components: ISceneComponent[];
  35200. /**
  35201. * @hidden
  35202. * Backing store of defined scene components.
  35203. */
  35204. _serializableComponents: ISceneSerializableComponent[];
  35205. /**
  35206. * List of components to register on the next registration step.
  35207. */
  35208. private _transientComponents;
  35209. /**
  35210. * Registers the transient components if needed.
  35211. */
  35212. private _registerTransientComponents;
  35213. /**
  35214. * @hidden
  35215. * Add a component to the scene.
  35216. * Note that the ccomponent could be registered on th next frame if this is called after
  35217. * the register component stage.
  35218. * @param component Defines the component to add to the scene
  35219. */
  35220. _addComponent(component: ISceneComponent): void;
  35221. /**
  35222. * @hidden
  35223. * Gets a component from the scene.
  35224. * @param name defines the name of the component to retrieve
  35225. * @returns the component or null if not present
  35226. */
  35227. _getComponent(name: string): Nullable<ISceneComponent>;
  35228. /**
  35229. * @hidden
  35230. * Defines the actions happening before camera updates.
  35231. */
  35232. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35233. /**
  35234. * @hidden
  35235. * Defines the actions happening before clear the canvas.
  35236. */
  35237. _beforeClearStage: Stage<SimpleStageAction>;
  35238. /**
  35239. * @hidden
  35240. * Defines the actions when collecting render targets for the frame.
  35241. */
  35242. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35243. /**
  35244. * @hidden
  35245. * Defines the actions happening for one camera in the frame.
  35246. */
  35247. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35248. /**
  35249. * @hidden
  35250. * Defines the actions happening during the per mesh ready checks.
  35251. */
  35252. _isReadyForMeshStage: Stage<MeshStageAction>;
  35253. /**
  35254. * @hidden
  35255. * Defines the actions happening before evaluate active mesh checks.
  35256. */
  35257. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35258. /**
  35259. * @hidden
  35260. * Defines the actions happening during the evaluate sub mesh checks.
  35261. */
  35262. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35263. /**
  35264. * @hidden
  35265. * Defines the actions happening during the active mesh stage.
  35266. */
  35267. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35268. /**
  35269. * @hidden
  35270. * Defines the actions happening during the per camera render target step.
  35271. */
  35272. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35273. /**
  35274. * @hidden
  35275. * Defines the actions happening just before the active camera is drawing.
  35276. */
  35277. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35278. /**
  35279. * @hidden
  35280. * Defines the actions happening just before a render target is drawing.
  35281. */
  35282. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35283. /**
  35284. * @hidden
  35285. * Defines the actions happening just before a rendering group is drawing.
  35286. */
  35287. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35288. /**
  35289. * @hidden
  35290. * Defines the actions happening just before a mesh is drawing.
  35291. */
  35292. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35293. /**
  35294. * @hidden
  35295. * Defines the actions happening just after a mesh has been drawn.
  35296. */
  35297. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35298. /**
  35299. * @hidden
  35300. * Defines the actions happening just after a rendering group has been drawn.
  35301. */
  35302. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35303. /**
  35304. * @hidden
  35305. * Defines the actions happening just after the active camera has been drawn.
  35306. */
  35307. _afterCameraDrawStage: Stage<CameraStageAction>;
  35308. /**
  35309. * @hidden
  35310. * Defines the actions happening just after a render target has been drawn.
  35311. */
  35312. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35313. /**
  35314. * @hidden
  35315. * Defines the actions happening just after rendering all cameras and computing intersections.
  35316. */
  35317. _afterRenderStage: Stage<SimpleStageAction>;
  35318. /**
  35319. * @hidden
  35320. * Defines the actions happening when a pointer move event happens.
  35321. */
  35322. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35323. /**
  35324. * @hidden
  35325. * Defines the actions happening when a pointer down event happens.
  35326. */
  35327. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35328. /**
  35329. * @hidden
  35330. * Defines the actions happening when a pointer up event happens.
  35331. */
  35332. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35333. /**
  35334. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35335. */
  35336. private geometriesByUniqueId;
  35337. /**
  35338. * Creates a new Scene
  35339. * @param engine defines the engine to use to render this scene
  35340. * @param options defines the scene options
  35341. */
  35342. constructor(engine: Engine, options?: SceneOptions);
  35343. /**
  35344. * Gets a string idenfifying the name of the class
  35345. * @returns "Scene" string
  35346. */
  35347. getClassName(): string;
  35348. private _defaultMeshCandidates;
  35349. /**
  35350. * @hidden
  35351. */
  35352. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35353. private _defaultSubMeshCandidates;
  35354. /**
  35355. * @hidden
  35356. */
  35357. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35358. /**
  35359. * Sets the default candidate providers for the scene.
  35360. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35361. * and getCollidingSubMeshCandidates to their default function
  35362. */
  35363. setDefaultCandidateProviders(): void;
  35364. /**
  35365. * Gets the mesh that is currently under the pointer
  35366. */
  35367. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35368. /**
  35369. * Gets or sets the current on-screen X position of the pointer
  35370. */
  35371. pointerX: number;
  35372. /**
  35373. * Gets or sets the current on-screen Y position of the pointer
  35374. */
  35375. pointerY: number;
  35376. /**
  35377. * Gets the cached material (ie. the latest rendered one)
  35378. * @returns the cached material
  35379. */
  35380. getCachedMaterial(): Nullable<Material>;
  35381. /**
  35382. * Gets the cached effect (ie. the latest rendered one)
  35383. * @returns the cached effect
  35384. */
  35385. getCachedEffect(): Nullable<Effect>;
  35386. /**
  35387. * Gets the cached visibility state (ie. the latest rendered one)
  35388. * @returns the cached visibility state
  35389. */
  35390. getCachedVisibility(): Nullable<number>;
  35391. /**
  35392. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35393. * @param material defines the current material
  35394. * @param effect defines the current effect
  35395. * @param visibility defines the current visibility state
  35396. * @returns true if one parameter is not cached
  35397. */
  35398. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35399. /**
  35400. * Gets the engine associated with the scene
  35401. * @returns an Engine
  35402. */
  35403. getEngine(): Engine;
  35404. /**
  35405. * Gets the total number of vertices rendered per frame
  35406. * @returns the total number of vertices rendered per frame
  35407. */
  35408. getTotalVertices(): number;
  35409. /**
  35410. * Gets the performance counter for total vertices
  35411. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35412. */
  35413. readonly totalVerticesPerfCounter: PerfCounter;
  35414. /**
  35415. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35416. * @returns the total number of active indices rendered per frame
  35417. */
  35418. getActiveIndices(): number;
  35419. /**
  35420. * Gets the performance counter for active indices
  35421. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35422. */
  35423. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35424. /**
  35425. * Gets the total number of active particles rendered per frame
  35426. * @returns the total number of active particles rendered per frame
  35427. */
  35428. getActiveParticles(): number;
  35429. /**
  35430. * Gets the performance counter for active particles
  35431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35432. */
  35433. readonly activeParticlesPerfCounter: PerfCounter;
  35434. /**
  35435. * Gets the total number of active bones rendered per frame
  35436. * @returns the total number of active bones rendered per frame
  35437. */
  35438. getActiveBones(): number;
  35439. /**
  35440. * Gets the performance counter for active bones
  35441. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35442. */
  35443. readonly activeBonesPerfCounter: PerfCounter;
  35444. /**
  35445. * Gets the array of active meshes
  35446. * @returns an array of AbstractMesh
  35447. */
  35448. getActiveMeshes(): SmartArray<AbstractMesh>;
  35449. /**
  35450. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35451. * @returns a number
  35452. */
  35453. getAnimationRatio(): number;
  35454. /**
  35455. * Gets an unique Id for the current render phase
  35456. * @returns a number
  35457. */
  35458. getRenderId(): number;
  35459. /**
  35460. * Gets an unique Id for the current frame
  35461. * @returns a number
  35462. */
  35463. getFrameId(): number;
  35464. /** Call this function if you want to manually increment the render Id*/
  35465. incrementRenderId(): void;
  35466. private _createUbo;
  35467. /**
  35468. * Use this method to simulate a pointer move on a mesh
  35469. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35470. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35471. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35472. * @returns the current scene
  35473. */
  35474. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35475. /**
  35476. * Use this method to simulate a pointer down on a mesh
  35477. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35478. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35479. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35480. * @returns the current scene
  35481. */
  35482. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35483. /**
  35484. * Use this method to simulate a pointer up on a mesh
  35485. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35486. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35487. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35488. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35489. * @returns the current scene
  35490. */
  35491. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35492. /**
  35493. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35494. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35495. * @returns true if the pointer was captured
  35496. */
  35497. isPointerCaptured(pointerId?: number): boolean;
  35498. /**
  35499. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35500. * @param attachUp defines if you want to attach events to pointerup
  35501. * @param attachDown defines if you want to attach events to pointerdown
  35502. * @param attachMove defines if you want to attach events to pointermove
  35503. */
  35504. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35505. /** Detaches all event handlers*/
  35506. detachControl(): void;
  35507. /**
  35508. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35509. * Delay loaded resources are not taking in account
  35510. * @return true if all required resources are ready
  35511. */
  35512. isReady(): boolean;
  35513. /** Resets all cached information relative to material (including effect and visibility) */
  35514. resetCachedMaterial(): void;
  35515. /**
  35516. * Registers a function to be called before every frame render
  35517. * @param func defines the function to register
  35518. */
  35519. registerBeforeRender(func: () => void): void;
  35520. /**
  35521. * Unregisters a function called before every frame render
  35522. * @param func defines the function to unregister
  35523. */
  35524. unregisterBeforeRender(func: () => void): void;
  35525. /**
  35526. * Registers a function to be called after every frame render
  35527. * @param func defines the function to register
  35528. */
  35529. registerAfterRender(func: () => void): void;
  35530. /**
  35531. * Unregisters a function called after every frame render
  35532. * @param func defines the function to unregister
  35533. */
  35534. unregisterAfterRender(func: () => void): void;
  35535. private _executeOnceBeforeRender;
  35536. /**
  35537. * The provided function will run before render once and will be disposed afterwards.
  35538. * A timeout delay can be provided so that the function will be executed in N ms.
  35539. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35540. * @param func The function to be executed.
  35541. * @param timeout optional delay in ms
  35542. */
  35543. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35544. /** @hidden */
  35545. _addPendingData(data: any): void;
  35546. /** @hidden */
  35547. _removePendingData(data: any): void;
  35548. /**
  35549. * Returns the number of items waiting to be loaded
  35550. * @returns the number of items waiting to be loaded
  35551. */
  35552. getWaitingItemsCount(): number;
  35553. /**
  35554. * Returns a boolean indicating if the scene is still loading data
  35555. */
  35556. readonly isLoading: boolean;
  35557. /**
  35558. * Registers a function to be executed when the scene is ready
  35559. * @param {Function} func - the function to be executed
  35560. */
  35561. executeWhenReady(func: () => void): void;
  35562. /**
  35563. * Returns a promise that resolves when the scene is ready
  35564. * @returns A promise that resolves when the scene is ready
  35565. */
  35566. whenReadyAsync(): Promise<void>;
  35567. /** @hidden */
  35568. _checkIsReady(): void;
  35569. /**
  35570. * Gets all animatable attached to the scene
  35571. */
  35572. readonly animatables: Animatable[];
  35573. /**
  35574. * Resets the last animation time frame.
  35575. * Useful to override when animations start running when loading a scene for the first time.
  35576. */
  35577. resetLastAnimationTimeFrame(): void;
  35578. /**
  35579. * Gets the current view matrix
  35580. * @returns a Matrix
  35581. */
  35582. getViewMatrix(): Matrix;
  35583. /**
  35584. * Gets the current projection matrix
  35585. * @returns a Matrix
  35586. */
  35587. getProjectionMatrix(): Matrix;
  35588. /**
  35589. * Gets the current transform matrix
  35590. * @returns a Matrix made of View * Projection
  35591. */
  35592. getTransformMatrix(): Matrix;
  35593. /**
  35594. * Sets the current transform matrix
  35595. * @param viewL defines the View matrix to use
  35596. * @param projectionL defines the Projection matrix to use
  35597. * @param viewR defines the right View matrix to use (if provided)
  35598. * @param projectionR defines the right Projection matrix to use (if provided)
  35599. */
  35600. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35601. /**
  35602. * Gets the uniform buffer used to store scene data
  35603. * @returns a UniformBuffer
  35604. */
  35605. getSceneUniformBuffer(): UniformBuffer;
  35606. /**
  35607. * Gets an unique (relatively to the current scene) Id
  35608. * @returns an unique number for the scene
  35609. */
  35610. getUniqueId(): number;
  35611. /**
  35612. * Add a mesh to the list of scene's meshes
  35613. * @param newMesh defines the mesh to add
  35614. * @param recursive if all child meshes should also be added to the scene
  35615. */
  35616. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35617. /**
  35618. * Remove a mesh for the list of scene's meshes
  35619. * @param toRemove defines the mesh to remove
  35620. * @param recursive if all child meshes should also be removed from the scene
  35621. * @returns the index where the mesh was in the mesh list
  35622. */
  35623. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35624. /**
  35625. * Add a transform node to the list of scene's transform nodes
  35626. * @param newTransformNode defines the transform node to add
  35627. */
  35628. addTransformNode(newTransformNode: TransformNode): void;
  35629. /**
  35630. * Remove a transform node for the list of scene's transform nodes
  35631. * @param toRemove defines the transform node to remove
  35632. * @returns the index where the transform node was in the transform node list
  35633. */
  35634. removeTransformNode(toRemove: TransformNode): number;
  35635. /**
  35636. * Remove a skeleton for the list of scene's skeletons
  35637. * @param toRemove defines the skeleton to remove
  35638. * @returns the index where the skeleton was in the skeleton list
  35639. */
  35640. removeSkeleton(toRemove: Skeleton): number;
  35641. /**
  35642. * Remove a morph target for the list of scene's morph targets
  35643. * @param toRemove defines the morph target to remove
  35644. * @returns the index where the morph target was in the morph target list
  35645. */
  35646. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35647. /**
  35648. * Remove a light for the list of scene's lights
  35649. * @param toRemove defines the light to remove
  35650. * @returns the index where the light was in the light list
  35651. */
  35652. removeLight(toRemove: Light): number;
  35653. /**
  35654. * Remove a camera for the list of scene's cameras
  35655. * @param toRemove defines the camera to remove
  35656. * @returns the index where the camera was in the camera list
  35657. */
  35658. removeCamera(toRemove: Camera): number;
  35659. /**
  35660. * Remove a particle system for the list of scene's particle systems
  35661. * @param toRemove defines the particle system to remove
  35662. * @returns the index where the particle system was in the particle system list
  35663. */
  35664. removeParticleSystem(toRemove: IParticleSystem): number;
  35665. /**
  35666. * Remove a animation for the list of scene's animations
  35667. * @param toRemove defines the animation to remove
  35668. * @returns the index where the animation was in the animation list
  35669. */
  35670. removeAnimation(toRemove: Animation): number;
  35671. /**
  35672. * Will stop the animation of the given target
  35673. * @param target - the target
  35674. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35675. * @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)
  35676. */
  35677. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35678. /**
  35679. * Removes the given animation group from this scene.
  35680. * @param toRemove The animation group to remove
  35681. * @returns The index of the removed animation group
  35682. */
  35683. removeAnimationGroup(toRemove: AnimationGroup): number;
  35684. /**
  35685. * Removes the given multi-material from this scene.
  35686. * @param toRemove The multi-material to remove
  35687. * @returns The index of the removed multi-material
  35688. */
  35689. removeMultiMaterial(toRemove: MultiMaterial): number;
  35690. /**
  35691. * Removes the given material from this scene.
  35692. * @param toRemove The material to remove
  35693. * @returns The index of the removed material
  35694. */
  35695. removeMaterial(toRemove: Material): number;
  35696. /**
  35697. * Removes the given action manager from this scene.
  35698. * @param toRemove The action manager to remove
  35699. * @returns The index of the removed action manager
  35700. */
  35701. removeActionManager(toRemove: AbstractActionManager): number;
  35702. /**
  35703. * Removes the given texture from this scene.
  35704. * @param toRemove The texture to remove
  35705. * @returns The index of the removed texture
  35706. */
  35707. removeTexture(toRemove: BaseTexture): number;
  35708. /**
  35709. * Adds the given light to this scene
  35710. * @param newLight The light to add
  35711. */
  35712. addLight(newLight: Light): void;
  35713. /**
  35714. * Sorts the list list based on light priorities
  35715. */
  35716. sortLightsByPriority(): void;
  35717. /**
  35718. * Adds the given camera to this scene
  35719. * @param newCamera The camera to add
  35720. */
  35721. addCamera(newCamera: Camera): void;
  35722. /**
  35723. * Adds the given skeleton to this scene
  35724. * @param newSkeleton The skeleton to add
  35725. */
  35726. addSkeleton(newSkeleton: Skeleton): void;
  35727. /**
  35728. * Adds the given particle system to this scene
  35729. * @param newParticleSystem The particle system to add
  35730. */
  35731. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35732. /**
  35733. * Adds the given animation to this scene
  35734. * @param newAnimation The animation to add
  35735. */
  35736. addAnimation(newAnimation: Animation): void;
  35737. /**
  35738. * Adds the given animation group to this scene.
  35739. * @param newAnimationGroup The animation group to add
  35740. */
  35741. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35742. /**
  35743. * Adds the given multi-material to this scene
  35744. * @param newMultiMaterial The multi-material to add
  35745. */
  35746. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35747. /**
  35748. * Adds the given material to this scene
  35749. * @param newMaterial The material to add
  35750. */
  35751. addMaterial(newMaterial: Material): void;
  35752. /**
  35753. * Adds the given morph target to this scene
  35754. * @param newMorphTargetManager The morph target to add
  35755. */
  35756. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35757. /**
  35758. * Adds the given geometry to this scene
  35759. * @param newGeometry The geometry to add
  35760. */
  35761. addGeometry(newGeometry: Geometry): void;
  35762. /**
  35763. * Adds the given action manager to this scene
  35764. * @param newActionManager The action manager to add
  35765. */
  35766. addActionManager(newActionManager: AbstractActionManager): void;
  35767. /**
  35768. * Adds the given texture to this scene.
  35769. * @param newTexture The texture to add
  35770. */
  35771. addTexture(newTexture: BaseTexture): void;
  35772. /**
  35773. * Switch active camera
  35774. * @param newCamera defines the new active camera
  35775. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35776. */
  35777. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35778. /**
  35779. * sets the active camera of the scene using its ID
  35780. * @param id defines the camera's ID
  35781. * @return the new active camera or null if none found.
  35782. */
  35783. setActiveCameraByID(id: string): Nullable<Camera>;
  35784. /**
  35785. * sets the active camera of the scene using its name
  35786. * @param name defines the camera's name
  35787. * @returns the new active camera or null if none found.
  35788. */
  35789. setActiveCameraByName(name: string): Nullable<Camera>;
  35790. /**
  35791. * get an animation group using its name
  35792. * @param name defines the material's name
  35793. * @return the animation group or null if none found.
  35794. */
  35795. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35796. /**
  35797. * Get a material using its unique id
  35798. * @param uniqueId defines the material's unique id
  35799. * @return the material or null if none found.
  35800. */
  35801. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35802. /**
  35803. * get a material using its id
  35804. * @param id defines the material's ID
  35805. * @return the material or null if none found.
  35806. */
  35807. getMaterialByID(id: string): Nullable<Material>;
  35808. /**
  35809. * Gets a the last added material using a given id
  35810. * @param id defines the material's ID
  35811. * @return the last material with the given id or null if none found.
  35812. */
  35813. getLastMaterialByID(id: string): Nullable<Material>;
  35814. /**
  35815. * Gets a material using its name
  35816. * @param name defines the material's name
  35817. * @return the material or null if none found.
  35818. */
  35819. getMaterialByName(name: string): Nullable<Material>;
  35820. /**
  35821. * Get a texture using its unique id
  35822. * @param uniqueId defines the texture's unique id
  35823. * @return the texture or null if none found.
  35824. */
  35825. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35826. /**
  35827. * Gets a camera using its id
  35828. * @param id defines the id to look for
  35829. * @returns the camera or null if not found
  35830. */
  35831. getCameraByID(id: string): Nullable<Camera>;
  35832. /**
  35833. * Gets a camera using its unique id
  35834. * @param uniqueId defines the unique id to look for
  35835. * @returns the camera or null if not found
  35836. */
  35837. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35838. /**
  35839. * Gets a camera using its name
  35840. * @param name defines the camera's name
  35841. * @return the camera or null if none found.
  35842. */
  35843. getCameraByName(name: string): Nullable<Camera>;
  35844. /**
  35845. * Gets a bone using its id
  35846. * @param id defines the bone's id
  35847. * @return the bone or null if not found
  35848. */
  35849. getBoneByID(id: string): Nullable<Bone>;
  35850. /**
  35851. * Gets a bone using its id
  35852. * @param name defines the bone's name
  35853. * @return the bone or null if not found
  35854. */
  35855. getBoneByName(name: string): Nullable<Bone>;
  35856. /**
  35857. * Gets a light node using its name
  35858. * @param name defines the the light's name
  35859. * @return the light or null if none found.
  35860. */
  35861. getLightByName(name: string): Nullable<Light>;
  35862. /**
  35863. * Gets a light node using its id
  35864. * @param id defines the light's id
  35865. * @return the light or null if none found.
  35866. */
  35867. getLightByID(id: string): Nullable<Light>;
  35868. /**
  35869. * Gets a light node using its scene-generated unique ID
  35870. * @param uniqueId defines the light's unique id
  35871. * @return the light or null if none found.
  35872. */
  35873. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35874. /**
  35875. * Gets a particle system by id
  35876. * @param id defines the particle system id
  35877. * @return the corresponding system or null if none found
  35878. */
  35879. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35880. /**
  35881. * Gets a geometry using its ID
  35882. * @param id defines the geometry's id
  35883. * @return the geometry or null if none found.
  35884. */
  35885. getGeometryByID(id: string): Nullable<Geometry>;
  35886. private _getGeometryByUniqueID;
  35887. /**
  35888. * Add a new geometry to this scene
  35889. * @param geometry defines the geometry to be added to the scene.
  35890. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35891. * @return a boolean defining if the geometry was added or not
  35892. */
  35893. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35894. /**
  35895. * Removes an existing geometry
  35896. * @param geometry defines the geometry to be removed from the scene
  35897. * @return a boolean defining if the geometry was removed or not
  35898. */
  35899. removeGeometry(geometry: Geometry): boolean;
  35900. /**
  35901. * Gets the list of geometries attached to the scene
  35902. * @returns an array of Geometry
  35903. */
  35904. getGeometries(): Geometry[];
  35905. /**
  35906. * Gets the first added mesh found of a given ID
  35907. * @param id defines the id to search for
  35908. * @return the mesh found or null if not found at all
  35909. */
  35910. getMeshByID(id: string): Nullable<AbstractMesh>;
  35911. /**
  35912. * Gets a list of meshes using their id
  35913. * @param id defines the id to search for
  35914. * @returns a list of meshes
  35915. */
  35916. getMeshesByID(id: string): Array<AbstractMesh>;
  35917. /**
  35918. * Gets the first added transform node found of a given ID
  35919. * @param id defines the id to search for
  35920. * @return the found transform node or null if not found at all.
  35921. */
  35922. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35923. /**
  35924. * Gets a transform node with its auto-generated unique id
  35925. * @param uniqueId efines the unique id to search for
  35926. * @return the found transform node or null if not found at all.
  35927. */
  35928. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35929. /**
  35930. * Gets a list of transform nodes using their id
  35931. * @param id defines the id to search for
  35932. * @returns a list of transform nodes
  35933. */
  35934. getTransformNodesByID(id: string): Array<TransformNode>;
  35935. /**
  35936. * Gets a mesh with its auto-generated unique id
  35937. * @param uniqueId defines the unique id to search for
  35938. * @return the found mesh or null if not found at all.
  35939. */
  35940. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35941. /**
  35942. * Gets a the last added mesh using a given id
  35943. * @param id defines the id to search for
  35944. * @return the found mesh or null if not found at all.
  35945. */
  35946. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35947. /**
  35948. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35949. * @param id defines the id to search for
  35950. * @return the found node or null if not found at all
  35951. */
  35952. getLastEntryByID(id: string): Nullable<Node>;
  35953. /**
  35954. * Gets a node (Mesh, Camera, Light) using a given id
  35955. * @param id defines the id to search for
  35956. * @return the found node or null if not found at all
  35957. */
  35958. getNodeByID(id: string): Nullable<Node>;
  35959. /**
  35960. * Gets a node (Mesh, Camera, Light) using a given name
  35961. * @param name defines the name to search for
  35962. * @return the found node or null if not found at all.
  35963. */
  35964. getNodeByName(name: string): Nullable<Node>;
  35965. /**
  35966. * Gets a mesh using a given name
  35967. * @param name defines the name to search for
  35968. * @return the found mesh or null if not found at all.
  35969. */
  35970. getMeshByName(name: string): Nullable<AbstractMesh>;
  35971. /**
  35972. * Gets a transform node using a given name
  35973. * @param name defines the name to search for
  35974. * @return the found transform node or null if not found at all.
  35975. */
  35976. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35977. /**
  35978. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35979. * @param id defines the id to search for
  35980. * @return the found skeleton or null if not found at all.
  35981. */
  35982. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35983. /**
  35984. * Gets a skeleton using a given auto generated unique id
  35985. * @param uniqueId defines the unique id to search for
  35986. * @return the found skeleton or null if not found at all.
  35987. */
  35988. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35989. /**
  35990. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35991. * @param id defines the id to search for
  35992. * @return the found skeleton or null if not found at all.
  35993. */
  35994. getSkeletonById(id: string): Nullable<Skeleton>;
  35995. /**
  35996. * Gets a skeleton using a given name
  35997. * @param name defines the name to search for
  35998. * @return the found skeleton or null if not found at all.
  35999. */
  36000. getSkeletonByName(name: string): Nullable<Skeleton>;
  36001. /**
  36002. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36003. * @param id defines the id to search for
  36004. * @return the found morph target manager or null if not found at all.
  36005. */
  36006. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36007. /**
  36008. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36009. * @param id defines the id to search for
  36010. * @return the found morph target or null if not found at all.
  36011. */
  36012. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36013. /**
  36014. * Gets a boolean indicating if the given mesh is active
  36015. * @param mesh defines the mesh to look for
  36016. * @returns true if the mesh is in the active list
  36017. */
  36018. isActiveMesh(mesh: AbstractMesh): boolean;
  36019. /**
  36020. * Return a unique id as a string which can serve as an identifier for the scene
  36021. */
  36022. readonly uid: string;
  36023. /**
  36024. * Add an externaly attached data from its key.
  36025. * This method call will fail and return false, if such key already exists.
  36026. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36027. * @param key the unique key that identifies the data
  36028. * @param data the data object to associate to the key for this Engine instance
  36029. * @return true if no such key were already present and the data was added successfully, false otherwise
  36030. */
  36031. addExternalData<T>(key: string, data: T): boolean;
  36032. /**
  36033. * Get an externaly attached data from its key
  36034. * @param key the unique key that identifies the data
  36035. * @return the associated data, if present (can be null), or undefined if not present
  36036. */
  36037. getExternalData<T>(key: string): Nullable<T>;
  36038. /**
  36039. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36040. * @param key the unique key that identifies the data
  36041. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36042. * @return the associated data, can be null if the factory returned null.
  36043. */
  36044. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36045. /**
  36046. * Remove an externaly attached data from the Engine instance
  36047. * @param key the unique key that identifies the data
  36048. * @return true if the data was successfully removed, false if it doesn't exist
  36049. */
  36050. removeExternalData(key: string): boolean;
  36051. private _evaluateSubMesh;
  36052. /**
  36053. * Clear the processed materials smart array preventing retention point in material dispose.
  36054. */
  36055. freeProcessedMaterials(): void;
  36056. private _preventFreeActiveMeshesAndRenderingGroups;
  36057. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36058. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36059. * when disposing several meshes in a row or a hierarchy of meshes.
  36060. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36061. */
  36062. blockfreeActiveMeshesAndRenderingGroups: boolean;
  36063. /**
  36064. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36065. */
  36066. freeActiveMeshes(): void;
  36067. /**
  36068. * Clear the info related to rendering groups preventing retention points during dispose.
  36069. */
  36070. freeRenderingGroups(): void;
  36071. /** @hidden */
  36072. _isInIntermediateRendering(): boolean;
  36073. /**
  36074. * Lambda returning the list of potentially active meshes.
  36075. */
  36076. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36077. /**
  36078. * Lambda returning the list of potentially active sub meshes.
  36079. */
  36080. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36081. /**
  36082. * Lambda returning the list of potentially intersecting sub meshes.
  36083. */
  36084. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36085. /**
  36086. * Lambda returning the list of potentially colliding sub meshes.
  36087. */
  36088. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36089. private _activeMeshesFrozen;
  36090. private _skipEvaluateActiveMeshesCompletely;
  36091. /**
  36092. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36093. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36094. * @returns the current scene
  36095. */
  36096. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36097. /**
  36098. * Use this function to restart evaluating active meshes on every frame
  36099. * @returns the current scene
  36100. */
  36101. unfreezeActiveMeshes(): Scene;
  36102. private _evaluateActiveMeshes;
  36103. private _activeMesh;
  36104. /**
  36105. * Update the transform matrix to update from the current active camera
  36106. * @param force defines a boolean used to force the update even if cache is up to date
  36107. */
  36108. updateTransformMatrix(force?: boolean): void;
  36109. private _bindFrameBuffer;
  36110. /** @hidden */
  36111. _allowPostProcessClearColor: boolean;
  36112. /** @hidden */
  36113. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36114. private _processSubCameras;
  36115. private _checkIntersections;
  36116. /** @hidden */
  36117. _advancePhysicsEngineStep(step: number): void;
  36118. /**
  36119. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36120. */
  36121. getDeterministicFrameTime: () => number;
  36122. /** @hidden */
  36123. _animate(): void;
  36124. /** Execute all animations (for a frame) */
  36125. animate(): void;
  36126. /**
  36127. * Render the scene
  36128. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36129. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36130. */
  36131. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36132. /**
  36133. * Freeze all materials
  36134. * A frozen material will not be updatable but should be faster to render
  36135. */
  36136. freezeMaterials(): void;
  36137. /**
  36138. * Unfreeze all materials
  36139. * A frozen material will not be updatable but should be faster to render
  36140. */
  36141. unfreezeMaterials(): void;
  36142. /**
  36143. * Releases all held ressources
  36144. */
  36145. dispose(): void;
  36146. /**
  36147. * Gets if the scene is already disposed
  36148. */
  36149. readonly isDisposed: boolean;
  36150. /**
  36151. * Call this function to reduce memory footprint of the scene.
  36152. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36153. */
  36154. clearCachedVertexData(): void;
  36155. /**
  36156. * This function will remove the local cached buffer data from texture.
  36157. * It will save memory but will prevent the texture from being rebuilt
  36158. */
  36159. cleanCachedTextureBuffer(): void;
  36160. /**
  36161. * Get the world extend vectors with an optional filter
  36162. *
  36163. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36164. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36165. */
  36166. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36167. min: Vector3;
  36168. max: Vector3;
  36169. };
  36170. /**
  36171. * Creates a ray that can be used to pick in the scene
  36172. * @param x defines the x coordinate of the origin (on-screen)
  36173. * @param y defines the y coordinate of the origin (on-screen)
  36174. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36175. * @param camera defines the camera to use for the picking
  36176. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36177. * @returns a Ray
  36178. */
  36179. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36180. /**
  36181. * Creates a ray that can be used to pick in the scene
  36182. * @param x defines the x coordinate of the origin (on-screen)
  36183. * @param y defines the y coordinate of the origin (on-screen)
  36184. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36185. * @param result defines the ray where to store the picking ray
  36186. * @param camera defines the camera to use for the picking
  36187. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36188. * @returns the current scene
  36189. */
  36190. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36191. /**
  36192. * Creates a ray that can be used to pick in the scene
  36193. * @param x defines the x coordinate of the origin (on-screen)
  36194. * @param y defines the y coordinate of the origin (on-screen)
  36195. * @param camera defines the camera to use for the picking
  36196. * @returns a Ray
  36197. */
  36198. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36199. /**
  36200. * Creates a ray that can be used to pick in the scene
  36201. * @param x defines the x coordinate of the origin (on-screen)
  36202. * @param y defines the y coordinate of the origin (on-screen)
  36203. * @param result defines the ray where to store the picking ray
  36204. * @param camera defines the camera to use for the picking
  36205. * @returns the current scene
  36206. */
  36207. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36208. /** Launch a ray to try to pick a mesh in the scene
  36209. * @param x position on screen
  36210. * @param y position on screen
  36211. * @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
  36212. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36213. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36214. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36215. * @returns a PickingInfo
  36216. */
  36217. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36218. /** Use the given ray to pick a mesh in the scene
  36219. * @param ray The ray to use to pick meshes
  36220. * @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
  36221. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36222. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36223. * @returns a PickingInfo
  36224. */
  36225. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36226. /**
  36227. * Launch a ray to try to pick a mesh in the scene
  36228. * @param x X position on screen
  36229. * @param y Y position on screen
  36230. * @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
  36231. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36232. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36233. * @returns an array of PickingInfo
  36234. */
  36235. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36236. /**
  36237. * Launch a ray to try to pick a mesh in the scene
  36238. * @param ray Ray to use
  36239. * @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
  36240. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36241. * @returns an array of PickingInfo
  36242. */
  36243. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36244. /**
  36245. * Force the value of meshUnderPointer
  36246. * @param mesh defines the mesh to use
  36247. */
  36248. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36249. /**
  36250. * Gets the mesh under the pointer
  36251. * @returns a Mesh or null if no mesh is under the pointer
  36252. */
  36253. getPointerOverMesh(): Nullable<AbstractMesh>;
  36254. /** @hidden */
  36255. _rebuildGeometries(): void;
  36256. /** @hidden */
  36257. _rebuildTextures(): void;
  36258. private _getByTags;
  36259. /**
  36260. * Get a list of meshes by tags
  36261. * @param tagsQuery defines the tags query to use
  36262. * @param forEach defines a predicate used to filter results
  36263. * @returns an array of Mesh
  36264. */
  36265. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36266. /**
  36267. * Get a list of cameras by tags
  36268. * @param tagsQuery defines the tags query to use
  36269. * @param forEach defines a predicate used to filter results
  36270. * @returns an array of Camera
  36271. */
  36272. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36273. /**
  36274. * Get a list of lights by tags
  36275. * @param tagsQuery defines the tags query to use
  36276. * @param forEach defines a predicate used to filter results
  36277. * @returns an array of Light
  36278. */
  36279. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36280. /**
  36281. * Get a list of materials by tags
  36282. * @param tagsQuery defines the tags query to use
  36283. * @param forEach defines a predicate used to filter results
  36284. * @returns an array of Material
  36285. */
  36286. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36287. /**
  36288. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36289. * This allowed control for front to back rendering or reversly depending of the special needs.
  36290. *
  36291. * @param renderingGroupId The rendering group id corresponding to its index
  36292. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36293. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36294. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36295. */
  36296. 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;
  36297. /**
  36298. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36299. *
  36300. * @param renderingGroupId The rendering group id corresponding to its index
  36301. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36302. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36303. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36304. */
  36305. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36306. /**
  36307. * Gets the current auto clear configuration for one rendering group of the rendering
  36308. * manager.
  36309. * @param index the rendering group index to get the information for
  36310. * @returns The auto clear setup for the requested rendering group
  36311. */
  36312. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36313. private _blockMaterialDirtyMechanism;
  36314. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36315. blockMaterialDirtyMechanism: boolean;
  36316. /**
  36317. * Will flag all materials as dirty to trigger new shader compilation
  36318. * @param flag defines the flag used to specify which material part must be marked as dirty
  36319. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36320. */
  36321. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36322. /** @hidden */
  36323. _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;
  36324. /** @hidden */
  36325. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36326. /** @hidden */
  36327. _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;
  36328. /** @hidden */
  36329. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36330. /** @hidden */
  36331. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36332. /** @hidden */
  36333. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36334. }
  36335. }
  36336. declare module BABYLON {
  36337. /**
  36338. * Set of assets to keep when moving a scene into an asset container.
  36339. */
  36340. export class KeepAssets extends AbstractScene {
  36341. }
  36342. /**
  36343. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36344. */
  36345. export class InstantiatedEntries {
  36346. /**
  36347. * List of new root nodes (eg. nodes with no parent)
  36348. */
  36349. rootNodes: TransformNode[];
  36350. /**
  36351. * List of new skeletons
  36352. */
  36353. skeletons: Skeleton[];
  36354. /**
  36355. * List of new animation groups
  36356. */
  36357. animationGroups: AnimationGroup[];
  36358. }
  36359. /**
  36360. * Container with a set of assets that can be added or removed from a scene.
  36361. */
  36362. export class AssetContainer extends AbstractScene {
  36363. /**
  36364. * The scene the AssetContainer belongs to.
  36365. */
  36366. scene: Scene;
  36367. /**
  36368. * Instantiates an AssetContainer.
  36369. * @param scene The scene the AssetContainer belongs to.
  36370. */
  36371. constructor(scene: Scene);
  36372. /**
  36373. * Instantiate or clone all meshes and add the new ones to the scene.
  36374. * Skeletons and animation groups will all be cloned
  36375. * @param nameFunction defines an optional function used to get new names for clones
  36376. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36377. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36378. */
  36379. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36380. /**
  36381. * Adds all the assets from the container to the scene.
  36382. */
  36383. addAllToScene(): void;
  36384. /**
  36385. * Removes all the assets in the container from the scene
  36386. */
  36387. removeAllFromScene(): void;
  36388. /**
  36389. * Disposes all the assets in the container
  36390. */
  36391. dispose(): void;
  36392. private _moveAssets;
  36393. /**
  36394. * Removes all the assets contained in the scene and adds them to the container.
  36395. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36396. */
  36397. moveAllFromScene(keepAssets?: KeepAssets): void;
  36398. /**
  36399. * 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.
  36400. * @returns the root mesh
  36401. */
  36402. createRootMesh(): Mesh;
  36403. /**
  36404. * Merge animations from this asset container into a scene
  36405. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36406. * @param animatables set of animatables to retarget to a node from the scene
  36407. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36408. */
  36409. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36410. }
  36411. }
  36412. declare module BABYLON {
  36413. /**
  36414. * Defines how the parser contract is defined.
  36415. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36416. */
  36417. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36418. /**
  36419. * Defines how the individual parser contract is defined.
  36420. * These parser can parse an individual asset
  36421. */
  36422. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36423. /**
  36424. * Base class of the scene acting as a container for the different elements composing a scene.
  36425. * This class is dynamically extended by the different components of the scene increasing
  36426. * flexibility and reducing coupling
  36427. */
  36428. export abstract class AbstractScene {
  36429. /**
  36430. * Stores the list of available parsers in the application.
  36431. */
  36432. private static _BabylonFileParsers;
  36433. /**
  36434. * Stores the list of available individual parsers in the application.
  36435. */
  36436. private static _IndividualBabylonFileParsers;
  36437. /**
  36438. * Adds a parser in the list of available ones
  36439. * @param name Defines the name of the parser
  36440. * @param parser Defines the parser to add
  36441. */
  36442. static AddParser(name: string, parser: BabylonFileParser): void;
  36443. /**
  36444. * Gets a general parser from the list of avaialble ones
  36445. * @param name Defines the name of the parser
  36446. * @returns the requested parser or null
  36447. */
  36448. static GetParser(name: string): Nullable<BabylonFileParser>;
  36449. /**
  36450. * Adds n individual parser in the list of available ones
  36451. * @param name Defines the name of the parser
  36452. * @param parser Defines the parser to add
  36453. */
  36454. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36455. /**
  36456. * Gets an individual parser from the list of avaialble ones
  36457. * @param name Defines the name of the parser
  36458. * @returns the requested parser or null
  36459. */
  36460. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36461. /**
  36462. * Parser json data and populate both a scene and its associated container object
  36463. * @param jsonData Defines the data to parse
  36464. * @param scene Defines the scene to parse the data for
  36465. * @param container Defines the container attached to the parsing sequence
  36466. * @param rootUrl Defines the root url of the data
  36467. */
  36468. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36469. /**
  36470. * Gets the list of root nodes (ie. nodes with no parent)
  36471. */
  36472. rootNodes: Node[];
  36473. /** All of the cameras added to this scene
  36474. * @see http://doc.babylonjs.com/babylon101/cameras
  36475. */
  36476. cameras: Camera[];
  36477. /**
  36478. * All of the lights added to this scene
  36479. * @see http://doc.babylonjs.com/babylon101/lights
  36480. */
  36481. lights: Light[];
  36482. /**
  36483. * All of the (abstract) meshes added to this scene
  36484. */
  36485. meshes: AbstractMesh[];
  36486. /**
  36487. * The list of skeletons added to the scene
  36488. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36489. */
  36490. skeletons: Skeleton[];
  36491. /**
  36492. * All of the particle systems added to this scene
  36493. * @see http://doc.babylonjs.com/babylon101/particles
  36494. */
  36495. particleSystems: IParticleSystem[];
  36496. /**
  36497. * Gets a list of Animations associated with the scene
  36498. */
  36499. animations: Animation[];
  36500. /**
  36501. * All of the animation groups added to this scene
  36502. * @see http://doc.babylonjs.com/how_to/group
  36503. */
  36504. animationGroups: AnimationGroup[];
  36505. /**
  36506. * All of the multi-materials added to this scene
  36507. * @see http://doc.babylonjs.com/how_to/multi_materials
  36508. */
  36509. multiMaterials: MultiMaterial[];
  36510. /**
  36511. * All of the materials added to this scene
  36512. * In the context of a Scene, it is not supposed to be modified manually.
  36513. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36514. * Note also that the order of the Material within the array is not significant and might change.
  36515. * @see http://doc.babylonjs.com/babylon101/materials
  36516. */
  36517. materials: Material[];
  36518. /**
  36519. * The list of morph target managers added to the scene
  36520. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36521. */
  36522. morphTargetManagers: MorphTargetManager[];
  36523. /**
  36524. * The list of geometries used in the scene.
  36525. */
  36526. geometries: Geometry[];
  36527. /**
  36528. * All of the tranform nodes added to this scene
  36529. * In the context of a Scene, it is not supposed to be modified manually.
  36530. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36531. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36532. * @see http://doc.babylonjs.com/how_to/transformnode
  36533. */
  36534. transformNodes: TransformNode[];
  36535. /**
  36536. * ActionManagers available on the scene.
  36537. */
  36538. actionManagers: AbstractActionManager[];
  36539. /**
  36540. * Textures to keep.
  36541. */
  36542. textures: BaseTexture[];
  36543. /**
  36544. * Environment texture for the scene
  36545. */
  36546. environmentTexture: Nullable<BaseTexture>;
  36547. /**
  36548. * @returns all meshes, lights, cameras, transformNodes and bones
  36549. */
  36550. getNodes(): Array<Node>;
  36551. }
  36552. }
  36553. declare module BABYLON {
  36554. /**
  36555. * Interface used to define options for Sound class
  36556. */
  36557. export interface ISoundOptions {
  36558. /**
  36559. * Does the sound autoplay once loaded.
  36560. */
  36561. autoplay?: boolean;
  36562. /**
  36563. * Does the sound loop after it finishes playing once.
  36564. */
  36565. loop?: boolean;
  36566. /**
  36567. * Sound's volume
  36568. */
  36569. volume?: number;
  36570. /**
  36571. * Is it a spatial sound?
  36572. */
  36573. spatialSound?: boolean;
  36574. /**
  36575. * Maximum distance to hear that sound
  36576. */
  36577. maxDistance?: number;
  36578. /**
  36579. * Uses user defined attenuation function
  36580. */
  36581. useCustomAttenuation?: boolean;
  36582. /**
  36583. * Define the roll off factor of spatial sounds.
  36584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36585. */
  36586. rolloffFactor?: number;
  36587. /**
  36588. * Define the reference distance the sound should be heard perfectly.
  36589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36590. */
  36591. refDistance?: number;
  36592. /**
  36593. * Define the distance attenuation model the sound will follow.
  36594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36595. */
  36596. distanceModel?: string;
  36597. /**
  36598. * Defines the playback speed (1 by default)
  36599. */
  36600. playbackRate?: number;
  36601. /**
  36602. * Defines if the sound is from a streaming source
  36603. */
  36604. streaming?: boolean;
  36605. /**
  36606. * Defines an optional length (in seconds) inside the sound file
  36607. */
  36608. length?: number;
  36609. /**
  36610. * Defines an optional offset (in seconds) inside the sound file
  36611. */
  36612. offset?: number;
  36613. /**
  36614. * If true, URLs will not be required to state the audio file codec to use.
  36615. */
  36616. skipCodecCheck?: boolean;
  36617. }
  36618. /**
  36619. * Defines a sound that can be played in the application.
  36620. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36622. */
  36623. export class Sound {
  36624. /**
  36625. * The name of the sound in the scene.
  36626. */
  36627. name: string;
  36628. /**
  36629. * Does the sound autoplay once loaded.
  36630. */
  36631. autoplay: boolean;
  36632. /**
  36633. * Does the sound loop after it finishes playing once.
  36634. */
  36635. loop: boolean;
  36636. /**
  36637. * Does the sound use a custom attenuation curve to simulate the falloff
  36638. * happening when the source gets further away from the camera.
  36639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36640. */
  36641. useCustomAttenuation: boolean;
  36642. /**
  36643. * The sound track id this sound belongs to.
  36644. */
  36645. soundTrackId: number;
  36646. /**
  36647. * Is this sound currently played.
  36648. */
  36649. isPlaying: boolean;
  36650. /**
  36651. * Is this sound currently paused.
  36652. */
  36653. isPaused: boolean;
  36654. /**
  36655. * Does this sound enables spatial sound.
  36656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36657. */
  36658. spatialSound: boolean;
  36659. /**
  36660. * Define the reference distance the sound should be heard perfectly.
  36661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36662. */
  36663. refDistance: number;
  36664. /**
  36665. * Define the roll off factor of spatial sounds.
  36666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36667. */
  36668. rolloffFactor: number;
  36669. /**
  36670. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36672. */
  36673. maxDistance: number;
  36674. /**
  36675. * Define the distance attenuation model the sound will follow.
  36676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36677. */
  36678. distanceModel: string;
  36679. /**
  36680. * @hidden
  36681. * Back Compat
  36682. **/
  36683. onended: () => any;
  36684. /**
  36685. * Observable event when the current playing sound finishes.
  36686. */
  36687. onEndedObservable: Observable<Sound>;
  36688. private _panningModel;
  36689. private _playbackRate;
  36690. private _streaming;
  36691. private _startTime;
  36692. private _startOffset;
  36693. private _position;
  36694. /** @hidden */
  36695. _positionInEmitterSpace: boolean;
  36696. private _localDirection;
  36697. private _volume;
  36698. private _isReadyToPlay;
  36699. private _isDirectional;
  36700. private _readyToPlayCallback;
  36701. private _audioBuffer;
  36702. private _soundSource;
  36703. private _streamingSource;
  36704. private _soundPanner;
  36705. private _soundGain;
  36706. private _inputAudioNode;
  36707. private _outputAudioNode;
  36708. private _coneInnerAngle;
  36709. private _coneOuterAngle;
  36710. private _coneOuterGain;
  36711. private _scene;
  36712. private _connectedTransformNode;
  36713. private _customAttenuationFunction;
  36714. private _registerFunc;
  36715. private _isOutputConnected;
  36716. private _htmlAudioElement;
  36717. private _urlType;
  36718. private _length?;
  36719. private _offset?;
  36720. /** @hidden */
  36721. static _SceneComponentInitialization: (scene: Scene) => void;
  36722. /**
  36723. * Create a sound and attach it to a scene
  36724. * @param name Name of your sound
  36725. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36726. * @param scene defines the scene the sound belongs to
  36727. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36728. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36729. */
  36730. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36731. /**
  36732. * Release the sound and its associated resources
  36733. */
  36734. dispose(): void;
  36735. /**
  36736. * Gets if the sounds is ready to be played or not.
  36737. * @returns true if ready, otherwise false
  36738. */
  36739. isReady(): boolean;
  36740. private _soundLoaded;
  36741. /**
  36742. * Sets the data of the sound from an audiobuffer
  36743. * @param audioBuffer The audioBuffer containing the data
  36744. */
  36745. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36746. /**
  36747. * Updates the current sounds options such as maxdistance, loop...
  36748. * @param options A JSON object containing values named as the object properties
  36749. */
  36750. updateOptions(options: ISoundOptions): void;
  36751. private _createSpatialParameters;
  36752. private _updateSpatialParameters;
  36753. /**
  36754. * Switch the panning model to HRTF:
  36755. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36757. */
  36758. switchPanningModelToHRTF(): void;
  36759. /**
  36760. * Switch the panning model to Equal Power:
  36761. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36763. */
  36764. switchPanningModelToEqualPower(): void;
  36765. private _switchPanningModel;
  36766. /**
  36767. * Connect this sound to a sound track audio node like gain...
  36768. * @param soundTrackAudioNode the sound track audio node to connect to
  36769. */
  36770. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36771. /**
  36772. * Transform this sound into a directional source
  36773. * @param coneInnerAngle Size of the inner cone in degree
  36774. * @param coneOuterAngle Size of the outer cone in degree
  36775. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36776. */
  36777. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36778. /**
  36779. * Gets or sets the inner angle for the directional cone.
  36780. */
  36781. /**
  36782. * Gets or sets the inner angle for the directional cone.
  36783. */
  36784. directionalConeInnerAngle: number;
  36785. /**
  36786. * Gets or sets the outer angle for the directional cone.
  36787. */
  36788. /**
  36789. * Gets or sets the outer angle for the directional cone.
  36790. */
  36791. directionalConeOuterAngle: number;
  36792. /**
  36793. * Sets the position of the emitter if spatial sound is enabled
  36794. * @param newPosition Defines the new posisiton
  36795. */
  36796. setPosition(newPosition: Vector3): void;
  36797. /**
  36798. * Sets the local direction of the emitter if spatial sound is enabled
  36799. * @param newLocalDirection Defines the new local direction
  36800. */
  36801. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36802. private _updateDirection;
  36803. /** @hidden */
  36804. updateDistanceFromListener(): void;
  36805. /**
  36806. * Sets a new custom attenuation function for the sound.
  36807. * @param callback Defines the function used for the attenuation
  36808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36809. */
  36810. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36811. /**
  36812. * Play the sound
  36813. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36814. * @param offset (optional) Start the sound at a specific time in seconds
  36815. * @param length (optional) Sound duration (in seconds)
  36816. */
  36817. play(time?: number, offset?: number, length?: number): void;
  36818. private _onended;
  36819. /**
  36820. * Stop the sound
  36821. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36822. */
  36823. stop(time?: number): void;
  36824. /**
  36825. * Put the sound in pause
  36826. */
  36827. pause(): void;
  36828. /**
  36829. * Sets a dedicated volume for this sounds
  36830. * @param newVolume Define the new volume of the sound
  36831. * @param time Define time for gradual change to new volume
  36832. */
  36833. setVolume(newVolume: number, time?: number): void;
  36834. /**
  36835. * Set the sound play back rate
  36836. * @param newPlaybackRate Define the playback rate the sound should be played at
  36837. */
  36838. setPlaybackRate(newPlaybackRate: number): void;
  36839. /**
  36840. * Gets the volume of the sound.
  36841. * @returns the volume of the sound
  36842. */
  36843. getVolume(): number;
  36844. /**
  36845. * Attach the sound to a dedicated mesh
  36846. * @param transformNode The transform node to connect the sound with
  36847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36848. */
  36849. attachToMesh(transformNode: TransformNode): void;
  36850. /**
  36851. * Detach the sound from the previously attached mesh
  36852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36853. */
  36854. detachFromMesh(): void;
  36855. private _onRegisterAfterWorldMatrixUpdate;
  36856. /**
  36857. * Clone the current sound in the scene.
  36858. * @returns the new sound clone
  36859. */
  36860. clone(): Nullable<Sound>;
  36861. /**
  36862. * Gets the current underlying audio buffer containing the data
  36863. * @returns the audio buffer
  36864. */
  36865. getAudioBuffer(): Nullable<AudioBuffer>;
  36866. /**
  36867. * Serializes the Sound in a JSON representation
  36868. * @returns the JSON representation of the sound
  36869. */
  36870. serialize(): any;
  36871. /**
  36872. * Parse a JSON representation of a sound to innstantiate in a given scene
  36873. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36874. * @param scene Define the scene the new parsed sound should be created in
  36875. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36876. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36877. * @returns the newly parsed sound
  36878. */
  36879. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36880. }
  36881. }
  36882. declare module BABYLON {
  36883. /**
  36884. * This defines an action helpful to play a defined sound on a triggered action.
  36885. */
  36886. export class PlaySoundAction extends Action {
  36887. private _sound;
  36888. /**
  36889. * Instantiate the action
  36890. * @param triggerOptions defines the trigger options
  36891. * @param sound defines the sound to play
  36892. * @param condition defines the trigger related conditions
  36893. */
  36894. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36895. /** @hidden */
  36896. _prepare(): void;
  36897. /**
  36898. * Execute the action and play the sound.
  36899. */
  36900. execute(): void;
  36901. /**
  36902. * Serializes the actions and its related information.
  36903. * @param parent defines the object to serialize in
  36904. * @returns the serialized object
  36905. */
  36906. serialize(parent: any): any;
  36907. }
  36908. /**
  36909. * This defines an action helpful to stop a defined sound on a triggered action.
  36910. */
  36911. export class StopSoundAction extends Action {
  36912. private _sound;
  36913. /**
  36914. * Instantiate the action
  36915. * @param triggerOptions defines the trigger options
  36916. * @param sound defines the sound to stop
  36917. * @param condition defines the trigger related conditions
  36918. */
  36919. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36920. /** @hidden */
  36921. _prepare(): void;
  36922. /**
  36923. * Execute the action and stop the sound.
  36924. */
  36925. execute(): void;
  36926. /**
  36927. * Serializes the actions and its related information.
  36928. * @param parent defines the object to serialize in
  36929. * @returns the serialized object
  36930. */
  36931. serialize(parent: any): any;
  36932. }
  36933. }
  36934. declare module BABYLON {
  36935. /**
  36936. * This defines an action responsible to change the value of a property
  36937. * by interpolating between its current value and the newly set one once triggered.
  36938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36939. */
  36940. export class InterpolateValueAction extends Action {
  36941. /**
  36942. * Defines the path of the property where the value should be interpolated
  36943. */
  36944. propertyPath: string;
  36945. /**
  36946. * Defines the target value at the end of the interpolation.
  36947. */
  36948. value: any;
  36949. /**
  36950. * Defines the time it will take for the property to interpolate to the value.
  36951. */
  36952. duration: number;
  36953. /**
  36954. * Defines if the other scene animations should be stopped when the action has been triggered
  36955. */
  36956. stopOtherAnimations?: boolean;
  36957. /**
  36958. * Defines a callback raised once the interpolation animation has been done.
  36959. */
  36960. onInterpolationDone?: () => void;
  36961. /**
  36962. * Observable triggered once the interpolation animation has been done.
  36963. */
  36964. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36965. private _target;
  36966. private _effectiveTarget;
  36967. private _property;
  36968. /**
  36969. * Instantiate the action
  36970. * @param triggerOptions defines the trigger options
  36971. * @param target defines the object containing the value to interpolate
  36972. * @param propertyPath defines the path to the property in the target object
  36973. * @param value defines the target value at the end of the interpolation
  36974. * @param duration deines the time it will take for the property to interpolate to the value.
  36975. * @param condition defines the trigger related conditions
  36976. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36977. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36978. */
  36979. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36980. /** @hidden */
  36981. _prepare(): void;
  36982. /**
  36983. * Execute the action starts the value interpolation.
  36984. */
  36985. execute(): void;
  36986. /**
  36987. * Serializes the actions and its related information.
  36988. * @param parent defines the object to serialize in
  36989. * @returns the serialized object
  36990. */
  36991. serialize(parent: any): any;
  36992. }
  36993. }
  36994. declare module BABYLON {
  36995. /**
  36996. * Options allowed during the creation of a sound track.
  36997. */
  36998. export interface ISoundTrackOptions {
  36999. /**
  37000. * The volume the sound track should take during creation
  37001. */
  37002. volume?: number;
  37003. /**
  37004. * Define if the sound track is the main sound track of the scene
  37005. */
  37006. mainTrack?: boolean;
  37007. }
  37008. /**
  37009. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37010. * It will be also used in a future release to apply effects on a specific track.
  37011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37012. */
  37013. export class SoundTrack {
  37014. /**
  37015. * The unique identifier of the sound track in the scene.
  37016. */
  37017. id: number;
  37018. /**
  37019. * The list of sounds included in the sound track.
  37020. */
  37021. soundCollection: Array<Sound>;
  37022. private _outputAudioNode;
  37023. private _scene;
  37024. private _connectedAnalyser;
  37025. private _options;
  37026. private _isInitialized;
  37027. /**
  37028. * Creates a new sound track.
  37029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37030. * @param scene Define the scene the sound track belongs to
  37031. * @param options
  37032. */
  37033. constructor(scene: Scene, options?: ISoundTrackOptions);
  37034. private _initializeSoundTrackAudioGraph;
  37035. /**
  37036. * Release the sound track and its associated resources
  37037. */
  37038. dispose(): void;
  37039. /**
  37040. * Adds a sound to this sound track
  37041. * @param sound define the cound to add
  37042. * @ignoreNaming
  37043. */
  37044. AddSound(sound: Sound): void;
  37045. /**
  37046. * Removes a sound to this sound track
  37047. * @param sound define the cound to remove
  37048. * @ignoreNaming
  37049. */
  37050. RemoveSound(sound: Sound): void;
  37051. /**
  37052. * Set a global volume for the full sound track.
  37053. * @param newVolume Define the new volume of the sound track
  37054. */
  37055. setVolume(newVolume: number): void;
  37056. /**
  37057. * Switch the panning model to HRTF:
  37058. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37060. */
  37061. switchPanningModelToHRTF(): void;
  37062. /**
  37063. * Switch the panning model to Equal Power:
  37064. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37066. */
  37067. switchPanningModelToEqualPower(): void;
  37068. /**
  37069. * Connect the sound track to an audio analyser allowing some amazing
  37070. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37072. * @param analyser The analyser to connect to the engine
  37073. */
  37074. connectToAnalyser(analyser: Analyser): void;
  37075. }
  37076. }
  37077. declare module BABYLON {
  37078. interface AbstractScene {
  37079. /**
  37080. * The list of sounds used in the scene.
  37081. */
  37082. sounds: Nullable<Array<Sound>>;
  37083. }
  37084. interface Scene {
  37085. /**
  37086. * @hidden
  37087. * Backing field
  37088. */
  37089. _mainSoundTrack: SoundTrack;
  37090. /**
  37091. * The main sound track played by the scene.
  37092. * It cotains your primary collection of sounds.
  37093. */
  37094. mainSoundTrack: SoundTrack;
  37095. /**
  37096. * The list of sound tracks added to the scene
  37097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37098. */
  37099. soundTracks: Nullable<Array<SoundTrack>>;
  37100. /**
  37101. * Gets a sound using a given name
  37102. * @param name defines the name to search for
  37103. * @return the found sound or null if not found at all.
  37104. */
  37105. getSoundByName(name: string): Nullable<Sound>;
  37106. /**
  37107. * Gets or sets if audio support is enabled
  37108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37109. */
  37110. audioEnabled: boolean;
  37111. /**
  37112. * Gets or sets if audio will be output to headphones
  37113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37114. */
  37115. headphone: boolean;
  37116. /**
  37117. * Gets or sets custom audio listener position provider
  37118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37119. */
  37120. audioListenerPositionProvider: Nullable<() => Vector3>;
  37121. /**
  37122. * Gets or sets a refresh rate when using 3D audio positioning
  37123. */
  37124. audioPositioningRefreshRate: number;
  37125. }
  37126. /**
  37127. * Defines the sound scene component responsible to manage any sounds
  37128. * in a given scene.
  37129. */
  37130. export class AudioSceneComponent implements ISceneSerializableComponent {
  37131. /**
  37132. * The component name helpfull to identify the component in the list of scene components.
  37133. */
  37134. readonly name: string;
  37135. /**
  37136. * The scene the component belongs to.
  37137. */
  37138. scene: Scene;
  37139. private _audioEnabled;
  37140. /**
  37141. * Gets whether audio is enabled or not.
  37142. * Please use related enable/disable method to switch state.
  37143. */
  37144. readonly audioEnabled: boolean;
  37145. private _headphone;
  37146. /**
  37147. * Gets whether audio is outputing to headphone or not.
  37148. * Please use the according Switch methods to change output.
  37149. */
  37150. readonly headphone: boolean;
  37151. /**
  37152. * Gets or sets a refresh rate when using 3D audio positioning
  37153. */
  37154. audioPositioningRefreshRate: number;
  37155. private _audioListenerPositionProvider;
  37156. /**
  37157. * Gets the current audio listener position provider
  37158. */
  37159. /**
  37160. * Sets a custom listener position for all sounds in the scene
  37161. * By default, this is the position of the first active camera
  37162. */
  37163. audioListenerPositionProvider: Nullable<() => Vector3>;
  37164. /**
  37165. * Creates a new instance of the component for the given scene
  37166. * @param scene Defines the scene to register the component in
  37167. */
  37168. constructor(scene: Scene);
  37169. /**
  37170. * Registers the component in a given scene
  37171. */
  37172. register(): void;
  37173. /**
  37174. * Rebuilds the elements related to this component in case of
  37175. * context lost for instance.
  37176. */
  37177. rebuild(): void;
  37178. /**
  37179. * Serializes the component data to the specified json object
  37180. * @param serializationObject The object to serialize to
  37181. */
  37182. serialize(serializationObject: any): void;
  37183. /**
  37184. * Adds all the elements from the container to the scene
  37185. * @param container the container holding the elements
  37186. */
  37187. addFromContainer(container: AbstractScene): void;
  37188. /**
  37189. * Removes all the elements in the container from the scene
  37190. * @param container contains the elements to remove
  37191. * @param dispose if the removed element should be disposed (default: false)
  37192. */
  37193. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37194. /**
  37195. * Disposes the component and the associated ressources.
  37196. */
  37197. dispose(): void;
  37198. /**
  37199. * Disables audio in the associated scene.
  37200. */
  37201. disableAudio(): void;
  37202. /**
  37203. * Enables audio in the associated scene.
  37204. */
  37205. enableAudio(): void;
  37206. /**
  37207. * Switch audio to headphone output.
  37208. */
  37209. switchAudioModeForHeadphones(): void;
  37210. /**
  37211. * Switch audio to normal speakers.
  37212. */
  37213. switchAudioModeForNormalSpeakers(): void;
  37214. private _cachedCameraDirection;
  37215. private _cachedCameraPosition;
  37216. private _lastCheck;
  37217. private _afterRender;
  37218. }
  37219. }
  37220. declare module BABYLON {
  37221. /**
  37222. * Wraps one or more Sound objects and selects one with random weight for playback.
  37223. */
  37224. export class WeightedSound {
  37225. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37226. loop: boolean;
  37227. private _coneInnerAngle;
  37228. private _coneOuterAngle;
  37229. private _volume;
  37230. /** A Sound is currently playing. */
  37231. isPlaying: boolean;
  37232. /** A Sound is currently paused. */
  37233. isPaused: boolean;
  37234. private _sounds;
  37235. private _weights;
  37236. private _currentIndex?;
  37237. /**
  37238. * Creates a new WeightedSound from the list of sounds given.
  37239. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37240. * @param sounds Array of Sounds that will be selected from.
  37241. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37242. */
  37243. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37244. /**
  37245. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37246. */
  37247. /**
  37248. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37249. */
  37250. directionalConeInnerAngle: number;
  37251. /**
  37252. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37253. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37254. */
  37255. /**
  37256. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37257. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37258. */
  37259. directionalConeOuterAngle: number;
  37260. /**
  37261. * Playback volume.
  37262. */
  37263. /**
  37264. * Playback volume.
  37265. */
  37266. volume: number;
  37267. private _onended;
  37268. /**
  37269. * Suspend playback
  37270. */
  37271. pause(): void;
  37272. /**
  37273. * Stop playback
  37274. */
  37275. stop(): void;
  37276. /**
  37277. * Start playback.
  37278. * @param startOffset Position the clip head at a specific time in seconds.
  37279. */
  37280. play(startOffset?: number): void;
  37281. }
  37282. }
  37283. declare module BABYLON {
  37284. /**
  37285. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37287. */
  37288. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37289. /**
  37290. * Gets the name of the behavior.
  37291. */
  37292. readonly name: string;
  37293. /**
  37294. * The easing function used by animations
  37295. */
  37296. static EasingFunction: BackEase;
  37297. /**
  37298. * The easing mode used by animations
  37299. */
  37300. static EasingMode: number;
  37301. /**
  37302. * The duration of the animation, in milliseconds
  37303. */
  37304. transitionDuration: number;
  37305. /**
  37306. * Length of the distance animated by the transition when lower radius is reached
  37307. */
  37308. lowerRadiusTransitionRange: number;
  37309. /**
  37310. * Length of the distance animated by the transition when upper radius is reached
  37311. */
  37312. upperRadiusTransitionRange: number;
  37313. private _autoTransitionRange;
  37314. /**
  37315. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37316. */
  37317. /**
  37318. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37319. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37320. */
  37321. autoTransitionRange: boolean;
  37322. private _attachedCamera;
  37323. private _onAfterCheckInputsObserver;
  37324. private _onMeshTargetChangedObserver;
  37325. /**
  37326. * Initializes the behavior.
  37327. */
  37328. init(): void;
  37329. /**
  37330. * Attaches the behavior to its arc rotate camera.
  37331. * @param camera Defines the camera to attach the behavior to
  37332. */
  37333. attach(camera: ArcRotateCamera): void;
  37334. /**
  37335. * Detaches the behavior from its current arc rotate camera.
  37336. */
  37337. detach(): void;
  37338. private _radiusIsAnimating;
  37339. private _radiusBounceTransition;
  37340. private _animatables;
  37341. private _cachedWheelPrecision;
  37342. /**
  37343. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37344. * @param radiusLimit The limit to check against.
  37345. * @return Bool to indicate if at limit.
  37346. */
  37347. private _isRadiusAtLimit;
  37348. /**
  37349. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37350. * @param radiusDelta The delta by which to animate to. Can be negative.
  37351. */
  37352. private _applyBoundRadiusAnimation;
  37353. /**
  37354. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37355. */
  37356. protected _clearAnimationLocks(): void;
  37357. /**
  37358. * Stops and removes all animations that have been applied to the camera
  37359. */
  37360. stopAllAnimations(): void;
  37361. }
  37362. }
  37363. declare module BABYLON {
  37364. /**
  37365. * 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.
  37366. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37367. */
  37368. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37369. /**
  37370. * Gets the name of the behavior.
  37371. */
  37372. readonly name: string;
  37373. private _mode;
  37374. private _radiusScale;
  37375. private _positionScale;
  37376. private _defaultElevation;
  37377. private _elevationReturnTime;
  37378. private _elevationReturnWaitTime;
  37379. private _zoomStopsAnimation;
  37380. private _framingTime;
  37381. /**
  37382. * The easing function used by animations
  37383. */
  37384. static EasingFunction: ExponentialEase;
  37385. /**
  37386. * The easing mode used by animations
  37387. */
  37388. static EasingMode: number;
  37389. /**
  37390. * Sets the current mode used by the behavior
  37391. */
  37392. /**
  37393. * Gets current mode used by the behavior.
  37394. */
  37395. mode: number;
  37396. /**
  37397. * Sets the scale applied to the radius (1 by default)
  37398. */
  37399. /**
  37400. * Gets the scale applied to the radius
  37401. */
  37402. radiusScale: number;
  37403. /**
  37404. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37405. */
  37406. /**
  37407. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37408. */
  37409. positionScale: number;
  37410. /**
  37411. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37412. * behaviour is triggered, in radians.
  37413. */
  37414. /**
  37415. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37416. * behaviour is triggered, in radians.
  37417. */
  37418. defaultElevation: number;
  37419. /**
  37420. * Sets the time (in milliseconds) taken to return to the default beta position.
  37421. * Negative value indicates camera should not return to default.
  37422. */
  37423. /**
  37424. * Gets the time (in milliseconds) taken to return to the default beta position.
  37425. * Negative value indicates camera should not return to default.
  37426. */
  37427. elevationReturnTime: number;
  37428. /**
  37429. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37430. */
  37431. /**
  37432. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37433. */
  37434. elevationReturnWaitTime: number;
  37435. /**
  37436. * Sets the flag that indicates if user zooming should stop animation.
  37437. */
  37438. /**
  37439. * Gets the flag that indicates if user zooming should stop animation.
  37440. */
  37441. zoomStopsAnimation: boolean;
  37442. /**
  37443. * Sets the transition time when framing the mesh, in milliseconds
  37444. */
  37445. /**
  37446. * Gets the transition time when framing the mesh, in milliseconds
  37447. */
  37448. framingTime: number;
  37449. /**
  37450. * Define if the behavior should automatically change the configured
  37451. * camera limits and sensibilities.
  37452. */
  37453. autoCorrectCameraLimitsAndSensibility: boolean;
  37454. private _onPrePointerObservableObserver;
  37455. private _onAfterCheckInputsObserver;
  37456. private _onMeshTargetChangedObserver;
  37457. private _attachedCamera;
  37458. private _isPointerDown;
  37459. private _lastInteractionTime;
  37460. /**
  37461. * Initializes the behavior.
  37462. */
  37463. init(): void;
  37464. /**
  37465. * Attaches the behavior to its arc rotate camera.
  37466. * @param camera Defines the camera to attach the behavior to
  37467. */
  37468. attach(camera: ArcRotateCamera): void;
  37469. /**
  37470. * Detaches the behavior from its current arc rotate camera.
  37471. */
  37472. detach(): void;
  37473. private _animatables;
  37474. private _betaIsAnimating;
  37475. private _betaTransition;
  37476. private _radiusTransition;
  37477. private _vectorTransition;
  37478. /**
  37479. * Targets the given mesh and updates zoom level accordingly.
  37480. * @param mesh The mesh to target.
  37481. * @param radius Optional. If a cached radius position already exists, overrides default.
  37482. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37483. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37484. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37485. */
  37486. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37487. /**
  37488. * Targets the given mesh with its children and updates zoom level accordingly.
  37489. * @param mesh The mesh to target.
  37490. * @param radius Optional. If a cached radius position already exists, overrides default.
  37491. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37492. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37493. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37494. */
  37495. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37496. /**
  37497. * Targets the given meshes with their children and updates zoom level accordingly.
  37498. * @param meshes The mesh to target.
  37499. * @param radius Optional. If a cached radius position already exists, overrides default.
  37500. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37501. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37502. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37503. */
  37504. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37505. /**
  37506. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37507. * @param minimumWorld Determines the smaller position of the bounding box extend
  37508. * @param maximumWorld Determines the bigger position of the bounding box extend
  37509. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37510. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37511. */
  37512. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37513. /**
  37514. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37515. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37516. * frustum width.
  37517. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37518. * to fully enclose the mesh in the viewing frustum.
  37519. */
  37520. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37521. /**
  37522. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37523. * is automatically returned to its default position (expected to be above ground plane).
  37524. */
  37525. private _maintainCameraAboveGround;
  37526. /**
  37527. * Returns the frustum slope based on the canvas ratio and camera FOV
  37528. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37529. */
  37530. private _getFrustumSlope;
  37531. /**
  37532. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37533. */
  37534. private _clearAnimationLocks;
  37535. /**
  37536. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37537. */
  37538. private _applyUserInteraction;
  37539. /**
  37540. * Stops and removes all animations that have been applied to the camera
  37541. */
  37542. stopAllAnimations(): void;
  37543. /**
  37544. * Gets a value indicating if the user is moving the camera
  37545. */
  37546. readonly isUserIsMoving: boolean;
  37547. /**
  37548. * The camera can move all the way towards the mesh.
  37549. */
  37550. static IgnoreBoundsSizeMode: number;
  37551. /**
  37552. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37553. */
  37554. static FitFrustumSidesMode: number;
  37555. }
  37556. }
  37557. declare module BABYLON {
  37558. /**
  37559. * Base class for Camera Pointer Inputs.
  37560. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37561. * for example usage.
  37562. */
  37563. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37564. /**
  37565. * Defines the camera the input is attached to.
  37566. */
  37567. abstract camera: Camera;
  37568. /**
  37569. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37570. */
  37571. protected _altKey: boolean;
  37572. protected _ctrlKey: boolean;
  37573. protected _metaKey: boolean;
  37574. protected _shiftKey: boolean;
  37575. /**
  37576. * Which mouse buttons were pressed at time of last mouse event.
  37577. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37578. */
  37579. protected _buttonsPressed: number;
  37580. /**
  37581. * Defines the buttons associated with the input to handle camera move.
  37582. */
  37583. buttons: number[];
  37584. /**
  37585. * Attach the input controls to a specific dom element to get the input from.
  37586. * @param element Defines the element the controls should be listened from
  37587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37588. */
  37589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37590. /**
  37591. * Detach the current controls from the specified dom element.
  37592. * @param element Defines the element to stop listening the inputs from
  37593. */
  37594. detachControl(element: Nullable<HTMLElement>): void;
  37595. /**
  37596. * Gets the class name of the current input.
  37597. * @returns the class name
  37598. */
  37599. getClassName(): string;
  37600. /**
  37601. * Get the friendly name associated with the input class.
  37602. * @returns the input friendly name
  37603. */
  37604. getSimpleName(): string;
  37605. /**
  37606. * Called on pointer POINTERDOUBLETAP event.
  37607. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37608. */
  37609. protected onDoubleTap(type: string): void;
  37610. /**
  37611. * Called on pointer POINTERMOVE event if only a single touch is active.
  37612. * Override this method to provide functionality.
  37613. */
  37614. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37615. /**
  37616. * Called on pointer POINTERMOVE event if multiple touches are active.
  37617. * Override this method to provide functionality.
  37618. */
  37619. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37620. /**
  37621. * Called on JS contextmenu event.
  37622. * Override this method to provide functionality.
  37623. */
  37624. protected onContextMenu(evt: PointerEvent): void;
  37625. /**
  37626. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37627. * press.
  37628. * Override this method to provide functionality.
  37629. */
  37630. protected onButtonDown(evt: PointerEvent): void;
  37631. /**
  37632. * Called each time a new POINTERUP event occurs. Ie, for each button
  37633. * release.
  37634. * Override this method to provide functionality.
  37635. */
  37636. protected onButtonUp(evt: PointerEvent): void;
  37637. /**
  37638. * Called when window becomes inactive.
  37639. * Override this method to provide functionality.
  37640. */
  37641. protected onLostFocus(): void;
  37642. private _pointerInput;
  37643. private _observer;
  37644. private _onLostFocus;
  37645. private pointA;
  37646. private pointB;
  37647. }
  37648. }
  37649. declare module BABYLON {
  37650. /**
  37651. * Manage the pointers inputs to control an arc rotate camera.
  37652. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37653. */
  37654. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37655. /**
  37656. * Defines the camera the input is attached to.
  37657. */
  37658. camera: ArcRotateCamera;
  37659. /**
  37660. * Gets the class name of the current input.
  37661. * @returns the class name
  37662. */
  37663. getClassName(): string;
  37664. /**
  37665. * Defines the buttons associated with the input to handle camera move.
  37666. */
  37667. buttons: number[];
  37668. /**
  37669. * Defines the pointer angular sensibility along the X axis or how fast is
  37670. * the camera rotating.
  37671. */
  37672. angularSensibilityX: number;
  37673. /**
  37674. * Defines the pointer angular sensibility along the Y axis or how fast is
  37675. * the camera rotating.
  37676. */
  37677. angularSensibilityY: number;
  37678. /**
  37679. * Defines the pointer pinch precision or how fast is the camera zooming.
  37680. */
  37681. pinchPrecision: number;
  37682. /**
  37683. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37684. * from 0.
  37685. * It defines the percentage of current camera.radius to use as delta when
  37686. * pinch zoom is used.
  37687. */
  37688. pinchDeltaPercentage: number;
  37689. /**
  37690. * Defines the pointer panning sensibility or how fast is the camera moving.
  37691. */
  37692. panningSensibility: number;
  37693. /**
  37694. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37695. */
  37696. multiTouchPanning: boolean;
  37697. /**
  37698. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37699. * zoom (pinch) through multitouch.
  37700. */
  37701. multiTouchPanAndZoom: boolean;
  37702. /**
  37703. * Revers pinch action direction.
  37704. */
  37705. pinchInwards: boolean;
  37706. private _isPanClick;
  37707. private _twoFingerActivityCount;
  37708. private _isPinching;
  37709. /**
  37710. * Called on pointer POINTERMOVE event if only a single touch is active.
  37711. */
  37712. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37713. /**
  37714. * Called on pointer POINTERDOUBLETAP event.
  37715. */
  37716. protected onDoubleTap(type: string): void;
  37717. /**
  37718. * Called on pointer POINTERMOVE event if multiple touches are active.
  37719. */
  37720. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37721. /**
  37722. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37723. * press.
  37724. */
  37725. protected onButtonDown(evt: PointerEvent): void;
  37726. /**
  37727. * Called each time a new POINTERUP event occurs. Ie, for each button
  37728. * release.
  37729. */
  37730. protected onButtonUp(evt: PointerEvent): void;
  37731. /**
  37732. * Called when window becomes inactive.
  37733. */
  37734. protected onLostFocus(): void;
  37735. }
  37736. }
  37737. declare module BABYLON {
  37738. /**
  37739. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37741. */
  37742. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37743. /**
  37744. * Defines the camera the input is attached to.
  37745. */
  37746. camera: ArcRotateCamera;
  37747. /**
  37748. * Defines the list of key codes associated with the up action (increase alpha)
  37749. */
  37750. keysUp: number[];
  37751. /**
  37752. * Defines the list of key codes associated with the down action (decrease alpha)
  37753. */
  37754. keysDown: number[];
  37755. /**
  37756. * Defines the list of key codes associated with the left action (increase beta)
  37757. */
  37758. keysLeft: number[];
  37759. /**
  37760. * Defines the list of key codes associated with the right action (decrease beta)
  37761. */
  37762. keysRight: number[];
  37763. /**
  37764. * Defines the list of key codes associated with the reset action.
  37765. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37766. */
  37767. keysReset: number[];
  37768. /**
  37769. * Defines the panning sensibility of the inputs.
  37770. * (How fast is the camera paning)
  37771. */
  37772. panningSensibility: number;
  37773. /**
  37774. * Defines the zooming sensibility of the inputs.
  37775. * (How fast is the camera zooming)
  37776. */
  37777. zoomingSensibility: number;
  37778. /**
  37779. * Defines wether maintaining the alt key down switch the movement mode from
  37780. * orientation to zoom.
  37781. */
  37782. useAltToZoom: boolean;
  37783. /**
  37784. * Rotation speed of the camera
  37785. */
  37786. angularSpeed: number;
  37787. private _keys;
  37788. private _ctrlPressed;
  37789. private _altPressed;
  37790. private _onCanvasBlurObserver;
  37791. private _onKeyboardObserver;
  37792. private _engine;
  37793. private _scene;
  37794. /**
  37795. * Attach the input controls to a specific dom element to get the input from.
  37796. * @param element Defines the element the controls should be listened from
  37797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37798. */
  37799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37800. /**
  37801. * Detach the current controls from the specified dom element.
  37802. * @param element Defines the element to stop listening the inputs from
  37803. */
  37804. detachControl(element: Nullable<HTMLElement>): void;
  37805. /**
  37806. * Update the current camera state depending on the inputs that have been used this frame.
  37807. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37808. */
  37809. checkInputs(): void;
  37810. /**
  37811. * Gets the class name of the current intput.
  37812. * @returns the class name
  37813. */
  37814. getClassName(): string;
  37815. /**
  37816. * Get the friendly name associated with the input class.
  37817. * @returns the input friendly name
  37818. */
  37819. getSimpleName(): string;
  37820. }
  37821. }
  37822. declare module BABYLON {
  37823. /**
  37824. * Manage the mouse wheel inputs to control an arc rotate camera.
  37825. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37826. */
  37827. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37828. /**
  37829. * Defines the camera the input is attached to.
  37830. */
  37831. camera: ArcRotateCamera;
  37832. /**
  37833. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37834. */
  37835. wheelPrecision: number;
  37836. /**
  37837. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37838. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37839. */
  37840. wheelDeltaPercentage: number;
  37841. private _wheel;
  37842. private _observer;
  37843. private computeDeltaFromMouseWheelLegacyEvent;
  37844. /**
  37845. * Attach the input controls to a specific dom element to get the input from.
  37846. * @param element Defines the element the controls should be listened from
  37847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37848. */
  37849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37850. /**
  37851. * Detach the current controls from the specified dom element.
  37852. * @param element Defines the element to stop listening the inputs from
  37853. */
  37854. detachControl(element: Nullable<HTMLElement>): void;
  37855. /**
  37856. * Gets the class name of the current intput.
  37857. * @returns the class name
  37858. */
  37859. getClassName(): string;
  37860. /**
  37861. * Get the friendly name associated with the input class.
  37862. * @returns the input friendly name
  37863. */
  37864. getSimpleName(): string;
  37865. }
  37866. }
  37867. declare module BABYLON {
  37868. /**
  37869. * Default Inputs manager for the ArcRotateCamera.
  37870. * It groups all the default supported inputs for ease of use.
  37871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37872. */
  37873. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37874. /**
  37875. * Instantiates a new ArcRotateCameraInputsManager.
  37876. * @param camera Defines the camera the inputs belong to
  37877. */
  37878. constructor(camera: ArcRotateCamera);
  37879. /**
  37880. * Add mouse wheel input support to the input manager.
  37881. * @returns the current input manager
  37882. */
  37883. addMouseWheel(): ArcRotateCameraInputsManager;
  37884. /**
  37885. * Add pointers input support to the input manager.
  37886. * @returns the current input manager
  37887. */
  37888. addPointers(): ArcRotateCameraInputsManager;
  37889. /**
  37890. * Add keyboard input support to the input manager.
  37891. * @returns the current input manager
  37892. */
  37893. addKeyboard(): ArcRotateCameraInputsManager;
  37894. }
  37895. }
  37896. declare module BABYLON {
  37897. /**
  37898. * This represents an orbital type of camera.
  37899. *
  37900. * 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.
  37901. * 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.
  37902. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37903. */
  37904. export class ArcRotateCamera extends TargetCamera {
  37905. /**
  37906. * Defines the rotation angle of the camera along the longitudinal axis.
  37907. */
  37908. alpha: number;
  37909. /**
  37910. * Defines the rotation angle of the camera along the latitudinal axis.
  37911. */
  37912. beta: number;
  37913. /**
  37914. * Defines the radius of the camera from it s target point.
  37915. */
  37916. radius: number;
  37917. protected _target: Vector3;
  37918. protected _targetHost: Nullable<AbstractMesh>;
  37919. /**
  37920. * Defines the target point of the camera.
  37921. * The camera looks towards it form the radius distance.
  37922. */
  37923. target: Vector3;
  37924. /**
  37925. * Define the current local position of the camera in the scene
  37926. */
  37927. position: Vector3;
  37928. protected _upVector: Vector3;
  37929. protected _upToYMatrix: Matrix;
  37930. protected _YToUpMatrix: Matrix;
  37931. /**
  37932. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37933. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37934. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37935. */
  37936. upVector: Vector3;
  37937. /**
  37938. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37939. */
  37940. setMatUp(): void;
  37941. /**
  37942. * Current inertia value on the longitudinal axis.
  37943. * The bigger this number the longer it will take for the camera to stop.
  37944. */
  37945. inertialAlphaOffset: number;
  37946. /**
  37947. * Current inertia value on the latitudinal axis.
  37948. * The bigger this number the longer it will take for the camera to stop.
  37949. */
  37950. inertialBetaOffset: number;
  37951. /**
  37952. * Current inertia value on the radius axis.
  37953. * The bigger this number the longer it will take for the camera to stop.
  37954. */
  37955. inertialRadiusOffset: number;
  37956. /**
  37957. * Minimum allowed angle on the longitudinal axis.
  37958. * This can help limiting how the Camera is able to move in the scene.
  37959. */
  37960. lowerAlphaLimit: Nullable<number>;
  37961. /**
  37962. * Maximum allowed angle on the longitudinal axis.
  37963. * This can help limiting how the Camera is able to move in the scene.
  37964. */
  37965. upperAlphaLimit: Nullable<number>;
  37966. /**
  37967. * Minimum allowed angle on the latitudinal axis.
  37968. * This can help limiting how the Camera is able to move in the scene.
  37969. */
  37970. lowerBetaLimit: number;
  37971. /**
  37972. * Maximum allowed angle on the latitudinal axis.
  37973. * This can help limiting how the Camera is able to move in the scene.
  37974. */
  37975. upperBetaLimit: number;
  37976. /**
  37977. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37978. * This can help limiting how the Camera is able to move in the scene.
  37979. */
  37980. lowerRadiusLimit: Nullable<number>;
  37981. /**
  37982. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37983. * This can help limiting how the Camera is able to move in the scene.
  37984. */
  37985. upperRadiusLimit: Nullable<number>;
  37986. /**
  37987. * Defines the current inertia value used during panning of the camera along the X axis.
  37988. */
  37989. inertialPanningX: number;
  37990. /**
  37991. * Defines the current inertia value used during panning of the camera along the Y axis.
  37992. */
  37993. inertialPanningY: number;
  37994. /**
  37995. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37996. * Basically if your fingers moves away from more than this distance you will be considered
  37997. * in pinch mode.
  37998. */
  37999. pinchToPanMaxDistance: number;
  38000. /**
  38001. * Defines the maximum distance the camera can pan.
  38002. * This could help keeping the cammera always in your scene.
  38003. */
  38004. panningDistanceLimit: Nullable<number>;
  38005. /**
  38006. * Defines the target of the camera before paning.
  38007. */
  38008. panningOriginTarget: Vector3;
  38009. /**
  38010. * Defines the value of the inertia used during panning.
  38011. * 0 would mean stop inertia and one would mean no decelleration at all.
  38012. */
  38013. panningInertia: number;
  38014. /**
  38015. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38016. */
  38017. angularSensibilityX: number;
  38018. /**
  38019. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38020. */
  38021. angularSensibilityY: number;
  38022. /**
  38023. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38024. */
  38025. pinchPrecision: number;
  38026. /**
  38027. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38028. * It will be used instead of pinchDeltaPrecision if different from 0.
  38029. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38030. */
  38031. pinchDeltaPercentage: number;
  38032. /**
  38033. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38034. */
  38035. panningSensibility: number;
  38036. /**
  38037. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38038. */
  38039. keysUp: number[];
  38040. /**
  38041. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38042. */
  38043. keysDown: number[];
  38044. /**
  38045. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38046. */
  38047. keysLeft: number[];
  38048. /**
  38049. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38050. */
  38051. keysRight: number[];
  38052. /**
  38053. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38054. */
  38055. wheelPrecision: number;
  38056. /**
  38057. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38058. * It will be used instead of pinchDeltaPrecision if different from 0.
  38059. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38060. */
  38061. wheelDeltaPercentage: number;
  38062. /**
  38063. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38064. */
  38065. zoomOnFactor: number;
  38066. /**
  38067. * Defines a screen offset for the camera position.
  38068. */
  38069. targetScreenOffset: Vector2;
  38070. /**
  38071. * Allows the camera to be completely reversed.
  38072. * If false the camera can not arrive upside down.
  38073. */
  38074. allowUpsideDown: boolean;
  38075. /**
  38076. * Define if double tap/click is used to restore the previously saved state of the camera.
  38077. */
  38078. useInputToRestoreState: boolean;
  38079. /** @hidden */
  38080. _viewMatrix: Matrix;
  38081. /** @hidden */
  38082. _useCtrlForPanning: boolean;
  38083. /** @hidden */
  38084. _panningMouseButton: number;
  38085. /**
  38086. * Defines the input associated to the camera.
  38087. */
  38088. inputs: ArcRotateCameraInputsManager;
  38089. /** @hidden */
  38090. _reset: () => void;
  38091. /**
  38092. * Defines the allowed panning axis.
  38093. */
  38094. panningAxis: Vector3;
  38095. protected _localDirection: Vector3;
  38096. protected _transformedDirection: Vector3;
  38097. private _bouncingBehavior;
  38098. /**
  38099. * Gets the bouncing behavior of the camera if it has been enabled.
  38100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38101. */
  38102. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38103. /**
  38104. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38106. */
  38107. useBouncingBehavior: boolean;
  38108. private _framingBehavior;
  38109. /**
  38110. * Gets the framing behavior of the camera if it has been enabled.
  38111. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38112. */
  38113. readonly framingBehavior: Nullable<FramingBehavior>;
  38114. /**
  38115. * Defines if the framing behavior of the camera is enabled on the camera.
  38116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38117. */
  38118. useFramingBehavior: boolean;
  38119. private _autoRotationBehavior;
  38120. /**
  38121. * Gets the auto rotation behavior of the camera if it has been enabled.
  38122. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38123. */
  38124. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38125. /**
  38126. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38127. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38128. */
  38129. useAutoRotationBehavior: boolean;
  38130. /**
  38131. * Observable triggered when the mesh target has been changed on the camera.
  38132. */
  38133. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38134. /**
  38135. * Event raised when the camera is colliding with a mesh.
  38136. */
  38137. onCollide: (collidedMesh: AbstractMesh) => void;
  38138. /**
  38139. * Defines whether the camera should check collision with the objects oh the scene.
  38140. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38141. */
  38142. checkCollisions: boolean;
  38143. /**
  38144. * Defines the collision radius of the camera.
  38145. * This simulates a sphere around the camera.
  38146. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38147. */
  38148. collisionRadius: Vector3;
  38149. protected _collider: Collider;
  38150. protected _previousPosition: Vector3;
  38151. protected _collisionVelocity: Vector3;
  38152. protected _newPosition: Vector3;
  38153. protected _previousAlpha: number;
  38154. protected _previousBeta: number;
  38155. protected _previousRadius: number;
  38156. protected _collisionTriggered: boolean;
  38157. protected _targetBoundingCenter: Nullable<Vector3>;
  38158. private _computationVector;
  38159. /**
  38160. * Instantiates a new ArcRotateCamera in a given scene
  38161. * @param name Defines the name of the camera
  38162. * @param alpha Defines the camera rotation along the logitudinal axis
  38163. * @param beta Defines the camera rotation along the latitudinal axis
  38164. * @param radius Defines the camera distance from its target
  38165. * @param target Defines the camera target
  38166. * @param scene Defines the scene the camera belongs to
  38167. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38168. */
  38169. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38170. /** @hidden */
  38171. _initCache(): void;
  38172. /** @hidden */
  38173. _updateCache(ignoreParentClass?: boolean): void;
  38174. protected _getTargetPosition(): Vector3;
  38175. private _storedAlpha;
  38176. private _storedBeta;
  38177. private _storedRadius;
  38178. private _storedTarget;
  38179. private _storedTargetScreenOffset;
  38180. /**
  38181. * Stores the current state of the camera (alpha, beta, radius and target)
  38182. * @returns the camera itself
  38183. */
  38184. storeState(): Camera;
  38185. /**
  38186. * @hidden
  38187. * Restored camera state. You must call storeState() first
  38188. */
  38189. _restoreStateValues(): boolean;
  38190. /** @hidden */
  38191. _isSynchronizedViewMatrix(): boolean;
  38192. /**
  38193. * Attached controls to the current camera.
  38194. * @param element Defines the element the controls should be listened from
  38195. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38196. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38197. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38198. */
  38199. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38200. /**
  38201. * Detach the current controls from the camera.
  38202. * The camera will stop reacting to inputs.
  38203. * @param element Defines the element to stop listening the inputs from
  38204. */
  38205. detachControl(element: HTMLElement): void;
  38206. /** @hidden */
  38207. _checkInputs(): void;
  38208. protected _checkLimits(): void;
  38209. /**
  38210. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38211. */
  38212. rebuildAnglesAndRadius(): void;
  38213. /**
  38214. * Use a position to define the current camera related information like alpha, beta and radius
  38215. * @param position Defines the position to set the camera at
  38216. */
  38217. setPosition(position: Vector3): void;
  38218. /**
  38219. * Defines the target the camera should look at.
  38220. * This will automatically adapt alpha beta and radius to fit within the new target.
  38221. * @param target Defines the new target as a Vector or a mesh
  38222. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38223. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38224. */
  38225. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38226. /** @hidden */
  38227. _getViewMatrix(): Matrix;
  38228. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38229. /**
  38230. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38231. * @param meshes Defines the mesh to zoom on
  38232. * @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)
  38233. */
  38234. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38235. /**
  38236. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38237. * The target will be changed but the radius
  38238. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38239. * @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)
  38240. */
  38241. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38242. min: Vector3;
  38243. max: Vector3;
  38244. distance: number;
  38245. }, doNotUpdateMaxZ?: boolean): void;
  38246. /**
  38247. * @override
  38248. * Override Camera.createRigCamera
  38249. */
  38250. createRigCamera(name: string, cameraIndex: number): Camera;
  38251. /**
  38252. * @hidden
  38253. * @override
  38254. * Override Camera._updateRigCameras
  38255. */
  38256. _updateRigCameras(): void;
  38257. /**
  38258. * Destroy the camera and release the current resources hold by it.
  38259. */
  38260. dispose(): void;
  38261. /**
  38262. * Gets the current object class name.
  38263. * @return the class name
  38264. */
  38265. getClassName(): string;
  38266. }
  38267. }
  38268. declare module BABYLON {
  38269. /**
  38270. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38271. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38272. */
  38273. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38274. /**
  38275. * Gets the name of the behavior.
  38276. */
  38277. readonly name: string;
  38278. private _zoomStopsAnimation;
  38279. private _idleRotationSpeed;
  38280. private _idleRotationWaitTime;
  38281. private _idleRotationSpinupTime;
  38282. /**
  38283. * Sets the flag that indicates if user zooming should stop animation.
  38284. */
  38285. /**
  38286. * Gets the flag that indicates if user zooming should stop animation.
  38287. */
  38288. zoomStopsAnimation: boolean;
  38289. /**
  38290. * Sets the default speed at which the camera rotates around the model.
  38291. */
  38292. /**
  38293. * Gets the default speed at which the camera rotates around the model.
  38294. */
  38295. idleRotationSpeed: number;
  38296. /**
  38297. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38298. */
  38299. /**
  38300. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38301. */
  38302. idleRotationWaitTime: number;
  38303. /**
  38304. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38305. */
  38306. /**
  38307. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38308. */
  38309. idleRotationSpinupTime: number;
  38310. /**
  38311. * Gets a value indicating if the camera is currently rotating because of this behavior
  38312. */
  38313. readonly rotationInProgress: boolean;
  38314. private _onPrePointerObservableObserver;
  38315. private _onAfterCheckInputsObserver;
  38316. private _attachedCamera;
  38317. private _isPointerDown;
  38318. private _lastFrameTime;
  38319. private _lastInteractionTime;
  38320. private _cameraRotationSpeed;
  38321. /**
  38322. * Initializes the behavior.
  38323. */
  38324. init(): void;
  38325. /**
  38326. * Attaches the behavior to its arc rotate camera.
  38327. * @param camera Defines the camera to attach the behavior to
  38328. */
  38329. attach(camera: ArcRotateCamera): void;
  38330. /**
  38331. * Detaches the behavior from its current arc rotate camera.
  38332. */
  38333. detach(): void;
  38334. /**
  38335. * Returns true if user is scrolling.
  38336. * @return true if user is scrolling.
  38337. */
  38338. private _userIsZooming;
  38339. private _lastFrameRadius;
  38340. private _shouldAnimationStopForInteraction;
  38341. /**
  38342. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38343. */
  38344. private _applyUserInteraction;
  38345. private _userIsMoving;
  38346. }
  38347. }
  38348. declare module BABYLON {
  38349. /**
  38350. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38351. */
  38352. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38353. private ui;
  38354. /**
  38355. * The name of the behavior
  38356. */
  38357. name: string;
  38358. /**
  38359. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38360. */
  38361. distanceAwayFromFace: number;
  38362. /**
  38363. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38364. */
  38365. distanceAwayFromBottomOfFace: number;
  38366. private _faceVectors;
  38367. private _target;
  38368. private _scene;
  38369. private _onRenderObserver;
  38370. private _tmpMatrix;
  38371. private _tmpVector;
  38372. /**
  38373. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38374. * @param ui The transform node that should be attched to the mesh
  38375. */
  38376. constructor(ui: TransformNode);
  38377. /**
  38378. * Initializes the behavior
  38379. */
  38380. init(): void;
  38381. private _closestFace;
  38382. private _zeroVector;
  38383. private _lookAtTmpMatrix;
  38384. private _lookAtToRef;
  38385. /**
  38386. * Attaches the AttachToBoxBehavior to the passed in mesh
  38387. * @param target The mesh that the specified node will be attached to
  38388. */
  38389. attach(target: Mesh): void;
  38390. /**
  38391. * Detaches the behavior from the mesh
  38392. */
  38393. detach(): void;
  38394. }
  38395. }
  38396. declare module BABYLON {
  38397. /**
  38398. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38399. */
  38400. export class FadeInOutBehavior implements Behavior<Mesh> {
  38401. /**
  38402. * Time in milliseconds to delay before fading in (Default: 0)
  38403. */
  38404. delay: number;
  38405. /**
  38406. * Time in milliseconds for the mesh to fade in (Default: 300)
  38407. */
  38408. fadeInTime: number;
  38409. private _millisecondsPerFrame;
  38410. private _hovered;
  38411. private _hoverValue;
  38412. private _ownerNode;
  38413. /**
  38414. * Instatiates the FadeInOutBehavior
  38415. */
  38416. constructor();
  38417. /**
  38418. * The name of the behavior
  38419. */
  38420. readonly name: string;
  38421. /**
  38422. * Initializes the behavior
  38423. */
  38424. init(): void;
  38425. /**
  38426. * Attaches the fade behavior on the passed in mesh
  38427. * @param ownerNode The mesh that will be faded in/out once attached
  38428. */
  38429. attach(ownerNode: Mesh): void;
  38430. /**
  38431. * Detaches the behavior from the mesh
  38432. */
  38433. detach(): void;
  38434. /**
  38435. * Triggers the mesh to begin fading in or out
  38436. * @param value if the object should fade in or out (true to fade in)
  38437. */
  38438. fadeIn(value: boolean): void;
  38439. private _update;
  38440. private _setAllVisibility;
  38441. }
  38442. }
  38443. declare module BABYLON {
  38444. /**
  38445. * Class containing a set of static utilities functions for managing Pivots
  38446. * @hidden
  38447. */
  38448. export class PivotTools {
  38449. private static _PivotCached;
  38450. private static _OldPivotPoint;
  38451. private static _PivotTranslation;
  38452. private static _PivotTmpVector;
  38453. /** @hidden */
  38454. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38455. /** @hidden */
  38456. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38457. }
  38458. }
  38459. declare module BABYLON {
  38460. /**
  38461. * Class containing static functions to help procedurally build meshes
  38462. */
  38463. export class PlaneBuilder {
  38464. /**
  38465. * Creates a plane mesh
  38466. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38467. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38468. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38470. * * 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
  38471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38472. * @param name defines the name of the mesh
  38473. * @param options defines the options used to create the mesh
  38474. * @param scene defines the hosting scene
  38475. * @returns the plane mesh
  38476. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38477. */
  38478. static CreatePlane(name: string, options: {
  38479. size?: number;
  38480. width?: number;
  38481. height?: number;
  38482. sideOrientation?: number;
  38483. frontUVs?: Vector4;
  38484. backUVs?: Vector4;
  38485. updatable?: boolean;
  38486. sourcePlane?: Plane;
  38487. }, scene?: Nullable<Scene>): Mesh;
  38488. }
  38489. }
  38490. declare module BABYLON {
  38491. /**
  38492. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38493. */
  38494. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38495. private static _AnyMouseID;
  38496. /**
  38497. * Abstract mesh the behavior is set on
  38498. */
  38499. attachedNode: AbstractMesh;
  38500. private _dragPlane;
  38501. private _scene;
  38502. private _pointerObserver;
  38503. private _beforeRenderObserver;
  38504. private static _planeScene;
  38505. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38506. /**
  38507. * 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)
  38508. */
  38509. maxDragAngle: number;
  38510. /**
  38511. * @hidden
  38512. */
  38513. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38514. /**
  38515. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38516. */
  38517. currentDraggingPointerID: number;
  38518. /**
  38519. * The last position where the pointer hit the drag plane in world space
  38520. */
  38521. lastDragPosition: Vector3;
  38522. /**
  38523. * If the behavior is currently in a dragging state
  38524. */
  38525. dragging: boolean;
  38526. /**
  38527. * 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)
  38528. */
  38529. dragDeltaRatio: number;
  38530. /**
  38531. * If the drag plane orientation should be updated during the dragging (Default: true)
  38532. */
  38533. updateDragPlane: boolean;
  38534. private _debugMode;
  38535. private _moving;
  38536. /**
  38537. * Fires each time the attached mesh is dragged with the pointer
  38538. * * delta between last drag position and current drag position in world space
  38539. * * dragDistance along the drag axis
  38540. * * dragPlaneNormal normal of the current drag plane used during the drag
  38541. * * dragPlanePoint in world space where the drag intersects the drag plane
  38542. */
  38543. onDragObservable: Observable<{
  38544. delta: Vector3;
  38545. dragPlanePoint: Vector3;
  38546. dragPlaneNormal: Vector3;
  38547. dragDistance: number;
  38548. pointerId: number;
  38549. }>;
  38550. /**
  38551. * Fires each time a drag begins (eg. mouse down on mesh)
  38552. */
  38553. onDragStartObservable: Observable<{
  38554. dragPlanePoint: Vector3;
  38555. pointerId: number;
  38556. }>;
  38557. /**
  38558. * Fires each time a drag ends (eg. mouse release after drag)
  38559. */
  38560. onDragEndObservable: Observable<{
  38561. dragPlanePoint: Vector3;
  38562. pointerId: number;
  38563. }>;
  38564. /**
  38565. * If the attached mesh should be moved when dragged
  38566. */
  38567. moveAttached: boolean;
  38568. /**
  38569. * If the drag behavior will react to drag events (Default: true)
  38570. */
  38571. enabled: boolean;
  38572. /**
  38573. * If pointer events should start and release the drag (Default: true)
  38574. */
  38575. startAndReleaseDragOnPointerEvents: boolean;
  38576. /**
  38577. * If camera controls should be detached during the drag
  38578. */
  38579. detachCameraControls: boolean;
  38580. /**
  38581. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38582. */
  38583. useObjectOrienationForDragging: boolean;
  38584. private _options;
  38585. /**
  38586. * Gets the options used by the behavior
  38587. */
  38588. /**
  38589. * Sets the options used by the behavior
  38590. */
  38591. options: {
  38592. dragAxis?: Vector3;
  38593. dragPlaneNormal?: Vector3;
  38594. };
  38595. /**
  38596. * Creates a pointer drag behavior that can be attached to a mesh
  38597. * @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)
  38598. */
  38599. constructor(options?: {
  38600. dragAxis?: Vector3;
  38601. dragPlaneNormal?: Vector3;
  38602. });
  38603. /**
  38604. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38605. */
  38606. validateDrag: (targetPosition: Vector3) => boolean;
  38607. /**
  38608. * The name of the behavior
  38609. */
  38610. readonly name: string;
  38611. /**
  38612. * Initializes the behavior
  38613. */
  38614. init(): void;
  38615. private _tmpVector;
  38616. private _alternatePickedPoint;
  38617. private _worldDragAxis;
  38618. private _targetPosition;
  38619. private _attachedElement;
  38620. /**
  38621. * Attaches the drag behavior the passed in mesh
  38622. * @param ownerNode The mesh that will be dragged around once attached
  38623. * @param predicate Predicate to use for pick filtering
  38624. */
  38625. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38626. /**
  38627. * Force relase the drag action by code.
  38628. */
  38629. releaseDrag(): void;
  38630. private _startDragRay;
  38631. private _lastPointerRay;
  38632. /**
  38633. * Simulates the start of a pointer drag event on the behavior
  38634. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38635. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38636. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38637. */
  38638. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38639. private _startDrag;
  38640. private _dragDelta;
  38641. private _moveDrag;
  38642. private _pickWithRayOnDragPlane;
  38643. private _pointA;
  38644. private _pointB;
  38645. private _pointC;
  38646. private _lineA;
  38647. private _lineB;
  38648. private _localAxis;
  38649. private _lookAt;
  38650. private _updateDragPlanePosition;
  38651. /**
  38652. * Detaches the behavior from the mesh
  38653. */
  38654. detach(): void;
  38655. }
  38656. }
  38657. declare module BABYLON {
  38658. /**
  38659. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38660. */
  38661. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38662. private _dragBehaviorA;
  38663. private _dragBehaviorB;
  38664. private _startDistance;
  38665. private _initialScale;
  38666. private _targetScale;
  38667. private _ownerNode;
  38668. private _sceneRenderObserver;
  38669. /**
  38670. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38671. */
  38672. constructor();
  38673. /**
  38674. * The name of the behavior
  38675. */
  38676. readonly name: string;
  38677. /**
  38678. * Initializes the behavior
  38679. */
  38680. init(): void;
  38681. private _getCurrentDistance;
  38682. /**
  38683. * Attaches the scale behavior the passed in mesh
  38684. * @param ownerNode The mesh that will be scaled around once attached
  38685. */
  38686. attach(ownerNode: Mesh): void;
  38687. /**
  38688. * Detaches the behavior from the mesh
  38689. */
  38690. detach(): void;
  38691. }
  38692. }
  38693. declare module BABYLON {
  38694. /**
  38695. * 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
  38696. */
  38697. export class SixDofDragBehavior implements Behavior<Mesh> {
  38698. private static _virtualScene;
  38699. private _ownerNode;
  38700. private _sceneRenderObserver;
  38701. private _scene;
  38702. private _targetPosition;
  38703. private _virtualOriginMesh;
  38704. private _virtualDragMesh;
  38705. private _pointerObserver;
  38706. private _moving;
  38707. private _startingOrientation;
  38708. /**
  38709. * 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)
  38710. */
  38711. private zDragFactor;
  38712. /**
  38713. * If the object should rotate to face the drag origin
  38714. */
  38715. rotateDraggedObject: boolean;
  38716. /**
  38717. * If the behavior is currently in a dragging state
  38718. */
  38719. dragging: boolean;
  38720. /**
  38721. * 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)
  38722. */
  38723. dragDeltaRatio: number;
  38724. /**
  38725. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38726. */
  38727. currentDraggingPointerID: number;
  38728. /**
  38729. * If camera controls should be detached during the drag
  38730. */
  38731. detachCameraControls: boolean;
  38732. /**
  38733. * Fires each time a drag starts
  38734. */
  38735. onDragStartObservable: Observable<{}>;
  38736. /**
  38737. * Fires each time a drag ends (eg. mouse release after drag)
  38738. */
  38739. onDragEndObservable: Observable<{}>;
  38740. /**
  38741. * 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
  38742. */
  38743. constructor();
  38744. /**
  38745. * The name of the behavior
  38746. */
  38747. readonly name: string;
  38748. /**
  38749. * Initializes the behavior
  38750. */
  38751. init(): void;
  38752. /**
  38753. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38754. */
  38755. private readonly _pointerCamera;
  38756. /**
  38757. * Attaches the scale behavior the passed in mesh
  38758. * @param ownerNode The mesh that will be scaled around once attached
  38759. */
  38760. attach(ownerNode: Mesh): void;
  38761. /**
  38762. * Detaches the behavior from the mesh
  38763. */
  38764. detach(): void;
  38765. }
  38766. }
  38767. declare module BABYLON {
  38768. /**
  38769. * Class used to apply inverse kinematics to bones
  38770. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38771. */
  38772. export class BoneIKController {
  38773. private static _tmpVecs;
  38774. private static _tmpQuat;
  38775. private static _tmpMats;
  38776. /**
  38777. * Gets or sets the target mesh
  38778. */
  38779. targetMesh: AbstractMesh;
  38780. /** Gets or sets the mesh used as pole */
  38781. poleTargetMesh: AbstractMesh;
  38782. /**
  38783. * Gets or sets the bone used as pole
  38784. */
  38785. poleTargetBone: Nullable<Bone>;
  38786. /**
  38787. * Gets or sets the target position
  38788. */
  38789. targetPosition: Vector3;
  38790. /**
  38791. * Gets or sets the pole target position
  38792. */
  38793. poleTargetPosition: Vector3;
  38794. /**
  38795. * Gets or sets the pole target local offset
  38796. */
  38797. poleTargetLocalOffset: Vector3;
  38798. /**
  38799. * Gets or sets the pole angle
  38800. */
  38801. poleAngle: number;
  38802. /**
  38803. * Gets or sets the mesh associated with the controller
  38804. */
  38805. mesh: AbstractMesh;
  38806. /**
  38807. * 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)
  38808. */
  38809. slerpAmount: number;
  38810. private _bone1Quat;
  38811. private _bone1Mat;
  38812. private _bone2Ang;
  38813. private _bone1;
  38814. private _bone2;
  38815. private _bone1Length;
  38816. private _bone2Length;
  38817. private _maxAngle;
  38818. private _maxReach;
  38819. private _rightHandedSystem;
  38820. private _bendAxis;
  38821. private _slerping;
  38822. private _adjustRoll;
  38823. /**
  38824. * Gets or sets maximum allowed angle
  38825. */
  38826. maxAngle: number;
  38827. /**
  38828. * Creates a new BoneIKController
  38829. * @param mesh defines the mesh to control
  38830. * @param bone defines the bone to control
  38831. * @param options defines options to set up the controller
  38832. */
  38833. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38834. targetMesh?: AbstractMesh;
  38835. poleTargetMesh?: AbstractMesh;
  38836. poleTargetBone?: Bone;
  38837. poleTargetLocalOffset?: Vector3;
  38838. poleAngle?: number;
  38839. bendAxis?: Vector3;
  38840. maxAngle?: number;
  38841. slerpAmount?: number;
  38842. });
  38843. private _setMaxAngle;
  38844. /**
  38845. * Force the controller to update the bones
  38846. */
  38847. update(): void;
  38848. }
  38849. }
  38850. declare module BABYLON {
  38851. /**
  38852. * Class used to make a bone look toward a point in space
  38853. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38854. */
  38855. export class BoneLookController {
  38856. private static _tmpVecs;
  38857. private static _tmpQuat;
  38858. private static _tmpMats;
  38859. /**
  38860. * The target Vector3 that the bone will look at
  38861. */
  38862. target: Vector3;
  38863. /**
  38864. * The mesh that the bone is attached to
  38865. */
  38866. mesh: AbstractMesh;
  38867. /**
  38868. * The bone that will be looking to the target
  38869. */
  38870. bone: Bone;
  38871. /**
  38872. * The up axis of the coordinate system that is used when the bone is rotated
  38873. */
  38874. upAxis: Vector3;
  38875. /**
  38876. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38877. */
  38878. upAxisSpace: Space;
  38879. /**
  38880. * Used to make an adjustment to the yaw of the bone
  38881. */
  38882. adjustYaw: number;
  38883. /**
  38884. * Used to make an adjustment to the pitch of the bone
  38885. */
  38886. adjustPitch: number;
  38887. /**
  38888. * Used to make an adjustment to the roll of the bone
  38889. */
  38890. adjustRoll: number;
  38891. /**
  38892. * 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)
  38893. */
  38894. slerpAmount: number;
  38895. private _minYaw;
  38896. private _maxYaw;
  38897. private _minPitch;
  38898. private _maxPitch;
  38899. private _minYawSin;
  38900. private _minYawCos;
  38901. private _maxYawSin;
  38902. private _maxYawCos;
  38903. private _midYawConstraint;
  38904. private _minPitchTan;
  38905. private _maxPitchTan;
  38906. private _boneQuat;
  38907. private _slerping;
  38908. private _transformYawPitch;
  38909. private _transformYawPitchInv;
  38910. private _firstFrameSkipped;
  38911. private _yawRange;
  38912. private _fowardAxis;
  38913. /**
  38914. * Gets or sets the minimum yaw angle that the bone can look to
  38915. */
  38916. minYaw: number;
  38917. /**
  38918. * Gets or sets the maximum yaw angle that the bone can look to
  38919. */
  38920. maxYaw: number;
  38921. /**
  38922. * Gets or sets the minimum pitch angle that the bone can look to
  38923. */
  38924. minPitch: number;
  38925. /**
  38926. * Gets or sets the maximum pitch angle that the bone can look to
  38927. */
  38928. maxPitch: number;
  38929. /**
  38930. * Create a BoneLookController
  38931. * @param mesh the mesh that the bone belongs to
  38932. * @param bone the bone that will be looking to the target
  38933. * @param target the target Vector3 to look at
  38934. * @param options optional settings:
  38935. * * maxYaw: the maximum angle the bone will yaw to
  38936. * * minYaw: the minimum angle the bone will yaw to
  38937. * * maxPitch: the maximum angle the bone will pitch to
  38938. * * minPitch: the minimum angle the bone will yaw to
  38939. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38940. * * upAxis: the up axis of the coordinate system
  38941. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38942. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38943. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38944. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38945. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38946. * * adjustRoll: used to make an adjustment to the roll of the bone
  38947. **/
  38948. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38949. maxYaw?: number;
  38950. minYaw?: number;
  38951. maxPitch?: number;
  38952. minPitch?: number;
  38953. slerpAmount?: number;
  38954. upAxis?: Vector3;
  38955. upAxisSpace?: Space;
  38956. yawAxis?: Vector3;
  38957. pitchAxis?: Vector3;
  38958. adjustYaw?: number;
  38959. adjustPitch?: number;
  38960. adjustRoll?: number;
  38961. });
  38962. /**
  38963. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38964. */
  38965. update(): void;
  38966. private _getAngleDiff;
  38967. private _getAngleBetween;
  38968. private _isAngleBetween;
  38969. }
  38970. }
  38971. declare module BABYLON {
  38972. /**
  38973. * Manage the gamepad inputs to control an arc rotate camera.
  38974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38975. */
  38976. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38977. /**
  38978. * Defines the camera the input is attached to.
  38979. */
  38980. camera: ArcRotateCamera;
  38981. /**
  38982. * Defines the gamepad the input is gathering event from.
  38983. */
  38984. gamepad: Nullable<Gamepad>;
  38985. /**
  38986. * Defines the gamepad rotation sensiblity.
  38987. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38988. */
  38989. gamepadRotationSensibility: number;
  38990. /**
  38991. * Defines the gamepad move sensiblity.
  38992. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38993. */
  38994. gamepadMoveSensibility: number;
  38995. private _yAxisScale;
  38996. /**
  38997. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38998. */
  38999. invertYAxis: boolean;
  39000. private _onGamepadConnectedObserver;
  39001. private _onGamepadDisconnectedObserver;
  39002. /**
  39003. * Attach the input controls to a specific dom element to get the input from.
  39004. * @param element Defines the element the controls should be listened from
  39005. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39006. */
  39007. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39008. /**
  39009. * Detach the current controls from the specified dom element.
  39010. * @param element Defines the element to stop listening the inputs from
  39011. */
  39012. detachControl(element: Nullable<HTMLElement>): void;
  39013. /**
  39014. * Update the current camera state depending on the inputs that have been used this frame.
  39015. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39016. */
  39017. checkInputs(): void;
  39018. /**
  39019. * Gets the class name of the current intput.
  39020. * @returns the class name
  39021. */
  39022. getClassName(): string;
  39023. /**
  39024. * Get the friendly name associated with the input class.
  39025. * @returns the input friendly name
  39026. */
  39027. getSimpleName(): string;
  39028. }
  39029. }
  39030. declare module BABYLON {
  39031. interface ArcRotateCameraInputsManager {
  39032. /**
  39033. * Add orientation input support to the input manager.
  39034. * @returns the current input manager
  39035. */
  39036. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39037. }
  39038. /**
  39039. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39041. */
  39042. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39043. /**
  39044. * Defines the camera the input is attached to.
  39045. */
  39046. camera: ArcRotateCamera;
  39047. /**
  39048. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39049. */
  39050. alphaCorrection: number;
  39051. /**
  39052. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39053. */
  39054. gammaCorrection: number;
  39055. private _alpha;
  39056. private _gamma;
  39057. private _dirty;
  39058. private _deviceOrientationHandler;
  39059. /**
  39060. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39061. */
  39062. constructor();
  39063. /**
  39064. * Attach the input controls to a specific dom element to get the input from.
  39065. * @param element Defines the element the controls should be listened from
  39066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39067. */
  39068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39069. /** @hidden */
  39070. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39071. /**
  39072. * Update the current camera state depending on the inputs that have been used this frame.
  39073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39074. */
  39075. checkInputs(): void;
  39076. /**
  39077. * Detach the current controls from the specified dom element.
  39078. * @param element Defines the element to stop listening the inputs from
  39079. */
  39080. detachControl(element: Nullable<HTMLElement>): void;
  39081. /**
  39082. * Gets the class name of the current intput.
  39083. * @returns the class name
  39084. */
  39085. getClassName(): string;
  39086. /**
  39087. * Get the friendly name associated with the input class.
  39088. * @returns the input friendly name
  39089. */
  39090. getSimpleName(): string;
  39091. }
  39092. }
  39093. declare module BABYLON {
  39094. /**
  39095. * Listen to mouse events to control the camera.
  39096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39097. */
  39098. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39099. /**
  39100. * Defines the camera the input is attached to.
  39101. */
  39102. camera: FlyCamera;
  39103. /**
  39104. * Defines if touch is enabled. (Default is true.)
  39105. */
  39106. touchEnabled: boolean;
  39107. /**
  39108. * Defines the buttons associated with the input to handle camera rotation.
  39109. */
  39110. buttons: number[];
  39111. /**
  39112. * Assign buttons for Yaw control.
  39113. */
  39114. buttonsYaw: number[];
  39115. /**
  39116. * Assign buttons for Pitch control.
  39117. */
  39118. buttonsPitch: number[];
  39119. /**
  39120. * Assign buttons for Roll control.
  39121. */
  39122. buttonsRoll: number[];
  39123. /**
  39124. * Detect if any button is being pressed while mouse is moved.
  39125. * -1 = Mouse locked.
  39126. * 0 = Left button.
  39127. * 1 = Middle Button.
  39128. * 2 = Right Button.
  39129. */
  39130. activeButton: number;
  39131. /**
  39132. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39133. * Higher values reduce its sensitivity.
  39134. */
  39135. angularSensibility: number;
  39136. private _mousemoveCallback;
  39137. private _observer;
  39138. private _rollObserver;
  39139. private previousPosition;
  39140. private noPreventDefault;
  39141. private element;
  39142. /**
  39143. * Listen to mouse events to control the camera.
  39144. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39146. */
  39147. constructor(touchEnabled?: boolean);
  39148. /**
  39149. * Attach the mouse control to the HTML DOM element.
  39150. * @param element Defines the element that listens to the input events.
  39151. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39152. */
  39153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39154. /**
  39155. * Detach the current controls from the specified dom element.
  39156. * @param element Defines the element to stop listening the inputs from
  39157. */
  39158. detachControl(element: Nullable<HTMLElement>): void;
  39159. /**
  39160. * Gets the class name of the current input.
  39161. * @returns the class name.
  39162. */
  39163. getClassName(): string;
  39164. /**
  39165. * Get the friendly name associated with the input class.
  39166. * @returns the input's friendly name.
  39167. */
  39168. getSimpleName(): string;
  39169. private _pointerInput;
  39170. private _onMouseMove;
  39171. /**
  39172. * Rotate camera by mouse offset.
  39173. */
  39174. private rotateCamera;
  39175. }
  39176. }
  39177. declare module BABYLON {
  39178. /**
  39179. * Default Inputs manager for the FlyCamera.
  39180. * It groups all the default supported inputs for ease of use.
  39181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39182. */
  39183. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39184. /**
  39185. * Instantiates a new FlyCameraInputsManager.
  39186. * @param camera Defines the camera the inputs belong to.
  39187. */
  39188. constructor(camera: FlyCamera);
  39189. /**
  39190. * Add keyboard input support to the input manager.
  39191. * @returns the new FlyCameraKeyboardMoveInput().
  39192. */
  39193. addKeyboard(): FlyCameraInputsManager;
  39194. /**
  39195. * Add mouse input support to the input manager.
  39196. * @param touchEnabled Enable touch screen support.
  39197. * @returns the new FlyCameraMouseInput().
  39198. */
  39199. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39200. }
  39201. }
  39202. declare module BABYLON {
  39203. /**
  39204. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39205. * such as in a 3D Space Shooter or a Flight Simulator.
  39206. */
  39207. export class FlyCamera extends TargetCamera {
  39208. /**
  39209. * Define the collision ellipsoid of the camera.
  39210. * This is helpful for simulating a camera body, like a player's body.
  39211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39212. */
  39213. ellipsoid: Vector3;
  39214. /**
  39215. * Define an offset for the position of the ellipsoid around the camera.
  39216. * This can be helpful if the camera is attached away from the player's body center,
  39217. * such as at its head.
  39218. */
  39219. ellipsoidOffset: Vector3;
  39220. /**
  39221. * Enable or disable collisions of the camera with the rest of the scene objects.
  39222. */
  39223. checkCollisions: boolean;
  39224. /**
  39225. * Enable or disable gravity on the camera.
  39226. */
  39227. applyGravity: boolean;
  39228. /**
  39229. * Define the current direction the camera is moving to.
  39230. */
  39231. cameraDirection: Vector3;
  39232. /**
  39233. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39234. * This overrides and empties cameraRotation.
  39235. */
  39236. rotationQuaternion: Quaternion;
  39237. /**
  39238. * Track Roll to maintain the wanted Rolling when looking around.
  39239. */
  39240. _trackRoll: number;
  39241. /**
  39242. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39243. */
  39244. rollCorrect: number;
  39245. /**
  39246. * Mimic a banked turn, Rolling the camera when Yawing.
  39247. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39248. */
  39249. bankedTurn: boolean;
  39250. /**
  39251. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39252. */
  39253. bankedTurnLimit: number;
  39254. /**
  39255. * Value of 0 disables the banked Roll.
  39256. * Value of 1 is equal to the Yaw angle in radians.
  39257. */
  39258. bankedTurnMultiplier: number;
  39259. /**
  39260. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39261. */
  39262. inputs: FlyCameraInputsManager;
  39263. /**
  39264. * Gets the input sensibility for mouse input.
  39265. * Higher values reduce sensitivity.
  39266. */
  39267. /**
  39268. * Sets the input sensibility for a mouse input.
  39269. * Higher values reduce sensitivity.
  39270. */
  39271. angularSensibility: number;
  39272. /**
  39273. * Get the keys for camera movement forward.
  39274. */
  39275. /**
  39276. * Set the keys for camera movement forward.
  39277. */
  39278. keysForward: number[];
  39279. /**
  39280. * Get the keys for camera movement backward.
  39281. */
  39282. keysBackward: number[];
  39283. /**
  39284. * Get the keys for camera movement up.
  39285. */
  39286. /**
  39287. * Set the keys for camera movement up.
  39288. */
  39289. keysUp: number[];
  39290. /**
  39291. * Get the keys for camera movement down.
  39292. */
  39293. /**
  39294. * Set the keys for camera movement down.
  39295. */
  39296. keysDown: number[];
  39297. /**
  39298. * Get the keys for camera movement left.
  39299. */
  39300. /**
  39301. * Set the keys for camera movement left.
  39302. */
  39303. keysLeft: number[];
  39304. /**
  39305. * Set the keys for camera movement right.
  39306. */
  39307. /**
  39308. * Set the keys for camera movement right.
  39309. */
  39310. keysRight: number[];
  39311. /**
  39312. * Event raised when the camera collides with a mesh in the scene.
  39313. */
  39314. onCollide: (collidedMesh: AbstractMesh) => void;
  39315. private _collider;
  39316. private _needMoveForGravity;
  39317. private _oldPosition;
  39318. private _diffPosition;
  39319. private _newPosition;
  39320. /** @hidden */
  39321. _localDirection: Vector3;
  39322. /** @hidden */
  39323. _transformedDirection: Vector3;
  39324. /**
  39325. * Instantiates a FlyCamera.
  39326. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39327. * such as in a 3D Space Shooter or a Flight Simulator.
  39328. * @param name Define the name of the camera in the scene.
  39329. * @param position Define the starting position of the camera in the scene.
  39330. * @param scene Define the scene the camera belongs to.
  39331. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39332. */
  39333. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39334. /**
  39335. * Attach a control to the HTML DOM element.
  39336. * @param element Defines the element that listens to the input events.
  39337. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39338. */
  39339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39340. /**
  39341. * Detach a control from the HTML DOM element.
  39342. * The camera will stop reacting to that input.
  39343. * @param element Defines the element that listens to the input events.
  39344. */
  39345. detachControl(element: HTMLElement): void;
  39346. private _collisionMask;
  39347. /**
  39348. * Get the mask that the camera ignores in collision events.
  39349. */
  39350. /**
  39351. * Set the mask that the camera ignores in collision events.
  39352. */
  39353. collisionMask: number;
  39354. /** @hidden */
  39355. _collideWithWorld(displacement: Vector3): void;
  39356. /** @hidden */
  39357. private _onCollisionPositionChange;
  39358. /** @hidden */
  39359. _checkInputs(): void;
  39360. /** @hidden */
  39361. _decideIfNeedsToMove(): boolean;
  39362. /** @hidden */
  39363. _updatePosition(): void;
  39364. /**
  39365. * Restore the Roll to its target value at the rate specified.
  39366. * @param rate - Higher means slower restoring.
  39367. * @hidden
  39368. */
  39369. restoreRoll(rate: number): void;
  39370. /**
  39371. * Destroy the camera and release the current resources held by it.
  39372. */
  39373. dispose(): void;
  39374. /**
  39375. * Get the current object class name.
  39376. * @returns the class name.
  39377. */
  39378. getClassName(): string;
  39379. }
  39380. }
  39381. declare module BABYLON {
  39382. /**
  39383. * Listen to keyboard events to control the camera.
  39384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39385. */
  39386. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39387. /**
  39388. * Defines the camera the input is attached to.
  39389. */
  39390. camera: FlyCamera;
  39391. /**
  39392. * The list of keyboard keys used to control the forward move of the camera.
  39393. */
  39394. keysForward: number[];
  39395. /**
  39396. * The list of keyboard keys used to control the backward move of the camera.
  39397. */
  39398. keysBackward: number[];
  39399. /**
  39400. * The list of keyboard keys used to control the forward move of the camera.
  39401. */
  39402. keysUp: number[];
  39403. /**
  39404. * The list of keyboard keys used to control the backward move of the camera.
  39405. */
  39406. keysDown: number[];
  39407. /**
  39408. * The list of keyboard keys used to control the right strafe move of the camera.
  39409. */
  39410. keysRight: number[];
  39411. /**
  39412. * The list of keyboard keys used to control the left strafe move of the camera.
  39413. */
  39414. keysLeft: number[];
  39415. private _keys;
  39416. private _onCanvasBlurObserver;
  39417. private _onKeyboardObserver;
  39418. private _engine;
  39419. private _scene;
  39420. /**
  39421. * Attach the input controls to a specific dom element to get the input from.
  39422. * @param element Defines the element the controls should be listened from
  39423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39424. */
  39425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39426. /**
  39427. * Detach the current controls from the specified dom element.
  39428. * @param element Defines the element to stop listening the inputs from
  39429. */
  39430. detachControl(element: Nullable<HTMLElement>): void;
  39431. /**
  39432. * Gets the class name of the current intput.
  39433. * @returns the class name
  39434. */
  39435. getClassName(): string;
  39436. /** @hidden */
  39437. _onLostFocus(e: FocusEvent): void;
  39438. /**
  39439. * Get the friendly name associated with the input class.
  39440. * @returns the input friendly name
  39441. */
  39442. getSimpleName(): string;
  39443. /**
  39444. * Update the current camera state depending on the inputs that have been used this frame.
  39445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39446. */
  39447. checkInputs(): void;
  39448. }
  39449. }
  39450. declare module BABYLON {
  39451. /**
  39452. * Manage the mouse wheel inputs to control a follow camera.
  39453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39454. */
  39455. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39456. /**
  39457. * Defines the camera the input is attached to.
  39458. */
  39459. camera: FollowCamera;
  39460. /**
  39461. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39462. */
  39463. axisControlRadius: boolean;
  39464. /**
  39465. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39466. */
  39467. axisControlHeight: boolean;
  39468. /**
  39469. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39470. */
  39471. axisControlRotation: boolean;
  39472. /**
  39473. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39474. * relation to mouseWheel events.
  39475. */
  39476. wheelPrecision: number;
  39477. /**
  39478. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39479. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39480. */
  39481. wheelDeltaPercentage: number;
  39482. private _wheel;
  39483. private _observer;
  39484. /**
  39485. * Attach the input controls to a specific dom element to get the input from.
  39486. * @param element Defines the element the controls should be listened from
  39487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39488. */
  39489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39490. /**
  39491. * Detach the current controls from the specified dom element.
  39492. * @param element Defines the element to stop listening the inputs from
  39493. */
  39494. detachControl(element: Nullable<HTMLElement>): void;
  39495. /**
  39496. * Gets the class name of the current intput.
  39497. * @returns the class name
  39498. */
  39499. getClassName(): string;
  39500. /**
  39501. * Get the friendly name associated with the input class.
  39502. * @returns the input friendly name
  39503. */
  39504. getSimpleName(): string;
  39505. }
  39506. }
  39507. declare module BABYLON {
  39508. /**
  39509. * Manage the pointers inputs to control an follow camera.
  39510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39511. */
  39512. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39513. /**
  39514. * Defines the camera the input is attached to.
  39515. */
  39516. camera: FollowCamera;
  39517. /**
  39518. * Gets the class name of the current input.
  39519. * @returns the class name
  39520. */
  39521. getClassName(): string;
  39522. /**
  39523. * Defines the pointer angular sensibility along the X axis or how fast is
  39524. * the camera rotating.
  39525. * A negative number will reverse the axis direction.
  39526. */
  39527. angularSensibilityX: number;
  39528. /**
  39529. * Defines the pointer angular sensibility along the Y axis or how fast is
  39530. * the camera rotating.
  39531. * A negative number will reverse the axis direction.
  39532. */
  39533. angularSensibilityY: number;
  39534. /**
  39535. * Defines the pointer pinch precision or how fast is the camera zooming.
  39536. * A negative number will reverse the axis direction.
  39537. */
  39538. pinchPrecision: number;
  39539. /**
  39540. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39541. * from 0.
  39542. * It defines the percentage of current camera.radius to use as delta when
  39543. * pinch zoom is used.
  39544. */
  39545. pinchDeltaPercentage: number;
  39546. /**
  39547. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39548. */
  39549. axisXControlRadius: boolean;
  39550. /**
  39551. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39552. */
  39553. axisXControlHeight: boolean;
  39554. /**
  39555. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39556. */
  39557. axisXControlRotation: boolean;
  39558. /**
  39559. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39560. */
  39561. axisYControlRadius: boolean;
  39562. /**
  39563. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39564. */
  39565. axisYControlHeight: boolean;
  39566. /**
  39567. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39568. */
  39569. axisYControlRotation: boolean;
  39570. /**
  39571. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39572. */
  39573. axisPinchControlRadius: boolean;
  39574. /**
  39575. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39576. */
  39577. axisPinchControlHeight: boolean;
  39578. /**
  39579. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39580. */
  39581. axisPinchControlRotation: boolean;
  39582. /**
  39583. * Log error messages if basic misconfiguration has occurred.
  39584. */
  39585. warningEnable: boolean;
  39586. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39587. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39588. private _warningCounter;
  39589. private _warning;
  39590. }
  39591. }
  39592. declare module BABYLON {
  39593. /**
  39594. * Default Inputs manager for the FollowCamera.
  39595. * It groups all the default supported inputs for ease of use.
  39596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39597. */
  39598. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39599. /**
  39600. * Instantiates a new FollowCameraInputsManager.
  39601. * @param camera Defines the camera the inputs belong to
  39602. */
  39603. constructor(camera: FollowCamera);
  39604. /**
  39605. * Add keyboard input support to the input manager.
  39606. * @returns the current input manager
  39607. */
  39608. addKeyboard(): FollowCameraInputsManager;
  39609. /**
  39610. * Add mouse wheel input support to the input manager.
  39611. * @returns the current input manager
  39612. */
  39613. addMouseWheel(): FollowCameraInputsManager;
  39614. /**
  39615. * Add pointers input support to the input manager.
  39616. * @returns the current input manager
  39617. */
  39618. addPointers(): FollowCameraInputsManager;
  39619. /**
  39620. * Add orientation input support to the input manager.
  39621. * @returns the current input manager
  39622. */
  39623. addVRDeviceOrientation(): FollowCameraInputsManager;
  39624. }
  39625. }
  39626. declare module BABYLON {
  39627. /**
  39628. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39629. * an arc rotate version arcFollowCamera are available.
  39630. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39631. */
  39632. export class FollowCamera extends TargetCamera {
  39633. /**
  39634. * Distance the follow camera should follow an object at
  39635. */
  39636. radius: number;
  39637. /**
  39638. * Minimum allowed distance of the camera to the axis of rotation
  39639. * (The camera can not get closer).
  39640. * This can help limiting how the Camera is able to move in the scene.
  39641. */
  39642. lowerRadiusLimit: Nullable<number>;
  39643. /**
  39644. * Maximum allowed distance of the camera to the axis of rotation
  39645. * (The camera can not get further).
  39646. * This can help limiting how the Camera is able to move in the scene.
  39647. */
  39648. upperRadiusLimit: Nullable<number>;
  39649. /**
  39650. * Define a rotation offset between the camera and the object it follows
  39651. */
  39652. rotationOffset: number;
  39653. /**
  39654. * Minimum allowed angle to camera position relative to target object.
  39655. * This can help limiting how the Camera is able to move in the scene.
  39656. */
  39657. lowerRotationOffsetLimit: Nullable<number>;
  39658. /**
  39659. * Maximum allowed angle to camera position relative to target object.
  39660. * This can help limiting how the Camera is able to move in the scene.
  39661. */
  39662. upperRotationOffsetLimit: Nullable<number>;
  39663. /**
  39664. * Define a height offset between the camera and the object it follows.
  39665. * It can help following an object from the top (like a car chaing a plane)
  39666. */
  39667. heightOffset: number;
  39668. /**
  39669. * Minimum allowed height of camera position relative to target object.
  39670. * This can help limiting how the Camera is able to move in the scene.
  39671. */
  39672. lowerHeightOffsetLimit: Nullable<number>;
  39673. /**
  39674. * Maximum allowed height of camera position relative to target object.
  39675. * This can help limiting how the Camera is able to move in the scene.
  39676. */
  39677. upperHeightOffsetLimit: Nullable<number>;
  39678. /**
  39679. * Define how fast the camera can accelerate to follow it s target.
  39680. */
  39681. cameraAcceleration: number;
  39682. /**
  39683. * Define the speed limit of the camera following an object.
  39684. */
  39685. maxCameraSpeed: number;
  39686. /**
  39687. * Define the target of the camera.
  39688. */
  39689. lockedTarget: Nullable<AbstractMesh>;
  39690. /**
  39691. * Defines the input associated with the camera.
  39692. */
  39693. inputs: FollowCameraInputsManager;
  39694. /**
  39695. * Instantiates the follow camera.
  39696. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39697. * @param name Define the name of the camera in the scene
  39698. * @param position Define the position of the camera
  39699. * @param scene Define the scene the camera belong to
  39700. * @param lockedTarget Define the target of the camera
  39701. */
  39702. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39703. private _follow;
  39704. /**
  39705. * Attached controls to the current camera.
  39706. * @param element Defines the element the controls should be listened from
  39707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39708. */
  39709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39710. /**
  39711. * Detach the current controls from the camera.
  39712. * The camera will stop reacting to inputs.
  39713. * @param element Defines the element to stop listening the inputs from
  39714. */
  39715. detachControl(element: HTMLElement): void;
  39716. /** @hidden */
  39717. _checkInputs(): void;
  39718. private _checkLimits;
  39719. /**
  39720. * Gets the camera class name.
  39721. * @returns the class name
  39722. */
  39723. getClassName(): string;
  39724. }
  39725. /**
  39726. * Arc Rotate version of the follow camera.
  39727. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39728. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39729. */
  39730. export class ArcFollowCamera extends TargetCamera {
  39731. /** The longitudinal angle of the camera */
  39732. alpha: number;
  39733. /** The latitudinal angle of the camera */
  39734. beta: number;
  39735. /** The radius of the camera from its target */
  39736. radius: number;
  39737. /** Define the camera target (the messh it should follow) */
  39738. target: Nullable<AbstractMesh>;
  39739. private _cartesianCoordinates;
  39740. /**
  39741. * Instantiates a new ArcFollowCamera
  39742. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39743. * @param name Define the name of the camera
  39744. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39745. * @param beta Define the rotation angle of the camera around the elevation axis
  39746. * @param radius Define the radius of the camera from its target point
  39747. * @param target Define the target of the camera
  39748. * @param scene Define the scene the camera belongs to
  39749. */
  39750. constructor(name: string,
  39751. /** The longitudinal angle of the camera */
  39752. alpha: number,
  39753. /** The latitudinal angle of the camera */
  39754. beta: number,
  39755. /** The radius of the camera from its target */
  39756. radius: number,
  39757. /** Define the camera target (the messh it should follow) */
  39758. target: Nullable<AbstractMesh>, scene: Scene);
  39759. private _follow;
  39760. /** @hidden */
  39761. _checkInputs(): void;
  39762. /**
  39763. * Returns the class name of the object.
  39764. * It is mostly used internally for serialization purposes.
  39765. */
  39766. getClassName(): string;
  39767. }
  39768. }
  39769. declare module BABYLON {
  39770. /**
  39771. * Manage the keyboard inputs to control the movement of a follow camera.
  39772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39773. */
  39774. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39775. /**
  39776. * Defines the camera the input is attached to.
  39777. */
  39778. camera: FollowCamera;
  39779. /**
  39780. * Defines the list of key codes associated with the up action (increase heightOffset)
  39781. */
  39782. keysHeightOffsetIncr: number[];
  39783. /**
  39784. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39785. */
  39786. keysHeightOffsetDecr: number[];
  39787. /**
  39788. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39789. */
  39790. keysHeightOffsetModifierAlt: boolean;
  39791. /**
  39792. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39793. */
  39794. keysHeightOffsetModifierCtrl: boolean;
  39795. /**
  39796. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39797. */
  39798. keysHeightOffsetModifierShift: boolean;
  39799. /**
  39800. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39801. */
  39802. keysRotationOffsetIncr: number[];
  39803. /**
  39804. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39805. */
  39806. keysRotationOffsetDecr: number[];
  39807. /**
  39808. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39809. */
  39810. keysRotationOffsetModifierAlt: boolean;
  39811. /**
  39812. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39813. */
  39814. keysRotationOffsetModifierCtrl: boolean;
  39815. /**
  39816. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39817. */
  39818. keysRotationOffsetModifierShift: boolean;
  39819. /**
  39820. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39821. */
  39822. keysRadiusIncr: number[];
  39823. /**
  39824. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39825. */
  39826. keysRadiusDecr: number[];
  39827. /**
  39828. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39829. */
  39830. keysRadiusModifierAlt: boolean;
  39831. /**
  39832. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39833. */
  39834. keysRadiusModifierCtrl: boolean;
  39835. /**
  39836. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39837. */
  39838. keysRadiusModifierShift: boolean;
  39839. /**
  39840. * Defines the rate of change of heightOffset.
  39841. */
  39842. heightSensibility: number;
  39843. /**
  39844. * Defines the rate of change of rotationOffset.
  39845. */
  39846. rotationSensibility: number;
  39847. /**
  39848. * Defines the rate of change of radius.
  39849. */
  39850. radiusSensibility: number;
  39851. private _keys;
  39852. private _ctrlPressed;
  39853. private _altPressed;
  39854. private _shiftPressed;
  39855. private _onCanvasBlurObserver;
  39856. private _onKeyboardObserver;
  39857. private _engine;
  39858. private _scene;
  39859. /**
  39860. * Attach the input controls to a specific dom element to get the input from.
  39861. * @param element Defines the element the controls should be listened from
  39862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39863. */
  39864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39865. /**
  39866. * Detach the current controls from the specified dom element.
  39867. * @param element Defines the element to stop listening the inputs from
  39868. */
  39869. detachControl(element: Nullable<HTMLElement>): void;
  39870. /**
  39871. * Update the current camera state depending on the inputs that have been used this frame.
  39872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39873. */
  39874. checkInputs(): void;
  39875. /**
  39876. * Gets the class name of the current input.
  39877. * @returns the class name
  39878. */
  39879. getClassName(): string;
  39880. /**
  39881. * Get the friendly name associated with the input class.
  39882. * @returns the input friendly name
  39883. */
  39884. getSimpleName(): string;
  39885. /**
  39886. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39887. * allow modification of the heightOffset value.
  39888. */
  39889. private _modifierHeightOffset;
  39890. /**
  39891. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39892. * allow modification of the rotationOffset value.
  39893. */
  39894. private _modifierRotationOffset;
  39895. /**
  39896. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39897. * allow modification of the radius value.
  39898. */
  39899. private _modifierRadius;
  39900. }
  39901. }
  39902. declare module BABYLON {
  39903. interface FreeCameraInputsManager {
  39904. /**
  39905. * @hidden
  39906. */
  39907. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39908. /**
  39909. * Add orientation input support to the input manager.
  39910. * @returns the current input manager
  39911. */
  39912. addDeviceOrientation(): FreeCameraInputsManager;
  39913. }
  39914. /**
  39915. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39916. * Screen rotation is taken into account.
  39917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39918. */
  39919. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39920. private _camera;
  39921. private _screenOrientationAngle;
  39922. private _constantTranform;
  39923. private _screenQuaternion;
  39924. private _alpha;
  39925. private _beta;
  39926. private _gamma;
  39927. /**
  39928. * Can be used to detect if a device orientation sensor is available on a device
  39929. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39930. * @returns a promise that will resolve on orientation change
  39931. */
  39932. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39933. /**
  39934. * @hidden
  39935. */
  39936. _onDeviceOrientationChangedObservable: Observable<void>;
  39937. /**
  39938. * Instantiates a new input
  39939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39940. */
  39941. constructor();
  39942. /**
  39943. * Define the camera controlled by the input.
  39944. */
  39945. camera: FreeCamera;
  39946. /**
  39947. * Attach the input controls to a specific dom element to get the input from.
  39948. * @param element Defines the element the controls should be listened from
  39949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39950. */
  39951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39952. private _orientationChanged;
  39953. private _deviceOrientation;
  39954. /**
  39955. * Detach the current controls from the specified dom element.
  39956. * @param element Defines the element to stop listening the inputs from
  39957. */
  39958. detachControl(element: Nullable<HTMLElement>): void;
  39959. /**
  39960. * Update the current camera state depending on the inputs that have been used this frame.
  39961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39962. */
  39963. checkInputs(): void;
  39964. /**
  39965. * Gets the class name of the current intput.
  39966. * @returns the class name
  39967. */
  39968. getClassName(): string;
  39969. /**
  39970. * Get the friendly name associated with the input class.
  39971. * @returns the input friendly name
  39972. */
  39973. getSimpleName(): string;
  39974. }
  39975. }
  39976. declare module BABYLON {
  39977. /**
  39978. * Manage the gamepad inputs to control a free camera.
  39979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39980. */
  39981. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39982. /**
  39983. * Define the camera the input is attached to.
  39984. */
  39985. camera: FreeCamera;
  39986. /**
  39987. * Define the Gamepad controlling the input
  39988. */
  39989. gamepad: Nullable<Gamepad>;
  39990. /**
  39991. * Defines the gamepad rotation sensiblity.
  39992. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39993. */
  39994. gamepadAngularSensibility: number;
  39995. /**
  39996. * Defines the gamepad move sensiblity.
  39997. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39998. */
  39999. gamepadMoveSensibility: number;
  40000. private _yAxisScale;
  40001. /**
  40002. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40003. */
  40004. invertYAxis: boolean;
  40005. private _onGamepadConnectedObserver;
  40006. private _onGamepadDisconnectedObserver;
  40007. private _cameraTransform;
  40008. private _deltaTransform;
  40009. private _vector3;
  40010. private _vector2;
  40011. /**
  40012. * Attach the input controls to a specific dom element to get the input from.
  40013. * @param element Defines the element the controls should be listened from
  40014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40015. */
  40016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40017. /**
  40018. * Detach the current controls from the specified dom element.
  40019. * @param element Defines the element to stop listening the inputs from
  40020. */
  40021. detachControl(element: Nullable<HTMLElement>): void;
  40022. /**
  40023. * Update the current camera state depending on the inputs that have been used this frame.
  40024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40025. */
  40026. checkInputs(): void;
  40027. /**
  40028. * Gets the class name of the current intput.
  40029. * @returns the class name
  40030. */
  40031. getClassName(): string;
  40032. /**
  40033. * Get the friendly name associated with the input class.
  40034. * @returns the input friendly name
  40035. */
  40036. getSimpleName(): string;
  40037. }
  40038. }
  40039. declare module BABYLON {
  40040. /**
  40041. * Defines the potential axis of a Joystick
  40042. */
  40043. export enum JoystickAxis {
  40044. /** X axis */
  40045. X = 0,
  40046. /** Y axis */
  40047. Y = 1,
  40048. /** Z axis */
  40049. Z = 2
  40050. }
  40051. /**
  40052. * Class used to define virtual joystick (used in touch mode)
  40053. */
  40054. export class VirtualJoystick {
  40055. /**
  40056. * Gets or sets a boolean indicating that left and right values must be inverted
  40057. */
  40058. reverseLeftRight: boolean;
  40059. /**
  40060. * Gets or sets a boolean indicating that up and down values must be inverted
  40061. */
  40062. reverseUpDown: boolean;
  40063. /**
  40064. * Gets the offset value for the position (ie. the change of the position value)
  40065. */
  40066. deltaPosition: Vector3;
  40067. /**
  40068. * Gets a boolean indicating if the virtual joystick was pressed
  40069. */
  40070. pressed: boolean;
  40071. /**
  40072. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40073. */
  40074. static Canvas: Nullable<HTMLCanvasElement>;
  40075. private static _globalJoystickIndex;
  40076. private static vjCanvasContext;
  40077. private static vjCanvasWidth;
  40078. private static vjCanvasHeight;
  40079. private static halfWidth;
  40080. private _action;
  40081. private _axisTargetedByLeftAndRight;
  40082. private _axisTargetedByUpAndDown;
  40083. private _joystickSensibility;
  40084. private _inversedSensibility;
  40085. private _joystickPointerID;
  40086. private _joystickColor;
  40087. private _joystickPointerPos;
  40088. private _joystickPreviousPointerPos;
  40089. private _joystickPointerStartPos;
  40090. private _deltaJoystickVector;
  40091. private _leftJoystick;
  40092. private _touches;
  40093. private _onPointerDownHandlerRef;
  40094. private _onPointerMoveHandlerRef;
  40095. private _onPointerUpHandlerRef;
  40096. private _onResize;
  40097. /**
  40098. * Creates a new virtual joystick
  40099. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40100. */
  40101. constructor(leftJoystick?: boolean);
  40102. /**
  40103. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40104. * @param newJoystickSensibility defines the new sensibility
  40105. */
  40106. setJoystickSensibility(newJoystickSensibility: number): void;
  40107. private _onPointerDown;
  40108. private _onPointerMove;
  40109. private _onPointerUp;
  40110. /**
  40111. * Change the color of the virtual joystick
  40112. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40113. */
  40114. setJoystickColor(newColor: string): void;
  40115. /**
  40116. * Defines a callback to call when the joystick is touched
  40117. * @param action defines the callback
  40118. */
  40119. setActionOnTouch(action: () => any): void;
  40120. /**
  40121. * Defines which axis you'd like to control for left & right
  40122. * @param axis defines the axis to use
  40123. */
  40124. setAxisForLeftRight(axis: JoystickAxis): void;
  40125. /**
  40126. * Defines which axis you'd like to control for up & down
  40127. * @param axis defines the axis to use
  40128. */
  40129. setAxisForUpDown(axis: JoystickAxis): void;
  40130. private _drawVirtualJoystick;
  40131. /**
  40132. * Release internal HTML canvas
  40133. */
  40134. releaseCanvas(): void;
  40135. }
  40136. }
  40137. declare module BABYLON {
  40138. interface FreeCameraInputsManager {
  40139. /**
  40140. * Add virtual joystick input support to the input manager.
  40141. * @returns the current input manager
  40142. */
  40143. addVirtualJoystick(): FreeCameraInputsManager;
  40144. }
  40145. /**
  40146. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40148. */
  40149. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40150. /**
  40151. * Defines the camera the input is attached to.
  40152. */
  40153. camera: FreeCamera;
  40154. private _leftjoystick;
  40155. private _rightjoystick;
  40156. /**
  40157. * Gets the left stick of the virtual joystick.
  40158. * @returns The virtual Joystick
  40159. */
  40160. getLeftJoystick(): VirtualJoystick;
  40161. /**
  40162. * Gets the right stick of the virtual joystick.
  40163. * @returns The virtual Joystick
  40164. */
  40165. getRightJoystick(): VirtualJoystick;
  40166. /**
  40167. * Update the current camera state depending on the inputs that have been used this frame.
  40168. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40169. */
  40170. checkInputs(): void;
  40171. /**
  40172. * Attach the input controls to a specific dom element to get the input from.
  40173. * @param element Defines the element the controls should be listened from
  40174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40175. */
  40176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40177. /**
  40178. * Detach the current controls from the specified dom element.
  40179. * @param element Defines the element to stop listening the inputs from
  40180. */
  40181. detachControl(element: Nullable<HTMLElement>): void;
  40182. /**
  40183. * Gets the class name of the current intput.
  40184. * @returns the class name
  40185. */
  40186. getClassName(): string;
  40187. /**
  40188. * Get the friendly name associated with the input class.
  40189. * @returns the input friendly name
  40190. */
  40191. getSimpleName(): string;
  40192. }
  40193. }
  40194. declare module BABYLON {
  40195. /**
  40196. * This represents a FPS type of camera controlled by touch.
  40197. * This is like a universal camera minus the Gamepad controls.
  40198. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40199. */
  40200. export class TouchCamera extends FreeCamera {
  40201. /**
  40202. * Defines the touch sensibility for rotation.
  40203. * The higher the faster.
  40204. */
  40205. touchAngularSensibility: number;
  40206. /**
  40207. * Defines the touch sensibility for move.
  40208. * The higher the faster.
  40209. */
  40210. touchMoveSensibility: number;
  40211. /**
  40212. * Instantiates a new touch camera.
  40213. * This represents a FPS type of camera controlled by touch.
  40214. * This is like a universal camera minus the Gamepad controls.
  40215. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40216. * @param name Define the name of the camera in the scene
  40217. * @param position Define the start position of the camera in the scene
  40218. * @param scene Define the scene the camera belongs to
  40219. */
  40220. constructor(name: string, position: Vector3, scene: Scene);
  40221. /**
  40222. * Gets the current object class name.
  40223. * @return the class name
  40224. */
  40225. getClassName(): string;
  40226. /** @hidden */
  40227. _setupInputs(): void;
  40228. }
  40229. }
  40230. declare module BABYLON {
  40231. /**
  40232. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40233. * being tilted forward or back and left or right.
  40234. */
  40235. export class DeviceOrientationCamera extends FreeCamera {
  40236. private _initialQuaternion;
  40237. private _quaternionCache;
  40238. private _tmpDragQuaternion;
  40239. private _disablePointerInputWhenUsingDeviceOrientation;
  40240. /**
  40241. * Creates a new device orientation camera
  40242. * @param name The name of the camera
  40243. * @param position The start position camera
  40244. * @param scene The scene the camera belongs to
  40245. */
  40246. constructor(name: string, position: Vector3, scene: Scene);
  40247. /**
  40248. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40249. */
  40250. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40251. private _dragFactor;
  40252. /**
  40253. * Enabled turning on the y axis when the orientation sensor is active
  40254. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40255. */
  40256. enableHorizontalDragging(dragFactor?: number): void;
  40257. /**
  40258. * Gets the current instance class name ("DeviceOrientationCamera").
  40259. * This helps avoiding instanceof at run time.
  40260. * @returns the class name
  40261. */
  40262. getClassName(): string;
  40263. /**
  40264. * @hidden
  40265. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40266. */
  40267. _checkInputs(): void;
  40268. /**
  40269. * Reset the camera to its default orientation on the specified axis only.
  40270. * @param axis The axis to reset
  40271. */
  40272. resetToCurrentRotation(axis?: Axis): void;
  40273. }
  40274. }
  40275. declare module BABYLON {
  40276. /**
  40277. * Defines supported buttons for XBox360 compatible gamepads
  40278. */
  40279. export enum Xbox360Button {
  40280. /** A */
  40281. A = 0,
  40282. /** B */
  40283. B = 1,
  40284. /** X */
  40285. X = 2,
  40286. /** Y */
  40287. Y = 3,
  40288. /** Start */
  40289. Start = 4,
  40290. /** Back */
  40291. Back = 5,
  40292. /** Left button */
  40293. LB = 6,
  40294. /** Right button */
  40295. RB = 7,
  40296. /** Left stick */
  40297. LeftStick = 8,
  40298. /** Right stick */
  40299. RightStick = 9
  40300. }
  40301. /** Defines values for XBox360 DPad */
  40302. export enum Xbox360Dpad {
  40303. /** Up */
  40304. Up = 0,
  40305. /** Down */
  40306. Down = 1,
  40307. /** Left */
  40308. Left = 2,
  40309. /** Right */
  40310. Right = 3
  40311. }
  40312. /**
  40313. * Defines a XBox360 gamepad
  40314. */
  40315. export class Xbox360Pad extends Gamepad {
  40316. private _leftTrigger;
  40317. private _rightTrigger;
  40318. private _onlefttriggerchanged;
  40319. private _onrighttriggerchanged;
  40320. private _onbuttondown;
  40321. private _onbuttonup;
  40322. private _ondpaddown;
  40323. private _ondpadup;
  40324. /** Observable raised when a button is pressed */
  40325. onButtonDownObservable: Observable<Xbox360Button>;
  40326. /** Observable raised when a button is released */
  40327. onButtonUpObservable: Observable<Xbox360Button>;
  40328. /** Observable raised when a pad is pressed */
  40329. onPadDownObservable: Observable<Xbox360Dpad>;
  40330. /** Observable raised when a pad is released */
  40331. onPadUpObservable: Observable<Xbox360Dpad>;
  40332. private _buttonA;
  40333. private _buttonB;
  40334. private _buttonX;
  40335. private _buttonY;
  40336. private _buttonBack;
  40337. private _buttonStart;
  40338. private _buttonLB;
  40339. private _buttonRB;
  40340. private _buttonLeftStick;
  40341. private _buttonRightStick;
  40342. private _dPadUp;
  40343. private _dPadDown;
  40344. private _dPadLeft;
  40345. private _dPadRight;
  40346. private _isXboxOnePad;
  40347. /**
  40348. * Creates a new XBox360 gamepad object
  40349. * @param id defines the id of this gamepad
  40350. * @param index defines its index
  40351. * @param gamepad defines the internal HTML gamepad object
  40352. * @param xboxOne defines if it is a XBox One gamepad
  40353. */
  40354. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40355. /**
  40356. * Defines the callback to call when left trigger is pressed
  40357. * @param callback defines the callback to use
  40358. */
  40359. onlefttriggerchanged(callback: (value: number) => void): void;
  40360. /**
  40361. * Defines the callback to call when right trigger is pressed
  40362. * @param callback defines the callback to use
  40363. */
  40364. onrighttriggerchanged(callback: (value: number) => void): void;
  40365. /**
  40366. * Gets the left trigger value
  40367. */
  40368. /**
  40369. * Sets the left trigger value
  40370. */
  40371. leftTrigger: number;
  40372. /**
  40373. * Gets the right trigger value
  40374. */
  40375. /**
  40376. * Sets the right trigger value
  40377. */
  40378. rightTrigger: number;
  40379. /**
  40380. * Defines the callback to call when a button is pressed
  40381. * @param callback defines the callback to use
  40382. */
  40383. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40384. /**
  40385. * Defines the callback to call when a button is released
  40386. * @param callback defines the callback to use
  40387. */
  40388. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40389. /**
  40390. * Defines the callback to call when a pad is pressed
  40391. * @param callback defines the callback to use
  40392. */
  40393. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40394. /**
  40395. * Defines the callback to call when a pad is released
  40396. * @param callback defines the callback to use
  40397. */
  40398. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40399. private _setButtonValue;
  40400. private _setDPadValue;
  40401. /**
  40402. * Gets the value of the `A` button
  40403. */
  40404. /**
  40405. * Sets the value of the `A` button
  40406. */
  40407. buttonA: number;
  40408. /**
  40409. * Gets the value of the `B` button
  40410. */
  40411. /**
  40412. * Sets the value of the `B` button
  40413. */
  40414. buttonB: number;
  40415. /**
  40416. * Gets the value of the `X` button
  40417. */
  40418. /**
  40419. * Sets the value of the `X` button
  40420. */
  40421. buttonX: number;
  40422. /**
  40423. * Gets the value of the `Y` button
  40424. */
  40425. /**
  40426. * Sets the value of the `Y` button
  40427. */
  40428. buttonY: number;
  40429. /**
  40430. * Gets the value of the `Start` button
  40431. */
  40432. /**
  40433. * Sets the value of the `Start` button
  40434. */
  40435. buttonStart: number;
  40436. /**
  40437. * Gets the value of the `Back` button
  40438. */
  40439. /**
  40440. * Sets the value of the `Back` button
  40441. */
  40442. buttonBack: number;
  40443. /**
  40444. * Gets the value of the `Left` button
  40445. */
  40446. /**
  40447. * Sets the value of the `Left` button
  40448. */
  40449. buttonLB: number;
  40450. /**
  40451. * Gets the value of the `Right` button
  40452. */
  40453. /**
  40454. * Sets the value of the `Right` button
  40455. */
  40456. buttonRB: number;
  40457. /**
  40458. * Gets the value of the Left joystick
  40459. */
  40460. /**
  40461. * Sets the value of the Left joystick
  40462. */
  40463. buttonLeftStick: number;
  40464. /**
  40465. * Gets the value of the Right joystick
  40466. */
  40467. /**
  40468. * Sets the value of the Right joystick
  40469. */
  40470. buttonRightStick: number;
  40471. /**
  40472. * Gets the value of D-pad up
  40473. */
  40474. /**
  40475. * Sets the value of D-pad up
  40476. */
  40477. dPadUp: number;
  40478. /**
  40479. * Gets the value of D-pad down
  40480. */
  40481. /**
  40482. * Sets the value of D-pad down
  40483. */
  40484. dPadDown: number;
  40485. /**
  40486. * Gets the value of D-pad left
  40487. */
  40488. /**
  40489. * Sets the value of D-pad left
  40490. */
  40491. dPadLeft: number;
  40492. /**
  40493. * Gets the value of D-pad right
  40494. */
  40495. /**
  40496. * Sets the value of D-pad right
  40497. */
  40498. dPadRight: number;
  40499. /**
  40500. * Force the gamepad to synchronize with device values
  40501. */
  40502. update(): void;
  40503. /**
  40504. * Disposes the gamepad
  40505. */
  40506. dispose(): void;
  40507. }
  40508. }
  40509. declare module BABYLON {
  40510. /**
  40511. * Defines supported buttons for DualShock compatible gamepads
  40512. */
  40513. export enum DualShockButton {
  40514. /** Cross */
  40515. Cross = 0,
  40516. /** Circle */
  40517. Circle = 1,
  40518. /** Square */
  40519. Square = 2,
  40520. /** Triangle */
  40521. Triangle = 3,
  40522. /** Options */
  40523. Options = 4,
  40524. /** Share */
  40525. Share = 5,
  40526. /** L1 */
  40527. L1 = 6,
  40528. /** R1 */
  40529. R1 = 7,
  40530. /** Left stick */
  40531. LeftStick = 8,
  40532. /** Right stick */
  40533. RightStick = 9
  40534. }
  40535. /** Defines values for DualShock DPad */
  40536. export enum DualShockDpad {
  40537. /** Up */
  40538. Up = 0,
  40539. /** Down */
  40540. Down = 1,
  40541. /** Left */
  40542. Left = 2,
  40543. /** Right */
  40544. Right = 3
  40545. }
  40546. /**
  40547. * Defines a DualShock gamepad
  40548. */
  40549. export class DualShockPad extends Gamepad {
  40550. private _leftTrigger;
  40551. private _rightTrigger;
  40552. private _onlefttriggerchanged;
  40553. private _onrighttriggerchanged;
  40554. private _onbuttondown;
  40555. private _onbuttonup;
  40556. private _ondpaddown;
  40557. private _ondpadup;
  40558. /** Observable raised when a button is pressed */
  40559. onButtonDownObservable: Observable<DualShockButton>;
  40560. /** Observable raised when a button is released */
  40561. onButtonUpObservable: Observable<DualShockButton>;
  40562. /** Observable raised when a pad is pressed */
  40563. onPadDownObservable: Observable<DualShockDpad>;
  40564. /** Observable raised when a pad is released */
  40565. onPadUpObservable: Observable<DualShockDpad>;
  40566. private _buttonCross;
  40567. private _buttonCircle;
  40568. private _buttonSquare;
  40569. private _buttonTriangle;
  40570. private _buttonShare;
  40571. private _buttonOptions;
  40572. private _buttonL1;
  40573. private _buttonR1;
  40574. private _buttonLeftStick;
  40575. private _buttonRightStick;
  40576. private _dPadUp;
  40577. private _dPadDown;
  40578. private _dPadLeft;
  40579. private _dPadRight;
  40580. /**
  40581. * Creates a new DualShock gamepad object
  40582. * @param id defines the id of this gamepad
  40583. * @param index defines its index
  40584. * @param gamepad defines the internal HTML gamepad object
  40585. */
  40586. constructor(id: string, index: number, gamepad: any);
  40587. /**
  40588. * Defines the callback to call when left trigger is pressed
  40589. * @param callback defines the callback to use
  40590. */
  40591. onlefttriggerchanged(callback: (value: number) => void): void;
  40592. /**
  40593. * Defines the callback to call when right trigger is pressed
  40594. * @param callback defines the callback to use
  40595. */
  40596. onrighttriggerchanged(callback: (value: number) => void): void;
  40597. /**
  40598. * Gets the left trigger value
  40599. */
  40600. /**
  40601. * Sets the left trigger value
  40602. */
  40603. leftTrigger: number;
  40604. /**
  40605. * Gets the right trigger value
  40606. */
  40607. /**
  40608. * Sets the right trigger value
  40609. */
  40610. rightTrigger: number;
  40611. /**
  40612. * Defines the callback to call when a button is pressed
  40613. * @param callback defines the callback to use
  40614. */
  40615. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40616. /**
  40617. * Defines the callback to call when a button is released
  40618. * @param callback defines the callback to use
  40619. */
  40620. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40621. /**
  40622. * Defines the callback to call when a pad is pressed
  40623. * @param callback defines the callback to use
  40624. */
  40625. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40626. /**
  40627. * Defines the callback to call when a pad is released
  40628. * @param callback defines the callback to use
  40629. */
  40630. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40631. private _setButtonValue;
  40632. private _setDPadValue;
  40633. /**
  40634. * Gets the value of the `Cross` button
  40635. */
  40636. /**
  40637. * Sets the value of the `Cross` button
  40638. */
  40639. buttonCross: number;
  40640. /**
  40641. * Gets the value of the `Circle` button
  40642. */
  40643. /**
  40644. * Sets the value of the `Circle` button
  40645. */
  40646. buttonCircle: number;
  40647. /**
  40648. * Gets the value of the `Square` button
  40649. */
  40650. /**
  40651. * Sets the value of the `Square` button
  40652. */
  40653. buttonSquare: number;
  40654. /**
  40655. * Gets the value of the `Triangle` button
  40656. */
  40657. /**
  40658. * Sets the value of the `Triangle` button
  40659. */
  40660. buttonTriangle: number;
  40661. /**
  40662. * Gets the value of the `Options` button
  40663. */
  40664. /**
  40665. * Sets the value of the `Options` button
  40666. */
  40667. buttonOptions: number;
  40668. /**
  40669. * Gets the value of the `Share` button
  40670. */
  40671. /**
  40672. * Sets the value of the `Share` button
  40673. */
  40674. buttonShare: number;
  40675. /**
  40676. * Gets the value of the `L1` button
  40677. */
  40678. /**
  40679. * Sets the value of the `L1` button
  40680. */
  40681. buttonL1: number;
  40682. /**
  40683. * Gets the value of the `R1` button
  40684. */
  40685. /**
  40686. * Sets the value of the `R1` button
  40687. */
  40688. buttonR1: number;
  40689. /**
  40690. * Gets the value of the Left joystick
  40691. */
  40692. /**
  40693. * Sets the value of the Left joystick
  40694. */
  40695. buttonLeftStick: number;
  40696. /**
  40697. * Gets the value of the Right joystick
  40698. */
  40699. /**
  40700. * Sets the value of the Right joystick
  40701. */
  40702. buttonRightStick: number;
  40703. /**
  40704. * Gets the value of D-pad up
  40705. */
  40706. /**
  40707. * Sets the value of D-pad up
  40708. */
  40709. dPadUp: number;
  40710. /**
  40711. * Gets the value of D-pad down
  40712. */
  40713. /**
  40714. * Sets the value of D-pad down
  40715. */
  40716. dPadDown: number;
  40717. /**
  40718. * Gets the value of D-pad left
  40719. */
  40720. /**
  40721. * Sets the value of D-pad left
  40722. */
  40723. dPadLeft: number;
  40724. /**
  40725. * Gets the value of D-pad right
  40726. */
  40727. /**
  40728. * Sets the value of D-pad right
  40729. */
  40730. dPadRight: number;
  40731. /**
  40732. * Force the gamepad to synchronize with device values
  40733. */
  40734. update(): void;
  40735. /**
  40736. * Disposes the gamepad
  40737. */
  40738. dispose(): void;
  40739. }
  40740. }
  40741. declare module BABYLON {
  40742. /**
  40743. * Manager for handling gamepads
  40744. */
  40745. export class GamepadManager {
  40746. private _scene?;
  40747. private _babylonGamepads;
  40748. private _oneGamepadConnected;
  40749. /** @hidden */
  40750. _isMonitoring: boolean;
  40751. private _gamepadEventSupported;
  40752. private _gamepadSupport;
  40753. /**
  40754. * observable to be triggered when the gamepad controller has been connected
  40755. */
  40756. onGamepadConnectedObservable: Observable<Gamepad>;
  40757. /**
  40758. * observable to be triggered when the gamepad controller has been disconnected
  40759. */
  40760. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40761. private _onGamepadConnectedEvent;
  40762. private _onGamepadDisconnectedEvent;
  40763. /**
  40764. * Initializes the gamepad manager
  40765. * @param _scene BabylonJS scene
  40766. */
  40767. constructor(_scene?: Scene | undefined);
  40768. /**
  40769. * The gamepads in the game pad manager
  40770. */
  40771. readonly gamepads: Gamepad[];
  40772. /**
  40773. * Get the gamepad controllers based on type
  40774. * @param type The type of gamepad controller
  40775. * @returns Nullable gamepad
  40776. */
  40777. getGamepadByType(type?: number): Nullable<Gamepad>;
  40778. /**
  40779. * Disposes the gamepad manager
  40780. */
  40781. dispose(): void;
  40782. private _addNewGamepad;
  40783. private _startMonitoringGamepads;
  40784. private _stopMonitoringGamepads;
  40785. /** @hidden */
  40786. _checkGamepadsStatus(): void;
  40787. private _updateGamepadObjects;
  40788. }
  40789. }
  40790. declare module BABYLON {
  40791. interface Scene {
  40792. /** @hidden */
  40793. _gamepadManager: Nullable<GamepadManager>;
  40794. /**
  40795. * Gets the gamepad manager associated with the scene
  40796. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40797. */
  40798. gamepadManager: GamepadManager;
  40799. }
  40800. /**
  40801. * Interface representing a free camera inputs manager
  40802. */
  40803. interface FreeCameraInputsManager {
  40804. /**
  40805. * Adds gamepad input support to the FreeCameraInputsManager.
  40806. * @returns the FreeCameraInputsManager
  40807. */
  40808. addGamepad(): FreeCameraInputsManager;
  40809. }
  40810. /**
  40811. * Interface representing an arc rotate camera inputs manager
  40812. */
  40813. interface ArcRotateCameraInputsManager {
  40814. /**
  40815. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40816. * @returns the camera inputs manager
  40817. */
  40818. addGamepad(): ArcRotateCameraInputsManager;
  40819. }
  40820. /**
  40821. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40822. */
  40823. export class GamepadSystemSceneComponent implements ISceneComponent {
  40824. /**
  40825. * The component name helpfull to identify the component in the list of scene components.
  40826. */
  40827. readonly name: string;
  40828. /**
  40829. * The scene the component belongs to.
  40830. */
  40831. scene: Scene;
  40832. /**
  40833. * Creates a new instance of the component for the given scene
  40834. * @param scene Defines the scene to register the component in
  40835. */
  40836. constructor(scene: Scene);
  40837. /**
  40838. * Registers the component in a given scene
  40839. */
  40840. register(): void;
  40841. /**
  40842. * Rebuilds the elements related to this component in case of
  40843. * context lost for instance.
  40844. */
  40845. rebuild(): void;
  40846. /**
  40847. * Disposes the component and the associated ressources
  40848. */
  40849. dispose(): void;
  40850. private _beforeCameraUpdate;
  40851. }
  40852. }
  40853. declare module BABYLON {
  40854. /**
  40855. * 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,
  40856. * which still works and will still be found in many Playgrounds.
  40857. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40858. */
  40859. export class UniversalCamera extends TouchCamera {
  40860. /**
  40861. * Defines the gamepad rotation sensiblity.
  40862. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40863. */
  40864. gamepadAngularSensibility: number;
  40865. /**
  40866. * Defines the gamepad move sensiblity.
  40867. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40868. */
  40869. gamepadMoveSensibility: number;
  40870. /**
  40871. * 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,
  40872. * which still works and will still be found in many Playgrounds.
  40873. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40874. * @param name Define the name of the camera in the scene
  40875. * @param position Define the start position of the camera in the scene
  40876. * @param scene Define the scene the camera belongs to
  40877. */
  40878. constructor(name: string, position: Vector3, scene: Scene);
  40879. /**
  40880. * Gets the current object class name.
  40881. * @return the class name
  40882. */
  40883. getClassName(): string;
  40884. }
  40885. }
  40886. declare module BABYLON {
  40887. /**
  40888. * This represents a FPS type of camera. This is only here for back compat purpose.
  40889. * Please use the UniversalCamera instead as both are identical.
  40890. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40891. */
  40892. export class GamepadCamera extends UniversalCamera {
  40893. /**
  40894. * Instantiates a new Gamepad Camera
  40895. * This represents a FPS type of camera. This is only here for back compat purpose.
  40896. * Please use the UniversalCamera instead as both are identical.
  40897. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40898. * @param name Define the name of the camera in the scene
  40899. * @param position Define the start position of the camera in the scene
  40900. * @param scene Define the scene the camera belongs to
  40901. */
  40902. constructor(name: string, position: Vector3, scene: Scene);
  40903. /**
  40904. * Gets the current object class name.
  40905. * @return the class name
  40906. */
  40907. getClassName(): string;
  40908. }
  40909. }
  40910. declare module BABYLON {
  40911. /** @hidden */
  40912. export var passPixelShader: {
  40913. name: string;
  40914. shader: string;
  40915. };
  40916. }
  40917. declare module BABYLON {
  40918. /** @hidden */
  40919. export var passCubePixelShader: {
  40920. name: string;
  40921. shader: string;
  40922. };
  40923. }
  40924. declare module BABYLON {
  40925. /**
  40926. * PassPostProcess which produces an output the same as it's input
  40927. */
  40928. export class PassPostProcess extends PostProcess {
  40929. /**
  40930. * Creates the PassPostProcess
  40931. * @param name The name of the effect.
  40932. * @param options The required width/height ratio to downsize to before computing the render pass.
  40933. * @param camera The camera to apply the render pass to.
  40934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40935. * @param engine The engine which the post process will be applied. (default: current engine)
  40936. * @param reusable If the post process can be reused on the same frame. (default: false)
  40937. * @param textureType The type of texture to be used when performing the post processing.
  40938. * @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)
  40939. */
  40940. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40941. }
  40942. /**
  40943. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40944. */
  40945. export class PassCubePostProcess extends PostProcess {
  40946. private _face;
  40947. /**
  40948. * Gets or sets the cube face to display.
  40949. * * 0 is +X
  40950. * * 1 is -X
  40951. * * 2 is +Y
  40952. * * 3 is -Y
  40953. * * 4 is +Z
  40954. * * 5 is -Z
  40955. */
  40956. face: number;
  40957. /**
  40958. * Creates the PassCubePostProcess
  40959. * @param name The name of the effect.
  40960. * @param options The required width/height ratio to downsize to before computing the render pass.
  40961. * @param camera The camera to apply the render pass to.
  40962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40963. * @param engine The engine which the post process will be applied. (default: current engine)
  40964. * @param reusable If the post process can be reused on the same frame. (default: false)
  40965. * @param textureType The type of texture to be used when performing the post processing.
  40966. * @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)
  40967. */
  40968. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40969. }
  40970. }
  40971. declare module BABYLON {
  40972. /** @hidden */
  40973. export var anaglyphPixelShader: {
  40974. name: string;
  40975. shader: string;
  40976. };
  40977. }
  40978. declare module BABYLON {
  40979. /**
  40980. * Postprocess used to generate anaglyphic rendering
  40981. */
  40982. export class AnaglyphPostProcess extends PostProcess {
  40983. private _passedProcess;
  40984. /**
  40985. * Creates a new AnaglyphPostProcess
  40986. * @param name defines postprocess name
  40987. * @param options defines creation options or target ratio scale
  40988. * @param rigCameras defines cameras using this postprocess
  40989. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40990. * @param engine defines hosting engine
  40991. * @param reusable defines if the postprocess will be reused multiple times per frame
  40992. */
  40993. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40994. }
  40995. }
  40996. declare module BABYLON {
  40997. /**
  40998. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40999. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41000. */
  41001. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41002. /**
  41003. * Creates a new AnaglyphArcRotateCamera
  41004. * @param name defines camera name
  41005. * @param alpha defines alpha angle (in radians)
  41006. * @param beta defines beta angle (in radians)
  41007. * @param radius defines radius
  41008. * @param target defines camera target
  41009. * @param interaxialDistance defines distance between each color axis
  41010. * @param scene defines the hosting scene
  41011. */
  41012. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41013. /**
  41014. * Gets camera class name
  41015. * @returns AnaglyphArcRotateCamera
  41016. */
  41017. getClassName(): string;
  41018. }
  41019. }
  41020. declare module BABYLON {
  41021. /**
  41022. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41023. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41024. */
  41025. export class AnaglyphFreeCamera extends FreeCamera {
  41026. /**
  41027. * Creates a new AnaglyphFreeCamera
  41028. * @param name defines camera name
  41029. * @param position defines initial position
  41030. * @param interaxialDistance defines distance between each color axis
  41031. * @param scene defines the hosting scene
  41032. */
  41033. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41034. /**
  41035. * Gets camera class name
  41036. * @returns AnaglyphFreeCamera
  41037. */
  41038. getClassName(): string;
  41039. }
  41040. }
  41041. declare module BABYLON {
  41042. /**
  41043. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41044. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41045. */
  41046. export class AnaglyphGamepadCamera extends GamepadCamera {
  41047. /**
  41048. * Creates a new AnaglyphGamepadCamera
  41049. * @param name defines camera name
  41050. * @param position defines initial position
  41051. * @param interaxialDistance defines distance between each color axis
  41052. * @param scene defines the hosting scene
  41053. */
  41054. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41055. /**
  41056. * Gets camera class name
  41057. * @returns AnaglyphGamepadCamera
  41058. */
  41059. getClassName(): string;
  41060. }
  41061. }
  41062. declare module BABYLON {
  41063. /**
  41064. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41065. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41066. */
  41067. export class AnaglyphUniversalCamera extends UniversalCamera {
  41068. /**
  41069. * Creates a new AnaglyphUniversalCamera
  41070. * @param name defines camera name
  41071. * @param position defines initial position
  41072. * @param interaxialDistance defines distance between each color axis
  41073. * @param scene defines the hosting scene
  41074. */
  41075. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41076. /**
  41077. * Gets camera class name
  41078. * @returns AnaglyphUniversalCamera
  41079. */
  41080. getClassName(): string;
  41081. }
  41082. }
  41083. declare module BABYLON {
  41084. /** @hidden */
  41085. export var stereoscopicInterlacePixelShader: {
  41086. name: string;
  41087. shader: string;
  41088. };
  41089. }
  41090. declare module BABYLON {
  41091. /**
  41092. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41093. */
  41094. export class StereoscopicInterlacePostProcess extends PostProcess {
  41095. private _stepSize;
  41096. private _passedProcess;
  41097. /**
  41098. * Initializes a StereoscopicInterlacePostProcess
  41099. * @param name The name of the effect.
  41100. * @param rigCameras The rig cameras to be appled to the post process
  41101. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41103. * @param engine The engine which the post process will be applied. (default: current engine)
  41104. * @param reusable If the post process can be reused on the same frame. (default: false)
  41105. */
  41106. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41107. }
  41108. }
  41109. declare module BABYLON {
  41110. /**
  41111. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41112. * @see http://doc.babylonjs.com/features/cameras
  41113. */
  41114. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41115. /**
  41116. * Creates a new StereoscopicArcRotateCamera
  41117. * @param name defines camera name
  41118. * @param alpha defines alpha angle (in radians)
  41119. * @param beta defines beta angle (in radians)
  41120. * @param radius defines radius
  41121. * @param target defines camera target
  41122. * @param interaxialDistance defines distance between each color axis
  41123. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41124. * @param scene defines the hosting scene
  41125. */
  41126. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41127. /**
  41128. * Gets camera class name
  41129. * @returns StereoscopicArcRotateCamera
  41130. */
  41131. getClassName(): string;
  41132. }
  41133. }
  41134. declare module BABYLON {
  41135. /**
  41136. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41137. * @see http://doc.babylonjs.com/features/cameras
  41138. */
  41139. export class StereoscopicFreeCamera extends FreeCamera {
  41140. /**
  41141. * Creates a new StereoscopicFreeCamera
  41142. * @param name defines camera name
  41143. * @param position defines initial position
  41144. * @param interaxialDistance defines distance between each color axis
  41145. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41146. * @param scene defines the hosting scene
  41147. */
  41148. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41149. /**
  41150. * Gets camera class name
  41151. * @returns StereoscopicFreeCamera
  41152. */
  41153. getClassName(): string;
  41154. }
  41155. }
  41156. declare module BABYLON {
  41157. /**
  41158. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41159. * @see http://doc.babylonjs.com/features/cameras
  41160. */
  41161. export class StereoscopicGamepadCamera extends GamepadCamera {
  41162. /**
  41163. * Creates a new StereoscopicGamepadCamera
  41164. * @param name defines camera name
  41165. * @param position defines initial position
  41166. * @param interaxialDistance defines distance between each color axis
  41167. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41168. * @param scene defines the hosting scene
  41169. */
  41170. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41171. /**
  41172. * Gets camera class name
  41173. * @returns StereoscopicGamepadCamera
  41174. */
  41175. getClassName(): string;
  41176. }
  41177. }
  41178. declare module BABYLON {
  41179. /**
  41180. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41181. * @see http://doc.babylonjs.com/features/cameras
  41182. */
  41183. export class StereoscopicUniversalCamera extends UniversalCamera {
  41184. /**
  41185. * Creates a new StereoscopicUniversalCamera
  41186. * @param name defines camera name
  41187. * @param position defines initial position
  41188. * @param interaxialDistance defines distance between each color axis
  41189. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41190. * @param scene defines the hosting scene
  41191. */
  41192. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41193. /**
  41194. * Gets camera class name
  41195. * @returns StereoscopicUniversalCamera
  41196. */
  41197. getClassName(): string;
  41198. }
  41199. }
  41200. declare module BABYLON {
  41201. /**
  41202. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41203. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41204. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41205. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41206. */
  41207. export class VirtualJoysticksCamera extends FreeCamera {
  41208. /**
  41209. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41210. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41211. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41212. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41213. * @param name Define the name of the camera in the scene
  41214. * @param position Define the start position of the camera in the scene
  41215. * @param scene Define the scene the camera belongs to
  41216. */
  41217. constructor(name: string, position: Vector3, scene: Scene);
  41218. /**
  41219. * Gets the current object class name.
  41220. * @return the class name
  41221. */
  41222. getClassName(): string;
  41223. }
  41224. }
  41225. declare module BABYLON {
  41226. /**
  41227. * This represents all the required metrics to create a VR camera.
  41228. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41229. */
  41230. export class VRCameraMetrics {
  41231. /**
  41232. * Define the horizontal resolution off the screen.
  41233. */
  41234. hResolution: number;
  41235. /**
  41236. * Define the vertical resolution off the screen.
  41237. */
  41238. vResolution: number;
  41239. /**
  41240. * Define the horizontal screen size.
  41241. */
  41242. hScreenSize: number;
  41243. /**
  41244. * Define the vertical screen size.
  41245. */
  41246. vScreenSize: number;
  41247. /**
  41248. * Define the vertical screen center position.
  41249. */
  41250. vScreenCenter: number;
  41251. /**
  41252. * Define the distance of the eyes to the screen.
  41253. */
  41254. eyeToScreenDistance: number;
  41255. /**
  41256. * Define the distance between both lenses
  41257. */
  41258. lensSeparationDistance: number;
  41259. /**
  41260. * Define the distance between both viewer's eyes.
  41261. */
  41262. interpupillaryDistance: number;
  41263. /**
  41264. * Define the distortion factor of the VR postprocess.
  41265. * Please, touch with care.
  41266. */
  41267. distortionK: number[];
  41268. /**
  41269. * Define the chromatic aberration correction factors for the VR post process.
  41270. */
  41271. chromaAbCorrection: number[];
  41272. /**
  41273. * Define the scale factor of the post process.
  41274. * The smaller the better but the slower.
  41275. */
  41276. postProcessScaleFactor: number;
  41277. /**
  41278. * Define an offset for the lens center.
  41279. */
  41280. lensCenterOffset: number;
  41281. /**
  41282. * Define if the current vr camera should compensate the distortion of the lense or not.
  41283. */
  41284. compensateDistortion: boolean;
  41285. /**
  41286. * Defines if multiview should be enabled when rendering (Default: false)
  41287. */
  41288. multiviewEnabled: boolean;
  41289. /**
  41290. * Gets the rendering aspect ratio based on the provided resolutions.
  41291. */
  41292. readonly aspectRatio: number;
  41293. /**
  41294. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41295. */
  41296. readonly aspectRatioFov: number;
  41297. /**
  41298. * @hidden
  41299. */
  41300. readonly leftHMatrix: Matrix;
  41301. /**
  41302. * @hidden
  41303. */
  41304. readonly rightHMatrix: Matrix;
  41305. /**
  41306. * @hidden
  41307. */
  41308. readonly leftPreViewMatrix: Matrix;
  41309. /**
  41310. * @hidden
  41311. */
  41312. readonly rightPreViewMatrix: Matrix;
  41313. /**
  41314. * Get the default VRMetrics based on the most generic setup.
  41315. * @returns the default vr metrics
  41316. */
  41317. static GetDefault(): VRCameraMetrics;
  41318. }
  41319. }
  41320. declare module BABYLON {
  41321. /** @hidden */
  41322. export var vrDistortionCorrectionPixelShader: {
  41323. name: string;
  41324. shader: string;
  41325. };
  41326. }
  41327. declare module BABYLON {
  41328. /**
  41329. * VRDistortionCorrectionPostProcess used for mobile VR
  41330. */
  41331. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41332. private _isRightEye;
  41333. private _distortionFactors;
  41334. private _postProcessScaleFactor;
  41335. private _lensCenterOffset;
  41336. private _scaleIn;
  41337. private _scaleFactor;
  41338. private _lensCenter;
  41339. /**
  41340. * Initializes the VRDistortionCorrectionPostProcess
  41341. * @param name The name of the effect.
  41342. * @param camera The camera to apply the render pass to.
  41343. * @param isRightEye If this is for the right eye distortion
  41344. * @param vrMetrics All the required metrics for the VR camera
  41345. */
  41346. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41347. }
  41348. }
  41349. declare module BABYLON {
  41350. /**
  41351. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41352. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41353. */
  41354. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41355. /**
  41356. * Creates a new VRDeviceOrientationArcRotateCamera
  41357. * @param name defines camera name
  41358. * @param alpha defines the camera rotation along the logitudinal axis
  41359. * @param beta defines the camera rotation along the latitudinal axis
  41360. * @param radius defines the camera distance from its target
  41361. * @param target defines the camera target
  41362. * @param scene defines the scene the camera belongs to
  41363. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41364. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41365. */
  41366. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41367. /**
  41368. * Gets camera class name
  41369. * @returns VRDeviceOrientationArcRotateCamera
  41370. */
  41371. getClassName(): string;
  41372. }
  41373. }
  41374. declare module BABYLON {
  41375. /**
  41376. * Camera used to simulate VR rendering (based on FreeCamera)
  41377. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41378. */
  41379. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41380. /**
  41381. * Creates a new VRDeviceOrientationFreeCamera
  41382. * @param name defines camera name
  41383. * @param position defines the start position of the camera
  41384. * @param scene defines the scene the camera belongs to
  41385. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41386. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41387. */
  41388. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41389. /**
  41390. * Gets camera class name
  41391. * @returns VRDeviceOrientationFreeCamera
  41392. */
  41393. getClassName(): string;
  41394. }
  41395. }
  41396. declare module BABYLON {
  41397. /**
  41398. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41399. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41400. */
  41401. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41402. /**
  41403. * Creates a new VRDeviceOrientationGamepadCamera
  41404. * @param name defines camera name
  41405. * @param position defines the start position of the camera
  41406. * @param scene defines the scene the camera belongs to
  41407. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41408. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41409. */
  41410. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41411. /**
  41412. * Gets camera class name
  41413. * @returns VRDeviceOrientationGamepadCamera
  41414. */
  41415. getClassName(): string;
  41416. }
  41417. }
  41418. declare module BABYLON {
  41419. /** @hidden */
  41420. export var imageProcessingPixelShader: {
  41421. name: string;
  41422. shader: string;
  41423. };
  41424. }
  41425. declare module BABYLON {
  41426. /**
  41427. * ImageProcessingPostProcess
  41428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41429. */
  41430. export class ImageProcessingPostProcess extends PostProcess {
  41431. /**
  41432. * Default configuration related to image processing available in the PBR Material.
  41433. */
  41434. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41435. /**
  41436. * Gets the image processing configuration used either in this material.
  41437. */
  41438. /**
  41439. * Sets the Default image processing configuration used either in the this material.
  41440. *
  41441. * If sets to null, the scene one is in use.
  41442. */
  41443. imageProcessingConfiguration: ImageProcessingConfiguration;
  41444. /**
  41445. * Keep track of the image processing observer to allow dispose and replace.
  41446. */
  41447. private _imageProcessingObserver;
  41448. /**
  41449. * Attaches a new image processing configuration to the PBR Material.
  41450. * @param configuration
  41451. */
  41452. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41453. /**
  41454. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41455. */
  41456. /**
  41457. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41458. */
  41459. colorCurves: Nullable<ColorCurves>;
  41460. /**
  41461. * Gets wether the color curves effect is enabled.
  41462. */
  41463. /**
  41464. * Sets wether the color curves effect is enabled.
  41465. */
  41466. colorCurvesEnabled: boolean;
  41467. /**
  41468. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41469. */
  41470. /**
  41471. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41472. */
  41473. colorGradingTexture: Nullable<BaseTexture>;
  41474. /**
  41475. * Gets wether the color grading effect is enabled.
  41476. */
  41477. /**
  41478. * Gets wether the color grading effect is enabled.
  41479. */
  41480. colorGradingEnabled: boolean;
  41481. /**
  41482. * Gets exposure used in the effect.
  41483. */
  41484. /**
  41485. * Sets exposure used in the effect.
  41486. */
  41487. exposure: number;
  41488. /**
  41489. * Gets wether tonemapping is enabled or not.
  41490. */
  41491. /**
  41492. * Sets wether tonemapping is enabled or not
  41493. */
  41494. toneMappingEnabled: boolean;
  41495. /**
  41496. * Gets the type of tone mapping effect.
  41497. */
  41498. /**
  41499. * Sets the type of tone mapping effect.
  41500. */
  41501. toneMappingType: number;
  41502. /**
  41503. * Gets contrast used in the effect.
  41504. */
  41505. /**
  41506. * Sets contrast used in the effect.
  41507. */
  41508. contrast: number;
  41509. /**
  41510. * Gets Vignette stretch size.
  41511. */
  41512. /**
  41513. * Sets Vignette stretch size.
  41514. */
  41515. vignetteStretch: number;
  41516. /**
  41517. * Gets Vignette centre X Offset.
  41518. */
  41519. /**
  41520. * Sets Vignette centre X Offset.
  41521. */
  41522. vignetteCentreX: number;
  41523. /**
  41524. * Gets Vignette centre Y Offset.
  41525. */
  41526. /**
  41527. * Sets Vignette centre Y Offset.
  41528. */
  41529. vignetteCentreY: number;
  41530. /**
  41531. * Gets Vignette weight or intensity of the vignette effect.
  41532. */
  41533. /**
  41534. * Sets Vignette weight or intensity of the vignette effect.
  41535. */
  41536. vignetteWeight: number;
  41537. /**
  41538. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41539. * if vignetteEnabled is set to true.
  41540. */
  41541. /**
  41542. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41543. * if vignetteEnabled is set to true.
  41544. */
  41545. vignetteColor: Color4;
  41546. /**
  41547. * Gets Camera field of view used by the Vignette effect.
  41548. */
  41549. /**
  41550. * Sets Camera field of view used by the Vignette effect.
  41551. */
  41552. vignetteCameraFov: number;
  41553. /**
  41554. * Gets the vignette blend mode allowing different kind of effect.
  41555. */
  41556. /**
  41557. * Sets the vignette blend mode allowing different kind of effect.
  41558. */
  41559. vignetteBlendMode: number;
  41560. /**
  41561. * Gets wether the vignette effect is enabled.
  41562. */
  41563. /**
  41564. * Sets wether the vignette effect is enabled.
  41565. */
  41566. vignetteEnabled: boolean;
  41567. private _fromLinearSpace;
  41568. /**
  41569. * Gets wether the input of the processing is in Gamma or Linear Space.
  41570. */
  41571. /**
  41572. * Sets wether the input of the processing is in Gamma or Linear Space.
  41573. */
  41574. fromLinearSpace: boolean;
  41575. /**
  41576. * Defines cache preventing GC.
  41577. */
  41578. private _defines;
  41579. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41580. /**
  41581. * "ImageProcessingPostProcess"
  41582. * @returns "ImageProcessingPostProcess"
  41583. */
  41584. getClassName(): string;
  41585. protected _updateParameters(): void;
  41586. dispose(camera?: Camera): void;
  41587. }
  41588. }
  41589. declare module BABYLON {
  41590. /**
  41591. * Class containing static functions to help procedurally build meshes
  41592. */
  41593. export class GroundBuilder {
  41594. /**
  41595. * Creates a ground mesh
  41596. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41597. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41599. * @param name defines the name of the mesh
  41600. * @param options defines the options used to create the mesh
  41601. * @param scene defines the hosting scene
  41602. * @returns the ground mesh
  41603. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41604. */
  41605. static CreateGround(name: string, options: {
  41606. width?: number;
  41607. height?: number;
  41608. subdivisions?: number;
  41609. subdivisionsX?: number;
  41610. subdivisionsY?: number;
  41611. updatable?: boolean;
  41612. }, scene: any): Mesh;
  41613. /**
  41614. * Creates a tiled ground mesh
  41615. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41616. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41617. * * 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
  41618. * * 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
  41619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41620. * @param name defines the name of the mesh
  41621. * @param options defines the options used to create the mesh
  41622. * @param scene defines the hosting scene
  41623. * @returns the tiled ground mesh
  41624. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41625. */
  41626. static CreateTiledGround(name: string, options: {
  41627. xmin: number;
  41628. zmin: number;
  41629. xmax: number;
  41630. zmax: number;
  41631. subdivisions?: {
  41632. w: number;
  41633. h: number;
  41634. };
  41635. precision?: {
  41636. w: number;
  41637. h: number;
  41638. };
  41639. updatable?: boolean;
  41640. }, scene?: Nullable<Scene>): Mesh;
  41641. /**
  41642. * Creates a ground mesh from a height map
  41643. * * The parameter `url` sets the URL of the height map image resource.
  41644. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41645. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41646. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41647. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41648. * * 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.
  41649. * * 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).
  41650. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41652. * @param name defines the name of the mesh
  41653. * @param url defines the url to the height map
  41654. * @param options defines the options used to create the mesh
  41655. * @param scene defines the hosting scene
  41656. * @returns the ground mesh
  41657. * @see https://doc.babylonjs.com/babylon101/height_map
  41658. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41659. */
  41660. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41661. width?: number;
  41662. height?: number;
  41663. subdivisions?: number;
  41664. minHeight?: number;
  41665. maxHeight?: number;
  41666. colorFilter?: Color3;
  41667. alphaFilter?: number;
  41668. updatable?: boolean;
  41669. onReady?: (mesh: GroundMesh) => void;
  41670. }, scene?: Nullable<Scene>): GroundMesh;
  41671. }
  41672. }
  41673. declare module BABYLON {
  41674. /**
  41675. * Class containing static functions to help procedurally build meshes
  41676. */
  41677. export class TorusBuilder {
  41678. /**
  41679. * Creates a torus mesh
  41680. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41681. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41682. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41684. * * 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
  41685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41686. * @param name defines the name of the mesh
  41687. * @param options defines the options used to create the mesh
  41688. * @param scene defines the hosting scene
  41689. * @returns the torus mesh
  41690. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41691. */
  41692. static CreateTorus(name: string, options: {
  41693. diameter?: number;
  41694. thickness?: number;
  41695. tessellation?: number;
  41696. updatable?: boolean;
  41697. sideOrientation?: number;
  41698. frontUVs?: Vector4;
  41699. backUVs?: Vector4;
  41700. }, scene: any): Mesh;
  41701. }
  41702. }
  41703. declare module BABYLON {
  41704. /**
  41705. * Class containing static functions to help procedurally build meshes
  41706. */
  41707. export class CylinderBuilder {
  41708. /**
  41709. * Creates a cylinder or a cone mesh
  41710. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41711. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41712. * * 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.
  41713. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41714. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41715. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41716. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41717. * * 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).
  41718. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41719. * * 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).
  41720. * * 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
  41721. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41722. * * 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
  41723. * * 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.
  41724. * * If `enclose` is false, a ring surface is one element.
  41725. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41726. * * 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
  41727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41728. * * 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
  41729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41730. * @param name defines the name of the mesh
  41731. * @param options defines the options used to create the mesh
  41732. * @param scene defines the hosting scene
  41733. * @returns the cylinder mesh
  41734. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41735. */
  41736. static CreateCylinder(name: string, options: {
  41737. height?: number;
  41738. diameterTop?: number;
  41739. diameterBottom?: number;
  41740. diameter?: number;
  41741. tessellation?: number;
  41742. subdivisions?: number;
  41743. arc?: number;
  41744. faceColors?: Color4[];
  41745. faceUV?: Vector4[];
  41746. updatable?: boolean;
  41747. hasRings?: boolean;
  41748. enclose?: boolean;
  41749. cap?: number;
  41750. sideOrientation?: number;
  41751. frontUVs?: Vector4;
  41752. backUVs?: Vector4;
  41753. }, scene: any): Mesh;
  41754. }
  41755. }
  41756. declare module BABYLON {
  41757. /**
  41758. * States of the webXR experience
  41759. */
  41760. export enum WebXRState {
  41761. /**
  41762. * Transitioning to being in XR mode
  41763. */
  41764. ENTERING_XR = 0,
  41765. /**
  41766. * Transitioning to non XR mode
  41767. */
  41768. EXITING_XR = 1,
  41769. /**
  41770. * In XR mode and presenting
  41771. */
  41772. IN_XR = 2,
  41773. /**
  41774. * Not entered XR mode
  41775. */
  41776. NOT_IN_XR = 3
  41777. }
  41778. /**
  41779. * Abstraction of the XR render target
  41780. */
  41781. export interface WebXRRenderTarget extends IDisposable {
  41782. /**
  41783. * xrpresent context of the canvas which can be used to display/mirror xr content
  41784. */
  41785. canvasContext: WebGLRenderingContext;
  41786. /**
  41787. * xr layer for the canvas
  41788. */
  41789. xrLayer: Nullable<XRWebGLLayer>;
  41790. /**
  41791. * Initializes the xr layer for the session
  41792. * @param xrSession xr session
  41793. * @returns a promise that will resolve once the XR Layer has been created
  41794. */
  41795. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41796. }
  41797. }
  41798. declare module BABYLON {
  41799. /**
  41800. * COnfiguration object for WebXR output canvas
  41801. */
  41802. export class WebXRManagedOutputCanvasOptions {
  41803. /**
  41804. * Options for this XR Layer output
  41805. */
  41806. canvasOptions: XRWebGLLayerOptions;
  41807. /**
  41808. * CSS styling for a newly created canvas (if not provided)
  41809. */
  41810. newCanvasCssStyle?: string;
  41811. /**
  41812. * Get the default values of the configuration object
  41813. * @returns default values of this configuration object
  41814. */
  41815. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  41816. }
  41817. /**
  41818. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41819. */
  41820. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41821. private configuration;
  41822. private _engine;
  41823. private _canvas;
  41824. /**
  41825. * xrpresent context of the canvas which can be used to display/mirror xr content
  41826. */
  41827. canvasContext: WebGLRenderingContext;
  41828. /**
  41829. * xr layer for the canvas
  41830. */
  41831. xrLayer: Nullable<XRWebGLLayer>;
  41832. /**
  41833. * Initializes the xr layer for the session
  41834. * @param xrSession xr session
  41835. * @returns a promise that will resolve once the XR Layer has been created
  41836. */
  41837. initializeXRLayerAsync(xrSession: any): any;
  41838. /**
  41839. * Initializes the canvas to be added/removed upon entering/exiting xr
  41840. * @param engine the Babylon engine
  41841. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41842. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41843. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  41844. */
  41845. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  41846. /**
  41847. * Disposes of the object
  41848. */
  41849. dispose(): void;
  41850. private _setManagedOutputCanvas;
  41851. private _addCanvas;
  41852. private _removeCanvas;
  41853. }
  41854. }
  41855. declare module BABYLON {
  41856. /**
  41857. * Manages an XRSession to work with Babylon's engine
  41858. * @see https://doc.babylonjs.com/how_to/webxr
  41859. */
  41860. export class WebXRSessionManager implements IDisposable {
  41861. /** The scene which the session should be created for */
  41862. scene: Scene;
  41863. /**
  41864. * Fires every time a new xrFrame arrives which can be used to update the camera
  41865. */
  41866. onXRFrameObservable: Observable<XRFrame>;
  41867. /**
  41868. * Fires when the xr session is ended either by the device or manually done
  41869. */
  41870. onXRSessionEnded: Observable<any>;
  41871. /**
  41872. * Fires when the xr session is ended either by the device or manually done
  41873. */
  41874. onXRSessionInit: Observable<XRSession>;
  41875. /**
  41876. * Underlying xr session
  41877. */
  41878. session: XRSession;
  41879. /**
  41880. * Type of reference space used when creating the session
  41881. */
  41882. referenceSpace: XRReferenceSpace;
  41883. /**
  41884. * Current XR frame
  41885. */
  41886. currentFrame: Nullable<XRFrame>;
  41887. private _xrNavigator;
  41888. private baseLayer;
  41889. private _rttProvider;
  41890. private _sessionEnded;
  41891. /**
  41892. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41893. * @param scene The scene which the session should be created for
  41894. */
  41895. constructor(
  41896. /** The scene which the session should be created for */
  41897. scene: Scene);
  41898. /**
  41899. * Initializes the manager
  41900. * After initialization enterXR can be called to start an XR session
  41901. * @returns Promise which resolves after it is initialized
  41902. */
  41903. initializeAsync(): Promise<void>;
  41904. /**
  41905. * Initializes an xr session
  41906. * @param xrSessionMode mode to initialize
  41907. * @param optionalFeatures defines optional values to pass to the session builder
  41908. * @returns a promise which will resolve once the session has been initialized
  41909. */
  41910. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  41911. /**
  41912. * Sets the reference space on the xr session
  41913. * @param referenceSpace space to set
  41914. * @returns a promise that will resolve once the reference space has been set
  41915. */
  41916. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41917. /**
  41918. * Updates the render state of the session
  41919. * @param state state to set
  41920. * @returns a promise that resolves once the render state has been updated
  41921. */
  41922. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41923. /**
  41924. * Starts rendering to the xr layer
  41925. * @returns a promise that will resolve once rendering has started
  41926. */
  41927. startRenderingToXRAsync(): Promise<void>;
  41928. /**
  41929. * Gets the correct render target texture to be rendered this frame for this eye
  41930. * @param eye the eye for which to get the render target
  41931. * @returns the render target for the specified eye
  41932. */
  41933. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41934. /**
  41935. * Stops the xrSession and restores the renderloop
  41936. * @returns Promise which resolves after it exits XR
  41937. */
  41938. exitXRAsync(): Promise<void>;
  41939. /**
  41940. * Checks if a session would be supported for the creation options specified
  41941. * @param sessionMode session mode to check if supported eg. immersive-vr
  41942. * @returns true if supported
  41943. */
  41944. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41945. /**
  41946. * Creates a WebXRRenderTarget object for the XR session
  41947. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41948. * @param options optional options to provide when creating a new render target
  41949. * @returns a WebXR render target to which the session can render
  41950. */
  41951. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  41952. /**
  41953. * @hidden
  41954. * Converts the render layer of xrSession to a render target
  41955. * @param session session to create render target for
  41956. * @param scene scene the new render target should be created for
  41957. * @param baseLayer the webgl layer to create the render target for
  41958. */
  41959. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41960. /**
  41961. * Disposes of the session manager
  41962. */
  41963. dispose(): void;
  41964. /**
  41965. * Gets a promise returning true when fullfiled if the given session mode is supported
  41966. * @param sessionMode defines the session to test
  41967. * @returns a promise
  41968. */
  41969. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41970. }
  41971. }
  41972. declare module BABYLON {
  41973. /**
  41974. * WebXR Camera which holds the views for the xrSession
  41975. * @see https://doc.babylonjs.com/how_to/webxr
  41976. */
  41977. export class WebXRCamera extends FreeCamera {
  41978. /**
  41979. * Is the camera in debug mode. Used when using an emulator
  41980. */
  41981. debugMode: boolean;
  41982. /**
  41983. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41984. * @param name the name of the camera
  41985. * @param scene the scene to add the camera to
  41986. */
  41987. constructor(name: string, scene: Scene);
  41988. private _updateNumberOfRigCameras;
  41989. /** @hidden */
  41990. _updateForDualEyeDebugging(): void;
  41991. /**
  41992. * Updates the cameras position from the current pose information of the XR session
  41993. * @param xrSessionManager the session containing pose information
  41994. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41995. */
  41996. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41997. }
  41998. }
  41999. declare module BABYLON {
  42000. /**
  42001. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42002. * @see https://doc.babylonjs.com/how_to/webxr
  42003. */
  42004. export class WebXRExperienceHelper implements IDisposable {
  42005. private scene;
  42006. /**
  42007. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42008. */
  42009. container: AbstractMesh;
  42010. /**
  42011. * Camera used to render xr content
  42012. */
  42013. camera: WebXRCamera;
  42014. /**
  42015. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42016. */
  42017. state: WebXRState;
  42018. private _setState;
  42019. private static _TmpVector;
  42020. /**
  42021. * Fires when the state of the experience helper has changed
  42022. */
  42023. onStateChangedObservable: Observable<WebXRState>;
  42024. /** Session manager used to keep track of xr session */
  42025. sessionManager: WebXRSessionManager;
  42026. private _nonVRCamera;
  42027. private _originalSceneAutoClear;
  42028. private _supported;
  42029. /**
  42030. * Creates the experience helper
  42031. * @param scene the scene to attach the experience helper to
  42032. * @returns a promise for the experience helper
  42033. */
  42034. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42035. /**
  42036. * Creates a WebXRExperienceHelper
  42037. * @param scene The scene the helper should be created in
  42038. */
  42039. private constructor();
  42040. /**
  42041. * Exits XR mode and returns the scene to its original state
  42042. * @returns promise that resolves after xr mode has exited
  42043. */
  42044. exitXRAsync(): Promise<void>;
  42045. /**
  42046. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42047. * @param sessionMode options for the XR session
  42048. * @param referenceSpaceType frame of reference of the XR session
  42049. * @param renderTarget the output canvas that will be used to enter XR mode
  42050. * @returns promise that resolves after xr mode has entered
  42051. */
  42052. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42053. /**
  42054. * Updates the global position of the camera by moving the camera's container
  42055. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42056. * @param position The desired global position of the camera
  42057. */
  42058. setPositionOfCameraUsingContainer(position: Vector3): void;
  42059. /**
  42060. * Rotates the xr camera by rotating the camera's container around the camera's position
  42061. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42062. * @param rotation the desired quaternion rotation to apply to the camera
  42063. */
  42064. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42065. /**
  42066. * Disposes of the experience helper
  42067. */
  42068. dispose(): void;
  42069. }
  42070. }
  42071. declare module BABYLON {
  42072. /**
  42073. * Represents an XR input
  42074. */
  42075. export class WebXRController {
  42076. private scene;
  42077. /** The underlying input source for the controller */
  42078. inputSource: XRInputSource;
  42079. private parentContainer;
  42080. /**
  42081. * 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
  42082. */
  42083. grip?: AbstractMesh;
  42084. /**
  42085. * Pointer which can be used to select objects or attach a visible laser to
  42086. */
  42087. pointer: AbstractMesh;
  42088. private _gamepadMode;
  42089. /**
  42090. * If available, this is the gamepad object related to this controller.
  42091. * Using this object it is possible to get click events and trackpad changes of the
  42092. * webxr controller that is currently being used.
  42093. */
  42094. gamepadController?: WebVRController;
  42095. /**
  42096. * Event that fires when the controller is removed/disposed
  42097. */
  42098. onDisposeObservable: Observable<{}>;
  42099. private _tmpQuaternion;
  42100. private _tmpVector;
  42101. /**
  42102. * Creates the controller
  42103. * @see https://doc.babylonjs.com/how_to/webxr
  42104. * @param scene the scene which the controller should be associated to
  42105. * @param inputSource the underlying input source for the controller
  42106. * @param parentContainer parent that the controller meshes should be children of
  42107. */
  42108. constructor(scene: Scene,
  42109. /** The underlying input source for the controller */
  42110. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42111. /**
  42112. * Updates the controller pose based on the given XRFrame
  42113. * @param xrFrame xr frame to update the pose with
  42114. * @param referenceSpace reference space to use
  42115. */
  42116. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42117. /**
  42118. * Gets a world space ray coming from the controller
  42119. * @param result the resulting ray
  42120. */
  42121. getWorldPointerRayToRef(result: Ray): void;
  42122. /**
  42123. * Get the scene associated with this controller
  42124. * @returns the scene object
  42125. */
  42126. getScene(): Scene;
  42127. /**
  42128. * Disposes of the object
  42129. */
  42130. dispose(): void;
  42131. }
  42132. }
  42133. declare module BABYLON {
  42134. /**
  42135. * XR input used to track XR inputs such as controllers/rays
  42136. */
  42137. export class WebXRInput implements IDisposable {
  42138. /**
  42139. * Base experience the input listens to
  42140. */
  42141. baseExperience: WebXRExperienceHelper;
  42142. /**
  42143. * XR controllers being tracked
  42144. */
  42145. controllers: Array<WebXRController>;
  42146. private _frameObserver;
  42147. private _stateObserver;
  42148. /**
  42149. * Event when a controller has been connected/added
  42150. */
  42151. onControllerAddedObservable: Observable<WebXRController>;
  42152. /**
  42153. * Event when a controller has been removed/disconnected
  42154. */
  42155. onControllerRemovedObservable: Observable<WebXRController>;
  42156. /**
  42157. * Initializes the WebXRInput
  42158. * @param baseExperience experience helper which the input should be created for
  42159. */
  42160. constructor(
  42161. /**
  42162. * Base experience the input listens to
  42163. */
  42164. baseExperience: WebXRExperienceHelper);
  42165. private _onInputSourcesChange;
  42166. private _addAndRemoveControllers;
  42167. /**
  42168. * Disposes of the object
  42169. */
  42170. dispose(): void;
  42171. }
  42172. }
  42173. declare module BABYLON {
  42174. /**
  42175. * Class used to represent data loading progression
  42176. */
  42177. export class SceneLoaderProgressEvent {
  42178. /** defines if data length to load can be evaluated */
  42179. readonly lengthComputable: boolean;
  42180. /** defines the loaded data length */
  42181. readonly loaded: number;
  42182. /** defines the data length to load */
  42183. readonly total: number;
  42184. /**
  42185. * Create a new progress event
  42186. * @param lengthComputable defines if data length to load can be evaluated
  42187. * @param loaded defines the loaded data length
  42188. * @param total defines the data length to load
  42189. */
  42190. constructor(
  42191. /** defines if data length to load can be evaluated */
  42192. lengthComputable: boolean,
  42193. /** defines the loaded data length */
  42194. loaded: number,
  42195. /** defines the data length to load */
  42196. total: number);
  42197. /**
  42198. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42199. * @param event defines the source event
  42200. * @returns a new SceneLoaderProgressEvent
  42201. */
  42202. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42203. }
  42204. /**
  42205. * Interface used by SceneLoader plugins to define supported file extensions
  42206. */
  42207. export interface ISceneLoaderPluginExtensions {
  42208. /**
  42209. * Defines the list of supported extensions
  42210. */
  42211. [extension: string]: {
  42212. isBinary: boolean;
  42213. };
  42214. }
  42215. /**
  42216. * Interface used by SceneLoader plugin factory
  42217. */
  42218. export interface ISceneLoaderPluginFactory {
  42219. /**
  42220. * Defines the name of the factory
  42221. */
  42222. name: string;
  42223. /**
  42224. * Function called to create a new plugin
  42225. * @return the new plugin
  42226. */
  42227. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42228. /**
  42229. * The callback that returns true if the data can be directly loaded.
  42230. * @param data string containing the file data
  42231. * @returns if the data can be loaded directly
  42232. */
  42233. canDirectLoad?(data: string): boolean;
  42234. }
  42235. /**
  42236. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42237. */
  42238. export interface ISceneLoaderPluginBase {
  42239. /**
  42240. * The friendly name of this plugin.
  42241. */
  42242. name: string;
  42243. /**
  42244. * The file extensions supported by this plugin.
  42245. */
  42246. extensions: string | ISceneLoaderPluginExtensions;
  42247. /**
  42248. * The callback called when loading from a url.
  42249. * @param scene scene loading this url
  42250. * @param url url to load
  42251. * @param onSuccess callback called when the file successfully loads
  42252. * @param onProgress callback called while file is loading (if the server supports this mode)
  42253. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42254. * @param onError callback called when the file fails to load
  42255. * @returns a file request object
  42256. */
  42257. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42258. /**
  42259. * The callback called when loading from a file object.
  42260. * @param scene scene loading this file
  42261. * @param file defines the file to load
  42262. * @param onSuccess defines the callback to call when data is loaded
  42263. * @param onProgress defines the callback to call during loading process
  42264. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42265. * @param onError defines the callback to call when an error occurs
  42266. * @returns a file request object
  42267. */
  42268. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42269. /**
  42270. * The callback that returns true if the data can be directly loaded.
  42271. * @param data string containing the file data
  42272. * @returns if the data can be loaded directly
  42273. */
  42274. canDirectLoad?(data: string): boolean;
  42275. /**
  42276. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42277. * @param scene scene loading this data
  42278. * @param data string containing the data
  42279. * @returns data to pass to the plugin
  42280. */
  42281. directLoad?(scene: Scene, data: string): any;
  42282. /**
  42283. * The callback that allows custom handling of the root url based on the response url.
  42284. * @param rootUrl the original root url
  42285. * @param responseURL the response url if available
  42286. * @returns the new root url
  42287. */
  42288. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42289. }
  42290. /**
  42291. * Interface used to define a SceneLoader plugin
  42292. */
  42293. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42294. /**
  42295. * Import meshes into a scene.
  42296. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42297. * @param scene The scene to import into
  42298. * @param data The data to import
  42299. * @param rootUrl The root url for scene and resources
  42300. * @param meshes The meshes array to import into
  42301. * @param particleSystems The particle systems array to import into
  42302. * @param skeletons The skeletons array to import into
  42303. * @param onError The callback when import fails
  42304. * @returns True if successful or false otherwise
  42305. */
  42306. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42307. /**
  42308. * Load into a scene.
  42309. * @param scene The scene to load into
  42310. * @param data The data to import
  42311. * @param rootUrl The root url for scene and resources
  42312. * @param onError The callback when import fails
  42313. * @returns True if successful or false otherwise
  42314. */
  42315. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42316. /**
  42317. * Load into an asset container.
  42318. * @param scene The scene to load into
  42319. * @param data The data to import
  42320. * @param rootUrl The root url for scene and resources
  42321. * @param onError The callback when import fails
  42322. * @returns The loaded asset container
  42323. */
  42324. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42325. }
  42326. /**
  42327. * Interface used to define an async SceneLoader plugin
  42328. */
  42329. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42330. /**
  42331. * Import meshes into a scene.
  42332. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42333. * @param scene The scene to import into
  42334. * @param data The data to import
  42335. * @param rootUrl The root url for scene and resources
  42336. * @param onProgress The callback when the load progresses
  42337. * @param fileName Defines the name of the file to load
  42338. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42339. */
  42340. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42341. meshes: AbstractMesh[];
  42342. particleSystems: IParticleSystem[];
  42343. skeletons: Skeleton[];
  42344. animationGroups: AnimationGroup[];
  42345. }>;
  42346. /**
  42347. * Load into a scene.
  42348. * @param scene The scene to load into
  42349. * @param data The data to import
  42350. * @param rootUrl The root url for scene and resources
  42351. * @param onProgress The callback when the load progresses
  42352. * @param fileName Defines the name of the file to load
  42353. * @returns Nothing
  42354. */
  42355. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42356. /**
  42357. * Load into an asset container.
  42358. * @param scene The scene to load into
  42359. * @param data The data to import
  42360. * @param rootUrl The root url for scene and resources
  42361. * @param onProgress The callback when the load progresses
  42362. * @param fileName Defines the name of the file to load
  42363. * @returns The loaded asset container
  42364. */
  42365. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42366. }
  42367. /**
  42368. * Mode that determines how to handle old animation groups before loading new ones.
  42369. */
  42370. export enum SceneLoaderAnimationGroupLoadingMode {
  42371. /**
  42372. * Reset all old animations to initial state then dispose them.
  42373. */
  42374. Clean = 0,
  42375. /**
  42376. * Stop all old animations.
  42377. */
  42378. Stop = 1,
  42379. /**
  42380. * Restart old animations from first frame.
  42381. */
  42382. Sync = 2,
  42383. /**
  42384. * Old animations remains untouched.
  42385. */
  42386. NoSync = 3
  42387. }
  42388. /**
  42389. * Class used to load scene from various file formats using registered plugins
  42390. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42391. */
  42392. export class SceneLoader {
  42393. /**
  42394. * No logging while loading
  42395. */
  42396. static readonly NO_LOGGING: number;
  42397. /**
  42398. * Minimal logging while loading
  42399. */
  42400. static readonly MINIMAL_LOGGING: number;
  42401. /**
  42402. * Summary logging while loading
  42403. */
  42404. static readonly SUMMARY_LOGGING: number;
  42405. /**
  42406. * Detailled logging while loading
  42407. */
  42408. static readonly DETAILED_LOGGING: number;
  42409. /**
  42410. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42411. */
  42412. static ForceFullSceneLoadingForIncremental: boolean;
  42413. /**
  42414. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42415. */
  42416. static ShowLoadingScreen: boolean;
  42417. /**
  42418. * Defines the current logging level (while loading the scene)
  42419. * @ignorenaming
  42420. */
  42421. static loggingLevel: number;
  42422. /**
  42423. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42424. */
  42425. static CleanBoneMatrixWeights: boolean;
  42426. /**
  42427. * Event raised when a plugin is used to load a scene
  42428. */
  42429. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42430. private static _registeredPlugins;
  42431. private static _getDefaultPlugin;
  42432. private static _getPluginForExtension;
  42433. private static _getPluginForDirectLoad;
  42434. private static _getPluginForFilename;
  42435. private static _getDirectLoad;
  42436. private static _loadData;
  42437. private static _getFileInfo;
  42438. /**
  42439. * Gets a plugin that can load the given extension
  42440. * @param extension defines the extension to load
  42441. * @returns a plugin or null if none works
  42442. */
  42443. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42444. /**
  42445. * Gets a boolean indicating that the given extension can be loaded
  42446. * @param extension defines the extension to load
  42447. * @returns true if the extension is supported
  42448. */
  42449. static IsPluginForExtensionAvailable(extension: string): boolean;
  42450. /**
  42451. * Adds a new plugin to the list of registered plugins
  42452. * @param plugin defines the plugin to add
  42453. */
  42454. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42455. /**
  42456. * Import meshes into a scene
  42457. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42458. * @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)
  42459. * @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)
  42460. * @param scene the instance of BABYLON.Scene to append to
  42461. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42462. * @param onProgress a callback with a progress event for each file being loaded
  42463. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42464. * @param pluginExtension the extension used to determine the plugin
  42465. * @returns The loaded plugin
  42466. */
  42467. 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>;
  42468. /**
  42469. * Import meshes into a scene
  42470. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42471. * @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)
  42472. * @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)
  42473. * @param scene the instance of BABYLON.Scene to append to
  42474. * @param onProgress a callback with a progress event for each file being loaded
  42475. * @param pluginExtension the extension used to determine the plugin
  42476. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42477. */
  42478. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42479. meshes: AbstractMesh[];
  42480. particleSystems: IParticleSystem[];
  42481. skeletons: Skeleton[];
  42482. animationGroups: AnimationGroup[];
  42483. }>;
  42484. /**
  42485. * Load a scene
  42486. * @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)
  42487. * @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)
  42488. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42489. * @param onSuccess a callback with the scene when import succeeds
  42490. * @param onProgress a callback with a progress event for each file being loaded
  42491. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42492. * @param pluginExtension the extension used to determine the plugin
  42493. * @returns The loaded plugin
  42494. */
  42495. 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>;
  42496. /**
  42497. * Load a scene
  42498. * @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)
  42499. * @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)
  42500. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42501. * @param onProgress a callback with a progress event for each file being loaded
  42502. * @param pluginExtension the extension used to determine the plugin
  42503. * @returns The loaded scene
  42504. */
  42505. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42506. /**
  42507. * Append a scene
  42508. * @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)
  42509. * @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)
  42510. * @param scene is the instance of BABYLON.Scene to append to
  42511. * @param onSuccess a callback with the scene when import succeeds
  42512. * @param onProgress a callback with a progress event for each file being loaded
  42513. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42514. * @param pluginExtension the extension used to determine the plugin
  42515. * @returns The loaded plugin
  42516. */
  42517. 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>;
  42518. /**
  42519. * Append a scene
  42520. * @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)
  42521. * @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)
  42522. * @param scene is the instance of BABYLON.Scene to append to
  42523. * @param onProgress a callback with a progress event for each file being loaded
  42524. * @param pluginExtension the extension used to determine the plugin
  42525. * @returns The given scene
  42526. */
  42527. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42528. /**
  42529. * Load a scene into an asset container
  42530. * @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)
  42531. * @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)
  42532. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42533. * @param onSuccess a callback with the scene when import succeeds
  42534. * @param onProgress a callback with a progress event for each file being loaded
  42535. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42536. * @param pluginExtension the extension used to determine the plugin
  42537. * @returns The loaded plugin
  42538. */
  42539. 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>;
  42540. /**
  42541. * Load a scene into an asset container
  42542. * @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)
  42543. * @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)
  42544. * @param scene is the instance of Scene to append to
  42545. * @param onProgress a callback with a progress event for each file being loaded
  42546. * @param pluginExtension the extension used to determine the plugin
  42547. * @returns The loaded asset container
  42548. */
  42549. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42550. /**
  42551. * Import animations from a file into a scene
  42552. * @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)
  42553. * @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)
  42554. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42555. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  42556. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  42557. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  42558. * @param onSuccess a callback with the scene when import succeeds
  42559. * @param onProgress a callback with a progress event for each file being loaded
  42560. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42561. */
  42562. 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;
  42563. /**
  42564. * Import animations from a file into a scene
  42565. * @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)
  42566. * @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)
  42567. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42568. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  42569. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  42570. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  42571. * @param onSuccess a callback with the scene when import succeeds
  42572. * @param onProgress a callback with a progress event for each file being loaded
  42573. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42574. * @returns the updated scene with imported animations
  42575. */
  42576. 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>;
  42577. }
  42578. }
  42579. declare module BABYLON {
  42580. /**
  42581. * Generic Controller
  42582. */
  42583. export class GenericController extends WebVRController {
  42584. /**
  42585. * Base Url for the controller model.
  42586. */
  42587. static readonly MODEL_BASE_URL: string;
  42588. /**
  42589. * File name for the controller model.
  42590. */
  42591. static readonly MODEL_FILENAME: string;
  42592. /**
  42593. * Creates a new GenericController from a gamepad
  42594. * @param vrGamepad the gamepad that the controller should be created from
  42595. */
  42596. constructor(vrGamepad: any);
  42597. /**
  42598. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42599. * @param scene scene in which to add meshes
  42600. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42601. */
  42602. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42603. /**
  42604. * Called once for each button that changed state since the last frame
  42605. * @param buttonIdx Which button index changed
  42606. * @param state New state of the button
  42607. * @param changes Which properties on the state changed since last frame
  42608. */
  42609. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42610. }
  42611. }
  42612. declare module BABYLON {
  42613. /**
  42614. * Defines the WindowsMotionController object that the state of the windows motion controller
  42615. */
  42616. export class WindowsMotionController extends WebVRController {
  42617. /**
  42618. * The base url used to load the left and right controller models
  42619. */
  42620. static MODEL_BASE_URL: string;
  42621. /**
  42622. * The name of the left controller model file
  42623. */
  42624. static MODEL_LEFT_FILENAME: string;
  42625. /**
  42626. * The name of the right controller model file
  42627. */
  42628. static MODEL_RIGHT_FILENAME: string;
  42629. /**
  42630. * The controller name prefix for this controller type
  42631. */
  42632. static readonly GAMEPAD_ID_PREFIX: string;
  42633. /**
  42634. * The controller id pattern for this controller type
  42635. */
  42636. private static readonly GAMEPAD_ID_PATTERN;
  42637. private _loadedMeshInfo;
  42638. protected readonly _mapping: {
  42639. buttons: string[];
  42640. buttonMeshNames: {
  42641. 'trigger': string;
  42642. 'menu': string;
  42643. 'grip': string;
  42644. 'thumbstick': string;
  42645. 'trackpad': string;
  42646. };
  42647. buttonObservableNames: {
  42648. 'trigger': string;
  42649. 'menu': string;
  42650. 'grip': string;
  42651. 'thumbstick': string;
  42652. 'trackpad': string;
  42653. };
  42654. axisMeshNames: string[];
  42655. pointingPoseMeshName: string;
  42656. };
  42657. /**
  42658. * Fired when the trackpad on this controller is clicked
  42659. */
  42660. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42661. /**
  42662. * Fired when the trackpad on this controller is modified
  42663. */
  42664. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42665. /**
  42666. * The current x and y values of this controller's trackpad
  42667. */
  42668. trackpad: StickValues;
  42669. /**
  42670. * Creates a new WindowsMotionController from a gamepad
  42671. * @param vrGamepad the gamepad that the controller should be created from
  42672. */
  42673. constructor(vrGamepad: any);
  42674. /**
  42675. * Fired when the trigger on this controller is modified
  42676. */
  42677. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42678. /**
  42679. * Fired when the menu button on this controller is modified
  42680. */
  42681. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42682. /**
  42683. * Fired when the grip button on this controller is modified
  42684. */
  42685. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42686. /**
  42687. * Fired when the thumbstick button on this controller is modified
  42688. */
  42689. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42690. /**
  42691. * Fired when the touchpad button on this controller is modified
  42692. */
  42693. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42694. /**
  42695. * Fired when the touchpad values on this controller are modified
  42696. */
  42697. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42698. protected _updateTrackpad(): void;
  42699. /**
  42700. * Called once per frame by the engine.
  42701. */
  42702. update(): void;
  42703. /**
  42704. * Called once for each button that changed state since the last frame
  42705. * @param buttonIdx Which button index changed
  42706. * @param state New state of the button
  42707. * @param changes Which properties on the state changed since last frame
  42708. */
  42709. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42710. /**
  42711. * Moves the buttons on the controller mesh based on their current state
  42712. * @param buttonName the name of the button to move
  42713. * @param buttonValue the value of the button which determines the buttons new position
  42714. */
  42715. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42716. /**
  42717. * Moves the axis on the controller mesh based on its current state
  42718. * @param axis the index of the axis
  42719. * @param axisValue the value of the axis which determines the meshes new position
  42720. * @hidden
  42721. */
  42722. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42723. /**
  42724. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42725. * @param scene scene in which to add meshes
  42726. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42727. */
  42728. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42729. /**
  42730. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42731. * can be transformed by button presses and axes values, based on this._mapping.
  42732. *
  42733. * @param scene scene in which the meshes exist
  42734. * @param meshes list of meshes that make up the controller model to process
  42735. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42736. */
  42737. private processModel;
  42738. private createMeshInfo;
  42739. /**
  42740. * Gets the ray of the controller in the direction the controller is pointing
  42741. * @param length the length the resulting ray should be
  42742. * @returns a ray in the direction the controller is pointing
  42743. */
  42744. getForwardRay(length?: number): Ray;
  42745. /**
  42746. * Disposes of the controller
  42747. */
  42748. dispose(): void;
  42749. }
  42750. /**
  42751. * This class represents a new windows motion controller in XR.
  42752. */
  42753. export class XRWindowsMotionController extends WindowsMotionController {
  42754. /**
  42755. * Changing the original WIndowsMotionController mapping to fir the new mapping
  42756. */
  42757. protected readonly _mapping: {
  42758. buttons: string[];
  42759. buttonMeshNames: {
  42760. 'trigger': string;
  42761. 'menu': string;
  42762. 'grip': string;
  42763. 'thumbstick': string;
  42764. 'trackpad': string;
  42765. };
  42766. buttonObservableNames: {
  42767. 'trigger': string;
  42768. 'menu': string;
  42769. 'grip': string;
  42770. 'thumbstick': string;
  42771. 'trackpad': string;
  42772. };
  42773. axisMeshNames: string[];
  42774. pointingPoseMeshName: string;
  42775. };
  42776. /**
  42777. * Construct a new XR-Based windows motion controller
  42778. *
  42779. * @param gamepadInfo the gamepad object from the browser
  42780. */
  42781. constructor(gamepadInfo: any);
  42782. /**
  42783. * holds the thumbstick values (X,Y)
  42784. */
  42785. thumbstickValues: StickValues;
  42786. /**
  42787. * Fired when the thumbstick on this controller is clicked
  42788. */
  42789. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  42790. /**
  42791. * Fired when the thumbstick on this controller is modified
  42792. */
  42793. onThumbstickValuesChangedObservable: Observable<StickValues>;
  42794. /**
  42795. * Fired when the touchpad button on this controller is modified
  42796. */
  42797. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42798. /**
  42799. * Fired when the touchpad values on this controller are modified
  42800. */
  42801. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42802. /**
  42803. * Fired when the thumbstick button on this controller is modified
  42804. * here to prevent breaking changes
  42805. */
  42806. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42807. /**
  42808. * updating the thumbstick(!) and not the trackpad.
  42809. * This is named this way due to the difference between WebVR and XR and to avoid
  42810. * changing the parent class.
  42811. */
  42812. protected _updateTrackpad(): void;
  42813. /**
  42814. * Disposes the class with joy
  42815. */
  42816. dispose(): void;
  42817. }
  42818. }
  42819. declare module BABYLON {
  42820. /**
  42821. * Oculus Touch Controller
  42822. */
  42823. export class OculusTouchController extends WebVRController {
  42824. /**
  42825. * Base Url for the controller model.
  42826. */
  42827. static MODEL_BASE_URL: string;
  42828. /**
  42829. * File name for the left controller model.
  42830. */
  42831. static MODEL_LEFT_FILENAME: string;
  42832. /**
  42833. * File name for the right controller model.
  42834. */
  42835. static MODEL_RIGHT_FILENAME: string;
  42836. /**
  42837. * Base Url for the Quest controller model.
  42838. */
  42839. static QUEST_MODEL_BASE_URL: string;
  42840. /**
  42841. * @hidden
  42842. * If the controllers are running on a device that needs the updated Quest controller models
  42843. */
  42844. static _IsQuest: boolean;
  42845. /**
  42846. * Fired when the secondary trigger on this controller is modified
  42847. */
  42848. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42849. /**
  42850. * Fired when the thumb rest on this controller is modified
  42851. */
  42852. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42853. /**
  42854. * Creates a new OculusTouchController from a gamepad
  42855. * @param vrGamepad the gamepad that the controller should be created from
  42856. */
  42857. constructor(vrGamepad: any);
  42858. /**
  42859. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42860. * @param scene scene in which to add meshes
  42861. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42862. */
  42863. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42864. /**
  42865. * Fired when the A button on this controller is modified
  42866. */
  42867. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42868. /**
  42869. * Fired when the B button on this controller is modified
  42870. */
  42871. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42872. /**
  42873. * Fired when the X button on this controller is modified
  42874. */
  42875. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42876. /**
  42877. * Fired when the Y button on this controller is modified
  42878. */
  42879. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42880. /**
  42881. * Called once for each button that changed state since the last frame
  42882. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42883. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42884. * 2) secondary trigger (same)
  42885. * 3) A (right) X (left), touch, pressed = value
  42886. * 4) B / Y
  42887. * 5) thumb rest
  42888. * @param buttonIdx Which button index changed
  42889. * @param state New state of the button
  42890. * @param changes Which properties on the state changed since last frame
  42891. */
  42892. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42893. }
  42894. }
  42895. declare module BABYLON {
  42896. /**
  42897. * Vive Controller
  42898. */
  42899. export class ViveController extends WebVRController {
  42900. /**
  42901. * Base Url for the controller model.
  42902. */
  42903. static MODEL_BASE_URL: string;
  42904. /**
  42905. * File name for the controller model.
  42906. */
  42907. static MODEL_FILENAME: string;
  42908. /**
  42909. * Creates a new ViveController from a gamepad
  42910. * @param vrGamepad the gamepad that the controller should be created from
  42911. */
  42912. constructor(vrGamepad: any);
  42913. /**
  42914. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42915. * @param scene scene in which to add meshes
  42916. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42917. */
  42918. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42919. /**
  42920. * Fired when the left button on this controller is modified
  42921. */
  42922. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42923. /**
  42924. * Fired when the right button on this controller is modified
  42925. */
  42926. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42927. /**
  42928. * Fired when the menu button on this controller is modified
  42929. */
  42930. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42931. /**
  42932. * Called once for each button that changed state since the last frame
  42933. * Vive mapping:
  42934. * 0: touchpad
  42935. * 1: trigger
  42936. * 2: left AND right buttons
  42937. * 3: menu button
  42938. * @param buttonIdx Which button index changed
  42939. * @param state New state of the button
  42940. * @param changes Which properties on the state changed since last frame
  42941. */
  42942. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42943. }
  42944. }
  42945. declare module BABYLON {
  42946. /**
  42947. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42948. */
  42949. export class WebXRControllerModelLoader {
  42950. /**
  42951. * an observable that triggers when a new model (the mesh itself) was initialized.
  42952. * To know when the mesh was loaded use the controller's own modelLoaded() method
  42953. */
  42954. onControllerModelLoaded: Observable<WebXRController>;
  42955. /**
  42956. * Creates the WebXRControllerModelLoader
  42957. * @param input xr input that creates the controllers
  42958. */
  42959. constructor(input: WebXRInput);
  42960. }
  42961. }
  42962. declare module BABYLON {
  42963. /**
  42964. * Handles pointer input automatically for the pointer of XR controllers
  42965. */
  42966. export class WebXRControllerPointerSelection {
  42967. private static _idCounter;
  42968. private _tmpRay;
  42969. /**
  42970. * Creates a WebXRControllerPointerSelection
  42971. * @param input input manager to setup pointer selection
  42972. */
  42973. constructor(input: WebXRInput);
  42974. private _convertNormalToDirectionOfRay;
  42975. private _updatePointerDistance;
  42976. }
  42977. }
  42978. declare module BABYLON {
  42979. /**
  42980. * Enables teleportation
  42981. */
  42982. export class WebXRControllerTeleportation {
  42983. private _teleportationFillColor;
  42984. private _teleportationBorderColor;
  42985. private _tmpRay;
  42986. private _tmpVector;
  42987. /**
  42988. * when set to true (default) teleportation will wait for thumbstick changes.
  42989. * When set to false teleportation will be disabled.
  42990. *
  42991. * If set to false while teleporting results can be unexpected.
  42992. */
  42993. enabled: boolean;
  42994. /**
  42995. * Creates a WebXRControllerTeleportation
  42996. * @param input input manager to add teleportation to
  42997. * @param floorMeshes floormeshes which can be teleported to
  42998. */
  42999. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43000. }
  43001. }
  43002. declare module BABYLON {
  43003. /**
  43004. * Button which can be used to enter a different mode of XR
  43005. */
  43006. export class WebXREnterExitUIButton {
  43007. /** button element */
  43008. element: HTMLElement;
  43009. /** XR initialization options for the button */
  43010. sessionMode: XRSessionMode;
  43011. /** Reference space type */
  43012. referenceSpaceType: XRReferenceSpaceType;
  43013. /**
  43014. * Creates a WebXREnterExitUIButton
  43015. * @param element button element
  43016. * @param sessionMode XR initialization session mode
  43017. * @param referenceSpaceType the type of reference space to be used
  43018. */
  43019. constructor(
  43020. /** button element */
  43021. element: HTMLElement,
  43022. /** XR initialization options for the button */
  43023. sessionMode: XRSessionMode,
  43024. /** Reference space type */
  43025. referenceSpaceType: XRReferenceSpaceType);
  43026. /**
  43027. * Overwritable function which can be used to update the button's visuals when the state changes
  43028. * @param activeButton the current active button in the UI
  43029. */
  43030. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43031. }
  43032. /**
  43033. * Options to create the webXR UI
  43034. */
  43035. export class WebXREnterExitUIOptions {
  43036. /**
  43037. * Context to enter xr with
  43038. */
  43039. renderTarget?: Nullable<WebXRRenderTarget>;
  43040. /**
  43041. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43042. */
  43043. customButtons?: Array<WebXREnterExitUIButton>;
  43044. /**
  43045. * A session mode to use when creating the default button.
  43046. * Default is immersive-vr
  43047. */
  43048. sessionMode?: XRSessionMode;
  43049. /**
  43050. * A reference space type to use when creating the default button.
  43051. * Default is local-floor
  43052. */
  43053. referenceSpaceType?: XRReferenceSpaceType;
  43054. }
  43055. /**
  43056. * UI to allow the user to enter/exit XR mode
  43057. */
  43058. export class WebXREnterExitUI implements IDisposable {
  43059. private scene;
  43060. /** version of the options passed to this UI */
  43061. options: WebXREnterExitUIOptions;
  43062. private _overlay;
  43063. private _buttons;
  43064. private _activeButton;
  43065. /**
  43066. * Fired every time the active button is changed.
  43067. *
  43068. * When xr is entered via a button that launches xr that button will be the callback parameter
  43069. *
  43070. * When exiting xr the callback parameter will be null)
  43071. */
  43072. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43073. /**
  43074. * Creates UI to allow the user to enter/exit XR mode
  43075. * @param scene the scene to add the ui to
  43076. * @param helper the xr experience helper to enter/exit xr with
  43077. * @param options options to configure the UI
  43078. * @returns the created ui
  43079. */
  43080. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43081. /**
  43082. *
  43083. * @param scene babylon scene object to use
  43084. * @param options (read-only) version of the options passed to this UI
  43085. */
  43086. private constructor();
  43087. private _updateButtons;
  43088. /**
  43089. * Disposes of the object
  43090. */
  43091. dispose(): void;
  43092. }
  43093. }
  43094. declare module BABYLON {
  43095. /**
  43096. * Options for the default xr helper
  43097. */
  43098. export class WebXRDefaultExperienceOptions {
  43099. /**
  43100. * Floor meshes that should be used for teleporting
  43101. */
  43102. floorMeshes: Array<AbstractMesh>;
  43103. /**
  43104. * Enable or disable default UI to enter XR
  43105. */
  43106. disableDefaultUI?: boolean;
  43107. /**
  43108. * optional configuration for the output canvas
  43109. */
  43110. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43111. /**
  43112. * optional UI options. This can be used among other to change session mode and reference space type
  43113. */
  43114. uiOptions?: WebXREnterExitUIOptions;
  43115. }
  43116. /**
  43117. * Default experience which provides a similar setup to the previous webVRExperience
  43118. */
  43119. export class WebXRDefaultExperience {
  43120. /**
  43121. * Base experience
  43122. */
  43123. baseExperience: WebXRExperienceHelper;
  43124. /**
  43125. * Input experience extension
  43126. */
  43127. input: WebXRInput;
  43128. /**
  43129. * Loads the controller models
  43130. */
  43131. controllerModelLoader: WebXRControllerModelLoader;
  43132. /**
  43133. * Enables laser pointer and selection
  43134. */
  43135. pointerSelection: WebXRControllerPointerSelection;
  43136. /**
  43137. * Enables teleportation
  43138. */
  43139. teleportation: WebXRControllerTeleportation;
  43140. /**
  43141. * Enables ui for entering/exiting xr
  43142. */
  43143. enterExitUI: WebXREnterExitUI;
  43144. /**
  43145. * Default target xr should render to
  43146. */
  43147. renderTarget: WebXRRenderTarget;
  43148. /**
  43149. * Creates the default xr experience
  43150. * @param scene scene
  43151. * @param options options for basic configuration
  43152. * @returns resulting WebXRDefaultExperience
  43153. */
  43154. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43155. private constructor();
  43156. /**
  43157. * DIsposes of the experience helper
  43158. */
  43159. dispose(): void;
  43160. }
  43161. }
  43162. declare module BABYLON {
  43163. /**
  43164. * Options to modify the vr teleportation behavior.
  43165. */
  43166. export interface VRTeleportationOptions {
  43167. /**
  43168. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43169. */
  43170. floorMeshName?: string;
  43171. /**
  43172. * A list of meshes to be used as the teleportation floor. (default: empty)
  43173. */
  43174. floorMeshes?: Mesh[];
  43175. /**
  43176. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43177. */
  43178. teleportationMode?: number;
  43179. /**
  43180. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43181. */
  43182. teleportationTime?: number;
  43183. /**
  43184. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43185. */
  43186. teleportationSpeed?: number;
  43187. /**
  43188. * The easing function used in the animation or null for Linear. (default CircleEase)
  43189. */
  43190. easingFunction?: EasingFunction;
  43191. }
  43192. /**
  43193. * Options to modify the vr experience helper's behavior.
  43194. */
  43195. export interface VRExperienceHelperOptions extends WebVROptions {
  43196. /**
  43197. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43198. */
  43199. createDeviceOrientationCamera?: boolean;
  43200. /**
  43201. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43202. */
  43203. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43204. /**
  43205. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43206. */
  43207. laserToggle?: boolean;
  43208. /**
  43209. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43210. */
  43211. floorMeshes?: Mesh[];
  43212. /**
  43213. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43214. */
  43215. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43216. /**
  43217. * Defines if WebXR should be used instead of WebVR (if available)
  43218. */
  43219. useXR?: boolean;
  43220. }
  43221. /**
  43222. * Event containing information after VR has been entered
  43223. */
  43224. export class OnAfterEnteringVRObservableEvent {
  43225. /**
  43226. * If entering vr was successful
  43227. */
  43228. success: boolean;
  43229. }
  43230. /**
  43231. * Helps to quickly add VR support to an existing scene.
  43232. * See http://doc.babylonjs.com/how_to/webvr_helper
  43233. */
  43234. export class VRExperienceHelper {
  43235. /** Options to modify the vr experience helper's behavior. */
  43236. webVROptions: VRExperienceHelperOptions;
  43237. private _scene;
  43238. private _position;
  43239. private _btnVR;
  43240. private _btnVRDisplayed;
  43241. private _webVRsupported;
  43242. private _webVRready;
  43243. private _webVRrequesting;
  43244. private _webVRpresenting;
  43245. private _hasEnteredVR;
  43246. private _fullscreenVRpresenting;
  43247. private _inputElement;
  43248. private _webVRCamera;
  43249. private _vrDeviceOrientationCamera;
  43250. private _deviceOrientationCamera;
  43251. private _existingCamera;
  43252. private _onKeyDown;
  43253. private _onVrDisplayPresentChange;
  43254. private _onVRDisplayChanged;
  43255. private _onVRRequestPresentStart;
  43256. private _onVRRequestPresentComplete;
  43257. /**
  43258. * 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)
  43259. */
  43260. enableGazeEvenWhenNoPointerLock: boolean;
  43261. /**
  43262. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43263. */
  43264. exitVROnDoubleTap: boolean;
  43265. /**
  43266. * Observable raised right before entering VR.
  43267. */
  43268. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43269. /**
  43270. * Observable raised when entering VR has completed.
  43271. */
  43272. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43273. /**
  43274. * Observable raised when exiting VR.
  43275. */
  43276. onExitingVRObservable: Observable<VRExperienceHelper>;
  43277. /**
  43278. * Observable raised when controller mesh is loaded.
  43279. */
  43280. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43281. /** Return this.onEnteringVRObservable
  43282. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43283. */
  43284. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43285. /** Return this.onExitingVRObservable
  43286. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43287. */
  43288. readonly onExitingVR: Observable<VRExperienceHelper>;
  43289. /** Return this.onControllerMeshLoadedObservable
  43290. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43291. */
  43292. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43293. private _rayLength;
  43294. private _useCustomVRButton;
  43295. private _teleportationRequested;
  43296. private _teleportActive;
  43297. private _floorMeshName;
  43298. private _floorMeshesCollection;
  43299. private _teleportationMode;
  43300. private _teleportationTime;
  43301. private _teleportationSpeed;
  43302. private _teleportationEasing;
  43303. private _rotationAllowed;
  43304. private _teleportBackwardsVector;
  43305. private _teleportationTarget;
  43306. private _isDefaultTeleportationTarget;
  43307. private _postProcessMove;
  43308. private _teleportationFillColor;
  43309. private _teleportationBorderColor;
  43310. private _rotationAngle;
  43311. private _haloCenter;
  43312. private _cameraGazer;
  43313. private _padSensibilityUp;
  43314. private _padSensibilityDown;
  43315. private _leftController;
  43316. private _rightController;
  43317. /**
  43318. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43319. */
  43320. onNewMeshSelected: Observable<AbstractMesh>;
  43321. /**
  43322. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43323. * This observable will provide the mesh and the controller used to select the mesh
  43324. */
  43325. onMeshSelectedWithController: Observable<{
  43326. mesh: AbstractMesh;
  43327. controller: WebVRController;
  43328. }>;
  43329. /**
  43330. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43331. */
  43332. onNewMeshPicked: Observable<PickingInfo>;
  43333. private _circleEase;
  43334. /**
  43335. * Observable raised before camera teleportation
  43336. */
  43337. onBeforeCameraTeleport: Observable<Vector3>;
  43338. /**
  43339. * Observable raised after camera teleportation
  43340. */
  43341. onAfterCameraTeleport: Observable<Vector3>;
  43342. /**
  43343. * Observable raised when current selected mesh gets unselected
  43344. */
  43345. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43346. private _raySelectionPredicate;
  43347. /**
  43348. * To be optionaly changed by user to define custom ray selection
  43349. */
  43350. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43351. /**
  43352. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43353. */
  43354. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43355. /**
  43356. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43357. */
  43358. teleportationEnabled: boolean;
  43359. private _defaultHeight;
  43360. private _teleportationInitialized;
  43361. private _interactionsEnabled;
  43362. private _interactionsRequested;
  43363. private _displayGaze;
  43364. private _displayLaserPointer;
  43365. /**
  43366. * The mesh used to display where the user is going to teleport.
  43367. */
  43368. /**
  43369. * Sets the mesh to be used to display where the user is going to teleport.
  43370. */
  43371. teleportationTarget: Mesh;
  43372. /**
  43373. * 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
  43374. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43375. * See http://doc.babylonjs.com/resources/baking_transformations
  43376. */
  43377. gazeTrackerMesh: Mesh;
  43378. /**
  43379. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43380. */
  43381. updateGazeTrackerScale: boolean;
  43382. /**
  43383. * If the gaze trackers color should be updated when selecting meshes
  43384. */
  43385. updateGazeTrackerColor: boolean;
  43386. /**
  43387. * If the controller laser color should be updated when selecting meshes
  43388. */
  43389. updateControllerLaserColor: boolean;
  43390. /**
  43391. * The gaze tracking mesh corresponding to the left controller
  43392. */
  43393. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43394. /**
  43395. * The gaze tracking mesh corresponding to the right controller
  43396. */
  43397. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43398. /**
  43399. * If the ray of the gaze should be displayed.
  43400. */
  43401. /**
  43402. * Sets if the ray of the gaze should be displayed.
  43403. */
  43404. displayGaze: boolean;
  43405. /**
  43406. * If the ray of the LaserPointer should be displayed.
  43407. */
  43408. /**
  43409. * Sets if the ray of the LaserPointer should be displayed.
  43410. */
  43411. displayLaserPointer: boolean;
  43412. /**
  43413. * The deviceOrientationCamera used as the camera when not in VR.
  43414. */
  43415. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43416. /**
  43417. * Based on the current WebVR support, returns the current VR camera used.
  43418. */
  43419. readonly currentVRCamera: Nullable<Camera>;
  43420. /**
  43421. * The webVRCamera which is used when in VR.
  43422. */
  43423. readonly webVRCamera: WebVRFreeCamera;
  43424. /**
  43425. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43426. */
  43427. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43428. /**
  43429. * The html button that is used to trigger entering into VR.
  43430. */
  43431. readonly vrButton: Nullable<HTMLButtonElement>;
  43432. private readonly _teleportationRequestInitiated;
  43433. /**
  43434. * Defines wether or not Pointer lock should be requested when switching to
  43435. * full screen.
  43436. */
  43437. requestPointerLockOnFullScreen: boolean;
  43438. /**
  43439. * If asking to force XR, this will be populated with the default xr experience
  43440. */
  43441. xr: WebXRDefaultExperience;
  43442. /**
  43443. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  43444. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  43445. */
  43446. xrTestDone: boolean;
  43447. /**
  43448. * Instantiates a VRExperienceHelper.
  43449. * Helps to quickly add VR support to an existing scene.
  43450. * @param scene The scene the VRExperienceHelper belongs to.
  43451. * @param webVROptions Options to modify the vr experience helper's behavior.
  43452. */
  43453. constructor(scene: Scene,
  43454. /** Options to modify the vr experience helper's behavior. */
  43455. webVROptions?: VRExperienceHelperOptions);
  43456. private completeVRInit;
  43457. private _onDefaultMeshLoaded;
  43458. private _onResize;
  43459. private _onFullscreenChange;
  43460. /**
  43461. * Gets a value indicating if we are currently in VR mode.
  43462. */
  43463. readonly isInVRMode: boolean;
  43464. private onVrDisplayPresentChange;
  43465. private onVRDisplayChanged;
  43466. private moveButtonToBottomRight;
  43467. private displayVRButton;
  43468. private updateButtonVisibility;
  43469. private _cachedAngularSensibility;
  43470. /**
  43471. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43472. * Otherwise, will use the fullscreen API.
  43473. */
  43474. enterVR(): void;
  43475. /**
  43476. * Attempt to exit VR, or fullscreen.
  43477. */
  43478. exitVR(): void;
  43479. /**
  43480. * The position of the vr experience helper.
  43481. */
  43482. /**
  43483. * Sets the position of the vr experience helper.
  43484. */
  43485. position: Vector3;
  43486. /**
  43487. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43488. */
  43489. enableInteractions(): void;
  43490. private readonly _noControllerIsActive;
  43491. private beforeRender;
  43492. private _isTeleportationFloor;
  43493. /**
  43494. * Adds a floor mesh to be used for teleportation.
  43495. * @param floorMesh the mesh to be used for teleportation.
  43496. */
  43497. addFloorMesh(floorMesh: Mesh): void;
  43498. /**
  43499. * Removes a floor mesh from being used for teleportation.
  43500. * @param floorMesh the mesh to be removed.
  43501. */
  43502. removeFloorMesh(floorMesh: Mesh): void;
  43503. /**
  43504. * Enables interactions and teleportation using the VR controllers and gaze.
  43505. * @param vrTeleportationOptions options to modify teleportation behavior.
  43506. */
  43507. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43508. private _onNewGamepadConnected;
  43509. private _tryEnableInteractionOnController;
  43510. private _onNewGamepadDisconnected;
  43511. private _enableInteractionOnController;
  43512. private _checkTeleportWithRay;
  43513. private _checkRotate;
  43514. private _checkTeleportBackwards;
  43515. private _enableTeleportationOnController;
  43516. private _createTeleportationCircles;
  43517. private _displayTeleportationTarget;
  43518. private _hideTeleportationTarget;
  43519. private _rotateCamera;
  43520. private _moveTeleportationSelectorTo;
  43521. private _workingVector;
  43522. private _workingQuaternion;
  43523. private _workingMatrix;
  43524. /**
  43525. * Time Constant Teleportation Mode
  43526. */
  43527. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  43528. /**
  43529. * Speed Constant Teleportation Mode
  43530. */
  43531. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  43532. /**
  43533. * Teleports the users feet to the desired location
  43534. * @param location The location where the user's feet should be placed
  43535. */
  43536. teleportCamera(location: Vector3): void;
  43537. private _convertNormalToDirectionOfRay;
  43538. private _castRayAndSelectObject;
  43539. private _notifySelectedMeshUnselected;
  43540. /**
  43541. * Sets the color of the laser ray from the vr controllers.
  43542. * @param color new color for the ray.
  43543. */
  43544. changeLaserColor(color: Color3): void;
  43545. /**
  43546. * Sets the color of the ray from the vr headsets gaze.
  43547. * @param color new color for the ray.
  43548. */
  43549. changeGazeColor(color: Color3): void;
  43550. /**
  43551. * Exits VR and disposes of the vr experience helper
  43552. */
  43553. dispose(): void;
  43554. /**
  43555. * Gets the name of the VRExperienceHelper class
  43556. * @returns "VRExperienceHelper"
  43557. */
  43558. getClassName(): string;
  43559. }
  43560. }
  43561. declare module BABYLON {
  43562. /**
  43563. * Contains an array of blocks representing the octree
  43564. */
  43565. export interface IOctreeContainer<T> {
  43566. /**
  43567. * Blocks within the octree
  43568. */
  43569. blocks: Array<OctreeBlock<T>>;
  43570. }
  43571. /**
  43572. * Class used to store a cell in an octree
  43573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43574. */
  43575. export class OctreeBlock<T> {
  43576. /**
  43577. * Gets the content of the current block
  43578. */
  43579. entries: T[];
  43580. /**
  43581. * Gets the list of block children
  43582. */
  43583. blocks: Array<OctreeBlock<T>>;
  43584. private _depth;
  43585. private _maxDepth;
  43586. private _capacity;
  43587. private _minPoint;
  43588. private _maxPoint;
  43589. private _boundingVectors;
  43590. private _creationFunc;
  43591. /**
  43592. * Creates a new block
  43593. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43594. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43595. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43596. * @param depth defines the current depth of this block in the octree
  43597. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43598. * @param creationFunc defines a callback to call when an element is added to the block
  43599. */
  43600. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43601. /**
  43602. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43603. */
  43604. readonly capacity: number;
  43605. /**
  43606. * Gets the minimum vector (in world space) of the block's bounding box
  43607. */
  43608. readonly minPoint: Vector3;
  43609. /**
  43610. * Gets the maximum vector (in world space) of the block's bounding box
  43611. */
  43612. readonly maxPoint: Vector3;
  43613. /**
  43614. * Add a new element to this block
  43615. * @param entry defines the element to add
  43616. */
  43617. addEntry(entry: T): void;
  43618. /**
  43619. * Remove an element from this block
  43620. * @param entry defines the element to remove
  43621. */
  43622. removeEntry(entry: T): void;
  43623. /**
  43624. * Add an array of elements to this block
  43625. * @param entries defines the array of elements to add
  43626. */
  43627. addEntries(entries: T[]): void;
  43628. /**
  43629. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43630. * @param frustumPlanes defines the frustum planes to test
  43631. * @param selection defines the array to store current content if selection is positive
  43632. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43633. */
  43634. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43635. /**
  43636. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43637. * @param sphereCenter defines the bounding sphere center
  43638. * @param sphereRadius defines the bounding sphere radius
  43639. * @param selection defines the array to store current content if selection is positive
  43640. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43641. */
  43642. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43643. /**
  43644. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43645. * @param ray defines the ray to test with
  43646. * @param selection defines the array to store current content if selection is positive
  43647. */
  43648. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43649. /**
  43650. * Subdivide the content into child blocks (this block will then be empty)
  43651. */
  43652. createInnerBlocks(): void;
  43653. /**
  43654. * @hidden
  43655. */
  43656. 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;
  43657. }
  43658. }
  43659. declare module BABYLON {
  43660. /**
  43661. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43662. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43663. */
  43664. export class Octree<T> {
  43665. /** 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.) */
  43666. maxDepth: number;
  43667. /**
  43668. * Blocks within the octree containing objects
  43669. */
  43670. blocks: Array<OctreeBlock<T>>;
  43671. /**
  43672. * Content stored in the octree
  43673. */
  43674. dynamicContent: T[];
  43675. private _maxBlockCapacity;
  43676. private _selectionContent;
  43677. private _creationFunc;
  43678. /**
  43679. * Creates a octree
  43680. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43681. * @param creationFunc function to be used to instatiate the octree
  43682. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43683. * @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.)
  43684. */
  43685. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43686. /** 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.) */
  43687. maxDepth?: number);
  43688. /**
  43689. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43690. * @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);
  43691. * @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);
  43692. * @param entries meshes to be added to the octree blocks
  43693. */
  43694. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43695. /**
  43696. * Adds a mesh to the octree
  43697. * @param entry Mesh to add to the octree
  43698. */
  43699. addMesh(entry: T): void;
  43700. /**
  43701. * Remove an element from the octree
  43702. * @param entry defines the element to remove
  43703. */
  43704. removeMesh(entry: T): void;
  43705. /**
  43706. * Selects an array of meshes within the frustum
  43707. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43708. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43709. * @returns array of meshes within the frustum
  43710. */
  43711. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43712. /**
  43713. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43714. * @param sphereCenter defines the bounding sphere center
  43715. * @param sphereRadius defines the bounding sphere radius
  43716. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43717. * @returns an array of objects that intersect the sphere
  43718. */
  43719. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43720. /**
  43721. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43722. * @param ray defines the ray to test with
  43723. * @returns array of intersected objects
  43724. */
  43725. intersectsRay(ray: Ray): SmartArray<T>;
  43726. /**
  43727. * Adds a mesh into the octree block if it intersects the block
  43728. */
  43729. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43730. /**
  43731. * Adds a submesh into the octree block if it intersects the block
  43732. */
  43733. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43734. }
  43735. }
  43736. declare module BABYLON {
  43737. interface Scene {
  43738. /**
  43739. * @hidden
  43740. * Backing Filed
  43741. */
  43742. _selectionOctree: Octree<AbstractMesh>;
  43743. /**
  43744. * Gets the octree used to boost mesh selection (picking)
  43745. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43746. */
  43747. selectionOctree: Octree<AbstractMesh>;
  43748. /**
  43749. * Creates or updates the octree used to boost selection (picking)
  43750. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43751. * @param maxCapacity defines the maximum capacity per leaf
  43752. * @param maxDepth defines the maximum depth of the octree
  43753. * @returns an octree of AbstractMesh
  43754. */
  43755. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43756. }
  43757. interface AbstractMesh {
  43758. /**
  43759. * @hidden
  43760. * Backing Field
  43761. */
  43762. _submeshesOctree: Octree<SubMesh>;
  43763. /**
  43764. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43765. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43766. * @param maxCapacity defines the maximum size of each block (64 by default)
  43767. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43768. * @returns the new octree
  43769. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43770. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43771. */
  43772. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43773. }
  43774. /**
  43775. * Defines the octree scene component responsible to manage any octrees
  43776. * in a given scene.
  43777. */
  43778. export class OctreeSceneComponent {
  43779. /**
  43780. * The component name help to identify the component in the list of scene components.
  43781. */
  43782. readonly name: string;
  43783. /**
  43784. * The scene the component belongs to.
  43785. */
  43786. scene: Scene;
  43787. /**
  43788. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43789. */
  43790. readonly checksIsEnabled: boolean;
  43791. /**
  43792. * Creates a new instance of the component for the given scene
  43793. * @param scene Defines the scene to register the component in
  43794. */
  43795. constructor(scene: Scene);
  43796. /**
  43797. * Registers the component in a given scene
  43798. */
  43799. register(): void;
  43800. /**
  43801. * Return the list of active meshes
  43802. * @returns the list of active meshes
  43803. */
  43804. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43805. /**
  43806. * Return the list of active sub meshes
  43807. * @param mesh The mesh to get the candidates sub meshes from
  43808. * @returns the list of active sub meshes
  43809. */
  43810. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43811. private _tempRay;
  43812. /**
  43813. * Return the list of sub meshes intersecting with a given local ray
  43814. * @param mesh defines the mesh to find the submesh for
  43815. * @param localRay defines the ray in local space
  43816. * @returns the list of intersecting sub meshes
  43817. */
  43818. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43819. /**
  43820. * Return the list of sub meshes colliding with a collider
  43821. * @param mesh defines the mesh to find the submesh for
  43822. * @param collider defines the collider to evaluate the collision against
  43823. * @returns the list of colliding sub meshes
  43824. */
  43825. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43826. /**
  43827. * Rebuilds the elements related to this component in case of
  43828. * context lost for instance.
  43829. */
  43830. rebuild(): void;
  43831. /**
  43832. * Disposes the component and the associated ressources.
  43833. */
  43834. dispose(): void;
  43835. }
  43836. }
  43837. declare module BABYLON {
  43838. /**
  43839. * Renders a layer on top of an existing scene
  43840. */
  43841. export class UtilityLayerRenderer implements IDisposable {
  43842. /** the original scene that will be rendered on top of */
  43843. originalScene: Scene;
  43844. private _pointerCaptures;
  43845. private _lastPointerEvents;
  43846. private static _DefaultUtilityLayer;
  43847. private static _DefaultKeepDepthUtilityLayer;
  43848. private _sharedGizmoLight;
  43849. private _renderCamera;
  43850. /**
  43851. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43852. * @returns the camera that is used when rendering the utility layer
  43853. */
  43854. getRenderCamera(): Nullable<Camera>;
  43855. /**
  43856. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43857. * @param cam the camera that should be used when rendering the utility layer
  43858. */
  43859. setRenderCamera(cam: Nullable<Camera>): void;
  43860. /**
  43861. * @hidden
  43862. * Light which used by gizmos to get light shading
  43863. */
  43864. _getSharedGizmoLight(): HemisphericLight;
  43865. /**
  43866. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43867. */
  43868. pickUtilitySceneFirst: boolean;
  43869. /**
  43870. * 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)
  43871. */
  43872. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43873. /**
  43874. * 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)
  43875. */
  43876. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43877. /**
  43878. * The scene that is rendered on top of the original scene
  43879. */
  43880. utilityLayerScene: Scene;
  43881. /**
  43882. * If the utility layer should automatically be rendered on top of existing scene
  43883. */
  43884. shouldRender: boolean;
  43885. /**
  43886. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43887. */
  43888. onlyCheckPointerDownEvents: boolean;
  43889. /**
  43890. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43891. */
  43892. processAllEvents: boolean;
  43893. /**
  43894. * Observable raised when the pointer move from the utility layer scene to the main scene
  43895. */
  43896. onPointerOutObservable: Observable<number>;
  43897. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43898. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43899. private _afterRenderObserver;
  43900. private _sceneDisposeObserver;
  43901. private _originalPointerObserver;
  43902. /**
  43903. * Instantiates a UtilityLayerRenderer
  43904. * @param originalScene the original scene that will be rendered on top of
  43905. * @param handleEvents boolean indicating if the utility layer should handle events
  43906. */
  43907. constructor(
  43908. /** the original scene that will be rendered on top of */
  43909. originalScene: Scene, handleEvents?: boolean);
  43910. private _notifyObservers;
  43911. /**
  43912. * Renders the utility layers scene on top of the original scene
  43913. */
  43914. render(): void;
  43915. /**
  43916. * Disposes of the renderer
  43917. */
  43918. dispose(): void;
  43919. private _updateCamera;
  43920. }
  43921. }
  43922. declare module BABYLON {
  43923. /**
  43924. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43925. */
  43926. export class Gizmo implements IDisposable {
  43927. /** The utility layer the gizmo will be added to */
  43928. gizmoLayer: UtilityLayerRenderer;
  43929. /**
  43930. * The root mesh of the gizmo
  43931. */
  43932. _rootMesh: Mesh;
  43933. private _attachedMesh;
  43934. /**
  43935. * Ratio for the scale of the gizmo (Default: 1)
  43936. */
  43937. scaleRatio: number;
  43938. /**
  43939. * If a custom mesh has been set (Default: false)
  43940. */
  43941. protected _customMeshSet: boolean;
  43942. /**
  43943. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43944. * * When set, interactions will be enabled
  43945. */
  43946. attachedMesh: Nullable<AbstractMesh>;
  43947. /**
  43948. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43949. * @param mesh The mesh to replace the default mesh of the gizmo
  43950. */
  43951. setCustomMesh(mesh: Mesh): void;
  43952. /**
  43953. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43954. */
  43955. updateGizmoRotationToMatchAttachedMesh: boolean;
  43956. /**
  43957. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43958. */
  43959. updateGizmoPositionToMatchAttachedMesh: boolean;
  43960. /**
  43961. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43962. */
  43963. updateScale: boolean;
  43964. protected _interactionsEnabled: boolean;
  43965. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43966. private _beforeRenderObserver;
  43967. private _tempVector;
  43968. /**
  43969. * Creates a gizmo
  43970. * @param gizmoLayer The utility layer the gizmo will be added to
  43971. */
  43972. constructor(
  43973. /** The utility layer the gizmo will be added to */
  43974. gizmoLayer?: UtilityLayerRenderer);
  43975. /**
  43976. * Updates the gizmo to match the attached mesh's position/rotation
  43977. */
  43978. protected _update(): void;
  43979. /**
  43980. * Disposes of the gizmo
  43981. */
  43982. dispose(): void;
  43983. }
  43984. }
  43985. declare module BABYLON {
  43986. /**
  43987. * Single plane drag gizmo
  43988. */
  43989. export class PlaneDragGizmo extends Gizmo {
  43990. /**
  43991. * Drag behavior responsible for the gizmos dragging interactions
  43992. */
  43993. dragBehavior: PointerDragBehavior;
  43994. private _pointerObserver;
  43995. /**
  43996. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43997. */
  43998. snapDistance: number;
  43999. /**
  44000. * Event that fires each time the gizmo snaps to a new location.
  44001. * * snapDistance is the the change in distance
  44002. */
  44003. onSnapObservable: Observable<{
  44004. snapDistance: number;
  44005. }>;
  44006. private _plane;
  44007. private _coloredMaterial;
  44008. private _hoverMaterial;
  44009. private _isEnabled;
  44010. private _parent;
  44011. /** @hidden */
  44012. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44013. /** @hidden */
  44014. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44015. /**
  44016. * Creates a PlaneDragGizmo
  44017. * @param gizmoLayer The utility layer the gizmo will be added to
  44018. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44019. * @param color The color of the gizmo
  44020. */
  44021. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44022. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44023. /**
  44024. * If the gizmo is enabled
  44025. */
  44026. isEnabled: boolean;
  44027. /**
  44028. * Disposes of the gizmo
  44029. */
  44030. dispose(): void;
  44031. }
  44032. }
  44033. declare module BABYLON {
  44034. /**
  44035. * Gizmo that enables dragging a mesh along 3 axis
  44036. */
  44037. export class PositionGizmo extends Gizmo {
  44038. /**
  44039. * Internal gizmo used for interactions on the x axis
  44040. */
  44041. xGizmo: AxisDragGizmo;
  44042. /**
  44043. * Internal gizmo used for interactions on the y axis
  44044. */
  44045. yGizmo: AxisDragGizmo;
  44046. /**
  44047. * Internal gizmo used for interactions on the z axis
  44048. */
  44049. zGizmo: AxisDragGizmo;
  44050. /**
  44051. * Internal gizmo used for interactions on the yz plane
  44052. */
  44053. xPlaneGizmo: PlaneDragGizmo;
  44054. /**
  44055. * Internal gizmo used for interactions on the xz plane
  44056. */
  44057. yPlaneGizmo: PlaneDragGizmo;
  44058. /**
  44059. * Internal gizmo used for interactions on the xy plane
  44060. */
  44061. zPlaneGizmo: PlaneDragGizmo;
  44062. /**
  44063. * private variables
  44064. */
  44065. private _meshAttached;
  44066. private _updateGizmoRotationToMatchAttachedMesh;
  44067. private _snapDistance;
  44068. private _scaleRatio;
  44069. /** Fires an event when any of it's sub gizmos are dragged */
  44070. onDragStartObservable: Observable<unknown>;
  44071. /** Fires an event when any of it's sub gizmos are released from dragging */
  44072. onDragEndObservable: Observable<unknown>;
  44073. /**
  44074. * If set to true, planar drag is enabled
  44075. */
  44076. private _planarGizmoEnabled;
  44077. attachedMesh: Nullable<AbstractMesh>;
  44078. /**
  44079. * Creates a PositionGizmo
  44080. * @param gizmoLayer The utility layer the gizmo will be added to
  44081. */
  44082. constructor(gizmoLayer?: UtilityLayerRenderer);
  44083. /**
  44084. * If the planar drag gizmo is enabled
  44085. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44086. */
  44087. planarGizmoEnabled: boolean;
  44088. updateGizmoRotationToMatchAttachedMesh: boolean;
  44089. /**
  44090. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44091. */
  44092. snapDistance: number;
  44093. /**
  44094. * Ratio for the scale of the gizmo (Default: 1)
  44095. */
  44096. scaleRatio: number;
  44097. /**
  44098. * Disposes of the gizmo
  44099. */
  44100. dispose(): void;
  44101. /**
  44102. * CustomMeshes are not supported by this gizmo
  44103. * @param mesh The mesh to replace the default mesh of the gizmo
  44104. */
  44105. setCustomMesh(mesh: Mesh): void;
  44106. }
  44107. }
  44108. declare module BABYLON {
  44109. /**
  44110. * Single axis drag gizmo
  44111. */
  44112. export class AxisDragGizmo extends Gizmo {
  44113. /**
  44114. * Drag behavior responsible for the gizmos dragging interactions
  44115. */
  44116. dragBehavior: PointerDragBehavior;
  44117. private _pointerObserver;
  44118. /**
  44119. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44120. */
  44121. snapDistance: number;
  44122. /**
  44123. * Event that fires each time the gizmo snaps to a new location.
  44124. * * snapDistance is the the change in distance
  44125. */
  44126. onSnapObservable: Observable<{
  44127. snapDistance: number;
  44128. }>;
  44129. private _isEnabled;
  44130. private _parent;
  44131. private _arrow;
  44132. private _coloredMaterial;
  44133. private _hoverMaterial;
  44134. /** @hidden */
  44135. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44136. /** @hidden */
  44137. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44138. /**
  44139. * Creates an AxisDragGizmo
  44140. * @param gizmoLayer The utility layer the gizmo will be added to
  44141. * @param dragAxis The axis which the gizmo will be able to drag on
  44142. * @param color The color of the gizmo
  44143. */
  44144. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44145. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44146. /**
  44147. * If the gizmo is enabled
  44148. */
  44149. isEnabled: boolean;
  44150. /**
  44151. * Disposes of the gizmo
  44152. */
  44153. dispose(): void;
  44154. }
  44155. }
  44156. declare module BABYLON.Debug {
  44157. /**
  44158. * The Axes viewer will show 3 axes in a specific point in space
  44159. */
  44160. export class AxesViewer {
  44161. private _xAxis;
  44162. private _yAxis;
  44163. private _zAxis;
  44164. private _scaleLinesFactor;
  44165. private _instanced;
  44166. /**
  44167. * Gets the hosting scene
  44168. */
  44169. scene: Scene;
  44170. /**
  44171. * Gets or sets a number used to scale line length
  44172. */
  44173. scaleLines: number;
  44174. /** Gets the node hierarchy used to render x-axis */
  44175. readonly xAxis: TransformNode;
  44176. /** Gets the node hierarchy used to render y-axis */
  44177. readonly yAxis: TransformNode;
  44178. /** Gets the node hierarchy used to render z-axis */
  44179. readonly zAxis: TransformNode;
  44180. /**
  44181. * Creates a new AxesViewer
  44182. * @param scene defines the hosting scene
  44183. * @param scaleLines defines a number used to scale line length (1 by default)
  44184. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44185. * @param xAxis defines the node hierarchy used to render the x-axis
  44186. * @param yAxis defines the node hierarchy used to render the y-axis
  44187. * @param zAxis defines the node hierarchy used to render the z-axis
  44188. */
  44189. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44190. /**
  44191. * Force the viewer to update
  44192. * @param position defines the position of the viewer
  44193. * @param xaxis defines the x axis of the viewer
  44194. * @param yaxis defines the y axis of the viewer
  44195. * @param zaxis defines the z axis of the viewer
  44196. */
  44197. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44198. /**
  44199. * Creates an instance of this axes viewer.
  44200. * @returns a new axes viewer with instanced meshes
  44201. */
  44202. createInstance(): AxesViewer;
  44203. /** Releases resources */
  44204. dispose(): void;
  44205. private static _SetRenderingGroupId;
  44206. }
  44207. }
  44208. declare module BABYLON.Debug {
  44209. /**
  44210. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44211. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44212. */
  44213. export class BoneAxesViewer extends AxesViewer {
  44214. /**
  44215. * Gets or sets the target mesh where to display the axes viewer
  44216. */
  44217. mesh: Nullable<Mesh>;
  44218. /**
  44219. * Gets or sets the target bone where to display the axes viewer
  44220. */
  44221. bone: Nullable<Bone>;
  44222. /** Gets current position */
  44223. pos: Vector3;
  44224. /** Gets direction of X axis */
  44225. xaxis: Vector3;
  44226. /** Gets direction of Y axis */
  44227. yaxis: Vector3;
  44228. /** Gets direction of Z axis */
  44229. zaxis: Vector3;
  44230. /**
  44231. * Creates a new BoneAxesViewer
  44232. * @param scene defines the hosting scene
  44233. * @param bone defines the target bone
  44234. * @param mesh defines the target mesh
  44235. * @param scaleLines defines a scaling factor for line length (1 by default)
  44236. */
  44237. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44238. /**
  44239. * Force the viewer to update
  44240. */
  44241. update(): void;
  44242. /** Releases resources */
  44243. dispose(): void;
  44244. }
  44245. }
  44246. declare module BABYLON {
  44247. /**
  44248. * Interface used to define scene explorer extensibility option
  44249. */
  44250. export interface IExplorerExtensibilityOption {
  44251. /**
  44252. * Define the option label
  44253. */
  44254. label: string;
  44255. /**
  44256. * Defines the action to execute on click
  44257. */
  44258. action: (entity: any) => void;
  44259. }
  44260. /**
  44261. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44262. */
  44263. export interface IExplorerExtensibilityGroup {
  44264. /**
  44265. * Defines a predicate to test if a given type mut be extended
  44266. */
  44267. predicate: (entity: any) => boolean;
  44268. /**
  44269. * Gets the list of options added to a type
  44270. */
  44271. entries: IExplorerExtensibilityOption[];
  44272. }
  44273. /**
  44274. * Interface used to define the options to use to create the Inspector
  44275. */
  44276. export interface IInspectorOptions {
  44277. /**
  44278. * Display in overlay mode (default: false)
  44279. */
  44280. overlay?: boolean;
  44281. /**
  44282. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44283. */
  44284. globalRoot?: HTMLElement;
  44285. /**
  44286. * Display the Scene explorer
  44287. */
  44288. showExplorer?: boolean;
  44289. /**
  44290. * Display the property inspector
  44291. */
  44292. showInspector?: boolean;
  44293. /**
  44294. * Display in embed mode (both panes on the right)
  44295. */
  44296. embedMode?: boolean;
  44297. /**
  44298. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44299. */
  44300. handleResize?: boolean;
  44301. /**
  44302. * Allow the panes to popup (default: true)
  44303. */
  44304. enablePopup?: boolean;
  44305. /**
  44306. * Allow the panes to be closed by users (default: true)
  44307. */
  44308. enableClose?: boolean;
  44309. /**
  44310. * Optional list of extensibility entries
  44311. */
  44312. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44313. /**
  44314. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44315. */
  44316. inspectorURL?: string;
  44317. /**
  44318. * Optional initial tab (default to DebugLayerTab.Properties)
  44319. */
  44320. initialTab?: DebugLayerTab;
  44321. }
  44322. interface Scene {
  44323. /**
  44324. * @hidden
  44325. * Backing field
  44326. */
  44327. _debugLayer: DebugLayer;
  44328. /**
  44329. * Gets the debug layer (aka Inspector) associated with the scene
  44330. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44331. */
  44332. debugLayer: DebugLayer;
  44333. }
  44334. /**
  44335. * Enum of inspector action tab
  44336. */
  44337. export enum DebugLayerTab {
  44338. /**
  44339. * Properties tag (default)
  44340. */
  44341. Properties = 0,
  44342. /**
  44343. * Debug tab
  44344. */
  44345. Debug = 1,
  44346. /**
  44347. * Statistics tab
  44348. */
  44349. Statistics = 2,
  44350. /**
  44351. * Tools tab
  44352. */
  44353. Tools = 3,
  44354. /**
  44355. * Settings tab
  44356. */
  44357. Settings = 4
  44358. }
  44359. /**
  44360. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44361. * what is happening in your scene
  44362. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44363. */
  44364. export class DebugLayer {
  44365. /**
  44366. * Define the url to get the inspector script from.
  44367. * By default it uses the babylonjs CDN.
  44368. * @ignoreNaming
  44369. */
  44370. static InspectorURL: string;
  44371. private _scene;
  44372. private BJSINSPECTOR;
  44373. private _onPropertyChangedObservable?;
  44374. /**
  44375. * Observable triggered when a property is changed through the inspector.
  44376. */
  44377. readonly onPropertyChangedObservable: any;
  44378. /**
  44379. * Instantiates a new debug layer.
  44380. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44381. * what is happening in your scene
  44382. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44383. * @param scene Defines the scene to inspect
  44384. */
  44385. constructor(scene: Scene);
  44386. /** Creates the inspector window. */
  44387. private _createInspector;
  44388. /**
  44389. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44390. * @param entity defines the entity to select
  44391. * @param lineContainerTitle defines the specific block to highlight
  44392. */
  44393. select(entity: any, lineContainerTitle?: string): void;
  44394. /** Get the inspector from bundle or global */
  44395. private _getGlobalInspector;
  44396. /**
  44397. * Get if the inspector is visible or not.
  44398. * @returns true if visible otherwise, false
  44399. */
  44400. isVisible(): boolean;
  44401. /**
  44402. * Hide the inspector and close its window.
  44403. */
  44404. hide(): void;
  44405. /**
  44406. * Launch the debugLayer.
  44407. * @param config Define the configuration of the inspector
  44408. * @return a promise fulfilled when the debug layer is visible
  44409. */
  44410. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44411. }
  44412. }
  44413. declare module BABYLON {
  44414. /**
  44415. * Class containing static functions to help procedurally build meshes
  44416. */
  44417. export class BoxBuilder {
  44418. /**
  44419. * Creates a box mesh
  44420. * * The parameter `size` sets the size (float) of each box side (default 1)
  44421. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44422. * * 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)
  44423. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44425. * * 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
  44426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44427. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44428. * @param name defines the name of the mesh
  44429. * @param options defines the options used to create the mesh
  44430. * @param scene defines the hosting scene
  44431. * @returns the box mesh
  44432. */
  44433. static CreateBox(name: string, options: {
  44434. size?: number;
  44435. width?: number;
  44436. height?: number;
  44437. depth?: number;
  44438. faceUV?: Vector4[];
  44439. faceColors?: Color4[];
  44440. sideOrientation?: number;
  44441. frontUVs?: Vector4;
  44442. backUVs?: Vector4;
  44443. wrap?: boolean;
  44444. topBaseAt?: number;
  44445. bottomBaseAt?: number;
  44446. updatable?: boolean;
  44447. }, scene?: Nullable<Scene>): Mesh;
  44448. }
  44449. }
  44450. declare module BABYLON {
  44451. /**
  44452. * Class containing static functions to help procedurally build meshes
  44453. */
  44454. export class SphereBuilder {
  44455. /**
  44456. * Creates a sphere mesh
  44457. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44458. * * 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`)
  44459. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44460. * * 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
  44461. * * 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)
  44462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44463. * * 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
  44464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44465. * @param name defines the name of the mesh
  44466. * @param options defines the options used to create the mesh
  44467. * @param scene defines the hosting scene
  44468. * @returns the sphere mesh
  44469. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44470. */
  44471. static CreateSphere(name: string, options: {
  44472. segments?: number;
  44473. diameter?: number;
  44474. diameterX?: number;
  44475. diameterY?: number;
  44476. diameterZ?: number;
  44477. arc?: number;
  44478. slice?: number;
  44479. sideOrientation?: number;
  44480. frontUVs?: Vector4;
  44481. backUVs?: Vector4;
  44482. updatable?: boolean;
  44483. }, scene?: Nullable<Scene>): Mesh;
  44484. }
  44485. }
  44486. declare module BABYLON.Debug {
  44487. /**
  44488. * Used to show the physics impostor around the specific mesh
  44489. */
  44490. export class PhysicsViewer {
  44491. /** @hidden */
  44492. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44493. /** @hidden */
  44494. protected _meshes: Array<Nullable<AbstractMesh>>;
  44495. /** @hidden */
  44496. protected _scene: Nullable<Scene>;
  44497. /** @hidden */
  44498. protected _numMeshes: number;
  44499. /** @hidden */
  44500. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44501. private _renderFunction;
  44502. private _utilityLayer;
  44503. private _debugBoxMesh;
  44504. private _debugSphereMesh;
  44505. private _debugCylinderMesh;
  44506. private _debugMaterial;
  44507. private _debugMeshMeshes;
  44508. /**
  44509. * Creates a new PhysicsViewer
  44510. * @param scene defines the hosting scene
  44511. */
  44512. constructor(scene: Scene);
  44513. /** @hidden */
  44514. protected _updateDebugMeshes(): void;
  44515. /**
  44516. * Renders a specified physic impostor
  44517. * @param impostor defines the impostor to render
  44518. * @param targetMesh defines the mesh represented by the impostor
  44519. * @returns the new debug mesh used to render the impostor
  44520. */
  44521. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44522. /**
  44523. * Hides a specified physic impostor
  44524. * @param impostor defines the impostor to hide
  44525. */
  44526. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44527. private _getDebugMaterial;
  44528. private _getDebugBoxMesh;
  44529. private _getDebugSphereMesh;
  44530. private _getDebugCylinderMesh;
  44531. private _getDebugMeshMesh;
  44532. private _getDebugMesh;
  44533. /** Releases all resources */
  44534. dispose(): void;
  44535. }
  44536. }
  44537. declare module BABYLON {
  44538. /**
  44539. * Class containing static functions to help procedurally build meshes
  44540. */
  44541. export class LinesBuilder {
  44542. /**
  44543. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44544. * * 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
  44545. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44546. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44547. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44548. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44549. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44550. * * 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
  44551. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44554. * @param name defines the name of the new line system
  44555. * @param options defines the options used to create the line system
  44556. * @param scene defines the hosting scene
  44557. * @returns a new line system mesh
  44558. */
  44559. static CreateLineSystem(name: string, options: {
  44560. lines: Vector3[][];
  44561. updatable?: boolean;
  44562. instance?: Nullable<LinesMesh>;
  44563. colors?: Nullable<Color4[][]>;
  44564. useVertexAlpha?: boolean;
  44565. }, scene: Nullable<Scene>): LinesMesh;
  44566. /**
  44567. * Creates a line mesh
  44568. * 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
  44569. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44570. * * The parameter `points` is an array successive Vector3
  44571. * * 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
  44572. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44573. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44574. * * When updating an instance, remember that only point positions can change, not the number of points
  44575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44577. * @param name defines the name of the new line system
  44578. * @param options defines the options used to create the line system
  44579. * @param scene defines the hosting scene
  44580. * @returns a new line mesh
  44581. */
  44582. static CreateLines(name: string, options: {
  44583. points: Vector3[];
  44584. updatable?: boolean;
  44585. instance?: Nullable<LinesMesh>;
  44586. colors?: Color4[];
  44587. useVertexAlpha?: boolean;
  44588. }, scene?: Nullable<Scene>): LinesMesh;
  44589. /**
  44590. * Creates a dashed line mesh
  44591. * * 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
  44592. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44593. * * The parameter `points` is an array successive Vector3
  44594. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44595. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44596. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44597. * * 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
  44598. * * When updating an instance, remember that only point positions can change, not the number of points
  44599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44600. * @param name defines the name of the mesh
  44601. * @param options defines the options used to create the mesh
  44602. * @param scene defines the hosting scene
  44603. * @returns the dashed line mesh
  44604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44605. */
  44606. static CreateDashedLines(name: string, options: {
  44607. points: Vector3[];
  44608. dashSize?: number;
  44609. gapSize?: number;
  44610. dashNb?: number;
  44611. updatable?: boolean;
  44612. instance?: LinesMesh;
  44613. }, scene?: Nullable<Scene>): LinesMesh;
  44614. }
  44615. }
  44616. declare module BABYLON {
  44617. /**
  44618. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44619. * in order to better appreciate the issue one might have.
  44620. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44621. */
  44622. export class RayHelper {
  44623. /**
  44624. * Defines the ray we are currently tryin to visualize.
  44625. */
  44626. ray: Nullable<Ray>;
  44627. private _renderPoints;
  44628. private _renderLine;
  44629. private _renderFunction;
  44630. private _scene;
  44631. private _updateToMeshFunction;
  44632. private _attachedToMesh;
  44633. private _meshSpaceDirection;
  44634. private _meshSpaceOrigin;
  44635. /**
  44636. * Helper function to create a colored helper in a scene in one line.
  44637. * @param ray Defines the ray we are currently tryin to visualize
  44638. * @param scene Defines the scene the ray is used in
  44639. * @param color Defines the color we want to see the ray in
  44640. * @returns The newly created ray helper.
  44641. */
  44642. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44643. /**
  44644. * Instantiate a new ray helper.
  44645. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44646. * in order to better appreciate the issue one might have.
  44647. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44648. * @param ray Defines the ray we are currently tryin to visualize
  44649. */
  44650. constructor(ray: Ray);
  44651. /**
  44652. * Shows the ray we are willing to debug.
  44653. * @param scene Defines the scene the ray needs to be rendered in
  44654. * @param color Defines the color the ray needs to be rendered in
  44655. */
  44656. show(scene: Scene, color?: Color3): void;
  44657. /**
  44658. * Hides the ray we are debugging.
  44659. */
  44660. hide(): void;
  44661. private _render;
  44662. /**
  44663. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44664. * @param mesh Defines the mesh we want the helper attached to
  44665. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44666. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44667. * @param length Defines the length of the ray
  44668. */
  44669. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44670. /**
  44671. * Detach the ray helper from the mesh it has previously been attached to.
  44672. */
  44673. detachFromMesh(): void;
  44674. private _updateToMesh;
  44675. /**
  44676. * Dispose the helper and release its associated resources.
  44677. */
  44678. dispose(): void;
  44679. }
  44680. }
  44681. declare module BABYLON.Debug {
  44682. /**
  44683. * Class used to render a debug view of a given skeleton
  44684. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44685. */
  44686. export class SkeletonViewer {
  44687. /** defines the skeleton to render */
  44688. skeleton: Skeleton;
  44689. /** defines the mesh attached to the skeleton */
  44690. mesh: AbstractMesh;
  44691. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44692. autoUpdateBonesMatrices: boolean;
  44693. /** defines the rendering group id to use with the viewer */
  44694. renderingGroupId: number;
  44695. /** Gets or sets the color used to render the skeleton */
  44696. color: Color3;
  44697. private _scene;
  44698. private _debugLines;
  44699. private _debugMesh;
  44700. private _isEnabled;
  44701. private _renderFunction;
  44702. private _utilityLayer;
  44703. /**
  44704. * Returns the mesh used to render the bones
  44705. */
  44706. readonly debugMesh: Nullable<LinesMesh>;
  44707. /**
  44708. * Creates a new SkeletonViewer
  44709. * @param skeleton defines the skeleton to render
  44710. * @param mesh defines the mesh attached to the skeleton
  44711. * @param scene defines the hosting scene
  44712. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44713. * @param renderingGroupId defines the rendering group id to use with the viewer
  44714. */
  44715. constructor(
  44716. /** defines the skeleton to render */
  44717. skeleton: Skeleton,
  44718. /** defines the mesh attached to the skeleton */
  44719. mesh: AbstractMesh, scene: Scene,
  44720. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44721. autoUpdateBonesMatrices?: boolean,
  44722. /** defines the rendering group id to use with the viewer */
  44723. renderingGroupId?: number);
  44724. /** Gets or sets a boolean indicating if the viewer is enabled */
  44725. isEnabled: boolean;
  44726. private _getBonePosition;
  44727. private _getLinesForBonesWithLength;
  44728. private _getLinesForBonesNoLength;
  44729. /** Update the viewer to sync with current skeleton state */
  44730. update(): void;
  44731. /** Release associated resources */
  44732. dispose(): void;
  44733. }
  44734. }
  44735. declare module BABYLON {
  44736. /**
  44737. * Options to create the null engine
  44738. */
  44739. export class NullEngineOptions {
  44740. /**
  44741. * Render width (Default: 512)
  44742. */
  44743. renderWidth: number;
  44744. /**
  44745. * Render height (Default: 256)
  44746. */
  44747. renderHeight: number;
  44748. /**
  44749. * Texture size (Default: 512)
  44750. */
  44751. textureSize: number;
  44752. /**
  44753. * If delta time between frames should be constant
  44754. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44755. */
  44756. deterministicLockstep: boolean;
  44757. /**
  44758. * Maximum about of steps between frames (Default: 4)
  44759. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44760. */
  44761. lockstepMaxSteps: number;
  44762. }
  44763. /**
  44764. * The null engine class provides support for headless version of babylon.js.
  44765. * This can be used in server side scenario or for testing purposes
  44766. */
  44767. export class NullEngine extends Engine {
  44768. private _options;
  44769. /**
  44770. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  44771. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44772. * @returns true if engine is in deterministic lock step mode
  44773. */
  44774. isDeterministicLockStep(): boolean;
  44775. /**
  44776. * Gets the max steps when engine is running in deterministic lock step
  44777. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44778. * @returns the max steps
  44779. */
  44780. getLockstepMaxSteps(): number;
  44781. /**
  44782. * Gets the current hardware scaling level.
  44783. * By default the hardware scaling level is computed from the window device ratio.
  44784. * 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.
  44785. * @returns a number indicating the current hardware scaling level
  44786. */
  44787. getHardwareScalingLevel(): number;
  44788. constructor(options?: NullEngineOptions);
  44789. /**
  44790. * Creates a vertex buffer
  44791. * @param vertices the data for the vertex buffer
  44792. * @returns the new WebGL static buffer
  44793. */
  44794. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44795. /**
  44796. * Creates a new index buffer
  44797. * @param indices defines the content of the index buffer
  44798. * @param updatable defines if the index buffer must be updatable
  44799. * @returns a new webGL buffer
  44800. */
  44801. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44802. /**
  44803. * Clear the current render buffer or the current render target (if any is set up)
  44804. * @param color defines the color to use
  44805. * @param backBuffer defines if the back buffer must be cleared
  44806. * @param depth defines if the depth buffer must be cleared
  44807. * @param stencil defines if the stencil buffer must be cleared
  44808. */
  44809. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44810. /**
  44811. * Gets the current render width
  44812. * @param useScreen defines if screen size must be used (or the current render target if any)
  44813. * @returns a number defining the current render width
  44814. */
  44815. getRenderWidth(useScreen?: boolean): number;
  44816. /**
  44817. * Gets the current render height
  44818. * @param useScreen defines if screen size must be used (or the current render target if any)
  44819. * @returns a number defining the current render height
  44820. */
  44821. getRenderHeight(useScreen?: boolean): number;
  44822. /**
  44823. * Set the WebGL's viewport
  44824. * @param viewport defines the viewport element to be used
  44825. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  44826. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  44827. */
  44828. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44829. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44830. /**
  44831. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  44832. * @param pipelineContext defines the pipeline context to use
  44833. * @param uniformsNames defines the list of uniform names
  44834. * @returns an array of webGL uniform locations
  44835. */
  44836. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44837. /**
  44838. * Gets the lsit of active attributes for a given webGL program
  44839. * @param pipelineContext defines the pipeline context to use
  44840. * @param attributesNames defines the list of attribute names to get
  44841. * @returns an array of indices indicating the offset of each attribute
  44842. */
  44843. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44844. /**
  44845. * Binds an effect to the webGL context
  44846. * @param effect defines the effect to bind
  44847. */
  44848. bindSamplers(effect: Effect): void;
  44849. /**
  44850. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  44851. * @param effect defines the effect to activate
  44852. */
  44853. enableEffect(effect: Effect): void;
  44854. /**
  44855. * Set various states to the webGL context
  44856. * @param culling defines backface culling state
  44857. * @param zOffset defines the value to apply to zOffset (0 by default)
  44858. * @param force defines if states must be applied even if cache is up to date
  44859. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44860. */
  44861. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44862. /**
  44863. * Set the value of an uniform to an array of int32
  44864. * @param uniform defines the webGL uniform location where to store the value
  44865. * @param array defines the array of int32 to store
  44866. */
  44867. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44868. /**
  44869. * Set the value of an uniform to an array of int32 (stored as vec2)
  44870. * @param uniform defines the webGL uniform location where to store the value
  44871. * @param array defines the array of int32 to store
  44872. */
  44873. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44874. /**
  44875. * Set the value of an uniform to an array of int32 (stored as vec3)
  44876. * @param uniform defines the webGL uniform location where to store the value
  44877. * @param array defines the array of int32 to store
  44878. */
  44879. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44880. /**
  44881. * Set the value of an uniform to an array of int32 (stored as vec4)
  44882. * @param uniform defines the webGL uniform location where to store the value
  44883. * @param array defines the array of int32 to store
  44884. */
  44885. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44886. /**
  44887. * Set the value of an uniform to an array of float32
  44888. * @param uniform defines the webGL uniform location where to store the value
  44889. * @param array defines the array of float32 to store
  44890. */
  44891. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44892. /**
  44893. * Set the value of an uniform to an array of float32 (stored as vec2)
  44894. * @param uniform defines the webGL uniform location where to store the value
  44895. * @param array defines the array of float32 to store
  44896. */
  44897. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44898. /**
  44899. * Set the value of an uniform to an array of float32 (stored as vec3)
  44900. * @param uniform defines the webGL uniform location where to store the value
  44901. * @param array defines the array of float32 to store
  44902. */
  44903. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44904. /**
  44905. * Set the value of an uniform to an array of float32 (stored as vec4)
  44906. * @param uniform defines the webGL uniform location where to store the value
  44907. * @param array defines the array of float32 to store
  44908. */
  44909. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44910. /**
  44911. * Set the value of an uniform to an array of number
  44912. * @param uniform defines the webGL uniform location where to store the value
  44913. * @param array defines the array of number to store
  44914. */
  44915. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44916. /**
  44917. * Set the value of an uniform to an array of number (stored as vec2)
  44918. * @param uniform defines the webGL uniform location where to store the value
  44919. * @param array defines the array of number to store
  44920. */
  44921. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44922. /**
  44923. * Set the value of an uniform to an array of number (stored as vec3)
  44924. * @param uniform defines the webGL uniform location where to store the value
  44925. * @param array defines the array of number to store
  44926. */
  44927. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44928. /**
  44929. * Set the value of an uniform to an array of number (stored as vec4)
  44930. * @param uniform defines the webGL uniform location where to store the value
  44931. * @param array defines the array of number to store
  44932. */
  44933. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44934. /**
  44935. * Set the value of an uniform to an array of float32 (stored as matrices)
  44936. * @param uniform defines the webGL uniform location where to store the value
  44937. * @param matrices defines the array of float32 to store
  44938. */
  44939. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44940. /**
  44941. * Set the value of an uniform to a matrix (3x3)
  44942. * @param uniform defines the webGL uniform location where to store the value
  44943. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  44944. */
  44945. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44946. /**
  44947. * Set the value of an uniform to a matrix (2x2)
  44948. * @param uniform defines the webGL uniform location where to store the value
  44949. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  44950. */
  44951. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44952. /**
  44953. * Set the value of an uniform to a number (float)
  44954. * @param uniform defines the webGL uniform location where to store the value
  44955. * @param value defines the float number to store
  44956. */
  44957. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44958. /**
  44959. * Set the value of an uniform to a vec2
  44960. * @param uniform defines the webGL uniform location where to store the value
  44961. * @param x defines the 1st component of the value
  44962. * @param y defines the 2nd component of the value
  44963. */
  44964. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44965. /**
  44966. * Set the value of an uniform to a vec3
  44967. * @param uniform defines the webGL uniform location where to store the value
  44968. * @param x defines the 1st component of the value
  44969. * @param y defines the 2nd component of the value
  44970. * @param z defines the 3rd component of the value
  44971. */
  44972. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44973. /**
  44974. * Set the value of an uniform to a boolean
  44975. * @param uniform defines the webGL uniform location where to store the value
  44976. * @param bool defines the boolean to store
  44977. */
  44978. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44979. /**
  44980. * Set the value of an uniform to a vec4
  44981. * @param uniform defines the webGL uniform location where to store the value
  44982. * @param x defines the 1st component of the value
  44983. * @param y defines the 2nd component of the value
  44984. * @param z defines the 3rd component of the value
  44985. * @param w defines the 4th component of the value
  44986. */
  44987. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44988. /**
  44989. * Sets the current alpha mode
  44990. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44991. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44992. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44993. */
  44994. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44995. /**
  44996. * Bind webGl buffers directly to the webGL context
  44997. * @param vertexBuffers defines the vertex buffer to bind
  44998. * @param indexBuffer defines the index buffer to bind
  44999. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45000. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45001. * @param effect defines the effect associated with the vertex buffer
  45002. */
  45003. bindBuffers(vertexBuffers: {
  45004. [key: string]: VertexBuffer;
  45005. }, indexBuffer: DataBuffer, effect: Effect): void;
  45006. /**
  45007. * Force the entire cache to be cleared
  45008. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45009. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45010. */
  45011. wipeCaches(bruteForce?: boolean): void;
  45012. /**
  45013. * Send a draw order
  45014. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45015. * @param indexStart defines the starting index
  45016. * @param indexCount defines the number of index to draw
  45017. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45018. */
  45019. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45020. /**
  45021. * Draw a list of indexed primitives
  45022. * @param fillMode defines the primitive to use
  45023. * @param indexStart defines the starting index
  45024. * @param indexCount defines the number of index to draw
  45025. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45026. */
  45027. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45028. /**
  45029. * Draw a list of unindexed primitives
  45030. * @param fillMode defines the primitive to use
  45031. * @param verticesStart defines the index of first vertex to draw
  45032. * @param verticesCount defines the count of vertices to draw
  45033. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45034. */
  45035. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45036. /** @hidden */
  45037. _createTexture(): WebGLTexture;
  45038. /** @hidden */
  45039. _releaseTexture(texture: InternalTexture): void;
  45040. /**
  45041. * Usually called from Texture.ts.
  45042. * Passed information to create a WebGLTexture
  45043. * @param urlArg defines a value which contains one of the following:
  45044. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45045. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45046. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45047. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45048. * @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)
  45049. * @param scene needed for loading to the correct scene
  45050. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45051. * @param onLoad optional callback to be called upon successful completion
  45052. * @param onError optional callback to be called upon failure
  45053. * @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
  45054. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45055. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45056. * @param forcedExtension defines the extension to use to pick the right loader
  45057. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45058. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45059. */
  45060. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  45061. /**
  45062. * Creates a new render target texture
  45063. * @param size defines the size of the texture
  45064. * @param options defines the options used to create the texture
  45065. * @returns a new render target texture stored in an InternalTexture
  45066. */
  45067. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45068. /**
  45069. * Update the sampling mode of a given texture
  45070. * @param samplingMode defines the required sampling mode
  45071. * @param texture defines the texture to update
  45072. */
  45073. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45074. /**
  45075. * Binds the frame buffer to the specified texture.
  45076. * @param texture The texture to render to or null for the default canvas
  45077. * @param faceIndex The face of the texture to render to in case of cube texture
  45078. * @param requiredWidth The width of the target to render to
  45079. * @param requiredHeight The height of the target to render to
  45080. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45081. * @param depthStencilTexture The depth stencil texture to use to render
  45082. * @param lodLevel defines le lod level to bind to the frame buffer
  45083. */
  45084. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45085. /**
  45086. * Unbind the current render target texture from the webGL context
  45087. * @param texture defines the render target texture to unbind
  45088. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45089. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45090. */
  45091. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45092. /**
  45093. * Creates a dynamic vertex buffer
  45094. * @param vertices the data for the dynamic vertex buffer
  45095. * @returns the new WebGL dynamic buffer
  45096. */
  45097. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45098. /**
  45099. * Update the content of a dynamic texture
  45100. * @param texture defines the texture to update
  45101. * @param canvas defines the canvas containing the source
  45102. * @param invertY defines if data must be stored with Y axis inverted
  45103. * @param premulAlpha defines if alpha is stored as premultiplied
  45104. * @param format defines the format of the data
  45105. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45106. */
  45107. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45108. /**
  45109. * Gets a boolean indicating if all created effects are ready
  45110. * @returns true if all effects are ready
  45111. */
  45112. areAllEffectsReady(): boolean;
  45113. /**
  45114. * @hidden
  45115. * Get the current error code of the webGL context
  45116. * @returns the error code
  45117. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45118. */
  45119. getError(): number;
  45120. /** @hidden */
  45121. _getUnpackAlignement(): number;
  45122. /** @hidden */
  45123. _unpackFlipY(value: boolean): void;
  45124. /**
  45125. * Update a dynamic index buffer
  45126. * @param indexBuffer defines the target index buffer
  45127. * @param indices defines the data to update
  45128. * @param offset defines the offset in the target index buffer where update should start
  45129. */
  45130. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45131. /**
  45132. * Updates a dynamic vertex buffer.
  45133. * @param vertexBuffer the vertex buffer to update
  45134. * @param vertices the data used to update the vertex buffer
  45135. * @param byteOffset the byte offset of the data (optional)
  45136. * @param byteLength the byte length of the data (optional)
  45137. */
  45138. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45139. /** @hidden */
  45140. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45141. /** @hidden */
  45142. _bindTexture(channel: number, texture: InternalTexture): void;
  45143. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45144. /**
  45145. * 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
  45146. */
  45147. releaseEffects(): void;
  45148. displayLoadingUI(): void;
  45149. hideLoadingUI(): void;
  45150. /** @hidden */
  45151. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45152. /** @hidden */
  45153. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45154. /** @hidden */
  45155. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45156. /** @hidden */
  45157. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45158. }
  45159. }
  45160. declare module BABYLON {
  45161. /** @hidden */
  45162. export class _OcclusionDataStorage {
  45163. /** @hidden */
  45164. occlusionInternalRetryCounter: number;
  45165. /** @hidden */
  45166. isOcclusionQueryInProgress: boolean;
  45167. /** @hidden */
  45168. isOccluded: boolean;
  45169. /** @hidden */
  45170. occlusionRetryCount: number;
  45171. /** @hidden */
  45172. occlusionType: number;
  45173. /** @hidden */
  45174. occlusionQueryAlgorithmType: number;
  45175. }
  45176. interface Engine {
  45177. /**
  45178. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45179. * @return the new query
  45180. */
  45181. createQuery(): WebGLQuery;
  45182. /**
  45183. * Delete and release a webGL query
  45184. * @param query defines the query to delete
  45185. * @return the current engine
  45186. */
  45187. deleteQuery(query: WebGLQuery): Engine;
  45188. /**
  45189. * Check if a given query has resolved and got its value
  45190. * @param query defines the query to check
  45191. * @returns true if the query got its value
  45192. */
  45193. isQueryResultAvailable(query: WebGLQuery): boolean;
  45194. /**
  45195. * Gets the value of a given query
  45196. * @param query defines the query to check
  45197. * @returns the value of the query
  45198. */
  45199. getQueryResult(query: WebGLQuery): number;
  45200. /**
  45201. * Initiates an occlusion query
  45202. * @param algorithmType defines the algorithm to use
  45203. * @param query defines the query to use
  45204. * @returns the current engine
  45205. * @see http://doc.babylonjs.com/features/occlusionquery
  45206. */
  45207. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45208. /**
  45209. * Ends an occlusion query
  45210. * @see http://doc.babylonjs.com/features/occlusionquery
  45211. * @param algorithmType defines the algorithm to use
  45212. * @returns the current engine
  45213. */
  45214. endOcclusionQuery(algorithmType: number): Engine;
  45215. /**
  45216. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45217. * Please note that only one query can be issued at a time
  45218. * @returns a time token used to track the time span
  45219. */
  45220. startTimeQuery(): Nullable<_TimeToken>;
  45221. /**
  45222. * Ends a time query
  45223. * @param token defines the token used to measure the time span
  45224. * @returns the time spent (in ns)
  45225. */
  45226. endTimeQuery(token: _TimeToken): int;
  45227. /** @hidden */
  45228. _currentNonTimestampToken: Nullable<_TimeToken>;
  45229. /** @hidden */
  45230. _createTimeQuery(): WebGLQuery;
  45231. /** @hidden */
  45232. _deleteTimeQuery(query: WebGLQuery): void;
  45233. /** @hidden */
  45234. _getGlAlgorithmType(algorithmType: number): number;
  45235. /** @hidden */
  45236. _getTimeQueryResult(query: WebGLQuery): any;
  45237. /** @hidden */
  45238. _getTimeQueryAvailability(query: WebGLQuery): any;
  45239. }
  45240. interface AbstractMesh {
  45241. /**
  45242. * Backing filed
  45243. * @hidden
  45244. */
  45245. __occlusionDataStorage: _OcclusionDataStorage;
  45246. /**
  45247. * Access property
  45248. * @hidden
  45249. */
  45250. _occlusionDataStorage: _OcclusionDataStorage;
  45251. /**
  45252. * 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.
  45253. * The default value is -1 which means don't break the query and wait till the result
  45254. * @see http://doc.babylonjs.com/features/occlusionquery
  45255. */
  45256. occlusionRetryCount: number;
  45257. /**
  45258. * 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:
  45259. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45260. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45261. * * 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.
  45262. * @see http://doc.babylonjs.com/features/occlusionquery
  45263. */
  45264. occlusionType: number;
  45265. /**
  45266. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45267. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45268. * * 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.
  45269. * @see http://doc.babylonjs.com/features/occlusionquery
  45270. */
  45271. occlusionQueryAlgorithmType: number;
  45272. /**
  45273. * 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
  45274. * @see http://doc.babylonjs.com/features/occlusionquery
  45275. */
  45276. isOccluded: boolean;
  45277. /**
  45278. * Flag to check the progress status of the query
  45279. * @see http://doc.babylonjs.com/features/occlusionquery
  45280. */
  45281. isOcclusionQueryInProgress: boolean;
  45282. }
  45283. }
  45284. declare module BABYLON {
  45285. /** @hidden */
  45286. export var _forceTransformFeedbackToBundle: boolean;
  45287. interface Engine {
  45288. /**
  45289. * Creates a webGL transform feedback object
  45290. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45291. * @returns the webGL transform feedback object
  45292. */
  45293. createTransformFeedback(): WebGLTransformFeedback;
  45294. /**
  45295. * Delete a webGL transform feedback object
  45296. * @param value defines the webGL transform feedback object to delete
  45297. */
  45298. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45299. /**
  45300. * Bind a webGL transform feedback object to the webgl context
  45301. * @param value defines the webGL transform feedback object to bind
  45302. */
  45303. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45304. /**
  45305. * Begins a transform feedback operation
  45306. * @param usePoints defines if points or triangles must be used
  45307. */
  45308. beginTransformFeedback(usePoints: boolean): void;
  45309. /**
  45310. * Ends a transform feedback operation
  45311. */
  45312. endTransformFeedback(): void;
  45313. /**
  45314. * Specify the varyings to use with transform feedback
  45315. * @param program defines the associated webGL program
  45316. * @param value defines the list of strings representing the varying names
  45317. */
  45318. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45319. /**
  45320. * Bind a webGL buffer for a transform feedback operation
  45321. * @param value defines the webGL buffer to bind
  45322. */
  45323. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45324. }
  45325. }
  45326. declare module BABYLON {
  45327. /**
  45328. * Creation options of the multi render target texture.
  45329. */
  45330. export interface IMultiRenderTargetOptions {
  45331. /**
  45332. * Define if the texture needs to create mip maps after render.
  45333. */
  45334. generateMipMaps?: boolean;
  45335. /**
  45336. * Define the types of all the draw buffers we want to create
  45337. */
  45338. types?: number[];
  45339. /**
  45340. * Define the sampling modes of all the draw buffers we want to create
  45341. */
  45342. samplingModes?: number[];
  45343. /**
  45344. * Define if a depth buffer is required
  45345. */
  45346. generateDepthBuffer?: boolean;
  45347. /**
  45348. * Define if a stencil buffer is required
  45349. */
  45350. generateStencilBuffer?: boolean;
  45351. /**
  45352. * Define if a depth texture is required instead of a depth buffer
  45353. */
  45354. generateDepthTexture?: boolean;
  45355. /**
  45356. * Define the number of desired draw buffers
  45357. */
  45358. textureCount?: number;
  45359. /**
  45360. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45361. */
  45362. doNotChangeAspectRatio?: boolean;
  45363. /**
  45364. * Define the default type of the buffers we are creating
  45365. */
  45366. defaultType?: number;
  45367. }
  45368. /**
  45369. * A multi render target, like a render target provides the ability to render to a texture.
  45370. * Unlike the render target, it can render to several draw buffers in one draw.
  45371. * This is specially interesting in deferred rendering or for any effects requiring more than
  45372. * just one color from a single pass.
  45373. */
  45374. export class MultiRenderTarget extends RenderTargetTexture {
  45375. private _internalTextures;
  45376. private _textures;
  45377. private _multiRenderTargetOptions;
  45378. /**
  45379. * Get if draw buffers are currently supported by the used hardware and browser.
  45380. */
  45381. readonly isSupported: boolean;
  45382. /**
  45383. * Get the list of textures generated by the multi render target.
  45384. */
  45385. readonly textures: Texture[];
  45386. /**
  45387. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45388. */
  45389. readonly depthTexture: Texture;
  45390. /**
  45391. * Set the wrapping mode on U of all the textures we are rendering to.
  45392. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45393. */
  45394. wrapU: number;
  45395. /**
  45396. * Set the wrapping mode on V of all the textures we are rendering to.
  45397. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45398. */
  45399. wrapV: number;
  45400. /**
  45401. * Instantiate a new multi render target texture.
  45402. * A multi render target, like a render target provides the ability to render to a texture.
  45403. * Unlike the render target, it can render to several draw buffers in one draw.
  45404. * This is specially interesting in deferred rendering or for any effects requiring more than
  45405. * just one color from a single pass.
  45406. * @param name Define the name of the texture
  45407. * @param size Define the size of the buffers to render to
  45408. * @param count Define the number of target we are rendering into
  45409. * @param scene Define the scene the texture belongs to
  45410. * @param options Define the options used to create the multi render target
  45411. */
  45412. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45413. /** @hidden */
  45414. _rebuild(): void;
  45415. private _createInternalTextures;
  45416. private _createTextures;
  45417. /**
  45418. * Define the number of samples used if MSAA is enabled.
  45419. */
  45420. samples: number;
  45421. /**
  45422. * Resize all the textures in the multi render target.
  45423. * Be carrefull as it will recreate all the data in the new texture.
  45424. * @param size Define the new size
  45425. */
  45426. resize(size: any): void;
  45427. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45428. /**
  45429. * Dispose the render targets and their associated resources
  45430. */
  45431. dispose(): void;
  45432. /**
  45433. * Release all the underlying texture used as draw buffers.
  45434. */
  45435. releaseInternalTextures(): void;
  45436. }
  45437. }
  45438. declare module BABYLON {
  45439. interface ThinEngine {
  45440. /**
  45441. * Unbind a list of render target textures from the webGL context
  45442. * This is used only when drawBuffer extension or webGL2 are active
  45443. * @param textures defines the render target textures to unbind
  45444. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45445. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45446. */
  45447. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45448. /**
  45449. * Create a multi render target texture
  45450. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45451. * @param size defines the size of the texture
  45452. * @param options defines the creation options
  45453. * @returns the cube texture as an InternalTexture
  45454. */
  45455. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45456. /**
  45457. * Update the sample count for a given multiple render target texture
  45458. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45459. * @param textures defines the textures to update
  45460. * @param samples defines the sample count to set
  45461. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45462. */
  45463. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45464. }
  45465. }
  45466. declare module BABYLON {
  45467. /**
  45468. * Class used to define an additional view for the engine
  45469. * @see https://doc.babylonjs.com/how_to/multi_canvases
  45470. */
  45471. export class EngineView {
  45472. /** Defines the canvas where to render the view */
  45473. target: HTMLCanvasElement;
  45474. /** Defines an optional camera used to render the view (will use active camera else) */
  45475. camera?: Camera;
  45476. }
  45477. interface Engine {
  45478. /**
  45479. * Gets or sets the HTML element to use for attaching events
  45480. */
  45481. inputElement: Nullable<HTMLElement>;
  45482. /**
  45483. * Gets the current engine view
  45484. * @see https://doc.babylonjs.com/how_to/multi_canvases
  45485. */
  45486. activeView: Nullable<EngineView>;
  45487. /** Gets or sets the list of views */
  45488. views: EngineView[];
  45489. /**
  45490. * Register a new child canvas
  45491. * @param canvas defines the canvas to register
  45492. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  45493. * @returns the associated view
  45494. */
  45495. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  45496. /**
  45497. * Remove a registered child canvas
  45498. * @param canvas defines the canvas to remove
  45499. * @returns the current engine
  45500. */
  45501. unRegisterView(canvas: HTMLCanvasElement): Engine;
  45502. }
  45503. }
  45504. declare module BABYLON {
  45505. /**
  45506. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  45507. */
  45508. export interface CubeMapInfo {
  45509. /**
  45510. * The pixel array for the front face.
  45511. * This is stored in format, left to right, up to down format.
  45512. */
  45513. front: Nullable<ArrayBufferView>;
  45514. /**
  45515. * The pixel array for the back face.
  45516. * This is stored in format, left to right, up to down format.
  45517. */
  45518. back: Nullable<ArrayBufferView>;
  45519. /**
  45520. * The pixel array for the left face.
  45521. * This is stored in format, left to right, up to down format.
  45522. */
  45523. left: Nullable<ArrayBufferView>;
  45524. /**
  45525. * The pixel array for the right face.
  45526. * This is stored in format, left to right, up to down format.
  45527. */
  45528. right: Nullable<ArrayBufferView>;
  45529. /**
  45530. * The pixel array for the up face.
  45531. * This is stored in format, left to right, up to down format.
  45532. */
  45533. up: Nullable<ArrayBufferView>;
  45534. /**
  45535. * The pixel array for the down face.
  45536. * This is stored in format, left to right, up to down format.
  45537. */
  45538. down: Nullable<ArrayBufferView>;
  45539. /**
  45540. * The size of the cubemap stored.
  45541. *
  45542. * Each faces will be size * size pixels.
  45543. */
  45544. size: number;
  45545. /**
  45546. * The format of the texture.
  45547. *
  45548. * RGBA, RGB.
  45549. */
  45550. format: number;
  45551. /**
  45552. * The type of the texture data.
  45553. *
  45554. * UNSIGNED_INT, FLOAT.
  45555. */
  45556. type: number;
  45557. /**
  45558. * Specifies whether the texture is in gamma space.
  45559. */
  45560. gammaSpace: boolean;
  45561. }
  45562. /**
  45563. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  45564. */
  45565. export class PanoramaToCubeMapTools {
  45566. private static FACE_FRONT;
  45567. private static FACE_BACK;
  45568. private static FACE_RIGHT;
  45569. private static FACE_LEFT;
  45570. private static FACE_DOWN;
  45571. private static FACE_UP;
  45572. /**
  45573. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  45574. *
  45575. * @param float32Array The source data.
  45576. * @param inputWidth The width of the input panorama.
  45577. * @param inputHeight The height of the input panorama.
  45578. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  45579. * @return The cubemap data
  45580. */
  45581. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  45582. private static CreateCubemapTexture;
  45583. private static CalcProjectionSpherical;
  45584. }
  45585. }
  45586. declare module BABYLON {
  45587. /**
  45588. * Helper class dealing with the extraction of spherical polynomial dataArray
  45589. * from a cube map.
  45590. */
  45591. export class CubeMapToSphericalPolynomialTools {
  45592. private static FileFaces;
  45593. /**
  45594. * Converts a texture to the according Spherical Polynomial data.
  45595. * This extracts the first 3 orders only as they are the only one used in the lighting.
  45596. *
  45597. * @param texture The texture to extract the information from.
  45598. * @return The Spherical Polynomial data.
  45599. */
  45600. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  45601. /**
  45602. * Converts a cubemap to the according Spherical Polynomial data.
  45603. * This extracts the first 3 orders only as they are the only one used in the lighting.
  45604. *
  45605. * @param cubeInfo The Cube map to extract the information from.
  45606. * @return The Spherical Polynomial data.
  45607. */
  45608. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  45609. }
  45610. }
  45611. declare module BABYLON {
  45612. interface BaseTexture {
  45613. /**
  45614. * Get the polynomial representation of the texture data.
  45615. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45616. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45617. */
  45618. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45619. }
  45620. }
  45621. declare module BABYLON {
  45622. /** @hidden */
  45623. export var rgbdEncodePixelShader: {
  45624. name: string;
  45625. shader: string;
  45626. };
  45627. }
  45628. declare module BABYLON {
  45629. /** @hidden */
  45630. export var rgbdDecodePixelShader: {
  45631. name: string;
  45632. shader: string;
  45633. };
  45634. }
  45635. declare module BABYLON {
  45636. /**
  45637. * Raw texture data and descriptor sufficient for WebGL texture upload
  45638. */
  45639. export interface EnvironmentTextureInfo {
  45640. /**
  45641. * Version of the environment map
  45642. */
  45643. version: number;
  45644. /**
  45645. * Width of image
  45646. */
  45647. width: number;
  45648. /**
  45649. * Irradiance information stored in the file.
  45650. */
  45651. irradiance: any;
  45652. /**
  45653. * Specular information stored in the file.
  45654. */
  45655. specular: any;
  45656. }
  45657. /**
  45658. * Defines One Image in the file. It requires only the position in the file
  45659. * as well as the length.
  45660. */
  45661. interface BufferImageData {
  45662. /**
  45663. * Length of the image data.
  45664. */
  45665. length: number;
  45666. /**
  45667. * Position of the data from the null terminator delimiting the end of the JSON.
  45668. */
  45669. position: number;
  45670. }
  45671. /**
  45672. * Defines the specular data enclosed in the file.
  45673. * This corresponds to the version 1 of the data.
  45674. */
  45675. export interface EnvironmentTextureSpecularInfoV1 {
  45676. /**
  45677. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45678. */
  45679. specularDataPosition?: number;
  45680. /**
  45681. * This contains all the images data needed to reconstruct the cubemap.
  45682. */
  45683. mipmaps: Array<BufferImageData>;
  45684. /**
  45685. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45686. */
  45687. lodGenerationScale: number;
  45688. }
  45689. /**
  45690. * Sets of helpers addressing the serialization and deserialization of environment texture
  45691. * stored in a BabylonJS env file.
  45692. * Those files are usually stored as .env files.
  45693. */
  45694. export class EnvironmentTextureTools {
  45695. /**
  45696. * Magic number identifying the env file.
  45697. */
  45698. private static _MagicBytes;
  45699. /**
  45700. * Gets the environment info from an env file.
  45701. * @param data The array buffer containing the .env bytes.
  45702. * @returns the environment file info (the json header) if successfully parsed.
  45703. */
  45704. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45705. /**
  45706. * Creates an environment texture from a loaded cube texture.
  45707. * @param texture defines the cube texture to convert in env file
  45708. * @return a promise containing the environment data if succesfull.
  45709. */
  45710. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45711. /**
  45712. * Creates a JSON representation of the spherical data.
  45713. * @param texture defines the texture containing the polynomials
  45714. * @return the JSON representation of the spherical info
  45715. */
  45716. private static _CreateEnvTextureIrradiance;
  45717. /**
  45718. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45719. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45720. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45721. * @return the views described by info providing access to the underlying buffer
  45722. */
  45723. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45724. /**
  45725. * Uploads the texture info contained in the env file to the GPU.
  45726. * @param texture defines the internal texture to upload to
  45727. * @param arrayBuffer defines the buffer cotaining the data to load
  45728. * @param info defines the texture info retrieved through the GetEnvInfo method
  45729. * @returns a promise
  45730. */
  45731. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45732. private static _OnImageReadyAsync;
  45733. /**
  45734. * Uploads the levels of image data to the GPU.
  45735. * @param texture defines the internal texture to upload to
  45736. * @param imageData defines the array buffer views of image data [mipmap][face]
  45737. * @returns a promise
  45738. */
  45739. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45740. /**
  45741. * Uploads spherical polynomials information to the texture.
  45742. * @param texture defines the texture we are trying to upload the information to
  45743. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45744. */
  45745. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45746. /** @hidden */
  45747. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45748. }
  45749. }
  45750. declare module BABYLON {
  45751. /**
  45752. * Contains position and normal vectors for a vertex
  45753. */
  45754. export class PositionNormalVertex {
  45755. /** the position of the vertex (defaut: 0,0,0) */
  45756. position: Vector3;
  45757. /** the normal of the vertex (defaut: 0,1,0) */
  45758. normal: Vector3;
  45759. /**
  45760. * Creates a PositionNormalVertex
  45761. * @param position the position of the vertex (defaut: 0,0,0)
  45762. * @param normal the normal of the vertex (defaut: 0,1,0)
  45763. */
  45764. constructor(
  45765. /** the position of the vertex (defaut: 0,0,0) */
  45766. position?: Vector3,
  45767. /** the normal of the vertex (defaut: 0,1,0) */
  45768. normal?: Vector3);
  45769. /**
  45770. * Clones the PositionNormalVertex
  45771. * @returns the cloned PositionNormalVertex
  45772. */
  45773. clone(): PositionNormalVertex;
  45774. }
  45775. /**
  45776. * Contains position, normal and uv vectors for a vertex
  45777. */
  45778. export class PositionNormalTextureVertex {
  45779. /** the position of the vertex (defaut: 0,0,0) */
  45780. position: Vector3;
  45781. /** the normal of the vertex (defaut: 0,1,0) */
  45782. normal: Vector3;
  45783. /** the uv of the vertex (default: 0,0) */
  45784. uv: Vector2;
  45785. /**
  45786. * Creates a PositionNormalTextureVertex
  45787. * @param position the position of the vertex (defaut: 0,0,0)
  45788. * @param normal the normal of the vertex (defaut: 0,1,0)
  45789. * @param uv the uv of the vertex (default: 0,0)
  45790. */
  45791. constructor(
  45792. /** the position of the vertex (defaut: 0,0,0) */
  45793. position?: Vector3,
  45794. /** the normal of the vertex (defaut: 0,1,0) */
  45795. normal?: Vector3,
  45796. /** the uv of the vertex (default: 0,0) */
  45797. uv?: Vector2);
  45798. /**
  45799. * Clones the PositionNormalTextureVertex
  45800. * @returns the cloned PositionNormalTextureVertex
  45801. */
  45802. clone(): PositionNormalTextureVertex;
  45803. }
  45804. }
  45805. declare module BABYLON {
  45806. /** @hidden */
  45807. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45808. private _genericAttributeLocation;
  45809. private _varyingLocationCount;
  45810. private _varyingLocationMap;
  45811. private _replacements;
  45812. private _textureCount;
  45813. private _uniforms;
  45814. lineProcessor(line: string): string;
  45815. attributeProcessor(attribute: string): string;
  45816. varyingProcessor(varying: string, isFragment: boolean): string;
  45817. uniformProcessor(uniform: string): string;
  45818. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45819. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45820. }
  45821. }
  45822. declare module BABYLON {
  45823. /**
  45824. * Container for accessors for natively-stored mesh data buffers.
  45825. */
  45826. class NativeDataBuffer extends DataBuffer {
  45827. /**
  45828. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45829. */
  45830. nativeIndexBuffer?: any;
  45831. /**
  45832. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45833. */
  45834. nativeVertexBuffer?: any;
  45835. }
  45836. /** @hidden */
  45837. class NativeTexture extends InternalTexture {
  45838. getInternalTexture(): InternalTexture;
  45839. getViewCount(): number;
  45840. }
  45841. /** @hidden */
  45842. export class NativeEngine extends Engine {
  45843. private readonly _native;
  45844. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  45845. private readonly INVALID_HANDLE;
  45846. getHardwareScalingLevel(): number;
  45847. constructor();
  45848. /**
  45849. * Can be used to override the current requestAnimationFrame requester.
  45850. * @hidden
  45851. */
  45852. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  45853. /**
  45854. * Override default engine behavior.
  45855. * @param color
  45856. * @param backBuffer
  45857. * @param depth
  45858. * @param stencil
  45859. */
  45860. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  45861. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45862. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45863. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45864. recordVertexArrayObject(vertexBuffers: {
  45865. [key: string]: VertexBuffer;
  45866. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45867. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45868. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45869. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45870. /**
  45871. * Draw a list of indexed primitives
  45872. * @param fillMode defines the primitive to use
  45873. * @param indexStart defines the starting index
  45874. * @param indexCount defines the number of index to draw
  45875. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45876. */
  45877. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45878. /**
  45879. * Draw a list of unindexed primitives
  45880. * @param fillMode defines the primitive to use
  45881. * @param verticesStart defines the index of first vertex to draw
  45882. * @param verticesCount defines the count of vertices to draw
  45883. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45884. */
  45885. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45886. createPipelineContext(): IPipelineContext;
  45887. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45888. /** @hidden */
  45889. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45890. /** @hidden */
  45891. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45892. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45893. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45894. protected _setProgram(program: WebGLProgram): void;
  45895. _releaseEffect(effect: Effect): void;
  45896. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45897. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45898. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45899. bindSamplers(effect: Effect): void;
  45900. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45901. getRenderWidth(useScreen?: boolean): number;
  45902. getRenderHeight(useScreen?: boolean): number;
  45903. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45904. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45905. /**
  45906. * Set the z offset to apply to current rendering
  45907. * @param value defines the offset to apply
  45908. */
  45909. setZOffset(value: number): void;
  45910. /**
  45911. * Gets the current value of the zOffset
  45912. * @returns the current zOffset state
  45913. */
  45914. getZOffset(): number;
  45915. /**
  45916. * Enable or disable depth buffering
  45917. * @param enable defines the state to set
  45918. */
  45919. setDepthBuffer(enable: boolean): void;
  45920. /**
  45921. * Gets a boolean indicating if depth writing is enabled
  45922. * @returns the current depth writing state
  45923. */
  45924. getDepthWrite(): boolean;
  45925. /**
  45926. * Enable or disable depth writing
  45927. * @param enable defines the state to set
  45928. */
  45929. setDepthWrite(enable: boolean): void;
  45930. /**
  45931. * Enable or disable color writing
  45932. * @param enable defines the state to set
  45933. */
  45934. setColorWrite(enable: boolean): void;
  45935. /**
  45936. * Gets a boolean indicating if color writing is enabled
  45937. * @returns the current color writing state
  45938. */
  45939. getColorWrite(): boolean;
  45940. /**
  45941. * Sets alpha constants used by some alpha blending modes
  45942. * @param r defines the red component
  45943. * @param g defines the green component
  45944. * @param b defines the blue component
  45945. * @param a defines the alpha component
  45946. */
  45947. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45948. /**
  45949. * Sets the current alpha mode
  45950. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45951. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45952. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45953. */
  45954. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45955. /**
  45956. * Gets the current alpha mode
  45957. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45958. * @returns the current alpha mode
  45959. */
  45960. getAlphaMode(): number;
  45961. setInt(uniform: WebGLUniformLocation, int: number): void;
  45962. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45963. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45964. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45965. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45966. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45967. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45968. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45969. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45970. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45971. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45972. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45973. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45974. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45975. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45976. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45977. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45978. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45979. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45980. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45981. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45982. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45983. wipeCaches(bruteForce?: boolean): void;
  45984. _createTexture(): WebGLTexture;
  45985. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45986. /**
  45987. * Usually called from BABYLON.Texture.ts.
  45988. * Passed information to create a WebGLTexture
  45989. * @param urlArg defines a value which contains one of the following:
  45990. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45991. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45992. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45993. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45994. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45995. * @param scene needed for loading to the correct scene
  45996. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45997. * @param onLoad optional callback to be called upon successful completion
  45998. * @param onError optional callback to be called upon failure
  45999. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46000. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46001. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46002. * @param forcedExtension defines the extension to use to pick the right loader
  46003. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46004. */
  46005. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  46006. /**
  46007. * Creates a cube texture
  46008. * @param rootUrl defines the url where the files to load is located
  46009. * @param scene defines the current scene
  46010. * @param files defines the list of files to load (1 per face)
  46011. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46012. * @param onLoad defines an optional callback raised when the texture is loaded
  46013. * @param onError defines an optional callback raised if there is an issue to load the texture
  46014. * @param format defines the format of the data
  46015. * @param forcedExtension defines the extension to use to pick the right loader
  46016. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46017. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46018. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46019. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46020. * @returns the cube texture as an InternalTexture
  46021. */
  46022. 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;
  46023. private _getSamplingFilter;
  46024. private static _GetNativeTextureFormat;
  46025. createRenderTargetTexture(size: number | {
  46026. width: number;
  46027. height: number;
  46028. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  46029. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46030. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46031. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46032. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46033. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46034. /**
  46035. * Updates a dynamic vertex buffer.
  46036. * @param vertexBuffer the vertex buffer to update
  46037. * @param data the data used to update the vertex buffer
  46038. * @param byteOffset the byte offset of the data (optional)
  46039. * @param byteLength the byte length of the data (optional)
  46040. */
  46041. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46042. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46043. private _updateAnisotropicLevel;
  46044. private _getAddressMode;
  46045. /** @hidden */
  46046. _bindTexture(channel: number, texture: InternalTexture): void;
  46047. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46048. releaseEffects(): void;
  46049. /** @hidden */
  46050. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46051. /** @hidden */
  46052. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46053. /** @hidden */
  46054. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46055. /** @hidden */
  46056. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46057. }
  46058. }
  46059. declare module BABYLON {
  46060. /**
  46061. * Gather the list of clipboard event types as constants.
  46062. */
  46063. export class ClipboardEventTypes {
  46064. /**
  46065. * The clipboard event is fired when a copy command is active (pressed).
  46066. */
  46067. static readonly COPY: number;
  46068. /**
  46069. * The clipboard event is fired when a cut command is active (pressed).
  46070. */
  46071. static readonly CUT: number;
  46072. /**
  46073. * The clipboard event is fired when a paste command is active (pressed).
  46074. */
  46075. static readonly PASTE: number;
  46076. }
  46077. /**
  46078. * This class is used to store clipboard related info for the onClipboardObservable event.
  46079. */
  46080. export class ClipboardInfo {
  46081. /**
  46082. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46083. */
  46084. type: number;
  46085. /**
  46086. * Defines the related dom event
  46087. */
  46088. event: ClipboardEvent;
  46089. /**
  46090. *Creates an instance of ClipboardInfo.
  46091. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46092. * @param event Defines the related dom event
  46093. */
  46094. constructor(
  46095. /**
  46096. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46097. */
  46098. type: number,
  46099. /**
  46100. * Defines the related dom event
  46101. */
  46102. event: ClipboardEvent);
  46103. /**
  46104. * Get the clipboard event's type from the keycode.
  46105. * @param keyCode Defines the keyCode for the current keyboard event.
  46106. * @return {number}
  46107. */
  46108. static GetTypeFromCharacter(keyCode: number): number;
  46109. }
  46110. }
  46111. declare module BABYLON {
  46112. /**
  46113. * Google Daydream controller
  46114. */
  46115. export class DaydreamController extends WebVRController {
  46116. /**
  46117. * Base Url for the controller model.
  46118. */
  46119. static MODEL_BASE_URL: string;
  46120. /**
  46121. * File name for the controller model.
  46122. */
  46123. static MODEL_FILENAME: string;
  46124. /**
  46125. * Gamepad Id prefix used to identify Daydream Controller.
  46126. */
  46127. static readonly GAMEPAD_ID_PREFIX: string;
  46128. /**
  46129. * Creates a new DaydreamController from a gamepad
  46130. * @param vrGamepad the gamepad that the controller should be created from
  46131. */
  46132. constructor(vrGamepad: any);
  46133. /**
  46134. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46135. * @param scene scene in which to add meshes
  46136. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46137. */
  46138. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46139. /**
  46140. * Called once for each button that changed state since the last frame
  46141. * @param buttonIdx Which button index changed
  46142. * @param state New state of the button
  46143. * @param changes Which properties on the state changed since last frame
  46144. */
  46145. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46146. }
  46147. }
  46148. declare module BABYLON {
  46149. /**
  46150. * Gear VR Controller
  46151. */
  46152. export class GearVRController extends WebVRController {
  46153. /**
  46154. * Base Url for the controller model.
  46155. */
  46156. static MODEL_BASE_URL: string;
  46157. /**
  46158. * File name for the controller model.
  46159. */
  46160. static MODEL_FILENAME: string;
  46161. /**
  46162. * Gamepad Id prefix used to identify this controller.
  46163. */
  46164. static readonly GAMEPAD_ID_PREFIX: string;
  46165. private readonly _buttonIndexToObservableNameMap;
  46166. /**
  46167. * Creates a new GearVRController from a gamepad
  46168. * @param vrGamepad the gamepad that the controller should be created from
  46169. */
  46170. constructor(vrGamepad: any);
  46171. /**
  46172. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46173. * @param scene scene in which to add meshes
  46174. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46175. */
  46176. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46177. /**
  46178. * Called once for each button that changed state since the last frame
  46179. * @param buttonIdx Which button index changed
  46180. * @param state New state of the button
  46181. * @param changes Which properties on the state changed since last frame
  46182. */
  46183. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46184. }
  46185. }
  46186. declare module BABYLON {
  46187. /**
  46188. * Class containing static functions to help procedurally build meshes
  46189. */
  46190. export class PolyhedronBuilder {
  46191. /**
  46192. * Creates a polyhedron mesh
  46193. * * 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
  46194. * * The parameter `size` (positive float, default 1) sets the polygon size
  46195. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46196. * * 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`
  46197. * * 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
  46198. * * 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)`)
  46199. * * 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
  46200. * * 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
  46201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46202. * * 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
  46203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46204. * @param name defines the name of the mesh
  46205. * @param options defines the options used to create the mesh
  46206. * @param scene defines the hosting scene
  46207. * @returns the polyhedron mesh
  46208. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46209. */
  46210. static CreatePolyhedron(name: string, options: {
  46211. type?: number;
  46212. size?: number;
  46213. sizeX?: number;
  46214. sizeY?: number;
  46215. sizeZ?: number;
  46216. custom?: any;
  46217. faceUV?: Vector4[];
  46218. faceColors?: Color4[];
  46219. flat?: boolean;
  46220. updatable?: boolean;
  46221. sideOrientation?: number;
  46222. frontUVs?: Vector4;
  46223. backUVs?: Vector4;
  46224. }, scene?: Nullable<Scene>): Mesh;
  46225. }
  46226. }
  46227. declare module BABYLON {
  46228. /**
  46229. * Gizmo that enables scaling a mesh along 3 axis
  46230. */
  46231. export class ScaleGizmo extends Gizmo {
  46232. /**
  46233. * Internal gizmo used for interactions on the x axis
  46234. */
  46235. xGizmo: AxisScaleGizmo;
  46236. /**
  46237. * Internal gizmo used for interactions on the y axis
  46238. */
  46239. yGizmo: AxisScaleGizmo;
  46240. /**
  46241. * Internal gizmo used for interactions on the z axis
  46242. */
  46243. zGizmo: AxisScaleGizmo;
  46244. /**
  46245. * Internal gizmo used to scale all axis equally
  46246. */
  46247. uniformScaleGizmo: AxisScaleGizmo;
  46248. private _meshAttached;
  46249. private _updateGizmoRotationToMatchAttachedMesh;
  46250. private _snapDistance;
  46251. private _scaleRatio;
  46252. private _uniformScalingMesh;
  46253. private _octahedron;
  46254. private _sensitivity;
  46255. /** Fires an event when any of it's sub gizmos are dragged */
  46256. onDragStartObservable: Observable<unknown>;
  46257. /** Fires an event when any of it's sub gizmos are released from dragging */
  46258. onDragEndObservable: Observable<unknown>;
  46259. attachedMesh: Nullable<AbstractMesh>;
  46260. /**
  46261. * Creates a ScaleGizmo
  46262. * @param gizmoLayer The utility layer the gizmo will be added to
  46263. */
  46264. constructor(gizmoLayer?: UtilityLayerRenderer);
  46265. updateGizmoRotationToMatchAttachedMesh: boolean;
  46266. /**
  46267. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46268. */
  46269. snapDistance: number;
  46270. /**
  46271. * Ratio for the scale of the gizmo (Default: 1)
  46272. */
  46273. scaleRatio: number;
  46274. /**
  46275. * Sensitivity factor for dragging (Default: 1)
  46276. */
  46277. sensitivity: number;
  46278. /**
  46279. * Disposes of the gizmo
  46280. */
  46281. dispose(): void;
  46282. }
  46283. }
  46284. declare module BABYLON {
  46285. /**
  46286. * Single axis scale gizmo
  46287. */
  46288. export class AxisScaleGizmo extends Gizmo {
  46289. /**
  46290. * Drag behavior responsible for the gizmos dragging interactions
  46291. */
  46292. dragBehavior: PointerDragBehavior;
  46293. private _pointerObserver;
  46294. /**
  46295. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46296. */
  46297. snapDistance: number;
  46298. /**
  46299. * Event that fires each time the gizmo snaps to a new location.
  46300. * * snapDistance is the the change in distance
  46301. */
  46302. onSnapObservable: Observable<{
  46303. snapDistance: number;
  46304. }>;
  46305. /**
  46306. * If the scaling operation should be done on all axis (default: false)
  46307. */
  46308. uniformScaling: boolean;
  46309. /**
  46310. * Custom sensitivity value for the drag strength
  46311. */
  46312. sensitivity: number;
  46313. private _isEnabled;
  46314. private _parent;
  46315. private _arrow;
  46316. private _coloredMaterial;
  46317. private _hoverMaterial;
  46318. /**
  46319. * Creates an AxisScaleGizmo
  46320. * @param gizmoLayer The utility layer the gizmo will be added to
  46321. * @param dragAxis The axis which the gizmo will be able to scale on
  46322. * @param color The color of the gizmo
  46323. */
  46324. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46325. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46326. /**
  46327. * If the gizmo is enabled
  46328. */
  46329. isEnabled: boolean;
  46330. /**
  46331. * Disposes of the gizmo
  46332. */
  46333. dispose(): void;
  46334. /**
  46335. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46336. * @param mesh The mesh to replace the default mesh of the gizmo
  46337. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46338. */
  46339. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46340. }
  46341. }
  46342. declare module BABYLON {
  46343. /**
  46344. * Bounding box gizmo
  46345. */
  46346. export class BoundingBoxGizmo extends Gizmo {
  46347. private _lineBoundingBox;
  46348. private _rotateSpheresParent;
  46349. private _scaleBoxesParent;
  46350. private _boundingDimensions;
  46351. private _renderObserver;
  46352. private _pointerObserver;
  46353. private _scaleDragSpeed;
  46354. private _tmpQuaternion;
  46355. private _tmpVector;
  46356. private _tmpRotationMatrix;
  46357. /**
  46358. * 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)
  46359. */
  46360. ignoreChildren: boolean;
  46361. /**
  46362. * 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)
  46363. */
  46364. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46365. /**
  46366. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46367. */
  46368. rotationSphereSize: number;
  46369. /**
  46370. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46371. */
  46372. scaleBoxSize: number;
  46373. /**
  46374. * 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)
  46375. */
  46376. fixedDragMeshScreenSize: boolean;
  46377. /**
  46378. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46379. */
  46380. fixedDragMeshScreenSizeDistanceFactor: number;
  46381. /**
  46382. * Fired when a rotation sphere or scale box is dragged
  46383. */
  46384. onDragStartObservable: Observable<{}>;
  46385. /**
  46386. * Fired when a scale box is dragged
  46387. */
  46388. onScaleBoxDragObservable: Observable<{}>;
  46389. /**
  46390. * Fired when a scale box drag is ended
  46391. */
  46392. onScaleBoxDragEndObservable: Observable<{}>;
  46393. /**
  46394. * Fired when a rotation sphere is dragged
  46395. */
  46396. onRotationSphereDragObservable: Observable<{}>;
  46397. /**
  46398. * Fired when a rotation sphere drag is ended
  46399. */
  46400. onRotationSphereDragEndObservable: Observable<{}>;
  46401. /**
  46402. * 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)
  46403. */
  46404. scalePivot: Nullable<Vector3>;
  46405. /**
  46406. * Mesh used as a pivot to rotate the attached mesh
  46407. */
  46408. private _anchorMesh;
  46409. private _existingMeshScale;
  46410. private _dragMesh;
  46411. private pointerDragBehavior;
  46412. private coloredMaterial;
  46413. private hoverColoredMaterial;
  46414. /**
  46415. * Sets the color of the bounding box gizmo
  46416. * @param color the color to set
  46417. */
  46418. setColor(color: Color3): void;
  46419. /**
  46420. * Creates an BoundingBoxGizmo
  46421. * @param gizmoLayer The utility layer the gizmo will be added to
  46422. * @param color The color of the gizmo
  46423. */
  46424. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46425. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46426. private _selectNode;
  46427. /**
  46428. * Updates the bounding box information for the Gizmo
  46429. */
  46430. updateBoundingBox(): void;
  46431. private _updateRotationSpheres;
  46432. private _updateScaleBoxes;
  46433. /**
  46434. * Enables rotation on the specified axis and disables rotation on the others
  46435. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46436. */
  46437. setEnabledRotationAxis(axis: string): void;
  46438. /**
  46439. * Enables/disables scaling
  46440. * @param enable if scaling should be enabled
  46441. */
  46442. setEnabledScaling(enable: boolean): void;
  46443. private _updateDummy;
  46444. /**
  46445. * Enables a pointer drag behavior on the bounding box of the gizmo
  46446. */
  46447. enableDragBehavior(): void;
  46448. /**
  46449. * Disposes of the gizmo
  46450. */
  46451. dispose(): void;
  46452. /**
  46453. * 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)
  46454. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46455. * @returns the bounding box mesh with the passed in mesh as a child
  46456. */
  46457. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46458. /**
  46459. * CustomMeshes are not supported by this gizmo
  46460. * @param mesh The mesh to replace the default mesh of the gizmo
  46461. */
  46462. setCustomMesh(mesh: Mesh): void;
  46463. }
  46464. }
  46465. declare module BABYLON {
  46466. /**
  46467. * Single plane rotation gizmo
  46468. */
  46469. export class PlaneRotationGizmo extends Gizmo {
  46470. /**
  46471. * Drag behavior responsible for the gizmos dragging interactions
  46472. */
  46473. dragBehavior: PointerDragBehavior;
  46474. private _pointerObserver;
  46475. /**
  46476. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46477. */
  46478. snapDistance: number;
  46479. /**
  46480. * Event that fires each time the gizmo snaps to a new location.
  46481. * * snapDistance is the the change in distance
  46482. */
  46483. onSnapObservable: Observable<{
  46484. snapDistance: number;
  46485. }>;
  46486. private _isEnabled;
  46487. private _parent;
  46488. /**
  46489. * Creates a PlaneRotationGizmo
  46490. * @param gizmoLayer The utility layer the gizmo will be added to
  46491. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46492. * @param color The color of the gizmo
  46493. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46494. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46495. */
  46496. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46497. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46498. /**
  46499. * If the gizmo is enabled
  46500. */
  46501. isEnabled: boolean;
  46502. /**
  46503. * Disposes of the gizmo
  46504. */
  46505. dispose(): void;
  46506. }
  46507. }
  46508. declare module BABYLON {
  46509. /**
  46510. * Gizmo that enables rotating a mesh along 3 axis
  46511. */
  46512. export class RotationGizmo extends Gizmo {
  46513. /**
  46514. * Internal gizmo used for interactions on the x axis
  46515. */
  46516. xGizmo: PlaneRotationGizmo;
  46517. /**
  46518. * Internal gizmo used for interactions on the y axis
  46519. */
  46520. yGizmo: PlaneRotationGizmo;
  46521. /**
  46522. * Internal gizmo used for interactions on the z axis
  46523. */
  46524. zGizmo: PlaneRotationGizmo;
  46525. /** Fires an event when any of it's sub gizmos are dragged */
  46526. onDragStartObservable: Observable<unknown>;
  46527. /** Fires an event when any of it's sub gizmos are released from dragging */
  46528. onDragEndObservable: Observable<unknown>;
  46529. private _meshAttached;
  46530. attachedMesh: Nullable<AbstractMesh>;
  46531. /**
  46532. * Creates a RotationGizmo
  46533. * @param gizmoLayer The utility layer the gizmo will be added to
  46534. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46535. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46536. */
  46537. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46538. updateGizmoRotationToMatchAttachedMesh: boolean;
  46539. /**
  46540. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46541. */
  46542. snapDistance: number;
  46543. /**
  46544. * Ratio for the scale of the gizmo (Default: 1)
  46545. */
  46546. scaleRatio: number;
  46547. /**
  46548. * Disposes of the gizmo
  46549. */
  46550. dispose(): void;
  46551. /**
  46552. * CustomMeshes are not supported by this gizmo
  46553. * @param mesh The mesh to replace the default mesh of the gizmo
  46554. */
  46555. setCustomMesh(mesh: Mesh): void;
  46556. }
  46557. }
  46558. declare module BABYLON {
  46559. /**
  46560. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46561. */
  46562. export class GizmoManager implements IDisposable {
  46563. private scene;
  46564. /**
  46565. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46566. */
  46567. gizmos: {
  46568. positionGizmo: Nullable<PositionGizmo>;
  46569. rotationGizmo: Nullable<RotationGizmo>;
  46570. scaleGizmo: Nullable<ScaleGizmo>;
  46571. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46572. };
  46573. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46574. clearGizmoOnEmptyPointerEvent: boolean;
  46575. /** Fires an event when the manager is attached to a mesh */
  46576. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46577. private _gizmosEnabled;
  46578. private _pointerObserver;
  46579. private _attachedMesh;
  46580. private _boundingBoxColor;
  46581. private _defaultUtilityLayer;
  46582. private _defaultKeepDepthUtilityLayer;
  46583. /**
  46584. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46585. */
  46586. boundingBoxDragBehavior: SixDofDragBehavior;
  46587. /**
  46588. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46589. */
  46590. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46591. /**
  46592. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46593. */
  46594. usePointerToAttachGizmos: boolean;
  46595. /**
  46596. * Utility layer that the bounding box gizmo belongs to
  46597. */
  46598. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46599. /**
  46600. * Utility layer that all gizmos besides bounding box belong to
  46601. */
  46602. readonly utilityLayer: UtilityLayerRenderer;
  46603. /**
  46604. * Instatiates a gizmo manager
  46605. * @param scene the scene to overlay the gizmos on top of
  46606. */
  46607. constructor(scene: Scene);
  46608. /**
  46609. * Attaches a set of gizmos to the specified mesh
  46610. * @param mesh The mesh the gizmo's should be attached to
  46611. */
  46612. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46613. /**
  46614. * If the position gizmo is enabled
  46615. */
  46616. positionGizmoEnabled: boolean;
  46617. /**
  46618. * If the rotation gizmo is enabled
  46619. */
  46620. rotationGizmoEnabled: boolean;
  46621. /**
  46622. * If the scale gizmo is enabled
  46623. */
  46624. scaleGizmoEnabled: boolean;
  46625. /**
  46626. * If the boundingBox gizmo is enabled
  46627. */
  46628. boundingBoxGizmoEnabled: boolean;
  46629. /**
  46630. * Disposes of the gizmo manager
  46631. */
  46632. dispose(): void;
  46633. }
  46634. }
  46635. declare module BABYLON {
  46636. /**
  46637. * A directional light is defined by a direction (what a surprise!).
  46638. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46639. * 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.
  46640. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46641. */
  46642. export class DirectionalLight extends ShadowLight {
  46643. private _shadowFrustumSize;
  46644. /**
  46645. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46646. */
  46647. /**
  46648. * Specifies a fix frustum size for the shadow generation.
  46649. */
  46650. shadowFrustumSize: number;
  46651. private _shadowOrthoScale;
  46652. /**
  46653. * Gets the shadow projection scale against the optimal computed one.
  46654. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46655. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46656. */
  46657. /**
  46658. * Sets the shadow projection scale against the optimal computed one.
  46659. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46660. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46661. */
  46662. shadowOrthoScale: number;
  46663. /**
  46664. * Automatically compute the projection matrix to best fit (including all the casters)
  46665. * on each frame.
  46666. */
  46667. autoUpdateExtends: boolean;
  46668. private _orthoLeft;
  46669. private _orthoRight;
  46670. private _orthoTop;
  46671. private _orthoBottom;
  46672. /**
  46673. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46674. * The directional light is emitted from everywhere in the given direction.
  46675. * It can cast shadows.
  46676. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46677. * @param name The friendly name of the light
  46678. * @param direction The direction of the light
  46679. * @param scene The scene the light belongs to
  46680. */
  46681. constructor(name: string, direction: Vector3, scene: Scene);
  46682. /**
  46683. * Returns the string "DirectionalLight".
  46684. * @return The class name
  46685. */
  46686. getClassName(): string;
  46687. /**
  46688. * Returns the integer 1.
  46689. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46690. */
  46691. getTypeID(): number;
  46692. /**
  46693. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46694. * Returns the DirectionalLight Shadow projection matrix.
  46695. */
  46696. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46697. /**
  46698. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46699. * Returns the DirectionalLight Shadow projection matrix.
  46700. */
  46701. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46702. /**
  46703. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46704. * Returns the DirectionalLight Shadow projection matrix.
  46705. */
  46706. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46707. protected _buildUniformLayout(): void;
  46708. /**
  46709. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46710. * @param effect The effect to update
  46711. * @param lightIndex The index of the light in the effect to update
  46712. * @returns The directional light
  46713. */
  46714. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46715. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46716. /**
  46717. * Gets the minZ used for shadow according to both the scene and the light.
  46718. *
  46719. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46720. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46721. * @param activeCamera The camera we are returning the min for
  46722. * @returns the depth min z
  46723. */
  46724. getDepthMinZ(activeCamera: Camera): number;
  46725. /**
  46726. * Gets the maxZ used for shadow according to both the scene and the light.
  46727. *
  46728. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46729. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46730. * @param activeCamera The camera we are returning the max for
  46731. * @returns the depth max z
  46732. */
  46733. getDepthMaxZ(activeCamera: Camera): number;
  46734. /**
  46735. * Prepares the list of defines specific to the light type.
  46736. * @param defines the list of defines
  46737. * @param lightIndex defines the index of the light for the effect
  46738. */
  46739. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46740. }
  46741. }
  46742. declare module BABYLON {
  46743. /**
  46744. * Class containing static functions to help procedurally build meshes
  46745. */
  46746. export class HemisphereBuilder {
  46747. /**
  46748. * Creates a hemisphere mesh
  46749. * @param name defines the name of the mesh
  46750. * @param options defines the options used to create the mesh
  46751. * @param scene defines the hosting scene
  46752. * @returns the hemisphere mesh
  46753. */
  46754. static CreateHemisphere(name: string, options: {
  46755. segments?: number;
  46756. diameter?: number;
  46757. sideOrientation?: number;
  46758. }, scene: any): Mesh;
  46759. }
  46760. }
  46761. declare module BABYLON {
  46762. /**
  46763. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46764. * These values define a cone of light starting from the position, emitting toward the direction.
  46765. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46766. * and the exponent defines the speed of the decay of the light with distance (reach).
  46767. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46768. */
  46769. export class SpotLight extends ShadowLight {
  46770. private _angle;
  46771. private _innerAngle;
  46772. private _cosHalfAngle;
  46773. private _lightAngleScale;
  46774. private _lightAngleOffset;
  46775. /**
  46776. * Gets the cone angle of the spot light in Radians.
  46777. */
  46778. /**
  46779. * Sets the cone angle of the spot light in Radians.
  46780. */
  46781. angle: number;
  46782. /**
  46783. * Only used in gltf falloff mode, this defines the angle where
  46784. * the directional falloff will start before cutting at angle which could be seen
  46785. * as outer angle.
  46786. */
  46787. /**
  46788. * Only used in gltf falloff mode, this defines the angle where
  46789. * the directional falloff will start before cutting at angle which could be seen
  46790. * as outer angle.
  46791. */
  46792. innerAngle: number;
  46793. private _shadowAngleScale;
  46794. /**
  46795. * Allows scaling the angle of the light for shadow generation only.
  46796. */
  46797. /**
  46798. * Allows scaling the angle of the light for shadow generation only.
  46799. */
  46800. shadowAngleScale: number;
  46801. /**
  46802. * The light decay speed with the distance from the emission spot.
  46803. */
  46804. exponent: number;
  46805. private _projectionTextureMatrix;
  46806. /**
  46807. * Allows reading the projecton texture
  46808. */
  46809. readonly projectionTextureMatrix: Matrix;
  46810. protected _projectionTextureLightNear: number;
  46811. /**
  46812. * Gets the near clip of the Spotlight for texture projection.
  46813. */
  46814. /**
  46815. * Sets the near clip of the Spotlight for texture projection.
  46816. */
  46817. projectionTextureLightNear: number;
  46818. protected _projectionTextureLightFar: number;
  46819. /**
  46820. * Gets the far clip of the Spotlight for texture projection.
  46821. */
  46822. /**
  46823. * Sets the far clip of the Spotlight for texture projection.
  46824. */
  46825. projectionTextureLightFar: number;
  46826. protected _projectionTextureUpDirection: Vector3;
  46827. /**
  46828. * Gets the Up vector of the Spotlight for texture projection.
  46829. */
  46830. /**
  46831. * Sets the Up vector of the Spotlight for texture projection.
  46832. */
  46833. projectionTextureUpDirection: Vector3;
  46834. private _projectionTexture;
  46835. /**
  46836. * Gets the projection texture of the light.
  46837. */
  46838. /**
  46839. * Sets the projection texture of the light.
  46840. */
  46841. projectionTexture: Nullable<BaseTexture>;
  46842. private _projectionTextureViewLightDirty;
  46843. private _projectionTextureProjectionLightDirty;
  46844. private _projectionTextureDirty;
  46845. private _projectionTextureViewTargetVector;
  46846. private _projectionTextureViewLightMatrix;
  46847. private _projectionTextureProjectionLightMatrix;
  46848. private _projectionTextureScalingMatrix;
  46849. /**
  46850. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46851. * It can cast shadows.
  46852. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46853. * @param name The light friendly name
  46854. * @param position The position of the spot light in the scene
  46855. * @param direction The direction of the light in the scene
  46856. * @param angle The cone angle of the light in Radians
  46857. * @param exponent The light decay speed with the distance from the emission spot
  46858. * @param scene The scene the lights belongs to
  46859. */
  46860. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46861. /**
  46862. * Returns the string "SpotLight".
  46863. * @returns the class name
  46864. */
  46865. getClassName(): string;
  46866. /**
  46867. * Returns the integer 2.
  46868. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46869. */
  46870. getTypeID(): number;
  46871. /**
  46872. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46873. */
  46874. protected _setDirection(value: Vector3): void;
  46875. /**
  46876. * Overrides the position setter to recompute the projection texture view light Matrix.
  46877. */
  46878. protected _setPosition(value: Vector3): void;
  46879. /**
  46880. * 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.
  46881. * Returns the SpotLight.
  46882. */
  46883. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46884. protected _computeProjectionTextureViewLightMatrix(): void;
  46885. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46886. /**
  46887. * Main function for light texture projection matrix computing.
  46888. */
  46889. protected _computeProjectionTextureMatrix(): void;
  46890. protected _buildUniformLayout(): void;
  46891. private _computeAngleValues;
  46892. /**
  46893. * Sets the passed Effect "effect" with the Light textures.
  46894. * @param effect The effect to update
  46895. * @param lightIndex The index of the light in the effect to update
  46896. * @returns The light
  46897. */
  46898. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  46899. /**
  46900. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46901. * @param effect The effect to update
  46902. * @param lightIndex The index of the light in the effect to update
  46903. * @returns The spot light
  46904. */
  46905. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46906. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46907. /**
  46908. * Disposes the light and the associated resources.
  46909. */
  46910. dispose(): void;
  46911. /**
  46912. * Prepares the list of defines specific to the light type.
  46913. * @param defines the list of defines
  46914. * @param lightIndex defines the index of the light for the effect
  46915. */
  46916. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46917. }
  46918. }
  46919. declare module BABYLON {
  46920. /**
  46921. * Gizmo that enables viewing a light
  46922. */
  46923. export class LightGizmo extends Gizmo {
  46924. private _lightMesh;
  46925. private _material;
  46926. private _cachedPosition;
  46927. private _cachedForward;
  46928. private _attachedMeshParent;
  46929. /**
  46930. * Creates a LightGizmo
  46931. * @param gizmoLayer The utility layer the gizmo will be added to
  46932. */
  46933. constructor(gizmoLayer?: UtilityLayerRenderer);
  46934. private _light;
  46935. /**
  46936. * The light that the gizmo is attached to
  46937. */
  46938. light: Nullable<Light>;
  46939. /**
  46940. * Gets the material used to render the light gizmo
  46941. */
  46942. readonly material: StandardMaterial;
  46943. /**
  46944. * @hidden
  46945. * Updates the gizmo to match the attached mesh's position/rotation
  46946. */
  46947. protected _update(): void;
  46948. private static _Scale;
  46949. /**
  46950. * Creates the lines for a light mesh
  46951. */
  46952. private static _CreateLightLines;
  46953. /**
  46954. * Disposes of the light gizmo
  46955. */
  46956. dispose(): void;
  46957. private static _CreateHemisphericLightMesh;
  46958. private static _CreatePointLightMesh;
  46959. private static _CreateSpotLightMesh;
  46960. private static _CreateDirectionalLightMesh;
  46961. }
  46962. }
  46963. declare module BABYLON {
  46964. /** @hidden */
  46965. export var backgroundFragmentDeclaration: {
  46966. name: string;
  46967. shader: string;
  46968. };
  46969. }
  46970. declare module BABYLON {
  46971. /** @hidden */
  46972. export var backgroundUboDeclaration: {
  46973. name: string;
  46974. shader: string;
  46975. };
  46976. }
  46977. declare module BABYLON {
  46978. /** @hidden */
  46979. export var backgroundPixelShader: {
  46980. name: string;
  46981. shader: string;
  46982. };
  46983. }
  46984. declare module BABYLON {
  46985. /** @hidden */
  46986. export var backgroundVertexDeclaration: {
  46987. name: string;
  46988. shader: string;
  46989. };
  46990. }
  46991. declare module BABYLON {
  46992. /** @hidden */
  46993. export var backgroundVertexShader: {
  46994. name: string;
  46995. shader: string;
  46996. };
  46997. }
  46998. declare module BABYLON {
  46999. /**
  47000. * Background material used to create an efficient environement around your scene.
  47001. */
  47002. export class BackgroundMaterial extends PushMaterial {
  47003. /**
  47004. * Standard reflectance value at parallel view angle.
  47005. */
  47006. static StandardReflectance0: number;
  47007. /**
  47008. * Standard reflectance value at grazing angle.
  47009. */
  47010. static StandardReflectance90: number;
  47011. protected _primaryColor: Color3;
  47012. /**
  47013. * Key light Color (multiply against the environement texture)
  47014. */
  47015. primaryColor: Color3;
  47016. protected __perceptualColor: Nullable<Color3>;
  47017. /**
  47018. * Experimental Internal Use Only.
  47019. *
  47020. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47021. * This acts as a helper to set the primary color to a more "human friendly" value.
  47022. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47023. * output color as close as possible from the chosen value.
  47024. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47025. * part of lighting setup.)
  47026. */
  47027. _perceptualColor: Nullable<Color3>;
  47028. protected _primaryColorShadowLevel: float;
  47029. /**
  47030. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47031. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47032. */
  47033. primaryColorShadowLevel: float;
  47034. protected _primaryColorHighlightLevel: float;
  47035. /**
  47036. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47037. * The primary color is used at the level chosen to define what the white area would look.
  47038. */
  47039. primaryColorHighlightLevel: float;
  47040. protected _reflectionTexture: Nullable<BaseTexture>;
  47041. /**
  47042. * Reflection Texture used in the material.
  47043. * Should be author in a specific way for the best result (refer to the documentation).
  47044. */
  47045. reflectionTexture: Nullable<BaseTexture>;
  47046. protected _reflectionBlur: float;
  47047. /**
  47048. * Reflection Texture level of blur.
  47049. *
  47050. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47051. * texture twice.
  47052. */
  47053. reflectionBlur: float;
  47054. protected _diffuseTexture: Nullable<BaseTexture>;
  47055. /**
  47056. * Diffuse Texture used in the material.
  47057. * Should be author in a specific way for the best result (refer to the documentation).
  47058. */
  47059. diffuseTexture: Nullable<BaseTexture>;
  47060. protected _shadowLights: Nullable<IShadowLight[]>;
  47061. /**
  47062. * Specify the list of lights casting shadow on the material.
  47063. * All scene shadow lights will be included if null.
  47064. */
  47065. shadowLights: Nullable<IShadowLight[]>;
  47066. protected _shadowLevel: float;
  47067. /**
  47068. * Helps adjusting the shadow to a softer level if required.
  47069. * 0 means black shadows and 1 means no shadows.
  47070. */
  47071. shadowLevel: float;
  47072. protected _sceneCenter: Vector3;
  47073. /**
  47074. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47075. * It is usually zero but might be interesting to modify according to your setup.
  47076. */
  47077. sceneCenter: Vector3;
  47078. protected _opacityFresnel: boolean;
  47079. /**
  47080. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47081. * This helps ensuring a nice transition when the camera goes under the ground.
  47082. */
  47083. opacityFresnel: boolean;
  47084. protected _reflectionFresnel: boolean;
  47085. /**
  47086. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47087. * This helps adding a mirror texture on the ground.
  47088. */
  47089. reflectionFresnel: boolean;
  47090. protected _reflectionFalloffDistance: number;
  47091. /**
  47092. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47093. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47094. */
  47095. reflectionFalloffDistance: number;
  47096. protected _reflectionAmount: number;
  47097. /**
  47098. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47099. */
  47100. reflectionAmount: number;
  47101. protected _reflectionReflectance0: number;
  47102. /**
  47103. * This specifies the weight of the reflection at grazing angle.
  47104. */
  47105. reflectionReflectance0: number;
  47106. protected _reflectionReflectance90: number;
  47107. /**
  47108. * This specifies the weight of the reflection at a perpendicular point of view.
  47109. */
  47110. reflectionReflectance90: number;
  47111. /**
  47112. * Sets the reflection reflectance fresnel values according to the default standard
  47113. * empirically know to work well :-)
  47114. */
  47115. reflectionStandardFresnelWeight: number;
  47116. protected _useRGBColor: boolean;
  47117. /**
  47118. * Helps to directly use the maps channels instead of their level.
  47119. */
  47120. useRGBColor: boolean;
  47121. protected _enableNoise: boolean;
  47122. /**
  47123. * This helps reducing the banding effect that could occur on the background.
  47124. */
  47125. enableNoise: boolean;
  47126. /**
  47127. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47128. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47129. * Recommended to be keep at 1.0 except for special cases.
  47130. */
  47131. fovMultiplier: number;
  47132. private _fovMultiplier;
  47133. /**
  47134. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47135. */
  47136. useEquirectangularFOV: boolean;
  47137. private _maxSimultaneousLights;
  47138. /**
  47139. * Number of Simultaneous lights allowed on the material.
  47140. */
  47141. maxSimultaneousLights: int;
  47142. /**
  47143. * Default configuration related to image processing available in the Background Material.
  47144. */
  47145. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47146. /**
  47147. * Keep track of the image processing observer to allow dispose and replace.
  47148. */
  47149. private _imageProcessingObserver;
  47150. /**
  47151. * Attaches a new image processing configuration to the PBR Material.
  47152. * @param configuration (if null the scene configuration will be use)
  47153. */
  47154. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47155. /**
  47156. * Gets the image processing configuration used either in this material.
  47157. */
  47158. /**
  47159. * Sets the Default image processing configuration used either in the this material.
  47160. *
  47161. * If sets to null, the scene one is in use.
  47162. */
  47163. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47164. /**
  47165. * Gets wether the color curves effect is enabled.
  47166. */
  47167. /**
  47168. * Sets wether the color curves effect is enabled.
  47169. */
  47170. cameraColorCurvesEnabled: boolean;
  47171. /**
  47172. * Gets wether the color grading effect is enabled.
  47173. */
  47174. /**
  47175. * Gets wether the color grading effect is enabled.
  47176. */
  47177. cameraColorGradingEnabled: boolean;
  47178. /**
  47179. * Gets wether tonemapping is enabled or not.
  47180. */
  47181. /**
  47182. * Sets wether tonemapping is enabled or not
  47183. */
  47184. cameraToneMappingEnabled: boolean;
  47185. /**
  47186. * The camera exposure used on this material.
  47187. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47188. * This corresponds to a photographic exposure.
  47189. */
  47190. /**
  47191. * The camera exposure used on this material.
  47192. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47193. * This corresponds to a photographic exposure.
  47194. */
  47195. cameraExposure: float;
  47196. /**
  47197. * Gets The camera contrast used on this material.
  47198. */
  47199. /**
  47200. * Sets The camera contrast used on this material.
  47201. */
  47202. cameraContrast: float;
  47203. /**
  47204. * Gets the Color Grading 2D Lookup Texture.
  47205. */
  47206. /**
  47207. * Sets the Color Grading 2D Lookup Texture.
  47208. */
  47209. cameraColorGradingTexture: Nullable<BaseTexture>;
  47210. /**
  47211. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47212. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47213. * 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;
  47214. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47215. */
  47216. /**
  47217. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47218. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47219. * 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;
  47220. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47221. */
  47222. cameraColorCurves: Nullable<ColorCurves>;
  47223. /**
  47224. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47225. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47226. */
  47227. switchToBGR: boolean;
  47228. private _renderTargets;
  47229. private _reflectionControls;
  47230. private _white;
  47231. private _primaryShadowColor;
  47232. private _primaryHighlightColor;
  47233. /**
  47234. * Instantiates a Background Material in the given scene
  47235. * @param name The friendly name of the material
  47236. * @param scene The scene to add the material to
  47237. */
  47238. constructor(name: string, scene: Scene);
  47239. /**
  47240. * Gets a boolean indicating that current material needs to register RTT
  47241. */
  47242. readonly hasRenderTargetTextures: boolean;
  47243. /**
  47244. * The entire material has been created in order to prevent overdraw.
  47245. * @returns false
  47246. */
  47247. needAlphaTesting(): boolean;
  47248. /**
  47249. * The entire material has been created in order to prevent overdraw.
  47250. * @returns true if blending is enable
  47251. */
  47252. needAlphaBlending(): boolean;
  47253. /**
  47254. * Checks wether the material is ready to be rendered for a given mesh.
  47255. * @param mesh The mesh to render
  47256. * @param subMesh The submesh to check against
  47257. * @param useInstances Specify wether or not the material is used with instances
  47258. * @returns true if all the dependencies are ready (Textures, Effects...)
  47259. */
  47260. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47261. /**
  47262. * Compute the primary color according to the chosen perceptual color.
  47263. */
  47264. private _computePrimaryColorFromPerceptualColor;
  47265. /**
  47266. * Compute the highlights and shadow colors according to their chosen levels.
  47267. */
  47268. private _computePrimaryColors;
  47269. /**
  47270. * Build the uniform buffer used in the material.
  47271. */
  47272. buildUniformLayout(): void;
  47273. /**
  47274. * Unbind the material.
  47275. */
  47276. unbind(): void;
  47277. /**
  47278. * Bind only the world matrix to the material.
  47279. * @param world The world matrix to bind.
  47280. */
  47281. bindOnlyWorldMatrix(world: Matrix): void;
  47282. /**
  47283. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47284. * @param world The world matrix to bind.
  47285. * @param subMesh The submesh to bind for.
  47286. */
  47287. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47288. /**
  47289. * Checks to see if a texture is used in the material.
  47290. * @param texture - Base texture to use.
  47291. * @returns - Boolean specifying if a texture is used in the material.
  47292. */
  47293. hasTexture(texture: BaseTexture): boolean;
  47294. /**
  47295. * Dispose the material.
  47296. * @param forceDisposeEffect Force disposal of the associated effect.
  47297. * @param forceDisposeTextures Force disposal of the associated textures.
  47298. */
  47299. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47300. /**
  47301. * Clones the material.
  47302. * @param name The cloned name.
  47303. * @returns The cloned material.
  47304. */
  47305. clone(name: string): BackgroundMaterial;
  47306. /**
  47307. * Serializes the current material to its JSON representation.
  47308. * @returns The JSON representation.
  47309. */
  47310. serialize(): any;
  47311. /**
  47312. * Gets the class name of the material
  47313. * @returns "BackgroundMaterial"
  47314. */
  47315. getClassName(): string;
  47316. /**
  47317. * Parse a JSON input to create back a background material.
  47318. * @param source The JSON data to parse
  47319. * @param scene The scene to create the parsed material in
  47320. * @param rootUrl The root url of the assets the material depends upon
  47321. * @returns the instantiated BackgroundMaterial.
  47322. */
  47323. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47324. }
  47325. }
  47326. declare module BABYLON {
  47327. /**
  47328. * Represents the different options available during the creation of
  47329. * a Environment helper.
  47330. *
  47331. * This can control the default ground, skybox and image processing setup of your scene.
  47332. */
  47333. export interface IEnvironmentHelperOptions {
  47334. /**
  47335. * Specifies wether or not to create a ground.
  47336. * True by default.
  47337. */
  47338. createGround: boolean;
  47339. /**
  47340. * Specifies the ground size.
  47341. * 15 by default.
  47342. */
  47343. groundSize: number;
  47344. /**
  47345. * The texture used on the ground for the main color.
  47346. * Comes from the BabylonJS CDN by default.
  47347. *
  47348. * Remarks: Can be either a texture or a url.
  47349. */
  47350. groundTexture: string | BaseTexture;
  47351. /**
  47352. * The color mixed in the ground texture by default.
  47353. * BabylonJS clearColor by default.
  47354. */
  47355. groundColor: Color3;
  47356. /**
  47357. * Specifies the ground opacity.
  47358. * 1 by default.
  47359. */
  47360. groundOpacity: number;
  47361. /**
  47362. * Enables the ground to receive shadows.
  47363. * True by default.
  47364. */
  47365. enableGroundShadow: boolean;
  47366. /**
  47367. * Helps preventing the shadow to be fully black on the ground.
  47368. * 0.5 by default.
  47369. */
  47370. groundShadowLevel: number;
  47371. /**
  47372. * Creates a mirror texture attach to the ground.
  47373. * false by default.
  47374. */
  47375. enableGroundMirror: boolean;
  47376. /**
  47377. * Specifies the ground mirror size ratio.
  47378. * 0.3 by default as the default kernel is 64.
  47379. */
  47380. groundMirrorSizeRatio: number;
  47381. /**
  47382. * Specifies the ground mirror blur kernel size.
  47383. * 64 by default.
  47384. */
  47385. groundMirrorBlurKernel: number;
  47386. /**
  47387. * Specifies the ground mirror visibility amount.
  47388. * 1 by default
  47389. */
  47390. groundMirrorAmount: number;
  47391. /**
  47392. * Specifies the ground mirror reflectance weight.
  47393. * This uses the standard weight of the background material to setup the fresnel effect
  47394. * of the mirror.
  47395. * 1 by default.
  47396. */
  47397. groundMirrorFresnelWeight: number;
  47398. /**
  47399. * Specifies the ground mirror Falloff distance.
  47400. * This can helps reducing the size of the reflection.
  47401. * 0 by Default.
  47402. */
  47403. groundMirrorFallOffDistance: number;
  47404. /**
  47405. * Specifies the ground mirror texture type.
  47406. * Unsigned Int by Default.
  47407. */
  47408. groundMirrorTextureType: number;
  47409. /**
  47410. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47411. * the shown objects.
  47412. */
  47413. groundYBias: number;
  47414. /**
  47415. * Specifies wether or not to create a skybox.
  47416. * True by default.
  47417. */
  47418. createSkybox: boolean;
  47419. /**
  47420. * Specifies the skybox size.
  47421. * 20 by default.
  47422. */
  47423. skyboxSize: number;
  47424. /**
  47425. * The texture used on the skybox for the main color.
  47426. * Comes from the BabylonJS CDN by default.
  47427. *
  47428. * Remarks: Can be either a texture or a url.
  47429. */
  47430. skyboxTexture: string | BaseTexture;
  47431. /**
  47432. * The color mixed in the skybox texture by default.
  47433. * BabylonJS clearColor by default.
  47434. */
  47435. skyboxColor: Color3;
  47436. /**
  47437. * The background rotation around the Y axis of the scene.
  47438. * This helps aligning the key lights of your scene with the background.
  47439. * 0 by default.
  47440. */
  47441. backgroundYRotation: number;
  47442. /**
  47443. * Compute automatically the size of the elements to best fit with the scene.
  47444. */
  47445. sizeAuto: boolean;
  47446. /**
  47447. * Default position of the rootMesh if autoSize is not true.
  47448. */
  47449. rootPosition: Vector3;
  47450. /**
  47451. * Sets up the image processing in the scene.
  47452. * true by default.
  47453. */
  47454. setupImageProcessing: boolean;
  47455. /**
  47456. * The texture used as your environment texture in the scene.
  47457. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47458. *
  47459. * Remarks: Can be either a texture or a url.
  47460. */
  47461. environmentTexture: string | BaseTexture;
  47462. /**
  47463. * The value of the exposure to apply to the scene.
  47464. * 0.6 by default if setupImageProcessing is true.
  47465. */
  47466. cameraExposure: number;
  47467. /**
  47468. * The value of the contrast to apply to the scene.
  47469. * 1.6 by default if setupImageProcessing is true.
  47470. */
  47471. cameraContrast: number;
  47472. /**
  47473. * Specifies wether or not tonemapping should be enabled in the scene.
  47474. * true by default if setupImageProcessing is true.
  47475. */
  47476. toneMappingEnabled: boolean;
  47477. }
  47478. /**
  47479. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47480. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47481. * It also helps with the default setup of your imageProcessing configuration.
  47482. */
  47483. export class EnvironmentHelper {
  47484. /**
  47485. * Default ground texture URL.
  47486. */
  47487. private static _groundTextureCDNUrl;
  47488. /**
  47489. * Default skybox texture URL.
  47490. */
  47491. private static _skyboxTextureCDNUrl;
  47492. /**
  47493. * Default environment texture URL.
  47494. */
  47495. private static _environmentTextureCDNUrl;
  47496. /**
  47497. * Creates the default options for the helper.
  47498. */
  47499. private static _getDefaultOptions;
  47500. private _rootMesh;
  47501. /**
  47502. * Gets the root mesh created by the helper.
  47503. */
  47504. readonly rootMesh: Mesh;
  47505. private _skybox;
  47506. /**
  47507. * Gets the skybox created by the helper.
  47508. */
  47509. readonly skybox: Nullable<Mesh>;
  47510. private _skyboxTexture;
  47511. /**
  47512. * Gets the skybox texture created by the helper.
  47513. */
  47514. readonly skyboxTexture: Nullable<BaseTexture>;
  47515. private _skyboxMaterial;
  47516. /**
  47517. * Gets the skybox material created by the helper.
  47518. */
  47519. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47520. private _ground;
  47521. /**
  47522. * Gets the ground mesh created by the helper.
  47523. */
  47524. readonly ground: Nullable<Mesh>;
  47525. private _groundTexture;
  47526. /**
  47527. * Gets the ground texture created by the helper.
  47528. */
  47529. readonly groundTexture: Nullable<BaseTexture>;
  47530. private _groundMirror;
  47531. /**
  47532. * Gets the ground mirror created by the helper.
  47533. */
  47534. readonly groundMirror: Nullable<MirrorTexture>;
  47535. /**
  47536. * Gets the ground mirror render list to helps pushing the meshes
  47537. * you wish in the ground reflection.
  47538. */
  47539. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47540. private _groundMaterial;
  47541. /**
  47542. * Gets the ground material created by the helper.
  47543. */
  47544. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47545. /**
  47546. * Stores the creation options.
  47547. */
  47548. private readonly _scene;
  47549. private _options;
  47550. /**
  47551. * This observable will be notified with any error during the creation of the environment,
  47552. * mainly texture creation errors.
  47553. */
  47554. onErrorObservable: Observable<{
  47555. message?: string;
  47556. exception?: any;
  47557. }>;
  47558. /**
  47559. * constructor
  47560. * @param options Defines the options we want to customize the helper
  47561. * @param scene The scene to add the material to
  47562. */
  47563. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47564. /**
  47565. * Updates the background according to the new options
  47566. * @param options
  47567. */
  47568. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47569. /**
  47570. * Sets the primary color of all the available elements.
  47571. * @param color the main color to affect to the ground and the background
  47572. */
  47573. setMainColor(color: Color3): void;
  47574. /**
  47575. * Setup the image processing according to the specified options.
  47576. */
  47577. private _setupImageProcessing;
  47578. /**
  47579. * Setup the environment texture according to the specified options.
  47580. */
  47581. private _setupEnvironmentTexture;
  47582. /**
  47583. * Setup the background according to the specified options.
  47584. */
  47585. private _setupBackground;
  47586. /**
  47587. * Get the scene sizes according to the setup.
  47588. */
  47589. private _getSceneSize;
  47590. /**
  47591. * Setup the ground according to the specified options.
  47592. */
  47593. private _setupGround;
  47594. /**
  47595. * Setup the ground material according to the specified options.
  47596. */
  47597. private _setupGroundMaterial;
  47598. /**
  47599. * Setup the ground diffuse texture according to the specified options.
  47600. */
  47601. private _setupGroundDiffuseTexture;
  47602. /**
  47603. * Setup the ground mirror texture according to the specified options.
  47604. */
  47605. private _setupGroundMirrorTexture;
  47606. /**
  47607. * Setup the ground to receive the mirror texture.
  47608. */
  47609. private _setupMirrorInGroundMaterial;
  47610. /**
  47611. * Setup the skybox according to the specified options.
  47612. */
  47613. private _setupSkybox;
  47614. /**
  47615. * Setup the skybox material according to the specified options.
  47616. */
  47617. private _setupSkyboxMaterial;
  47618. /**
  47619. * Setup the skybox reflection texture according to the specified options.
  47620. */
  47621. private _setupSkyboxReflectionTexture;
  47622. private _errorHandler;
  47623. /**
  47624. * Dispose all the elements created by the Helper.
  47625. */
  47626. dispose(): void;
  47627. }
  47628. }
  47629. declare module BABYLON {
  47630. /**
  47631. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47632. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47633. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47634. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47635. */
  47636. export class PhotoDome extends TransformNode {
  47637. /**
  47638. * Define the image as a Monoscopic panoramic 360 image.
  47639. */
  47640. static readonly MODE_MONOSCOPIC: number;
  47641. /**
  47642. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47643. */
  47644. static readonly MODE_TOPBOTTOM: number;
  47645. /**
  47646. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47647. */
  47648. static readonly MODE_SIDEBYSIDE: number;
  47649. private _useDirectMapping;
  47650. /**
  47651. * The texture being displayed on the sphere
  47652. */
  47653. protected _photoTexture: Texture;
  47654. /**
  47655. * Gets or sets the texture being displayed on the sphere
  47656. */
  47657. photoTexture: Texture;
  47658. /**
  47659. * Observable raised when an error occured while loading the 360 image
  47660. */
  47661. onLoadErrorObservable: Observable<string>;
  47662. /**
  47663. * The skybox material
  47664. */
  47665. protected _material: BackgroundMaterial;
  47666. /**
  47667. * The surface used for the skybox
  47668. */
  47669. protected _mesh: Mesh;
  47670. /**
  47671. * Gets the mesh used for the skybox.
  47672. */
  47673. readonly mesh: Mesh;
  47674. /**
  47675. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47676. * Also see the options.resolution property.
  47677. */
  47678. fovMultiplier: number;
  47679. private _imageMode;
  47680. /**
  47681. * Gets or set the current video mode for the video. It can be:
  47682. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47683. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47684. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47685. */
  47686. imageMode: number;
  47687. /**
  47688. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47689. * @param name Element's name, child elements will append suffixes for their own names.
  47690. * @param urlsOfPhoto defines the url of the photo to display
  47691. * @param options defines an object containing optional or exposed sub element properties
  47692. * @param onError defines a callback called when an error occured while loading the texture
  47693. */
  47694. constructor(name: string, urlOfPhoto: string, options: {
  47695. resolution?: number;
  47696. size?: number;
  47697. useDirectMapping?: boolean;
  47698. faceForward?: boolean;
  47699. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47700. private _onBeforeCameraRenderObserver;
  47701. private _changeImageMode;
  47702. /**
  47703. * Releases resources associated with this node.
  47704. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47705. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47706. */
  47707. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47708. }
  47709. }
  47710. declare module BABYLON {
  47711. /**
  47712. * Class used to host RGBD texture specific utilities
  47713. */
  47714. export class RGBDTextureTools {
  47715. /**
  47716. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47717. * @param texture the texture to expand.
  47718. */
  47719. static ExpandRGBDTexture(texture: Texture): void;
  47720. }
  47721. }
  47722. declare module BABYLON {
  47723. /**
  47724. * Class used to host texture specific utilities
  47725. */
  47726. export class BRDFTextureTools {
  47727. /**
  47728. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47729. * @param scene defines the hosting scene
  47730. * @returns the environment BRDF texture
  47731. */
  47732. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47733. private static _environmentBRDFBase64Texture;
  47734. }
  47735. }
  47736. declare module BABYLON {
  47737. /**
  47738. * @hidden
  47739. */
  47740. export interface IMaterialClearCoatDefines {
  47741. CLEARCOAT: boolean;
  47742. CLEARCOAT_DEFAULTIOR: boolean;
  47743. CLEARCOAT_TEXTURE: boolean;
  47744. CLEARCOAT_TEXTUREDIRECTUV: number;
  47745. CLEARCOAT_BUMP: boolean;
  47746. CLEARCOAT_BUMPDIRECTUV: number;
  47747. CLEARCOAT_TINT: boolean;
  47748. CLEARCOAT_TINT_TEXTURE: boolean;
  47749. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47750. /** @hidden */
  47751. _areTexturesDirty: boolean;
  47752. }
  47753. /**
  47754. * Define the code related to the clear coat parameters of the pbr material.
  47755. */
  47756. export class PBRClearCoatConfiguration {
  47757. /**
  47758. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47759. * The default fits with a polyurethane material.
  47760. */
  47761. private static readonly _DefaultIndexOfRefraction;
  47762. private _isEnabled;
  47763. /**
  47764. * Defines if the clear coat is enabled in the material.
  47765. */
  47766. isEnabled: boolean;
  47767. /**
  47768. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47769. */
  47770. intensity: number;
  47771. /**
  47772. * Defines the clear coat layer roughness.
  47773. */
  47774. roughness: number;
  47775. private _indexOfRefraction;
  47776. /**
  47777. * Defines the index of refraction of the clear coat.
  47778. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47779. * The default fits with a polyurethane material.
  47780. * Changing the default value is more performance intensive.
  47781. */
  47782. indexOfRefraction: number;
  47783. private _texture;
  47784. /**
  47785. * Stores the clear coat values in a texture.
  47786. */
  47787. texture: Nullable<BaseTexture>;
  47788. private _bumpTexture;
  47789. /**
  47790. * Define the clear coat specific bump texture.
  47791. */
  47792. bumpTexture: Nullable<BaseTexture>;
  47793. private _isTintEnabled;
  47794. /**
  47795. * Defines if the clear coat tint is enabled in the material.
  47796. */
  47797. isTintEnabled: boolean;
  47798. /**
  47799. * Defines the clear coat tint of the material.
  47800. * This is only use if tint is enabled
  47801. */
  47802. tintColor: Color3;
  47803. /**
  47804. * Defines the distance at which the tint color should be found in the
  47805. * clear coat media.
  47806. * This is only use if tint is enabled
  47807. */
  47808. tintColorAtDistance: number;
  47809. /**
  47810. * Defines the clear coat layer thickness.
  47811. * This is only use if tint is enabled
  47812. */
  47813. tintThickness: number;
  47814. private _tintTexture;
  47815. /**
  47816. * Stores the clear tint values in a texture.
  47817. * rgb is tint
  47818. * a is a thickness factor
  47819. */
  47820. tintTexture: Nullable<BaseTexture>;
  47821. /** @hidden */
  47822. private _internalMarkAllSubMeshesAsTexturesDirty;
  47823. /** @hidden */
  47824. _markAllSubMeshesAsTexturesDirty(): void;
  47825. /**
  47826. * Instantiate a new istance of clear coat configuration.
  47827. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47828. */
  47829. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47830. /**
  47831. * Gets wehter the submesh is ready to be used or not.
  47832. * @param defines the list of "defines" to update.
  47833. * @param scene defines the scene the material belongs to.
  47834. * @param engine defines the engine the material belongs to.
  47835. * @param disableBumpMap defines wether the material disables bump or not.
  47836. * @returns - boolean indicating that the submesh is ready or not.
  47837. */
  47838. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47839. /**
  47840. * Checks to see if a texture is used in the material.
  47841. * @param defines the list of "defines" to update.
  47842. * @param scene defines the scene to the material belongs to.
  47843. */
  47844. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47845. /**
  47846. * Binds the material data.
  47847. * @param uniformBuffer defines the Uniform buffer to fill in.
  47848. * @param scene defines the scene the material belongs to.
  47849. * @param engine defines the engine the material belongs to.
  47850. * @param disableBumpMap defines wether the material disables bump or not.
  47851. * @param isFrozen defines wether the material is frozen or not.
  47852. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47853. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47854. */
  47855. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47856. /**
  47857. * Checks to see if a texture is used in the material.
  47858. * @param texture - Base texture to use.
  47859. * @returns - Boolean specifying if a texture is used in the material.
  47860. */
  47861. hasTexture(texture: BaseTexture): boolean;
  47862. /**
  47863. * Returns an array of the actively used textures.
  47864. * @param activeTextures Array of BaseTextures
  47865. */
  47866. getActiveTextures(activeTextures: BaseTexture[]): void;
  47867. /**
  47868. * Returns the animatable textures.
  47869. * @param animatables Array of animatable textures.
  47870. */
  47871. getAnimatables(animatables: IAnimatable[]): void;
  47872. /**
  47873. * Disposes the resources of the material.
  47874. * @param forceDisposeTextures - Forces the disposal of all textures.
  47875. */
  47876. dispose(forceDisposeTextures?: boolean): void;
  47877. /**
  47878. * Get the current class name of the texture useful for serialization or dynamic coding.
  47879. * @returns "PBRClearCoatConfiguration"
  47880. */
  47881. getClassName(): string;
  47882. /**
  47883. * Add fallbacks to the effect fallbacks list.
  47884. * @param defines defines the Base texture to use.
  47885. * @param fallbacks defines the current fallback list.
  47886. * @param currentRank defines the current fallback rank.
  47887. * @returns the new fallback rank.
  47888. */
  47889. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47890. /**
  47891. * Add the required uniforms to the current list.
  47892. * @param uniforms defines the current uniform list.
  47893. */
  47894. static AddUniforms(uniforms: string[]): void;
  47895. /**
  47896. * Add the required samplers to the current list.
  47897. * @param samplers defines the current sampler list.
  47898. */
  47899. static AddSamplers(samplers: string[]): void;
  47900. /**
  47901. * Add the required uniforms to the current buffer.
  47902. * @param uniformBuffer defines the current uniform buffer.
  47903. */
  47904. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47905. /**
  47906. * Makes a duplicate of the current configuration into another one.
  47907. * @param clearCoatConfiguration define the config where to copy the info
  47908. */
  47909. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47910. /**
  47911. * Serializes this clear coat configuration.
  47912. * @returns - An object with the serialized config.
  47913. */
  47914. serialize(): any;
  47915. /**
  47916. * Parses a anisotropy Configuration from a serialized object.
  47917. * @param source - Serialized object.
  47918. * @param scene Defines the scene we are parsing for
  47919. * @param rootUrl Defines the rootUrl to load from
  47920. */
  47921. parse(source: any, scene: Scene, rootUrl: string): void;
  47922. }
  47923. }
  47924. declare module BABYLON {
  47925. /**
  47926. * @hidden
  47927. */
  47928. export interface IMaterialAnisotropicDefines {
  47929. ANISOTROPIC: boolean;
  47930. ANISOTROPIC_TEXTURE: boolean;
  47931. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47932. MAINUV1: boolean;
  47933. _areTexturesDirty: boolean;
  47934. _needUVs: boolean;
  47935. }
  47936. /**
  47937. * Define the code related to the anisotropic parameters of the pbr material.
  47938. */
  47939. export class PBRAnisotropicConfiguration {
  47940. private _isEnabled;
  47941. /**
  47942. * Defines if the anisotropy is enabled in the material.
  47943. */
  47944. isEnabled: boolean;
  47945. /**
  47946. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47947. */
  47948. intensity: number;
  47949. /**
  47950. * Defines if the effect is along the tangents, bitangents or in between.
  47951. * By default, the effect is "strectching" the highlights along the tangents.
  47952. */
  47953. direction: Vector2;
  47954. private _texture;
  47955. /**
  47956. * Stores the anisotropy values in a texture.
  47957. * rg is direction (like normal from -1 to 1)
  47958. * b is a intensity
  47959. */
  47960. texture: Nullable<BaseTexture>;
  47961. /** @hidden */
  47962. private _internalMarkAllSubMeshesAsTexturesDirty;
  47963. /** @hidden */
  47964. _markAllSubMeshesAsTexturesDirty(): void;
  47965. /**
  47966. * Instantiate a new istance of anisotropy configuration.
  47967. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47968. */
  47969. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47970. /**
  47971. * Specifies that the submesh is ready to be used.
  47972. * @param defines the list of "defines" to update.
  47973. * @param scene defines the scene the material belongs to.
  47974. * @returns - boolean indicating that the submesh is ready or not.
  47975. */
  47976. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47977. /**
  47978. * Checks to see if a texture is used in the material.
  47979. * @param defines the list of "defines" to update.
  47980. * @param mesh the mesh we are preparing the defines for.
  47981. * @param scene defines the scene the material belongs to.
  47982. */
  47983. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47984. /**
  47985. * Binds the material data.
  47986. * @param uniformBuffer defines the Uniform buffer to fill in.
  47987. * @param scene defines the scene the material belongs to.
  47988. * @param isFrozen defines wether the material is frozen or not.
  47989. */
  47990. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47991. /**
  47992. * Checks to see if a texture is used in the material.
  47993. * @param texture - Base texture to use.
  47994. * @returns - Boolean specifying if a texture is used in the material.
  47995. */
  47996. hasTexture(texture: BaseTexture): boolean;
  47997. /**
  47998. * Returns an array of the actively used textures.
  47999. * @param activeTextures Array of BaseTextures
  48000. */
  48001. getActiveTextures(activeTextures: BaseTexture[]): void;
  48002. /**
  48003. * Returns the animatable textures.
  48004. * @param animatables Array of animatable textures.
  48005. */
  48006. getAnimatables(animatables: IAnimatable[]): void;
  48007. /**
  48008. * Disposes the resources of the material.
  48009. * @param forceDisposeTextures - Forces the disposal of all textures.
  48010. */
  48011. dispose(forceDisposeTextures?: boolean): void;
  48012. /**
  48013. * Get the current class name of the texture useful for serialization or dynamic coding.
  48014. * @returns "PBRAnisotropicConfiguration"
  48015. */
  48016. getClassName(): string;
  48017. /**
  48018. * Add fallbacks to the effect fallbacks list.
  48019. * @param defines defines the Base texture to use.
  48020. * @param fallbacks defines the current fallback list.
  48021. * @param currentRank defines the current fallback rank.
  48022. * @returns the new fallback rank.
  48023. */
  48024. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48025. /**
  48026. * Add the required uniforms to the current list.
  48027. * @param uniforms defines the current uniform list.
  48028. */
  48029. static AddUniforms(uniforms: string[]): void;
  48030. /**
  48031. * Add the required uniforms to the current buffer.
  48032. * @param uniformBuffer defines the current uniform buffer.
  48033. */
  48034. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48035. /**
  48036. * Add the required samplers to the current list.
  48037. * @param samplers defines the current sampler list.
  48038. */
  48039. static AddSamplers(samplers: string[]): void;
  48040. /**
  48041. * Makes a duplicate of the current configuration into another one.
  48042. * @param anisotropicConfiguration define the config where to copy the info
  48043. */
  48044. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48045. /**
  48046. * Serializes this anisotropy configuration.
  48047. * @returns - An object with the serialized config.
  48048. */
  48049. serialize(): any;
  48050. /**
  48051. * Parses a anisotropy Configuration from a serialized object.
  48052. * @param source - Serialized object.
  48053. * @param scene Defines the scene we are parsing for
  48054. * @param rootUrl Defines the rootUrl to load from
  48055. */
  48056. parse(source: any, scene: Scene, rootUrl: string): void;
  48057. }
  48058. }
  48059. declare module BABYLON {
  48060. /**
  48061. * @hidden
  48062. */
  48063. export interface IMaterialBRDFDefines {
  48064. BRDF_V_HEIGHT_CORRELATED: boolean;
  48065. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48066. SPHERICAL_HARMONICS: boolean;
  48067. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48068. /** @hidden */
  48069. _areMiscDirty: boolean;
  48070. }
  48071. /**
  48072. * Define the code related to the BRDF parameters of the pbr material.
  48073. */
  48074. export class PBRBRDFConfiguration {
  48075. /**
  48076. * Default value used for the energy conservation.
  48077. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48078. */
  48079. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48080. /**
  48081. * Default value used for the Smith Visibility Height Correlated mode.
  48082. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48083. */
  48084. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48085. /**
  48086. * Default value used for the IBL diffuse part.
  48087. * This can help switching back to the polynomials mode globally which is a tiny bit
  48088. * less GPU intensive at the drawback of a lower quality.
  48089. */
  48090. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48091. /**
  48092. * Default value used for activating energy conservation for the specular workflow.
  48093. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48094. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48095. */
  48096. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48097. private _useEnergyConservation;
  48098. /**
  48099. * Defines if the material uses energy conservation.
  48100. */
  48101. useEnergyConservation: boolean;
  48102. private _useSmithVisibilityHeightCorrelated;
  48103. /**
  48104. * LEGACY Mode set to false
  48105. * Defines if the material uses height smith correlated visibility term.
  48106. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48107. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48108. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48109. * Not relying on height correlated will also disable energy conservation.
  48110. */
  48111. useSmithVisibilityHeightCorrelated: boolean;
  48112. private _useSphericalHarmonics;
  48113. /**
  48114. * LEGACY Mode set to false
  48115. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48116. * diffuse part of the IBL.
  48117. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48118. * to the ground truth.
  48119. */
  48120. useSphericalHarmonics: boolean;
  48121. private _useSpecularGlossinessInputEnergyConservation;
  48122. /**
  48123. * Defines if the material uses energy conservation, when the specular workflow is active.
  48124. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48125. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48126. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48127. */
  48128. useSpecularGlossinessInputEnergyConservation: boolean;
  48129. /** @hidden */
  48130. private _internalMarkAllSubMeshesAsMiscDirty;
  48131. /** @hidden */
  48132. _markAllSubMeshesAsMiscDirty(): void;
  48133. /**
  48134. * Instantiate a new istance of clear coat configuration.
  48135. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48136. */
  48137. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48138. /**
  48139. * Checks to see if a texture is used in the material.
  48140. * @param defines the list of "defines" to update.
  48141. */
  48142. prepareDefines(defines: IMaterialBRDFDefines): void;
  48143. /**
  48144. * Get the current class name of the texture useful for serialization or dynamic coding.
  48145. * @returns "PBRClearCoatConfiguration"
  48146. */
  48147. getClassName(): string;
  48148. /**
  48149. * Makes a duplicate of the current configuration into another one.
  48150. * @param brdfConfiguration define the config where to copy the info
  48151. */
  48152. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48153. /**
  48154. * Serializes this BRDF configuration.
  48155. * @returns - An object with the serialized config.
  48156. */
  48157. serialize(): any;
  48158. /**
  48159. * Parses a anisotropy Configuration from a serialized object.
  48160. * @param source - Serialized object.
  48161. * @param scene Defines the scene we are parsing for
  48162. * @param rootUrl Defines the rootUrl to load from
  48163. */
  48164. parse(source: any, scene: Scene, rootUrl: string): void;
  48165. }
  48166. }
  48167. declare module BABYLON {
  48168. /**
  48169. * @hidden
  48170. */
  48171. export interface IMaterialSheenDefines {
  48172. SHEEN: boolean;
  48173. SHEEN_TEXTURE: boolean;
  48174. SHEEN_TEXTUREDIRECTUV: number;
  48175. SHEEN_LINKWITHALBEDO: boolean;
  48176. /** @hidden */
  48177. _areTexturesDirty: boolean;
  48178. }
  48179. /**
  48180. * Define the code related to the Sheen parameters of the pbr material.
  48181. */
  48182. export class PBRSheenConfiguration {
  48183. private _isEnabled;
  48184. /**
  48185. * Defines if the material uses sheen.
  48186. */
  48187. isEnabled: boolean;
  48188. private _linkSheenWithAlbedo;
  48189. /**
  48190. * Defines if the sheen is linked to the sheen color.
  48191. */
  48192. linkSheenWithAlbedo: boolean;
  48193. /**
  48194. * Defines the sheen intensity.
  48195. */
  48196. intensity: number;
  48197. /**
  48198. * Defines the sheen color.
  48199. */
  48200. color: Color3;
  48201. private _texture;
  48202. /**
  48203. * Stores the sheen tint values in a texture.
  48204. * rgb is tint
  48205. * a is a intensity
  48206. */
  48207. texture: Nullable<BaseTexture>;
  48208. /** @hidden */
  48209. private _internalMarkAllSubMeshesAsTexturesDirty;
  48210. /** @hidden */
  48211. _markAllSubMeshesAsTexturesDirty(): void;
  48212. /**
  48213. * Instantiate a new istance of clear coat configuration.
  48214. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48215. */
  48216. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48217. /**
  48218. * Specifies that the submesh is ready to be used.
  48219. * @param defines the list of "defines" to update.
  48220. * @param scene defines the scene the material belongs to.
  48221. * @returns - boolean indicating that the submesh is ready or not.
  48222. */
  48223. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48224. /**
  48225. * Checks to see if a texture is used in the material.
  48226. * @param defines the list of "defines" to update.
  48227. * @param scene defines the scene the material belongs to.
  48228. */
  48229. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48230. /**
  48231. * Binds the material data.
  48232. * @param uniformBuffer defines the Uniform buffer to fill in.
  48233. * @param scene defines the scene the material belongs to.
  48234. * @param isFrozen defines wether the material is frozen or not.
  48235. */
  48236. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48237. /**
  48238. * Checks to see if a texture is used in the material.
  48239. * @param texture - Base texture to use.
  48240. * @returns - Boolean specifying if a texture is used in the material.
  48241. */
  48242. hasTexture(texture: BaseTexture): boolean;
  48243. /**
  48244. * Returns an array of the actively used textures.
  48245. * @param activeTextures Array of BaseTextures
  48246. */
  48247. getActiveTextures(activeTextures: BaseTexture[]): void;
  48248. /**
  48249. * Returns the animatable textures.
  48250. * @param animatables Array of animatable textures.
  48251. */
  48252. getAnimatables(animatables: IAnimatable[]): void;
  48253. /**
  48254. * Disposes the resources of the material.
  48255. * @param forceDisposeTextures - Forces the disposal of all textures.
  48256. */
  48257. dispose(forceDisposeTextures?: boolean): void;
  48258. /**
  48259. * Get the current class name of the texture useful for serialization or dynamic coding.
  48260. * @returns "PBRSheenConfiguration"
  48261. */
  48262. getClassName(): string;
  48263. /**
  48264. * Add fallbacks to the effect fallbacks list.
  48265. * @param defines defines the Base texture to use.
  48266. * @param fallbacks defines the current fallback list.
  48267. * @param currentRank defines the current fallback rank.
  48268. * @returns the new fallback rank.
  48269. */
  48270. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48271. /**
  48272. * Add the required uniforms to the current list.
  48273. * @param uniforms defines the current uniform list.
  48274. */
  48275. static AddUniforms(uniforms: string[]): void;
  48276. /**
  48277. * Add the required uniforms to the current buffer.
  48278. * @param uniformBuffer defines the current uniform buffer.
  48279. */
  48280. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48281. /**
  48282. * Add the required samplers to the current list.
  48283. * @param samplers defines the current sampler list.
  48284. */
  48285. static AddSamplers(samplers: string[]): void;
  48286. /**
  48287. * Makes a duplicate of the current configuration into another one.
  48288. * @param sheenConfiguration define the config where to copy the info
  48289. */
  48290. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48291. /**
  48292. * Serializes this BRDF configuration.
  48293. * @returns - An object with the serialized config.
  48294. */
  48295. serialize(): any;
  48296. /**
  48297. * Parses a anisotropy Configuration from a serialized object.
  48298. * @param source - Serialized object.
  48299. * @param scene Defines the scene we are parsing for
  48300. * @param rootUrl Defines the rootUrl to load from
  48301. */
  48302. parse(source: any, scene: Scene, rootUrl: string): void;
  48303. }
  48304. }
  48305. declare module BABYLON {
  48306. /**
  48307. * @hidden
  48308. */
  48309. export interface IMaterialSubSurfaceDefines {
  48310. SUBSURFACE: boolean;
  48311. SS_REFRACTION: boolean;
  48312. SS_TRANSLUCENCY: boolean;
  48313. SS_SCATERRING: boolean;
  48314. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48315. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48316. SS_REFRACTIONMAP_3D: boolean;
  48317. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48318. SS_LODINREFRACTIONALPHA: boolean;
  48319. SS_GAMMAREFRACTION: boolean;
  48320. SS_RGBDREFRACTION: boolean;
  48321. SS_LINEARSPECULARREFRACTION: boolean;
  48322. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48323. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48324. /** @hidden */
  48325. _areTexturesDirty: boolean;
  48326. }
  48327. /**
  48328. * Define the code related to the sub surface parameters of the pbr material.
  48329. */
  48330. export class PBRSubSurfaceConfiguration {
  48331. private _isRefractionEnabled;
  48332. /**
  48333. * Defines if the refraction is enabled in the material.
  48334. */
  48335. isRefractionEnabled: boolean;
  48336. private _isTranslucencyEnabled;
  48337. /**
  48338. * Defines if the translucency is enabled in the material.
  48339. */
  48340. isTranslucencyEnabled: boolean;
  48341. private _isScatteringEnabled;
  48342. /**
  48343. * Defines the refraction intensity of the material.
  48344. * The refraction when enabled replaces the Diffuse part of the material.
  48345. * The intensity helps transitionning between diffuse and refraction.
  48346. */
  48347. refractionIntensity: number;
  48348. /**
  48349. * Defines the translucency intensity of the material.
  48350. * When translucency has been enabled, this defines how much of the "translucency"
  48351. * is addded to the diffuse part of the material.
  48352. */
  48353. translucencyIntensity: number;
  48354. /**
  48355. * Defines the scattering intensity of the material.
  48356. * When scattering has been enabled, this defines how much of the "scattered light"
  48357. * is addded to the diffuse part of the material.
  48358. */
  48359. scatteringIntensity: number;
  48360. private _thicknessTexture;
  48361. /**
  48362. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48363. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48364. * 0 would mean minimumThickness
  48365. * 1 would mean maximumThickness
  48366. * The other channels might be use as a mask to vary the different effects intensity.
  48367. */
  48368. thicknessTexture: Nullable<BaseTexture>;
  48369. private _refractionTexture;
  48370. /**
  48371. * Defines the texture to use for refraction.
  48372. */
  48373. refractionTexture: Nullable<BaseTexture>;
  48374. private _indexOfRefraction;
  48375. /**
  48376. * Defines the index of refraction used in the material.
  48377. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48378. */
  48379. indexOfRefraction: number;
  48380. private _invertRefractionY;
  48381. /**
  48382. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48383. */
  48384. invertRefractionY: boolean;
  48385. private _linkRefractionWithTransparency;
  48386. /**
  48387. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48388. * Materials half opaque for instance using refraction could benefit from this control.
  48389. */
  48390. linkRefractionWithTransparency: boolean;
  48391. /**
  48392. * Defines the minimum thickness stored in the thickness map.
  48393. * If no thickness map is defined, this value will be used to simulate thickness.
  48394. */
  48395. minimumThickness: number;
  48396. /**
  48397. * Defines the maximum thickness stored in the thickness map.
  48398. */
  48399. maximumThickness: number;
  48400. /**
  48401. * Defines the volume tint of the material.
  48402. * This is used for both translucency and scattering.
  48403. */
  48404. tintColor: Color3;
  48405. /**
  48406. * Defines the distance at which the tint color should be found in the media.
  48407. * This is used for refraction only.
  48408. */
  48409. tintColorAtDistance: number;
  48410. /**
  48411. * Defines how far each channel transmit through the media.
  48412. * It is defined as a color to simplify it selection.
  48413. */
  48414. diffusionDistance: Color3;
  48415. private _useMaskFromThicknessTexture;
  48416. /**
  48417. * Stores the intensity of the different subsurface effects in the thickness texture.
  48418. * * the green channel is the translucency intensity.
  48419. * * the blue channel is the scattering intensity.
  48420. * * the alpha channel is the refraction intensity.
  48421. */
  48422. useMaskFromThicknessTexture: boolean;
  48423. /** @hidden */
  48424. private _internalMarkAllSubMeshesAsTexturesDirty;
  48425. /** @hidden */
  48426. _markAllSubMeshesAsTexturesDirty(): void;
  48427. /**
  48428. * Instantiate a new istance of sub surface configuration.
  48429. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48430. */
  48431. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48432. /**
  48433. * Gets wehter the submesh is ready to be used or not.
  48434. * @param defines the list of "defines" to update.
  48435. * @param scene defines the scene the material belongs to.
  48436. * @returns - boolean indicating that the submesh is ready or not.
  48437. */
  48438. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48439. /**
  48440. * Checks to see if a texture is used in the material.
  48441. * @param defines the list of "defines" to update.
  48442. * @param scene defines the scene to the material belongs to.
  48443. */
  48444. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48445. /**
  48446. * Binds the material data.
  48447. * @param uniformBuffer defines the Uniform buffer to fill in.
  48448. * @param scene defines the scene the material belongs to.
  48449. * @param engine defines the engine the material belongs to.
  48450. * @param isFrozen defines wether the material is frozen or not.
  48451. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48452. */
  48453. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48454. /**
  48455. * Unbinds the material from the mesh.
  48456. * @param activeEffect defines the effect that should be unbound from.
  48457. * @returns true if unbound, otherwise false
  48458. */
  48459. unbind(activeEffect: Effect): boolean;
  48460. /**
  48461. * Returns the texture used for refraction or null if none is used.
  48462. * @param scene defines the scene the material belongs to.
  48463. * @returns - Refraction texture if present. If no refraction texture and refraction
  48464. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48465. */
  48466. private _getRefractionTexture;
  48467. /**
  48468. * Returns true if alpha blending should be disabled.
  48469. */
  48470. readonly disableAlphaBlending: boolean;
  48471. /**
  48472. * Fills the list of render target textures.
  48473. * @param renderTargets the list of render targets to update
  48474. */
  48475. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48476. /**
  48477. * Checks to see if a texture is used in the material.
  48478. * @param texture - Base texture to use.
  48479. * @returns - Boolean specifying if a texture is used in the material.
  48480. */
  48481. hasTexture(texture: BaseTexture): boolean;
  48482. /**
  48483. * Gets a boolean indicating that current material needs to register RTT
  48484. * @returns true if this uses a render target otherwise false.
  48485. */
  48486. hasRenderTargetTextures(): boolean;
  48487. /**
  48488. * Returns an array of the actively used textures.
  48489. * @param activeTextures Array of BaseTextures
  48490. */
  48491. getActiveTextures(activeTextures: BaseTexture[]): void;
  48492. /**
  48493. * Returns the animatable textures.
  48494. * @param animatables Array of animatable textures.
  48495. */
  48496. getAnimatables(animatables: IAnimatable[]): void;
  48497. /**
  48498. * Disposes the resources of the material.
  48499. * @param forceDisposeTextures - Forces the disposal of all textures.
  48500. */
  48501. dispose(forceDisposeTextures?: boolean): void;
  48502. /**
  48503. * Get the current class name of the texture useful for serialization or dynamic coding.
  48504. * @returns "PBRSubSurfaceConfiguration"
  48505. */
  48506. getClassName(): string;
  48507. /**
  48508. * Add fallbacks to the effect fallbacks list.
  48509. * @param defines defines the Base texture to use.
  48510. * @param fallbacks defines the current fallback list.
  48511. * @param currentRank defines the current fallback rank.
  48512. * @returns the new fallback rank.
  48513. */
  48514. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48515. /**
  48516. * Add the required uniforms to the current list.
  48517. * @param uniforms defines the current uniform list.
  48518. */
  48519. static AddUniforms(uniforms: string[]): void;
  48520. /**
  48521. * Add the required samplers to the current list.
  48522. * @param samplers defines the current sampler list.
  48523. */
  48524. static AddSamplers(samplers: string[]): void;
  48525. /**
  48526. * Add the required uniforms to the current buffer.
  48527. * @param uniformBuffer defines the current uniform buffer.
  48528. */
  48529. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48530. /**
  48531. * Makes a duplicate of the current configuration into another one.
  48532. * @param configuration define the config where to copy the info
  48533. */
  48534. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48535. /**
  48536. * Serializes this Sub Surface configuration.
  48537. * @returns - An object with the serialized config.
  48538. */
  48539. serialize(): any;
  48540. /**
  48541. * Parses a anisotropy Configuration from a serialized object.
  48542. * @param source - Serialized object.
  48543. * @param scene Defines the scene we are parsing for
  48544. * @param rootUrl Defines the rootUrl to load from
  48545. */
  48546. parse(source: any, scene: Scene, rootUrl: string): void;
  48547. }
  48548. }
  48549. declare module BABYLON {
  48550. /** @hidden */
  48551. export var pbrFragmentDeclaration: {
  48552. name: string;
  48553. shader: string;
  48554. };
  48555. }
  48556. declare module BABYLON {
  48557. /** @hidden */
  48558. export var pbrUboDeclaration: {
  48559. name: string;
  48560. shader: string;
  48561. };
  48562. }
  48563. declare module BABYLON {
  48564. /** @hidden */
  48565. export var pbrFragmentExtraDeclaration: {
  48566. name: string;
  48567. shader: string;
  48568. };
  48569. }
  48570. declare module BABYLON {
  48571. /** @hidden */
  48572. export var pbrFragmentSamplersDeclaration: {
  48573. name: string;
  48574. shader: string;
  48575. };
  48576. }
  48577. declare module BABYLON {
  48578. /** @hidden */
  48579. export var pbrHelperFunctions: {
  48580. name: string;
  48581. shader: string;
  48582. };
  48583. }
  48584. declare module BABYLON {
  48585. /** @hidden */
  48586. export var harmonicsFunctions: {
  48587. name: string;
  48588. shader: string;
  48589. };
  48590. }
  48591. declare module BABYLON {
  48592. /** @hidden */
  48593. export var pbrDirectLightingSetupFunctions: {
  48594. name: string;
  48595. shader: string;
  48596. };
  48597. }
  48598. declare module BABYLON {
  48599. /** @hidden */
  48600. export var pbrDirectLightingFalloffFunctions: {
  48601. name: string;
  48602. shader: string;
  48603. };
  48604. }
  48605. declare module BABYLON {
  48606. /** @hidden */
  48607. export var pbrBRDFFunctions: {
  48608. name: string;
  48609. shader: string;
  48610. };
  48611. }
  48612. declare module BABYLON {
  48613. /** @hidden */
  48614. export var pbrDirectLightingFunctions: {
  48615. name: string;
  48616. shader: string;
  48617. };
  48618. }
  48619. declare module BABYLON {
  48620. /** @hidden */
  48621. export var pbrIBLFunctions: {
  48622. name: string;
  48623. shader: string;
  48624. };
  48625. }
  48626. declare module BABYLON {
  48627. /** @hidden */
  48628. export var pbrDebug: {
  48629. name: string;
  48630. shader: string;
  48631. };
  48632. }
  48633. declare module BABYLON {
  48634. /** @hidden */
  48635. export var pbrPixelShader: {
  48636. name: string;
  48637. shader: string;
  48638. };
  48639. }
  48640. declare module BABYLON {
  48641. /** @hidden */
  48642. export var pbrVertexDeclaration: {
  48643. name: string;
  48644. shader: string;
  48645. };
  48646. }
  48647. declare module BABYLON {
  48648. /** @hidden */
  48649. export var pbrVertexShader: {
  48650. name: string;
  48651. shader: string;
  48652. };
  48653. }
  48654. declare module BABYLON {
  48655. /**
  48656. * Manages the defines for the PBR Material.
  48657. * @hidden
  48658. */
  48659. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48660. PBR: boolean;
  48661. MAINUV1: boolean;
  48662. MAINUV2: boolean;
  48663. UV1: boolean;
  48664. UV2: boolean;
  48665. ALBEDO: boolean;
  48666. ALBEDODIRECTUV: number;
  48667. VERTEXCOLOR: boolean;
  48668. AMBIENT: boolean;
  48669. AMBIENTDIRECTUV: number;
  48670. AMBIENTINGRAYSCALE: boolean;
  48671. OPACITY: boolean;
  48672. VERTEXALPHA: boolean;
  48673. OPACITYDIRECTUV: number;
  48674. OPACITYRGB: boolean;
  48675. ALPHATEST: boolean;
  48676. DEPTHPREPASS: boolean;
  48677. ALPHABLEND: boolean;
  48678. ALPHAFROMALBEDO: boolean;
  48679. ALPHATESTVALUE: string;
  48680. SPECULAROVERALPHA: boolean;
  48681. RADIANCEOVERALPHA: boolean;
  48682. ALPHAFRESNEL: boolean;
  48683. LINEARALPHAFRESNEL: boolean;
  48684. PREMULTIPLYALPHA: boolean;
  48685. EMISSIVE: boolean;
  48686. EMISSIVEDIRECTUV: number;
  48687. REFLECTIVITY: boolean;
  48688. REFLECTIVITYDIRECTUV: number;
  48689. SPECULARTERM: boolean;
  48690. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48691. MICROSURFACEAUTOMATIC: boolean;
  48692. LODBASEDMICROSFURACE: boolean;
  48693. MICROSURFACEMAP: boolean;
  48694. MICROSURFACEMAPDIRECTUV: number;
  48695. METALLICWORKFLOW: boolean;
  48696. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48697. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48698. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48699. AOSTOREINMETALMAPRED: boolean;
  48700. METALLICF0FACTORFROMMETALLICMAP: boolean;
  48701. ENVIRONMENTBRDF: boolean;
  48702. ENVIRONMENTBRDF_RGBD: boolean;
  48703. NORMAL: boolean;
  48704. TANGENT: boolean;
  48705. BUMP: boolean;
  48706. BUMPDIRECTUV: number;
  48707. OBJECTSPACE_NORMALMAP: boolean;
  48708. PARALLAX: boolean;
  48709. PARALLAXOCCLUSION: boolean;
  48710. NORMALXYSCALE: boolean;
  48711. LIGHTMAP: boolean;
  48712. LIGHTMAPDIRECTUV: number;
  48713. USELIGHTMAPASSHADOWMAP: boolean;
  48714. GAMMALIGHTMAP: boolean;
  48715. RGBDLIGHTMAP: boolean;
  48716. REFLECTION: boolean;
  48717. REFLECTIONMAP_3D: boolean;
  48718. REFLECTIONMAP_SPHERICAL: boolean;
  48719. REFLECTIONMAP_PLANAR: boolean;
  48720. REFLECTIONMAP_CUBIC: boolean;
  48721. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48722. REFLECTIONMAP_PROJECTION: boolean;
  48723. REFLECTIONMAP_SKYBOX: boolean;
  48724. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48725. REFLECTIONMAP_EXPLICIT: boolean;
  48726. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48727. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48728. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48729. INVERTCUBICMAP: boolean;
  48730. USESPHERICALFROMREFLECTIONMAP: boolean;
  48731. USEIRRADIANCEMAP: boolean;
  48732. SPHERICAL_HARMONICS: boolean;
  48733. USESPHERICALINVERTEX: boolean;
  48734. REFLECTIONMAP_OPPOSITEZ: boolean;
  48735. LODINREFLECTIONALPHA: boolean;
  48736. GAMMAREFLECTION: boolean;
  48737. RGBDREFLECTION: boolean;
  48738. LINEARSPECULARREFLECTION: boolean;
  48739. RADIANCEOCCLUSION: boolean;
  48740. HORIZONOCCLUSION: boolean;
  48741. INSTANCES: boolean;
  48742. NUM_BONE_INFLUENCERS: number;
  48743. BonesPerMesh: number;
  48744. BONETEXTURE: boolean;
  48745. NONUNIFORMSCALING: boolean;
  48746. MORPHTARGETS: boolean;
  48747. MORPHTARGETS_NORMAL: boolean;
  48748. MORPHTARGETS_TANGENT: boolean;
  48749. MORPHTARGETS_UV: boolean;
  48750. NUM_MORPH_INFLUENCERS: number;
  48751. IMAGEPROCESSING: boolean;
  48752. VIGNETTE: boolean;
  48753. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48754. VIGNETTEBLENDMODEOPAQUE: boolean;
  48755. TONEMAPPING: boolean;
  48756. TONEMAPPING_ACES: boolean;
  48757. CONTRAST: boolean;
  48758. COLORCURVES: boolean;
  48759. COLORGRADING: boolean;
  48760. COLORGRADING3D: boolean;
  48761. SAMPLER3DGREENDEPTH: boolean;
  48762. SAMPLER3DBGRMAP: boolean;
  48763. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48764. EXPOSURE: boolean;
  48765. MULTIVIEW: boolean;
  48766. USEPHYSICALLIGHTFALLOFF: boolean;
  48767. USEGLTFLIGHTFALLOFF: boolean;
  48768. TWOSIDEDLIGHTING: boolean;
  48769. SHADOWFLOAT: boolean;
  48770. CLIPPLANE: boolean;
  48771. CLIPPLANE2: boolean;
  48772. CLIPPLANE3: boolean;
  48773. CLIPPLANE4: boolean;
  48774. POINTSIZE: boolean;
  48775. FOG: boolean;
  48776. LOGARITHMICDEPTH: boolean;
  48777. FORCENORMALFORWARD: boolean;
  48778. SPECULARAA: boolean;
  48779. CLEARCOAT: boolean;
  48780. CLEARCOAT_DEFAULTIOR: boolean;
  48781. CLEARCOAT_TEXTURE: boolean;
  48782. CLEARCOAT_TEXTUREDIRECTUV: number;
  48783. CLEARCOAT_BUMP: boolean;
  48784. CLEARCOAT_BUMPDIRECTUV: number;
  48785. CLEARCOAT_TINT: boolean;
  48786. CLEARCOAT_TINT_TEXTURE: boolean;
  48787. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48788. ANISOTROPIC: boolean;
  48789. ANISOTROPIC_TEXTURE: boolean;
  48790. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48791. BRDF_V_HEIGHT_CORRELATED: boolean;
  48792. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48793. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48794. SHEEN: boolean;
  48795. SHEEN_TEXTURE: boolean;
  48796. SHEEN_TEXTUREDIRECTUV: number;
  48797. SHEEN_LINKWITHALBEDO: boolean;
  48798. SUBSURFACE: boolean;
  48799. SS_REFRACTION: boolean;
  48800. SS_TRANSLUCENCY: boolean;
  48801. SS_SCATERRING: boolean;
  48802. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48803. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48804. SS_REFRACTIONMAP_3D: boolean;
  48805. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48806. SS_LODINREFRACTIONALPHA: boolean;
  48807. SS_GAMMAREFRACTION: boolean;
  48808. SS_RGBDREFRACTION: boolean;
  48809. SS_LINEARSPECULARREFRACTION: boolean;
  48810. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48811. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48812. UNLIT: boolean;
  48813. DEBUGMODE: number;
  48814. /**
  48815. * Initializes the PBR Material defines.
  48816. */
  48817. constructor();
  48818. /**
  48819. * Resets the PBR Material defines.
  48820. */
  48821. reset(): void;
  48822. }
  48823. /**
  48824. * The Physically based material base class of BJS.
  48825. *
  48826. * This offers the main features of a standard PBR material.
  48827. * For more information, please refer to the documentation :
  48828. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48829. */
  48830. export abstract class PBRBaseMaterial extends PushMaterial {
  48831. /**
  48832. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48833. */
  48834. static readonly PBRMATERIAL_OPAQUE: number;
  48835. /**
  48836. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48837. */
  48838. static readonly PBRMATERIAL_ALPHATEST: number;
  48839. /**
  48840. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48841. */
  48842. static readonly PBRMATERIAL_ALPHABLEND: number;
  48843. /**
  48844. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48845. * They are also discarded below the alpha cutoff threshold to improve performances.
  48846. */
  48847. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48848. /**
  48849. * Defines the default value of how much AO map is occluding the analytical lights
  48850. * (point spot...).
  48851. */
  48852. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48853. /**
  48854. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48855. */
  48856. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48857. /**
  48858. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48859. * to enhance interoperability with other engines.
  48860. */
  48861. static readonly LIGHTFALLOFF_GLTF: number;
  48862. /**
  48863. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48864. * to enhance interoperability with other materials.
  48865. */
  48866. static readonly LIGHTFALLOFF_STANDARD: number;
  48867. /**
  48868. * Intensity of the direct lights e.g. the four lights available in your scene.
  48869. * This impacts both the direct diffuse and specular highlights.
  48870. */
  48871. protected _directIntensity: number;
  48872. /**
  48873. * Intensity of the emissive part of the material.
  48874. * This helps controlling the emissive effect without modifying the emissive color.
  48875. */
  48876. protected _emissiveIntensity: number;
  48877. /**
  48878. * Intensity of the environment e.g. how much the environment will light the object
  48879. * either through harmonics for rough material or through the refelction for shiny ones.
  48880. */
  48881. protected _environmentIntensity: number;
  48882. /**
  48883. * This is a special control allowing the reduction of the specular highlights coming from the
  48884. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48885. */
  48886. protected _specularIntensity: number;
  48887. /**
  48888. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48889. */
  48890. private _lightingInfos;
  48891. /**
  48892. * Debug Control allowing disabling the bump map on this material.
  48893. */
  48894. protected _disableBumpMap: boolean;
  48895. /**
  48896. * AKA Diffuse Texture in standard nomenclature.
  48897. */
  48898. protected _albedoTexture: Nullable<BaseTexture>;
  48899. /**
  48900. * AKA Occlusion Texture in other nomenclature.
  48901. */
  48902. protected _ambientTexture: Nullable<BaseTexture>;
  48903. /**
  48904. * AKA Occlusion Texture Intensity in other nomenclature.
  48905. */
  48906. protected _ambientTextureStrength: number;
  48907. /**
  48908. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48909. * 1 means it completely occludes it
  48910. * 0 mean it has no impact
  48911. */
  48912. protected _ambientTextureImpactOnAnalyticalLights: number;
  48913. /**
  48914. * Stores the alpha values in a texture.
  48915. */
  48916. protected _opacityTexture: Nullable<BaseTexture>;
  48917. /**
  48918. * Stores the reflection values in a texture.
  48919. */
  48920. protected _reflectionTexture: Nullable<BaseTexture>;
  48921. /**
  48922. * Stores the emissive values in a texture.
  48923. */
  48924. protected _emissiveTexture: Nullable<BaseTexture>;
  48925. /**
  48926. * AKA Specular texture in other nomenclature.
  48927. */
  48928. protected _reflectivityTexture: Nullable<BaseTexture>;
  48929. /**
  48930. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48931. */
  48932. protected _metallicTexture: Nullable<BaseTexture>;
  48933. /**
  48934. * Specifies the metallic scalar of the metallic/roughness workflow.
  48935. * Can also be used to scale the metalness values of the metallic texture.
  48936. */
  48937. protected _metallic: Nullable<number>;
  48938. /**
  48939. * Specifies the roughness scalar of the metallic/roughness workflow.
  48940. * Can also be used to scale the roughness values of the metallic texture.
  48941. */
  48942. protected _roughness: Nullable<number>;
  48943. /**
  48944. * Specifies the an F0 factor to help configuring the material F0.
  48945. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48946. * to 0.5 the previously hard coded value stays the same.
  48947. * Can also be used to scale the F0 values of the metallic texture.
  48948. */
  48949. protected _metallicF0Factor: number;
  48950. /**
  48951. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48952. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48953. * your expectation as it multiplies with the texture data.
  48954. */
  48955. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  48956. /**
  48957. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48958. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48959. */
  48960. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48961. /**
  48962. * Stores surface normal data used to displace a mesh in a texture.
  48963. */
  48964. protected _bumpTexture: Nullable<BaseTexture>;
  48965. /**
  48966. * Stores the pre-calculated light information of a mesh in a texture.
  48967. */
  48968. protected _lightmapTexture: Nullable<BaseTexture>;
  48969. /**
  48970. * The color of a material in ambient lighting.
  48971. */
  48972. protected _ambientColor: Color3;
  48973. /**
  48974. * AKA Diffuse Color in other nomenclature.
  48975. */
  48976. protected _albedoColor: Color3;
  48977. /**
  48978. * AKA Specular Color in other nomenclature.
  48979. */
  48980. protected _reflectivityColor: Color3;
  48981. /**
  48982. * The color applied when light is reflected from a material.
  48983. */
  48984. protected _reflectionColor: Color3;
  48985. /**
  48986. * The color applied when light is emitted from a material.
  48987. */
  48988. protected _emissiveColor: Color3;
  48989. /**
  48990. * AKA Glossiness in other nomenclature.
  48991. */
  48992. protected _microSurface: number;
  48993. /**
  48994. * Specifies that the material will use the light map as a show map.
  48995. */
  48996. protected _useLightmapAsShadowmap: boolean;
  48997. /**
  48998. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48999. * makes the reflect vector face the model (under horizon).
  49000. */
  49001. protected _useHorizonOcclusion: boolean;
  49002. /**
  49003. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49004. * too much the area relying on ambient texture to define their ambient occlusion.
  49005. */
  49006. protected _useRadianceOcclusion: boolean;
  49007. /**
  49008. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49009. */
  49010. protected _useAlphaFromAlbedoTexture: boolean;
  49011. /**
  49012. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49013. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49014. */
  49015. protected _useSpecularOverAlpha: boolean;
  49016. /**
  49017. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49018. */
  49019. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49020. /**
  49021. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49022. */
  49023. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49024. /**
  49025. * Specifies if the metallic texture contains the roughness information in its green channel.
  49026. */
  49027. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49028. /**
  49029. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49030. */
  49031. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49032. /**
  49033. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49034. */
  49035. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49036. /**
  49037. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49038. */
  49039. protected _useAmbientInGrayScale: boolean;
  49040. /**
  49041. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49042. * The material will try to infer what glossiness each pixel should be.
  49043. */
  49044. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49045. /**
  49046. * Defines the falloff type used in this material.
  49047. * It by default is Physical.
  49048. */
  49049. protected _lightFalloff: number;
  49050. /**
  49051. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49052. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49053. */
  49054. protected _useRadianceOverAlpha: boolean;
  49055. /**
  49056. * Allows using an object space normal map (instead of tangent space).
  49057. */
  49058. protected _useObjectSpaceNormalMap: boolean;
  49059. /**
  49060. * Allows using the bump map in parallax mode.
  49061. */
  49062. protected _useParallax: boolean;
  49063. /**
  49064. * Allows using the bump map in parallax occlusion mode.
  49065. */
  49066. protected _useParallaxOcclusion: boolean;
  49067. /**
  49068. * Controls the scale bias of the parallax mode.
  49069. */
  49070. protected _parallaxScaleBias: number;
  49071. /**
  49072. * If sets to true, disables all the lights affecting the material.
  49073. */
  49074. protected _disableLighting: boolean;
  49075. /**
  49076. * Number of Simultaneous lights allowed on the material.
  49077. */
  49078. protected _maxSimultaneousLights: number;
  49079. /**
  49080. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49081. */
  49082. protected _invertNormalMapX: boolean;
  49083. /**
  49084. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49085. */
  49086. protected _invertNormalMapY: boolean;
  49087. /**
  49088. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49089. */
  49090. protected _twoSidedLighting: boolean;
  49091. /**
  49092. * Defines the alpha limits in alpha test mode.
  49093. */
  49094. protected _alphaCutOff: number;
  49095. /**
  49096. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49097. */
  49098. protected _forceAlphaTest: boolean;
  49099. /**
  49100. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49101. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49102. */
  49103. protected _useAlphaFresnel: boolean;
  49104. /**
  49105. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49106. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49107. */
  49108. protected _useLinearAlphaFresnel: boolean;
  49109. /**
  49110. * The transparency mode of the material.
  49111. */
  49112. protected _transparencyMode: Nullable<number>;
  49113. /**
  49114. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49115. * from cos thetav and roughness:
  49116. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49117. */
  49118. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49119. /**
  49120. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49121. */
  49122. protected _forceIrradianceInFragment: boolean;
  49123. /**
  49124. * Force normal to face away from face.
  49125. */
  49126. protected _forceNormalForward: boolean;
  49127. /**
  49128. * Enables specular anti aliasing in the PBR shader.
  49129. * It will both interacts on the Geometry for analytical and IBL lighting.
  49130. * It also prefilter the roughness map based on the bump values.
  49131. */
  49132. protected _enableSpecularAntiAliasing: boolean;
  49133. /**
  49134. * Default configuration related to image processing available in the PBR Material.
  49135. */
  49136. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49137. /**
  49138. * Keep track of the image processing observer to allow dispose and replace.
  49139. */
  49140. private _imageProcessingObserver;
  49141. /**
  49142. * Attaches a new image processing configuration to the PBR Material.
  49143. * @param configuration
  49144. */
  49145. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49146. /**
  49147. * Stores the available render targets.
  49148. */
  49149. private _renderTargets;
  49150. /**
  49151. * Sets the global ambient color for the material used in lighting calculations.
  49152. */
  49153. private _globalAmbientColor;
  49154. /**
  49155. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49156. */
  49157. private _useLogarithmicDepth;
  49158. /**
  49159. * If set to true, no lighting calculations will be applied.
  49160. */
  49161. private _unlit;
  49162. private _debugMode;
  49163. /**
  49164. * @hidden
  49165. * This is reserved for the inspector.
  49166. * Defines the material debug mode.
  49167. * It helps seeing only some components of the material while troubleshooting.
  49168. */
  49169. debugMode: number;
  49170. /**
  49171. * @hidden
  49172. * This is reserved for the inspector.
  49173. * Specify from where on screen the debug mode should start.
  49174. * The value goes from -1 (full screen) to 1 (not visible)
  49175. * It helps with side by side comparison against the final render
  49176. * This defaults to -1
  49177. */
  49178. private debugLimit;
  49179. /**
  49180. * @hidden
  49181. * This is reserved for the inspector.
  49182. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49183. * You can use the factor to better multiply the final value.
  49184. */
  49185. private debugFactor;
  49186. /**
  49187. * Defines the clear coat layer parameters for the material.
  49188. */
  49189. readonly clearCoat: PBRClearCoatConfiguration;
  49190. /**
  49191. * Defines the anisotropic parameters for the material.
  49192. */
  49193. readonly anisotropy: PBRAnisotropicConfiguration;
  49194. /**
  49195. * Defines the BRDF parameters for the material.
  49196. */
  49197. readonly brdf: PBRBRDFConfiguration;
  49198. /**
  49199. * Defines the Sheen parameters for the material.
  49200. */
  49201. readonly sheen: PBRSheenConfiguration;
  49202. /**
  49203. * Defines the SubSurface parameters for the material.
  49204. */
  49205. readonly subSurface: PBRSubSurfaceConfiguration;
  49206. /**
  49207. * Custom callback helping to override the default shader used in the material.
  49208. */
  49209. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49210. protected _rebuildInParallel: boolean;
  49211. /**
  49212. * Instantiates a new PBRMaterial instance.
  49213. *
  49214. * @param name The material name
  49215. * @param scene The scene the material will be use in.
  49216. */
  49217. constructor(name: string, scene: Scene);
  49218. /**
  49219. * Gets a boolean indicating that current material needs to register RTT
  49220. */
  49221. readonly hasRenderTargetTextures: boolean;
  49222. /**
  49223. * Gets the name of the material class.
  49224. */
  49225. getClassName(): string;
  49226. /**
  49227. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49228. */
  49229. /**
  49230. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49231. */
  49232. useLogarithmicDepth: boolean;
  49233. /**
  49234. * Gets the current transparency mode.
  49235. */
  49236. /**
  49237. * Sets the transparency mode of the material.
  49238. *
  49239. * | Value | Type | Description |
  49240. * | ----- | ----------------------------------- | ----------- |
  49241. * | 0 | OPAQUE | |
  49242. * | 1 | ALPHATEST | |
  49243. * | 2 | ALPHABLEND | |
  49244. * | 3 | ALPHATESTANDBLEND | |
  49245. *
  49246. */
  49247. transparencyMode: Nullable<number>;
  49248. /**
  49249. * Returns true if alpha blending should be disabled.
  49250. */
  49251. private readonly _disableAlphaBlending;
  49252. /**
  49253. * Specifies whether or not this material should be rendered in alpha blend mode.
  49254. */
  49255. needAlphaBlending(): boolean;
  49256. /**
  49257. * Specifies if the mesh will require alpha blending.
  49258. * @param mesh - BJS mesh.
  49259. */
  49260. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49261. /**
  49262. * Specifies whether or not this material should be rendered in alpha test mode.
  49263. */
  49264. needAlphaTesting(): boolean;
  49265. /**
  49266. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49267. */
  49268. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49269. /**
  49270. * Gets the texture used for the alpha test.
  49271. */
  49272. getAlphaTestTexture(): Nullable<BaseTexture>;
  49273. /**
  49274. * Specifies that the submesh is ready to be used.
  49275. * @param mesh - BJS mesh.
  49276. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49277. * @param useInstances - Specifies that instances should be used.
  49278. * @returns - boolean indicating that the submesh is ready or not.
  49279. */
  49280. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49281. /**
  49282. * Specifies if the material uses metallic roughness workflow.
  49283. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49284. */
  49285. isMetallicWorkflow(): boolean;
  49286. private _prepareEffect;
  49287. private _prepareDefines;
  49288. /**
  49289. * Force shader compilation
  49290. */
  49291. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  49292. /**
  49293. * Initializes the uniform buffer layout for the shader.
  49294. */
  49295. buildUniformLayout(): void;
  49296. /**
  49297. * Unbinds the material from the mesh
  49298. */
  49299. unbind(): void;
  49300. /**
  49301. * Binds the submesh data.
  49302. * @param world - The world matrix.
  49303. * @param mesh - The BJS mesh.
  49304. * @param subMesh - A submesh of the BJS mesh.
  49305. */
  49306. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49307. /**
  49308. * Returns the animatable textures.
  49309. * @returns - Array of animatable textures.
  49310. */
  49311. getAnimatables(): IAnimatable[];
  49312. /**
  49313. * Returns the texture used for reflections.
  49314. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49315. */
  49316. private _getReflectionTexture;
  49317. /**
  49318. * Returns an array of the actively used textures.
  49319. * @returns - Array of BaseTextures
  49320. */
  49321. getActiveTextures(): BaseTexture[];
  49322. /**
  49323. * Checks to see if a texture is used in the material.
  49324. * @param texture - Base texture to use.
  49325. * @returns - Boolean specifying if a texture is used in the material.
  49326. */
  49327. hasTexture(texture: BaseTexture): boolean;
  49328. /**
  49329. * Disposes the resources of the material.
  49330. * @param forceDisposeEffect - Forces the disposal of effects.
  49331. * @param forceDisposeTextures - Forces the disposal of all textures.
  49332. */
  49333. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49334. }
  49335. }
  49336. declare module BABYLON {
  49337. /**
  49338. * The Physically based material of BJS.
  49339. *
  49340. * This offers the main features of a standard PBR material.
  49341. * For more information, please refer to the documentation :
  49342. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49343. */
  49344. export class PBRMaterial extends PBRBaseMaterial {
  49345. /**
  49346. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49347. */
  49348. static readonly PBRMATERIAL_OPAQUE: number;
  49349. /**
  49350. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49351. */
  49352. static readonly PBRMATERIAL_ALPHATEST: number;
  49353. /**
  49354. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49355. */
  49356. static readonly PBRMATERIAL_ALPHABLEND: number;
  49357. /**
  49358. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49359. * They are also discarded below the alpha cutoff threshold to improve performances.
  49360. */
  49361. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49362. /**
  49363. * Defines the default value of how much AO map is occluding the analytical lights
  49364. * (point spot...).
  49365. */
  49366. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49367. /**
  49368. * Intensity of the direct lights e.g. the four lights available in your scene.
  49369. * This impacts both the direct diffuse and specular highlights.
  49370. */
  49371. directIntensity: number;
  49372. /**
  49373. * Intensity of the emissive part of the material.
  49374. * This helps controlling the emissive effect without modifying the emissive color.
  49375. */
  49376. emissiveIntensity: number;
  49377. /**
  49378. * Intensity of the environment e.g. how much the environment will light the object
  49379. * either through harmonics for rough material or through the refelction for shiny ones.
  49380. */
  49381. environmentIntensity: number;
  49382. /**
  49383. * This is a special control allowing the reduction of the specular highlights coming from the
  49384. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49385. */
  49386. specularIntensity: number;
  49387. /**
  49388. * Debug Control allowing disabling the bump map on this material.
  49389. */
  49390. disableBumpMap: boolean;
  49391. /**
  49392. * AKA Diffuse Texture in standard nomenclature.
  49393. */
  49394. albedoTexture: BaseTexture;
  49395. /**
  49396. * AKA Occlusion Texture in other nomenclature.
  49397. */
  49398. ambientTexture: BaseTexture;
  49399. /**
  49400. * AKA Occlusion Texture Intensity in other nomenclature.
  49401. */
  49402. ambientTextureStrength: number;
  49403. /**
  49404. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49405. * 1 means it completely occludes it
  49406. * 0 mean it has no impact
  49407. */
  49408. ambientTextureImpactOnAnalyticalLights: number;
  49409. /**
  49410. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  49411. */
  49412. opacityTexture: BaseTexture;
  49413. /**
  49414. * Stores the reflection values in a texture.
  49415. */
  49416. reflectionTexture: Nullable<BaseTexture>;
  49417. /**
  49418. * Stores the emissive values in a texture.
  49419. */
  49420. emissiveTexture: BaseTexture;
  49421. /**
  49422. * AKA Specular texture in other nomenclature.
  49423. */
  49424. reflectivityTexture: BaseTexture;
  49425. /**
  49426. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49427. */
  49428. metallicTexture: BaseTexture;
  49429. /**
  49430. * Specifies the metallic scalar of the metallic/roughness workflow.
  49431. * Can also be used to scale the metalness values of the metallic texture.
  49432. */
  49433. metallic: Nullable<number>;
  49434. /**
  49435. * Specifies the roughness scalar of the metallic/roughness workflow.
  49436. * Can also be used to scale the roughness values of the metallic texture.
  49437. */
  49438. roughness: Nullable<number>;
  49439. /**
  49440. * Specifies the an F0 factor to help configuring the material F0.
  49441. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49442. * to 0.5 the previously hard coded value stays the same.
  49443. * Can also be used to scale the F0 values of the metallic texture.
  49444. */
  49445. metallicF0Factor: number;
  49446. /**
  49447. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  49448. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  49449. * your expectation as it multiplies with the texture data.
  49450. */
  49451. useMetallicF0FactorFromMetallicTexture: boolean;
  49452. /**
  49453. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49454. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49455. */
  49456. microSurfaceTexture: BaseTexture;
  49457. /**
  49458. * Stores surface normal data used to displace a mesh in a texture.
  49459. */
  49460. bumpTexture: BaseTexture;
  49461. /**
  49462. * Stores the pre-calculated light information of a mesh in a texture.
  49463. */
  49464. lightmapTexture: BaseTexture;
  49465. /**
  49466. * Stores the refracted light information in a texture.
  49467. */
  49468. refractionTexture: Nullable<BaseTexture>;
  49469. /**
  49470. * The color of a material in ambient lighting.
  49471. */
  49472. ambientColor: Color3;
  49473. /**
  49474. * AKA Diffuse Color in other nomenclature.
  49475. */
  49476. albedoColor: Color3;
  49477. /**
  49478. * AKA Specular Color in other nomenclature.
  49479. */
  49480. reflectivityColor: Color3;
  49481. /**
  49482. * The color reflected from the material.
  49483. */
  49484. reflectionColor: Color3;
  49485. /**
  49486. * The color emitted from the material.
  49487. */
  49488. emissiveColor: Color3;
  49489. /**
  49490. * AKA Glossiness in other nomenclature.
  49491. */
  49492. microSurface: number;
  49493. /**
  49494. * source material index of refraction (IOR)' / 'destination material IOR.
  49495. */
  49496. indexOfRefraction: number;
  49497. /**
  49498. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49499. */
  49500. invertRefractionY: boolean;
  49501. /**
  49502. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49503. * Materials half opaque for instance using refraction could benefit from this control.
  49504. */
  49505. linkRefractionWithTransparency: boolean;
  49506. /**
  49507. * If true, the light map contains occlusion information instead of lighting info.
  49508. */
  49509. useLightmapAsShadowmap: boolean;
  49510. /**
  49511. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49512. */
  49513. useAlphaFromAlbedoTexture: boolean;
  49514. /**
  49515. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49516. */
  49517. forceAlphaTest: boolean;
  49518. /**
  49519. * Defines the alpha limits in alpha test mode.
  49520. */
  49521. alphaCutOff: number;
  49522. /**
  49523. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49524. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49525. */
  49526. useSpecularOverAlpha: boolean;
  49527. /**
  49528. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49529. */
  49530. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49531. /**
  49532. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49533. */
  49534. useRoughnessFromMetallicTextureAlpha: boolean;
  49535. /**
  49536. * Specifies if the metallic texture contains the roughness information in its green channel.
  49537. */
  49538. useRoughnessFromMetallicTextureGreen: boolean;
  49539. /**
  49540. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49541. */
  49542. useMetallnessFromMetallicTextureBlue: boolean;
  49543. /**
  49544. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49545. */
  49546. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49547. /**
  49548. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49549. */
  49550. useAmbientInGrayScale: boolean;
  49551. /**
  49552. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49553. * The material will try to infer what glossiness each pixel should be.
  49554. */
  49555. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49556. /**
  49557. * BJS is using an harcoded light falloff based on a manually sets up range.
  49558. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49559. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49560. */
  49561. /**
  49562. * BJS is using an harcoded light falloff based on a manually sets up range.
  49563. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49564. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49565. */
  49566. usePhysicalLightFalloff: boolean;
  49567. /**
  49568. * In order to support the falloff compatibility with gltf, a special mode has been added
  49569. * to reproduce the gltf light falloff.
  49570. */
  49571. /**
  49572. * In order to support the falloff compatibility with gltf, a special mode has been added
  49573. * to reproduce the gltf light falloff.
  49574. */
  49575. useGLTFLightFalloff: boolean;
  49576. /**
  49577. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49578. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49579. */
  49580. useRadianceOverAlpha: boolean;
  49581. /**
  49582. * Allows using an object space normal map (instead of tangent space).
  49583. */
  49584. useObjectSpaceNormalMap: boolean;
  49585. /**
  49586. * Allows using the bump map in parallax mode.
  49587. */
  49588. useParallax: boolean;
  49589. /**
  49590. * Allows using the bump map in parallax occlusion mode.
  49591. */
  49592. useParallaxOcclusion: boolean;
  49593. /**
  49594. * Controls the scale bias of the parallax mode.
  49595. */
  49596. parallaxScaleBias: number;
  49597. /**
  49598. * If sets to true, disables all the lights affecting the material.
  49599. */
  49600. disableLighting: boolean;
  49601. /**
  49602. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49603. */
  49604. forceIrradianceInFragment: boolean;
  49605. /**
  49606. * Number of Simultaneous lights allowed on the material.
  49607. */
  49608. maxSimultaneousLights: number;
  49609. /**
  49610. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49611. */
  49612. invertNormalMapX: boolean;
  49613. /**
  49614. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49615. */
  49616. invertNormalMapY: boolean;
  49617. /**
  49618. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49619. */
  49620. twoSidedLighting: boolean;
  49621. /**
  49622. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49623. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49624. */
  49625. useAlphaFresnel: boolean;
  49626. /**
  49627. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49628. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49629. */
  49630. useLinearAlphaFresnel: boolean;
  49631. /**
  49632. * Let user defines the brdf lookup texture used for IBL.
  49633. * A default 8bit version is embedded but you could point at :
  49634. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49635. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49636. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49637. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49638. */
  49639. environmentBRDFTexture: Nullable<BaseTexture>;
  49640. /**
  49641. * Force normal to face away from face.
  49642. */
  49643. forceNormalForward: boolean;
  49644. /**
  49645. * Enables specular anti aliasing in the PBR shader.
  49646. * It will both interacts on the Geometry for analytical and IBL lighting.
  49647. * It also prefilter the roughness map based on the bump values.
  49648. */
  49649. enableSpecularAntiAliasing: boolean;
  49650. /**
  49651. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49652. * makes the reflect vector face the model (under horizon).
  49653. */
  49654. useHorizonOcclusion: boolean;
  49655. /**
  49656. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49657. * too much the area relying on ambient texture to define their ambient occlusion.
  49658. */
  49659. useRadianceOcclusion: boolean;
  49660. /**
  49661. * If set to true, no lighting calculations will be applied.
  49662. */
  49663. unlit: boolean;
  49664. /**
  49665. * Gets the image processing configuration used either in this material.
  49666. */
  49667. /**
  49668. * Sets the Default image processing configuration used either in the this material.
  49669. *
  49670. * If sets to null, the scene one is in use.
  49671. */
  49672. imageProcessingConfiguration: ImageProcessingConfiguration;
  49673. /**
  49674. * Gets wether the color curves effect is enabled.
  49675. */
  49676. /**
  49677. * Sets wether the color curves effect is enabled.
  49678. */
  49679. cameraColorCurvesEnabled: boolean;
  49680. /**
  49681. * Gets wether the color grading effect is enabled.
  49682. */
  49683. /**
  49684. * Gets wether the color grading effect is enabled.
  49685. */
  49686. cameraColorGradingEnabled: boolean;
  49687. /**
  49688. * Gets wether tonemapping is enabled or not.
  49689. */
  49690. /**
  49691. * Sets wether tonemapping is enabled or not
  49692. */
  49693. cameraToneMappingEnabled: boolean;
  49694. /**
  49695. * The camera exposure used on this material.
  49696. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49697. * This corresponds to a photographic exposure.
  49698. */
  49699. /**
  49700. * The camera exposure used on this material.
  49701. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49702. * This corresponds to a photographic exposure.
  49703. */
  49704. cameraExposure: number;
  49705. /**
  49706. * Gets The camera contrast used on this material.
  49707. */
  49708. /**
  49709. * Sets The camera contrast used on this material.
  49710. */
  49711. cameraContrast: number;
  49712. /**
  49713. * Gets the Color Grading 2D Lookup Texture.
  49714. */
  49715. /**
  49716. * Sets the Color Grading 2D Lookup Texture.
  49717. */
  49718. cameraColorGradingTexture: Nullable<BaseTexture>;
  49719. /**
  49720. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49721. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49722. * 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;
  49723. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49724. */
  49725. /**
  49726. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49727. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49728. * 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;
  49729. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49730. */
  49731. cameraColorCurves: Nullable<ColorCurves>;
  49732. /**
  49733. * Instantiates a new PBRMaterial instance.
  49734. *
  49735. * @param name The material name
  49736. * @param scene The scene the material will be use in.
  49737. */
  49738. constructor(name: string, scene: Scene);
  49739. /**
  49740. * Returns the name of this material class.
  49741. */
  49742. getClassName(): string;
  49743. /**
  49744. * Makes a duplicate of the current material.
  49745. * @param name - name to use for the new material.
  49746. */
  49747. clone(name: string): PBRMaterial;
  49748. /**
  49749. * Serializes this PBR Material.
  49750. * @returns - An object with the serialized material.
  49751. */
  49752. serialize(): any;
  49753. /**
  49754. * Parses a PBR Material from a serialized object.
  49755. * @param source - Serialized object.
  49756. * @param scene - BJS scene instance.
  49757. * @param rootUrl - url for the scene object
  49758. * @returns - PBRMaterial
  49759. */
  49760. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49761. }
  49762. }
  49763. declare module BABYLON {
  49764. /**
  49765. * Direct draw surface info
  49766. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49767. */
  49768. export interface DDSInfo {
  49769. /**
  49770. * Width of the texture
  49771. */
  49772. width: number;
  49773. /**
  49774. * Width of the texture
  49775. */
  49776. height: number;
  49777. /**
  49778. * Number of Mipmaps for the texture
  49779. * @see https://en.wikipedia.org/wiki/Mipmap
  49780. */
  49781. mipmapCount: number;
  49782. /**
  49783. * If the textures format is a known fourCC format
  49784. * @see https://www.fourcc.org/
  49785. */
  49786. isFourCC: boolean;
  49787. /**
  49788. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49789. */
  49790. isRGB: boolean;
  49791. /**
  49792. * If the texture is a lumincance format
  49793. */
  49794. isLuminance: boolean;
  49795. /**
  49796. * If this is a cube texture
  49797. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49798. */
  49799. isCube: boolean;
  49800. /**
  49801. * If the texture is a compressed format eg. FOURCC_DXT1
  49802. */
  49803. isCompressed: boolean;
  49804. /**
  49805. * The dxgiFormat of the texture
  49806. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49807. */
  49808. dxgiFormat: number;
  49809. /**
  49810. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49811. */
  49812. textureType: number;
  49813. /**
  49814. * Sphericle polynomial created for the dds texture
  49815. */
  49816. sphericalPolynomial?: SphericalPolynomial;
  49817. }
  49818. /**
  49819. * Class used to provide DDS decompression tools
  49820. */
  49821. export class DDSTools {
  49822. /**
  49823. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49824. */
  49825. static StoreLODInAlphaChannel: boolean;
  49826. /**
  49827. * Gets DDS information from an array buffer
  49828. * @param arrayBuffer defines the array buffer to read data from
  49829. * @returns the DDS information
  49830. */
  49831. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49832. private static _FloatView;
  49833. private static _Int32View;
  49834. private static _ToHalfFloat;
  49835. private static _FromHalfFloat;
  49836. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49837. private static _GetHalfFloatRGBAArrayBuffer;
  49838. private static _GetFloatRGBAArrayBuffer;
  49839. private static _GetFloatAsUIntRGBAArrayBuffer;
  49840. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49841. private static _GetRGBAArrayBuffer;
  49842. private static _ExtractLongWordOrder;
  49843. private static _GetRGBArrayBuffer;
  49844. private static _GetLuminanceArrayBuffer;
  49845. /**
  49846. * Uploads DDS Levels to a Babylon Texture
  49847. * @hidden
  49848. */
  49849. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49850. }
  49851. interface ThinEngine {
  49852. /**
  49853. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49854. * @param rootUrl defines the url where the file to load is located
  49855. * @param scene defines the current scene
  49856. * @param lodScale defines scale to apply to the mip map selection
  49857. * @param lodOffset defines offset to apply to the mip map selection
  49858. * @param onLoad defines an optional callback raised when the texture is loaded
  49859. * @param onError defines an optional callback raised if there is an issue to load the texture
  49860. * @param format defines the format of the data
  49861. * @param forcedExtension defines the extension to use to pick the right loader
  49862. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49863. * @returns the cube texture as an InternalTexture
  49864. */
  49865. 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;
  49866. }
  49867. }
  49868. declare module BABYLON {
  49869. /**
  49870. * Implementation of the DDS Texture Loader.
  49871. * @hidden
  49872. */
  49873. export class _DDSTextureLoader implements IInternalTextureLoader {
  49874. /**
  49875. * Defines wether the loader supports cascade loading the different faces.
  49876. */
  49877. readonly supportCascades: boolean;
  49878. /**
  49879. * This returns if the loader support the current file information.
  49880. * @param extension defines the file extension of the file being loaded
  49881. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49882. * @param fallback defines the fallback internal texture if any
  49883. * @param isBase64 defines whether the texture is encoded as a base64
  49884. * @param isBuffer defines whether the texture data are stored as a buffer
  49885. * @returns true if the loader can load the specified file
  49886. */
  49887. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49888. /**
  49889. * Transform the url before loading if required.
  49890. * @param rootUrl the url of the texture
  49891. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49892. * @returns the transformed texture
  49893. */
  49894. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49895. /**
  49896. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49897. * @param rootUrl the url of the texture
  49898. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49899. * @returns the fallback texture
  49900. */
  49901. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49902. /**
  49903. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49904. * @param data contains the texture data
  49905. * @param texture defines the BabylonJS internal texture
  49906. * @param createPolynomials will be true if polynomials have been requested
  49907. * @param onLoad defines the callback to trigger once the texture is ready
  49908. * @param onError defines the callback to trigger in case of error
  49909. */
  49910. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49911. /**
  49912. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49913. * @param data contains the texture data
  49914. * @param texture defines the BabylonJS internal texture
  49915. * @param callback defines the method to call once ready to upload
  49916. */
  49917. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49918. }
  49919. }
  49920. declare module BABYLON {
  49921. /**
  49922. * Implementation of the ENV Texture Loader.
  49923. * @hidden
  49924. */
  49925. export class _ENVTextureLoader implements IInternalTextureLoader {
  49926. /**
  49927. * Defines wether the loader supports cascade loading the different faces.
  49928. */
  49929. readonly supportCascades: boolean;
  49930. /**
  49931. * This returns if the loader support the current file information.
  49932. * @param extension defines the file extension of the file being loaded
  49933. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49934. * @param fallback defines the fallback internal texture if any
  49935. * @param isBase64 defines whether the texture is encoded as a base64
  49936. * @param isBuffer defines whether the texture data are stored as a buffer
  49937. * @returns true if the loader can load the specified file
  49938. */
  49939. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49940. /**
  49941. * Transform the url before loading if required.
  49942. * @param rootUrl the url of the texture
  49943. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49944. * @returns the transformed texture
  49945. */
  49946. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49947. /**
  49948. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49949. * @param rootUrl the url of the texture
  49950. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49951. * @returns the fallback texture
  49952. */
  49953. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49954. /**
  49955. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49956. * @param data contains the texture data
  49957. * @param texture defines the BabylonJS internal texture
  49958. * @param createPolynomials will be true if polynomials have been requested
  49959. * @param onLoad defines the callback to trigger once the texture is ready
  49960. * @param onError defines the callback to trigger in case of error
  49961. */
  49962. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49963. /**
  49964. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49965. * @param data contains the texture data
  49966. * @param texture defines the BabylonJS internal texture
  49967. * @param callback defines the method to call once ready to upload
  49968. */
  49969. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49970. }
  49971. }
  49972. declare module BABYLON {
  49973. /**
  49974. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49975. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49976. */
  49977. export class KhronosTextureContainer {
  49978. /** contents of the KTX container file */
  49979. arrayBuffer: any;
  49980. private static HEADER_LEN;
  49981. private static COMPRESSED_2D;
  49982. private static COMPRESSED_3D;
  49983. private static TEX_2D;
  49984. private static TEX_3D;
  49985. /**
  49986. * Gets the openGL type
  49987. */
  49988. glType: number;
  49989. /**
  49990. * Gets the openGL type size
  49991. */
  49992. glTypeSize: number;
  49993. /**
  49994. * Gets the openGL format
  49995. */
  49996. glFormat: number;
  49997. /**
  49998. * Gets the openGL internal format
  49999. */
  50000. glInternalFormat: number;
  50001. /**
  50002. * Gets the base internal format
  50003. */
  50004. glBaseInternalFormat: number;
  50005. /**
  50006. * Gets image width in pixel
  50007. */
  50008. pixelWidth: number;
  50009. /**
  50010. * Gets image height in pixel
  50011. */
  50012. pixelHeight: number;
  50013. /**
  50014. * Gets image depth in pixels
  50015. */
  50016. pixelDepth: number;
  50017. /**
  50018. * Gets the number of array elements
  50019. */
  50020. numberOfArrayElements: number;
  50021. /**
  50022. * Gets the number of faces
  50023. */
  50024. numberOfFaces: number;
  50025. /**
  50026. * Gets the number of mipmap levels
  50027. */
  50028. numberOfMipmapLevels: number;
  50029. /**
  50030. * Gets the bytes of key value data
  50031. */
  50032. bytesOfKeyValueData: number;
  50033. /**
  50034. * Gets the load type
  50035. */
  50036. loadType: number;
  50037. /**
  50038. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50039. */
  50040. isInvalid: boolean;
  50041. /**
  50042. * Creates a new KhronosTextureContainer
  50043. * @param arrayBuffer contents of the KTX container file
  50044. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50045. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50046. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50047. */
  50048. constructor(
  50049. /** contents of the KTX container file */
  50050. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50051. /**
  50052. * Uploads KTX content to a Babylon Texture.
  50053. * It is assumed that the texture has already been created & is currently bound
  50054. * @hidden
  50055. */
  50056. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50057. private _upload2DCompressedLevels;
  50058. }
  50059. }
  50060. declare module BABYLON {
  50061. /**
  50062. * Implementation of the KTX Texture Loader.
  50063. * @hidden
  50064. */
  50065. export class _KTXTextureLoader implements IInternalTextureLoader {
  50066. /**
  50067. * Defines wether the loader supports cascade loading the different faces.
  50068. */
  50069. readonly supportCascades: boolean;
  50070. /**
  50071. * This returns if the loader support the current file information.
  50072. * @param extension defines the file extension of the file being loaded
  50073. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50074. * @param fallback defines the fallback internal texture if any
  50075. * @param isBase64 defines whether the texture is encoded as a base64
  50076. * @param isBuffer defines whether the texture data are stored as a buffer
  50077. * @returns true if the loader can load the specified file
  50078. */
  50079. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50080. /**
  50081. * Transform the url before loading if required.
  50082. * @param rootUrl the url of the texture
  50083. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50084. * @returns the transformed texture
  50085. */
  50086. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50087. /**
  50088. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50089. * @param rootUrl the url of the texture
  50090. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50091. * @returns the fallback texture
  50092. */
  50093. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50094. /**
  50095. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50096. * @param data contains the texture data
  50097. * @param texture defines the BabylonJS internal texture
  50098. * @param createPolynomials will be true if polynomials have been requested
  50099. * @param onLoad defines the callback to trigger once the texture is ready
  50100. * @param onError defines the callback to trigger in case of error
  50101. */
  50102. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50103. /**
  50104. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50105. * @param data contains the texture data
  50106. * @param texture defines the BabylonJS internal texture
  50107. * @param callback defines the method to call once ready to upload
  50108. */
  50109. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50110. }
  50111. }
  50112. declare module BABYLON {
  50113. /** @hidden */
  50114. export var _forceSceneHelpersToBundle: boolean;
  50115. interface Scene {
  50116. /**
  50117. * Creates a default light for the scene.
  50118. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50119. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50120. */
  50121. createDefaultLight(replace?: boolean): void;
  50122. /**
  50123. * Creates a default camera for the scene.
  50124. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50125. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50126. * @param replace has default false, when true replaces the active camera in the scene
  50127. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50128. */
  50129. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50130. /**
  50131. * Creates a default camera and a default light.
  50132. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50133. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50134. * @param replace has the default false, when true replaces the active camera/light in the scene
  50135. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50136. */
  50137. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50138. /**
  50139. * Creates a new sky box
  50140. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50141. * @param environmentTexture defines the texture to use as environment texture
  50142. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50143. * @param scale defines the overall scale of the skybox
  50144. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50145. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50146. * @returns a new mesh holding the sky box
  50147. */
  50148. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50149. /**
  50150. * Creates a new environment
  50151. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50152. * @param options defines the options you can use to configure the environment
  50153. * @returns the new EnvironmentHelper
  50154. */
  50155. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50156. /**
  50157. * Creates a new VREXperienceHelper
  50158. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50159. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50160. * @returns a new VREXperienceHelper
  50161. */
  50162. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50163. /**
  50164. * Creates a new WebXRDefaultExperience
  50165. * @see http://doc.babylonjs.com/how_to/webxr
  50166. * @param options experience options
  50167. * @returns a promise for a new WebXRDefaultExperience
  50168. */
  50169. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50170. }
  50171. }
  50172. declare module BABYLON {
  50173. /**
  50174. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50175. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50176. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50177. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50178. */
  50179. export class VideoDome extends TransformNode {
  50180. /**
  50181. * Define the video source as a Monoscopic panoramic 360 video.
  50182. */
  50183. static readonly MODE_MONOSCOPIC: number;
  50184. /**
  50185. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50186. */
  50187. static readonly MODE_TOPBOTTOM: number;
  50188. /**
  50189. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50190. */
  50191. static readonly MODE_SIDEBYSIDE: number;
  50192. private _halfDome;
  50193. private _useDirectMapping;
  50194. /**
  50195. * The video texture being displayed on the sphere
  50196. */
  50197. protected _videoTexture: VideoTexture;
  50198. /**
  50199. * Gets the video texture being displayed on the sphere
  50200. */
  50201. readonly videoTexture: VideoTexture;
  50202. /**
  50203. * The skybox material
  50204. */
  50205. protected _material: BackgroundMaterial;
  50206. /**
  50207. * The surface used for the skybox
  50208. */
  50209. protected _mesh: Mesh;
  50210. /**
  50211. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50212. */
  50213. private _halfDomeMask;
  50214. /**
  50215. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50216. * Also see the options.resolution property.
  50217. */
  50218. fovMultiplier: number;
  50219. private _videoMode;
  50220. /**
  50221. * Gets or set the current video mode for the video. It can be:
  50222. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50223. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50224. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50225. */
  50226. videoMode: number;
  50227. /**
  50228. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50229. *
  50230. */
  50231. /**
  50232. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50233. */
  50234. halfDome: boolean;
  50235. /**
  50236. * Oberserver used in Stereoscopic VR Mode.
  50237. */
  50238. private _onBeforeCameraRenderObserver;
  50239. /**
  50240. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50241. * @param name Element's name, child elements will append suffixes for their own names.
  50242. * @param urlsOrVideo defines the url(s) or the video element to use
  50243. * @param options An object containing optional or exposed sub element properties
  50244. */
  50245. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50246. resolution?: number;
  50247. clickToPlay?: boolean;
  50248. autoPlay?: boolean;
  50249. loop?: boolean;
  50250. size?: number;
  50251. poster?: string;
  50252. faceForward?: boolean;
  50253. useDirectMapping?: boolean;
  50254. halfDomeMode?: boolean;
  50255. }, scene: Scene);
  50256. private _changeVideoMode;
  50257. /**
  50258. * Releases resources associated with this node.
  50259. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50260. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50261. */
  50262. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50263. }
  50264. }
  50265. declare module BABYLON {
  50266. /**
  50267. * This class can be used to get instrumentation data from a Babylon engine
  50268. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50269. */
  50270. export class EngineInstrumentation implements IDisposable {
  50271. /**
  50272. * Define the instrumented engine.
  50273. */
  50274. engine: Engine;
  50275. private _captureGPUFrameTime;
  50276. private _gpuFrameTimeToken;
  50277. private _gpuFrameTime;
  50278. private _captureShaderCompilationTime;
  50279. private _shaderCompilationTime;
  50280. private _onBeginFrameObserver;
  50281. private _onEndFrameObserver;
  50282. private _onBeforeShaderCompilationObserver;
  50283. private _onAfterShaderCompilationObserver;
  50284. /**
  50285. * Gets the perf counter used for GPU frame time
  50286. */
  50287. readonly gpuFrameTimeCounter: PerfCounter;
  50288. /**
  50289. * Gets the GPU frame time capture status
  50290. */
  50291. /**
  50292. * Enable or disable the GPU frame time capture
  50293. */
  50294. captureGPUFrameTime: boolean;
  50295. /**
  50296. * Gets the perf counter used for shader compilation time
  50297. */
  50298. readonly shaderCompilationTimeCounter: PerfCounter;
  50299. /**
  50300. * Gets the shader compilation time capture status
  50301. */
  50302. /**
  50303. * Enable or disable the shader compilation time capture
  50304. */
  50305. captureShaderCompilationTime: boolean;
  50306. /**
  50307. * Instantiates a new engine instrumentation.
  50308. * This class can be used to get instrumentation data from a Babylon engine
  50309. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50310. * @param engine Defines the engine to instrument
  50311. */
  50312. constructor(
  50313. /**
  50314. * Define the instrumented engine.
  50315. */
  50316. engine: Engine);
  50317. /**
  50318. * Dispose and release associated resources.
  50319. */
  50320. dispose(): void;
  50321. }
  50322. }
  50323. declare module BABYLON {
  50324. /**
  50325. * This class can be used to get instrumentation data from a Babylon engine
  50326. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50327. */
  50328. export class SceneInstrumentation implements IDisposable {
  50329. /**
  50330. * Defines the scene to instrument
  50331. */
  50332. scene: Scene;
  50333. private _captureActiveMeshesEvaluationTime;
  50334. private _activeMeshesEvaluationTime;
  50335. private _captureRenderTargetsRenderTime;
  50336. private _renderTargetsRenderTime;
  50337. private _captureFrameTime;
  50338. private _frameTime;
  50339. private _captureRenderTime;
  50340. private _renderTime;
  50341. private _captureInterFrameTime;
  50342. private _interFrameTime;
  50343. private _captureParticlesRenderTime;
  50344. private _particlesRenderTime;
  50345. private _captureSpritesRenderTime;
  50346. private _spritesRenderTime;
  50347. private _capturePhysicsTime;
  50348. private _physicsTime;
  50349. private _captureAnimationsTime;
  50350. private _animationsTime;
  50351. private _captureCameraRenderTime;
  50352. private _cameraRenderTime;
  50353. private _onBeforeActiveMeshesEvaluationObserver;
  50354. private _onAfterActiveMeshesEvaluationObserver;
  50355. private _onBeforeRenderTargetsRenderObserver;
  50356. private _onAfterRenderTargetsRenderObserver;
  50357. private _onAfterRenderObserver;
  50358. private _onBeforeDrawPhaseObserver;
  50359. private _onAfterDrawPhaseObserver;
  50360. private _onBeforeAnimationsObserver;
  50361. private _onBeforeParticlesRenderingObserver;
  50362. private _onAfterParticlesRenderingObserver;
  50363. private _onBeforeSpritesRenderingObserver;
  50364. private _onAfterSpritesRenderingObserver;
  50365. private _onBeforePhysicsObserver;
  50366. private _onAfterPhysicsObserver;
  50367. private _onAfterAnimationsObserver;
  50368. private _onBeforeCameraRenderObserver;
  50369. private _onAfterCameraRenderObserver;
  50370. /**
  50371. * Gets the perf counter used for active meshes evaluation time
  50372. */
  50373. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50374. /**
  50375. * Gets the active meshes evaluation time capture status
  50376. */
  50377. /**
  50378. * Enable or disable the active meshes evaluation time capture
  50379. */
  50380. captureActiveMeshesEvaluationTime: boolean;
  50381. /**
  50382. * Gets the perf counter used for render targets render time
  50383. */
  50384. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50385. /**
  50386. * Gets the render targets render time capture status
  50387. */
  50388. /**
  50389. * Enable or disable the render targets render time capture
  50390. */
  50391. captureRenderTargetsRenderTime: boolean;
  50392. /**
  50393. * Gets the perf counter used for particles render time
  50394. */
  50395. readonly particlesRenderTimeCounter: PerfCounter;
  50396. /**
  50397. * Gets the particles render time capture status
  50398. */
  50399. /**
  50400. * Enable or disable the particles render time capture
  50401. */
  50402. captureParticlesRenderTime: boolean;
  50403. /**
  50404. * Gets the perf counter used for sprites render time
  50405. */
  50406. readonly spritesRenderTimeCounter: PerfCounter;
  50407. /**
  50408. * Gets the sprites render time capture status
  50409. */
  50410. /**
  50411. * Enable or disable the sprites render time capture
  50412. */
  50413. captureSpritesRenderTime: boolean;
  50414. /**
  50415. * Gets the perf counter used for physics time
  50416. */
  50417. readonly physicsTimeCounter: PerfCounter;
  50418. /**
  50419. * Gets the physics time capture status
  50420. */
  50421. /**
  50422. * Enable or disable the physics time capture
  50423. */
  50424. capturePhysicsTime: boolean;
  50425. /**
  50426. * Gets the perf counter used for animations time
  50427. */
  50428. readonly animationsTimeCounter: PerfCounter;
  50429. /**
  50430. * Gets the animations time capture status
  50431. */
  50432. /**
  50433. * Enable or disable the animations time capture
  50434. */
  50435. captureAnimationsTime: boolean;
  50436. /**
  50437. * Gets the perf counter used for frame time capture
  50438. */
  50439. readonly frameTimeCounter: PerfCounter;
  50440. /**
  50441. * Gets the frame time capture status
  50442. */
  50443. /**
  50444. * Enable or disable the frame time capture
  50445. */
  50446. captureFrameTime: boolean;
  50447. /**
  50448. * Gets the perf counter used for inter-frames time capture
  50449. */
  50450. readonly interFrameTimeCounter: PerfCounter;
  50451. /**
  50452. * Gets the inter-frames time capture status
  50453. */
  50454. /**
  50455. * Enable or disable the inter-frames time capture
  50456. */
  50457. captureInterFrameTime: boolean;
  50458. /**
  50459. * Gets the perf counter used for render time capture
  50460. */
  50461. readonly renderTimeCounter: PerfCounter;
  50462. /**
  50463. * Gets the render time capture status
  50464. */
  50465. /**
  50466. * Enable or disable the render time capture
  50467. */
  50468. captureRenderTime: boolean;
  50469. /**
  50470. * Gets the perf counter used for camera render time capture
  50471. */
  50472. readonly cameraRenderTimeCounter: PerfCounter;
  50473. /**
  50474. * Gets the camera render time capture status
  50475. */
  50476. /**
  50477. * Enable or disable the camera render time capture
  50478. */
  50479. captureCameraRenderTime: boolean;
  50480. /**
  50481. * Gets the perf counter used for draw calls
  50482. */
  50483. readonly drawCallsCounter: PerfCounter;
  50484. /**
  50485. * Instantiates a new scene instrumentation.
  50486. * This class can be used to get instrumentation data from a Babylon engine
  50487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50488. * @param scene Defines the scene to instrument
  50489. */
  50490. constructor(
  50491. /**
  50492. * Defines the scene to instrument
  50493. */
  50494. scene: Scene);
  50495. /**
  50496. * Dispose and release associated resources.
  50497. */
  50498. dispose(): void;
  50499. }
  50500. }
  50501. declare module BABYLON {
  50502. /** @hidden */
  50503. export var glowMapGenerationPixelShader: {
  50504. name: string;
  50505. shader: string;
  50506. };
  50507. }
  50508. declare module BABYLON {
  50509. /** @hidden */
  50510. export var glowMapGenerationVertexShader: {
  50511. name: string;
  50512. shader: string;
  50513. };
  50514. }
  50515. declare module BABYLON {
  50516. /**
  50517. * Effect layer options. This helps customizing the behaviour
  50518. * of the effect layer.
  50519. */
  50520. export interface IEffectLayerOptions {
  50521. /**
  50522. * Multiplication factor apply to the canvas size to compute the render target size
  50523. * used to generated the objects (the smaller the faster).
  50524. */
  50525. mainTextureRatio: number;
  50526. /**
  50527. * Enforces a fixed size texture to ensure effect stability across devices.
  50528. */
  50529. mainTextureFixedSize?: number;
  50530. /**
  50531. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50532. */
  50533. alphaBlendingMode: number;
  50534. /**
  50535. * The camera attached to the layer.
  50536. */
  50537. camera: Nullable<Camera>;
  50538. /**
  50539. * The rendering group to draw the layer in.
  50540. */
  50541. renderingGroupId: number;
  50542. }
  50543. /**
  50544. * The effect layer Helps adding post process effect blended with the main pass.
  50545. *
  50546. * This can be for instance use to generate glow or higlight effects on the scene.
  50547. *
  50548. * The effect layer class can not be used directly and is intented to inherited from to be
  50549. * customized per effects.
  50550. */
  50551. export abstract class EffectLayer {
  50552. private _vertexBuffers;
  50553. private _indexBuffer;
  50554. private _cachedDefines;
  50555. private _effectLayerMapGenerationEffect;
  50556. private _effectLayerOptions;
  50557. private _mergeEffect;
  50558. protected _scene: Scene;
  50559. protected _engine: Engine;
  50560. protected _maxSize: number;
  50561. protected _mainTextureDesiredSize: ISize;
  50562. protected _mainTexture: RenderTargetTexture;
  50563. protected _shouldRender: boolean;
  50564. protected _postProcesses: PostProcess[];
  50565. protected _textures: BaseTexture[];
  50566. protected _emissiveTextureAndColor: {
  50567. texture: Nullable<BaseTexture>;
  50568. color: Color4;
  50569. };
  50570. /**
  50571. * The name of the layer
  50572. */
  50573. name: string;
  50574. /**
  50575. * The clear color of the texture used to generate the glow map.
  50576. */
  50577. neutralColor: Color4;
  50578. /**
  50579. * Specifies wether the highlight layer is enabled or not.
  50580. */
  50581. isEnabled: boolean;
  50582. /**
  50583. * Gets the camera attached to the layer.
  50584. */
  50585. readonly camera: Nullable<Camera>;
  50586. /**
  50587. * Gets the rendering group id the layer should render in.
  50588. */
  50589. renderingGroupId: number;
  50590. /**
  50591. * An event triggered when the effect layer has been disposed.
  50592. */
  50593. onDisposeObservable: Observable<EffectLayer>;
  50594. /**
  50595. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50596. */
  50597. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50598. /**
  50599. * An event triggered when the generated texture is being merged in the scene.
  50600. */
  50601. onBeforeComposeObservable: Observable<EffectLayer>;
  50602. /**
  50603. * An event triggered when the mesh is rendered into the effect render target.
  50604. */
  50605. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  50606. /**
  50607. * An event triggered after the mesh has been rendered into the effect render target.
  50608. */
  50609. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  50610. /**
  50611. * An event triggered when the generated texture has been merged in the scene.
  50612. */
  50613. onAfterComposeObservable: Observable<EffectLayer>;
  50614. /**
  50615. * An event triggered when the efffect layer changes its size.
  50616. */
  50617. onSizeChangedObservable: Observable<EffectLayer>;
  50618. /** @hidden */
  50619. static _SceneComponentInitialization: (scene: Scene) => void;
  50620. /**
  50621. * Instantiates a new effect Layer and references it in the scene.
  50622. * @param name The name of the layer
  50623. * @param scene The scene to use the layer in
  50624. */
  50625. constructor(
  50626. /** The Friendly of the effect in the scene */
  50627. name: string, scene: Scene);
  50628. /**
  50629. * Get the effect name of the layer.
  50630. * @return The effect name
  50631. */
  50632. abstract getEffectName(): string;
  50633. /**
  50634. * Checks for the readiness of the element composing the layer.
  50635. * @param subMesh the mesh to check for
  50636. * @param useInstances specify wether or not to use instances to render the mesh
  50637. * @return true if ready otherwise, false
  50638. */
  50639. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50640. /**
  50641. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50642. * @returns true if the effect requires stencil during the main canvas render pass.
  50643. */
  50644. abstract needStencil(): boolean;
  50645. /**
  50646. * Create the merge effect. This is the shader use to blit the information back
  50647. * to the main canvas at the end of the scene rendering.
  50648. * @returns The effect containing the shader used to merge the effect on the main canvas
  50649. */
  50650. protected abstract _createMergeEffect(): Effect;
  50651. /**
  50652. * Creates the render target textures and post processes used in the effect layer.
  50653. */
  50654. protected abstract _createTextureAndPostProcesses(): void;
  50655. /**
  50656. * Implementation specific of rendering the generating effect on the main canvas.
  50657. * @param effect The effect used to render through
  50658. */
  50659. protected abstract _internalRender(effect: Effect): void;
  50660. /**
  50661. * Sets the required values for both the emissive texture and and the main color.
  50662. */
  50663. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50664. /**
  50665. * Free any resources and references associated to a mesh.
  50666. * Internal use
  50667. * @param mesh The mesh to free.
  50668. */
  50669. abstract _disposeMesh(mesh: Mesh): void;
  50670. /**
  50671. * Serializes this layer (Glow or Highlight for example)
  50672. * @returns a serialized layer object
  50673. */
  50674. abstract serialize?(): any;
  50675. /**
  50676. * Initializes the effect layer with the required options.
  50677. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50678. */
  50679. protected _init(options: Partial<IEffectLayerOptions>): void;
  50680. /**
  50681. * Generates the index buffer of the full screen quad blending to the main canvas.
  50682. */
  50683. private _generateIndexBuffer;
  50684. /**
  50685. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50686. */
  50687. private _generateVertexBuffer;
  50688. /**
  50689. * Sets the main texture desired size which is the closest power of two
  50690. * of the engine canvas size.
  50691. */
  50692. private _setMainTextureSize;
  50693. /**
  50694. * Creates the main texture for the effect layer.
  50695. */
  50696. protected _createMainTexture(): void;
  50697. /**
  50698. * Adds specific effects defines.
  50699. * @param defines The defines to add specifics to.
  50700. */
  50701. protected _addCustomEffectDefines(defines: string[]): void;
  50702. /**
  50703. * Checks for the readiness of the element composing the layer.
  50704. * @param subMesh the mesh to check for
  50705. * @param useInstances specify wether or not to use instances to render the mesh
  50706. * @param emissiveTexture the associated emissive texture used to generate the glow
  50707. * @return true if ready otherwise, false
  50708. */
  50709. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50710. /**
  50711. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50712. */
  50713. render(): void;
  50714. /**
  50715. * Determine if a given mesh will be used in the current effect.
  50716. * @param mesh mesh to test
  50717. * @returns true if the mesh will be used
  50718. */
  50719. hasMesh(mesh: AbstractMesh): boolean;
  50720. /**
  50721. * Returns true if the layer contains information to display, otherwise false.
  50722. * @returns true if the glow layer should be rendered
  50723. */
  50724. shouldRender(): boolean;
  50725. /**
  50726. * Returns true if the mesh should render, otherwise false.
  50727. * @param mesh The mesh to render
  50728. * @returns true if it should render otherwise false
  50729. */
  50730. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50731. /**
  50732. * Returns true if the mesh can be rendered, otherwise false.
  50733. * @param mesh The mesh to render
  50734. * @param material The material used on the mesh
  50735. * @returns true if it can be rendered otherwise false
  50736. */
  50737. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50738. /**
  50739. * Returns true if the mesh should render, otherwise false.
  50740. * @param mesh The mesh to render
  50741. * @returns true if it should render otherwise false
  50742. */
  50743. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50744. /**
  50745. * Renders the submesh passed in parameter to the generation map.
  50746. */
  50747. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50748. /**
  50749. * Defines wether the current material of the mesh should be use to render the effect.
  50750. * @param mesh defines the current mesh to render
  50751. */
  50752. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50753. /**
  50754. * Rebuild the required buffers.
  50755. * @hidden Internal use only.
  50756. */
  50757. _rebuild(): void;
  50758. /**
  50759. * Dispose only the render target textures and post process.
  50760. */
  50761. private _disposeTextureAndPostProcesses;
  50762. /**
  50763. * Dispose the highlight layer and free resources.
  50764. */
  50765. dispose(): void;
  50766. /**
  50767. * Gets the class name of the effect layer
  50768. * @returns the string with the class name of the effect layer
  50769. */
  50770. getClassName(): string;
  50771. /**
  50772. * Creates an effect layer from parsed effect layer data
  50773. * @param parsedEffectLayer defines effect layer data
  50774. * @param scene defines the current scene
  50775. * @param rootUrl defines the root URL containing the effect layer information
  50776. * @returns a parsed effect Layer
  50777. */
  50778. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50779. }
  50780. }
  50781. declare module BABYLON {
  50782. interface AbstractScene {
  50783. /**
  50784. * The list of effect layers (highlights/glow) added to the scene
  50785. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50786. * @see http://doc.babylonjs.com/how_to/glow_layer
  50787. */
  50788. effectLayers: Array<EffectLayer>;
  50789. /**
  50790. * Removes the given effect layer from this scene.
  50791. * @param toRemove defines the effect layer to remove
  50792. * @returns the index of the removed effect layer
  50793. */
  50794. removeEffectLayer(toRemove: EffectLayer): number;
  50795. /**
  50796. * Adds the given effect layer to this scene
  50797. * @param newEffectLayer defines the effect layer to add
  50798. */
  50799. addEffectLayer(newEffectLayer: EffectLayer): void;
  50800. }
  50801. /**
  50802. * Defines the layer scene component responsible to manage any effect layers
  50803. * in a given scene.
  50804. */
  50805. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50806. /**
  50807. * The component name helpfull to identify the component in the list of scene components.
  50808. */
  50809. readonly name: string;
  50810. /**
  50811. * The scene the component belongs to.
  50812. */
  50813. scene: Scene;
  50814. private _engine;
  50815. private _renderEffects;
  50816. private _needStencil;
  50817. private _previousStencilState;
  50818. /**
  50819. * Creates a new instance of the component for the given scene
  50820. * @param scene Defines the scene to register the component in
  50821. */
  50822. constructor(scene: Scene);
  50823. /**
  50824. * Registers the component in a given scene
  50825. */
  50826. register(): void;
  50827. /**
  50828. * Rebuilds the elements related to this component in case of
  50829. * context lost for instance.
  50830. */
  50831. rebuild(): void;
  50832. /**
  50833. * Serializes the component data to the specified json object
  50834. * @param serializationObject The object to serialize to
  50835. */
  50836. serialize(serializationObject: any): void;
  50837. /**
  50838. * Adds all the elements from the container to the scene
  50839. * @param container the container holding the elements
  50840. */
  50841. addFromContainer(container: AbstractScene): void;
  50842. /**
  50843. * Removes all the elements in the container from the scene
  50844. * @param container contains the elements to remove
  50845. * @param dispose if the removed element should be disposed (default: false)
  50846. */
  50847. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50848. /**
  50849. * Disposes the component and the associated ressources.
  50850. */
  50851. dispose(): void;
  50852. private _isReadyForMesh;
  50853. private _renderMainTexture;
  50854. private _setStencil;
  50855. private _setStencilBack;
  50856. private _draw;
  50857. private _drawCamera;
  50858. private _drawRenderingGroup;
  50859. }
  50860. }
  50861. declare module BABYLON {
  50862. /** @hidden */
  50863. export var glowMapMergePixelShader: {
  50864. name: string;
  50865. shader: string;
  50866. };
  50867. }
  50868. declare module BABYLON {
  50869. /** @hidden */
  50870. export var glowMapMergeVertexShader: {
  50871. name: string;
  50872. shader: string;
  50873. };
  50874. }
  50875. declare module BABYLON {
  50876. interface AbstractScene {
  50877. /**
  50878. * Return a the first highlight layer of the scene with a given name.
  50879. * @param name The name of the highlight layer to look for.
  50880. * @return The highlight layer if found otherwise null.
  50881. */
  50882. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50883. }
  50884. /**
  50885. * Glow layer options. This helps customizing the behaviour
  50886. * of the glow layer.
  50887. */
  50888. export interface IGlowLayerOptions {
  50889. /**
  50890. * Multiplication factor apply to the canvas size to compute the render target size
  50891. * used to generated the glowing objects (the smaller the faster).
  50892. */
  50893. mainTextureRatio: number;
  50894. /**
  50895. * Enforces a fixed size texture to ensure resize independant blur.
  50896. */
  50897. mainTextureFixedSize?: number;
  50898. /**
  50899. * How big is the kernel of the blur texture.
  50900. */
  50901. blurKernelSize: number;
  50902. /**
  50903. * The camera attached to the layer.
  50904. */
  50905. camera: Nullable<Camera>;
  50906. /**
  50907. * Enable MSAA by chosing the number of samples.
  50908. */
  50909. mainTextureSamples?: number;
  50910. /**
  50911. * The rendering group to draw the layer in.
  50912. */
  50913. renderingGroupId: number;
  50914. }
  50915. /**
  50916. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50917. *
  50918. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  50919. *
  50920. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50921. */
  50922. export class GlowLayer extends EffectLayer {
  50923. /**
  50924. * Effect Name of the layer.
  50925. */
  50926. static readonly EffectName: string;
  50927. /**
  50928. * The default blur kernel size used for the glow.
  50929. */
  50930. static DefaultBlurKernelSize: number;
  50931. /**
  50932. * The default texture size ratio used for the glow.
  50933. */
  50934. static DefaultTextureRatio: number;
  50935. /**
  50936. * Sets the kernel size of the blur.
  50937. */
  50938. /**
  50939. * Gets the kernel size of the blur.
  50940. */
  50941. blurKernelSize: number;
  50942. /**
  50943. * Sets the glow intensity.
  50944. */
  50945. /**
  50946. * Gets the glow intensity.
  50947. */
  50948. intensity: number;
  50949. private _options;
  50950. private _intensity;
  50951. private _horizontalBlurPostprocess1;
  50952. private _verticalBlurPostprocess1;
  50953. private _horizontalBlurPostprocess2;
  50954. private _verticalBlurPostprocess2;
  50955. private _blurTexture1;
  50956. private _blurTexture2;
  50957. private _postProcesses1;
  50958. private _postProcesses2;
  50959. private _includedOnlyMeshes;
  50960. private _excludedMeshes;
  50961. private _meshesUsingTheirOwnMaterials;
  50962. /**
  50963. * Callback used to let the user override the color selection on a per mesh basis
  50964. */
  50965. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50966. /**
  50967. * Callback used to let the user override the texture selection on a per mesh basis
  50968. */
  50969. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50970. /**
  50971. * Instantiates a new glow Layer and references it to the scene.
  50972. * @param name The name of the layer
  50973. * @param scene The scene to use the layer in
  50974. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50975. */
  50976. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50977. /**
  50978. * Get the effect name of the layer.
  50979. * @return The effect name
  50980. */
  50981. getEffectName(): string;
  50982. /**
  50983. * Create the merge effect. This is the shader use to blit the information back
  50984. * to the main canvas at the end of the scene rendering.
  50985. */
  50986. protected _createMergeEffect(): Effect;
  50987. /**
  50988. * Creates the render target textures and post processes used in the glow layer.
  50989. */
  50990. protected _createTextureAndPostProcesses(): void;
  50991. /**
  50992. * Checks for the readiness of the element composing the layer.
  50993. * @param subMesh the mesh to check for
  50994. * @param useInstances specify wether or not to use instances to render the mesh
  50995. * @param emissiveTexture the associated emissive texture used to generate the glow
  50996. * @return true if ready otherwise, false
  50997. */
  50998. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50999. /**
  51000. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51001. */
  51002. needStencil(): boolean;
  51003. /**
  51004. * Returns true if the mesh can be rendered, otherwise false.
  51005. * @param mesh The mesh to render
  51006. * @param material The material used on the mesh
  51007. * @returns true if it can be rendered otherwise false
  51008. */
  51009. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51010. /**
  51011. * Implementation specific of rendering the generating effect on the main canvas.
  51012. * @param effect The effect used to render through
  51013. */
  51014. protected _internalRender(effect: Effect): void;
  51015. /**
  51016. * Sets the required values for both the emissive texture and and the main color.
  51017. */
  51018. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51019. /**
  51020. * Returns true if the mesh should render, otherwise false.
  51021. * @param mesh The mesh to render
  51022. * @returns true if it should render otherwise false
  51023. */
  51024. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51025. /**
  51026. * Adds specific effects defines.
  51027. * @param defines The defines to add specifics to.
  51028. */
  51029. protected _addCustomEffectDefines(defines: string[]): void;
  51030. /**
  51031. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51032. * @param mesh The mesh to exclude from the glow layer
  51033. */
  51034. addExcludedMesh(mesh: Mesh): void;
  51035. /**
  51036. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51037. * @param mesh The mesh to remove
  51038. */
  51039. removeExcludedMesh(mesh: Mesh): void;
  51040. /**
  51041. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51042. * @param mesh The mesh to include in the glow layer
  51043. */
  51044. addIncludedOnlyMesh(mesh: Mesh): void;
  51045. /**
  51046. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51047. * @param mesh The mesh to remove
  51048. */
  51049. removeIncludedOnlyMesh(mesh: Mesh): void;
  51050. /**
  51051. * Determine if a given mesh will be used in the glow layer
  51052. * @param mesh The mesh to test
  51053. * @returns true if the mesh will be highlighted by the current glow layer
  51054. */
  51055. hasMesh(mesh: AbstractMesh): boolean;
  51056. /**
  51057. * Defines wether the current material of the mesh should be use to render the effect.
  51058. * @param mesh defines the current mesh to render
  51059. */
  51060. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51061. /**
  51062. * Add a mesh to be rendered through its own material and not with emissive only.
  51063. * @param mesh The mesh for which we need to use its material
  51064. */
  51065. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  51066. /**
  51067. * Remove a mesh from being rendered through its own material and not with emissive only.
  51068. * @param mesh The mesh for which we need to not use its material
  51069. */
  51070. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  51071. /**
  51072. * Free any resources and references associated to a mesh.
  51073. * Internal use
  51074. * @param mesh The mesh to free.
  51075. * @hidden
  51076. */
  51077. _disposeMesh(mesh: Mesh): void;
  51078. /**
  51079. * Gets the class name of the effect layer
  51080. * @returns the string with the class name of the effect layer
  51081. */
  51082. getClassName(): string;
  51083. /**
  51084. * Serializes this glow layer
  51085. * @returns a serialized glow layer object
  51086. */
  51087. serialize(): any;
  51088. /**
  51089. * Creates a Glow Layer from parsed glow layer data
  51090. * @param parsedGlowLayer defines glow layer data
  51091. * @param scene defines the current scene
  51092. * @param rootUrl defines the root URL containing the glow layer information
  51093. * @returns a parsed Glow Layer
  51094. */
  51095. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51096. }
  51097. }
  51098. declare module BABYLON {
  51099. /** @hidden */
  51100. export var glowBlurPostProcessPixelShader: {
  51101. name: string;
  51102. shader: string;
  51103. };
  51104. }
  51105. declare module BABYLON {
  51106. interface AbstractScene {
  51107. /**
  51108. * Return a the first highlight layer of the scene with a given name.
  51109. * @param name The name of the highlight layer to look for.
  51110. * @return The highlight layer if found otherwise null.
  51111. */
  51112. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51113. }
  51114. /**
  51115. * Highlight layer options. This helps customizing the behaviour
  51116. * of the highlight layer.
  51117. */
  51118. export interface IHighlightLayerOptions {
  51119. /**
  51120. * Multiplication factor apply to the canvas size to compute the render target size
  51121. * used to generated the glowing objects (the smaller the faster).
  51122. */
  51123. mainTextureRatio: number;
  51124. /**
  51125. * Enforces a fixed size texture to ensure resize independant blur.
  51126. */
  51127. mainTextureFixedSize?: number;
  51128. /**
  51129. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51130. * of the picture to blur (the smaller the faster).
  51131. */
  51132. blurTextureSizeRatio: number;
  51133. /**
  51134. * How big in texel of the blur texture is the vertical blur.
  51135. */
  51136. blurVerticalSize: number;
  51137. /**
  51138. * How big in texel of the blur texture is the horizontal blur.
  51139. */
  51140. blurHorizontalSize: number;
  51141. /**
  51142. * Alpha blending mode used to apply the blur. Default is combine.
  51143. */
  51144. alphaBlendingMode: number;
  51145. /**
  51146. * The camera attached to the layer.
  51147. */
  51148. camera: Nullable<Camera>;
  51149. /**
  51150. * Should we display highlight as a solid stroke?
  51151. */
  51152. isStroke?: boolean;
  51153. /**
  51154. * The rendering group to draw the layer in.
  51155. */
  51156. renderingGroupId: number;
  51157. }
  51158. /**
  51159. * The highlight layer Helps adding a glow effect around a mesh.
  51160. *
  51161. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  51162. * glowy meshes to your scene.
  51163. *
  51164. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51165. */
  51166. export class HighlightLayer extends EffectLayer {
  51167. name: string;
  51168. /**
  51169. * Effect Name of the highlight layer.
  51170. */
  51171. static readonly EffectName: string;
  51172. /**
  51173. * The neutral color used during the preparation of the glow effect.
  51174. * This is black by default as the blend operation is a blend operation.
  51175. */
  51176. static NeutralColor: Color4;
  51177. /**
  51178. * Stencil value used for glowing meshes.
  51179. */
  51180. static GlowingMeshStencilReference: number;
  51181. /**
  51182. * Stencil value used for the other meshes in the scene.
  51183. */
  51184. static NormalMeshStencilReference: number;
  51185. /**
  51186. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51187. */
  51188. innerGlow: boolean;
  51189. /**
  51190. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51191. */
  51192. outerGlow: boolean;
  51193. /**
  51194. * Specifies the horizontal size of the blur.
  51195. */
  51196. /**
  51197. * Gets the horizontal size of the blur.
  51198. */
  51199. blurHorizontalSize: number;
  51200. /**
  51201. * Specifies the vertical size of the blur.
  51202. */
  51203. /**
  51204. * Gets the vertical size of the blur.
  51205. */
  51206. blurVerticalSize: number;
  51207. /**
  51208. * An event triggered when the highlight layer is being blurred.
  51209. */
  51210. onBeforeBlurObservable: Observable<HighlightLayer>;
  51211. /**
  51212. * An event triggered when the highlight layer has been blurred.
  51213. */
  51214. onAfterBlurObservable: Observable<HighlightLayer>;
  51215. private _instanceGlowingMeshStencilReference;
  51216. private _options;
  51217. private _downSamplePostprocess;
  51218. private _horizontalBlurPostprocess;
  51219. private _verticalBlurPostprocess;
  51220. private _blurTexture;
  51221. private _meshes;
  51222. private _excludedMeshes;
  51223. /**
  51224. * Instantiates a new highlight Layer and references it to the scene..
  51225. * @param name The name of the layer
  51226. * @param scene The scene to use the layer in
  51227. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51228. */
  51229. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51230. /**
  51231. * Get the effect name of the layer.
  51232. * @return The effect name
  51233. */
  51234. getEffectName(): string;
  51235. /**
  51236. * Create the merge effect. This is the shader use to blit the information back
  51237. * to the main canvas at the end of the scene rendering.
  51238. */
  51239. protected _createMergeEffect(): Effect;
  51240. /**
  51241. * Creates the render target textures and post processes used in the highlight layer.
  51242. */
  51243. protected _createTextureAndPostProcesses(): void;
  51244. /**
  51245. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51246. */
  51247. needStencil(): boolean;
  51248. /**
  51249. * Checks for the readiness of the element composing the layer.
  51250. * @param subMesh the mesh to check for
  51251. * @param useInstances specify wether or not to use instances to render the mesh
  51252. * @param emissiveTexture the associated emissive texture used to generate the glow
  51253. * @return true if ready otherwise, false
  51254. */
  51255. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51256. /**
  51257. * Implementation specific of rendering the generating effect on the main canvas.
  51258. * @param effect The effect used to render through
  51259. */
  51260. protected _internalRender(effect: Effect): void;
  51261. /**
  51262. * Returns true if the layer contains information to display, otherwise false.
  51263. */
  51264. shouldRender(): boolean;
  51265. /**
  51266. * Returns true if the mesh should render, otherwise false.
  51267. * @param mesh The mesh to render
  51268. * @returns true if it should render otherwise false
  51269. */
  51270. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51271. /**
  51272. * Sets the required values for both the emissive texture and and the main color.
  51273. */
  51274. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51275. /**
  51276. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51277. * @param mesh The mesh to exclude from the highlight layer
  51278. */
  51279. addExcludedMesh(mesh: Mesh): void;
  51280. /**
  51281. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51282. * @param mesh The mesh to highlight
  51283. */
  51284. removeExcludedMesh(mesh: Mesh): void;
  51285. /**
  51286. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51287. * @param mesh mesh to test
  51288. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51289. */
  51290. hasMesh(mesh: AbstractMesh): boolean;
  51291. /**
  51292. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51293. * @param mesh The mesh to highlight
  51294. * @param color The color of the highlight
  51295. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51296. */
  51297. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51298. /**
  51299. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51300. * @param mesh The mesh to highlight
  51301. */
  51302. removeMesh(mesh: Mesh): void;
  51303. /**
  51304. * Force the stencil to the normal expected value for none glowing parts
  51305. */
  51306. private _defaultStencilReference;
  51307. /**
  51308. * Free any resources and references associated to a mesh.
  51309. * Internal use
  51310. * @param mesh The mesh to free.
  51311. * @hidden
  51312. */
  51313. _disposeMesh(mesh: Mesh): void;
  51314. /**
  51315. * Dispose the highlight layer and free resources.
  51316. */
  51317. dispose(): void;
  51318. /**
  51319. * Gets the class name of the effect layer
  51320. * @returns the string with the class name of the effect layer
  51321. */
  51322. getClassName(): string;
  51323. /**
  51324. * Serializes this Highlight layer
  51325. * @returns a serialized Highlight layer object
  51326. */
  51327. serialize(): any;
  51328. /**
  51329. * Creates a Highlight layer from parsed Highlight layer data
  51330. * @param parsedHightlightLayer defines the Highlight layer data
  51331. * @param scene defines the current scene
  51332. * @param rootUrl defines the root URL containing the Highlight layer information
  51333. * @returns a parsed Highlight layer
  51334. */
  51335. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51336. }
  51337. }
  51338. declare module BABYLON {
  51339. interface AbstractScene {
  51340. /**
  51341. * The list of layers (background and foreground) of the scene
  51342. */
  51343. layers: Array<Layer>;
  51344. }
  51345. /**
  51346. * Defines the layer scene component responsible to manage any layers
  51347. * in a given scene.
  51348. */
  51349. export class LayerSceneComponent implements ISceneComponent {
  51350. /**
  51351. * The component name helpfull to identify the component in the list of scene components.
  51352. */
  51353. readonly name: string;
  51354. /**
  51355. * The scene the component belongs to.
  51356. */
  51357. scene: Scene;
  51358. private _engine;
  51359. /**
  51360. * Creates a new instance of the component for the given scene
  51361. * @param scene Defines the scene to register the component in
  51362. */
  51363. constructor(scene: Scene);
  51364. /**
  51365. * Registers the component in a given scene
  51366. */
  51367. register(): void;
  51368. /**
  51369. * Rebuilds the elements related to this component in case of
  51370. * context lost for instance.
  51371. */
  51372. rebuild(): void;
  51373. /**
  51374. * Disposes the component and the associated ressources.
  51375. */
  51376. dispose(): void;
  51377. private _draw;
  51378. private _drawCameraPredicate;
  51379. private _drawCameraBackground;
  51380. private _drawCameraForeground;
  51381. private _drawRenderTargetPredicate;
  51382. private _drawRenderTargetBackground;
  51383. private _drawRenderTargetForeground;
  51384. /**
  51385. * Adds all the elements from the container to the scene
  51386. * @param container the container holding the elements
  51387. */
  51388. addFromContainer(container: AbstractScene): void;
  51389. /**
  51390. * Removes all the elements in the container from the scene
  51391. * @param container contains the elements to remove
  51392. * @param dispose if the removed element should be disposed (default: false)
  51393. */
  51394. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51395. }
  51396. }
  51397. declare module BABYLON {
  51398. /** @hidden */
  51399. export var layerPixelShader: {
  51400. name: string;
  51401. shader: string;
  51402. };
  51403. }
  51404. declare module BABYLON {
  51405. /** @hidden */
  51406. export var layerVertexShader: {
  51407. name: string;
  51408. shader: string;
  51409. };
  51410. }
  51411. declare module BABYLON {
  51412. /**
  51413. * This represents a full screen 2d layer.
  51414. * This can be useful to display a picture in the background of your scene for instance.
  51415. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51416. */
  51417. export class Layer {
  51418. /**
  51419. * Define the name of the layer.
  51420. */
  51421. name: string;
  51422. /**
  51423. * Define the texture the layer should display.
  51424. */
  51425. texture: Nullable<Texture>;
  51426. /**
  51427. * Is the layer in background or foreground.
  51428. */
  51429. isBackground: boolean;
  51430. /**
  51431. * Define the color of the layer (instead of texture).
  51432. */
  51433. color: Color4;
  51434. /**
  51435. * Define the scale of the layer in order to zoom in out of the texture.
  51436. */
  51437. scale: Vector2;
  51438. /**
  51439. * Define an offset for the layer in order to shift the texture.
  51440. */
  51441. offset: Vector2;
  51442. /**
  51443. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51444. */
  51445. alphaBlendingMode: number;
  51446. /**
  51447. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51448. * Alpha test will not mix with the background color in case of transparency.
  51449. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51450. */
  51451. alphaTest: boolean;
  51452. /**
  51453. * Define a mask to restrict the layer to only some of the scene cameras.
  51454. */
  51455. layerMask: number;
  51456. /**
  51457. * Define the list of render target the layer is visible into.
  51458. */
  51459. renderTargetTextures: RenderTargetTexture[];
  51460. /**
  51461. * Define if the layer is only used in renderTarget or if it also
  51462. * renders in the main frame buffer of the canvas.
  51463. */
  51464. renderOnlyInRenderTargetTextures: boolean;
  51465. private _scene;
  51466. private _vertexBuffers;
  51467. private _indexBuffer;
  51468. private _effect;
  51469. private _previousDefines;
  51470. /**
  51471. * An event triggered when the layer is disposed.
  51472. */
  51473. onDisposeObservable: Observable<Layer>;
  51474. private _onDisposeObserver;
  51475. /**
  51476. * Back compatibility with callback before the onDisposeObservable existed.
  51477. * The set callback will be triggered when the layer has been disposed.
  51478. */
  51479. onDispose: () => void;
  51480. /**
  51481. * An event triggered before rendering the scene
  51482. */
  51483. onBeforeRenderObservable: Observable<Layer>;
  51484. private _onBeforeRenderObserver;
  51485. /**
  51486. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51487. * The set callback will be triggered just before rendering the layer.
  51488. */
  51489. onBeforeRender: () => void;
  51490. /**
  51491. * An event triggered after rendering the scene
  51492. */
  51493. onAfterRenderObservable: Observable<Layer>;
  51494. private _onAfterRenderObserver;
  51495. /**
  51496. * Back compatibility with callback before the onAfterRenderObservable existed.
  51497. * The set callback will be triggered just after rendering the layer.
  51498. */
  51499. onAfterRender: () => void;
  51500. /**
  51501. * Instantiates a new layer.
  51502. * This represents a full screen 2d layer.
  51503. * This can be useful to display a picture in the background of your scene for instance.
  51504. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51505. * @param name Define the name of the layer in the scene
  51506. * @param imgUrl Define the url of the texture to display in the layer
  51507. * @param scene Define the scene the layer belongs to
  51508. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51509. * @param color Defines a color for the layer
  51510. */
  51511. constructor(
  51512. /**
  51513. * Define the name of the layer.
  51514. */
  51515. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51516. private _createIndexBuffer;
  51517. /** @hidden */
  51518. _rebuild(): void;
  51519. /**
  51520. * Renders the layer in the scene.
  51521. */
  51522. render(): void;
  51523. /**
  51524. * Disposes and releases the associated ressources.
  51525. */
  51526. dispose(): void;
  51527. }
  51528. }
  51529. declare module BABYLON {
  51530. /** @hidden */
  51531. export var lensFlarePixelShader: {
  51532. name: string;
  51533. shader: string;
  51534. };
  51535. }
  51536. declare module BABYLON {
  51537. /** @hidden */
  51538. export var lensFlareVertexShader: {
  51539. name: string;
  51540. shader: string;
  51541. };
  51542. }
  51543. declare module BABYLON {
  51544. /**
  51545. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51546. * It is usually composed of several `lensFlare`.
  51547. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51548. */
  51549. export class LensFlareSystem {
  51550. /**
  51551. * Define the name of the lens flare system
  51552. */
  51553. name: string;
  51554. /**
  51555. * List of lens flares used in this system.
  51556. */
  51557. lensFlares: LensFlare[];
  51558. /**
  51559. * Define a limit from the border the lens flare can be visible.
  51560. */
  51561. borderLimit: number;
  51562. /**
  51563. * Define a viewport border we do not want to see the lens flare in.
  51564. */
  51565. viewportBorder: number;
  51566. /**
  51567. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51568. */
  51569. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51570. /**
  51571. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51572. */
  51573. layerMask: number;
  51574. /**
  51575. * Define the id of the lens flare system in the scene.
  51576. * (equal to name by default)
  51577. */
  51578. id: string;
  51579. private _scene;
  51580. private _emitter;
  51581. private _vertexBuffers;
  51582. private _indexBuffer;
  51583. private _effect;
  51584. private _positionX;
  51585. private _positionY;
  51586. private _isEnabled;
  51587. /** @hidden */
  51588. static _SceneComponentInitialization: (scene: Scene) => void;
  51589. /**
  51590. * Instantiates a lens flare system.
  51591. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51592. * It is usually composed of several `lensFlare`.
  51593. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51594. * @param name Define the name of the lens flare system in the scene
  51595. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51596. * @param scene Define the scene the lens flare system belongs to
  51597. */
  51598. constructor(
  51599. /**
  51600. * Define the name of the lens flare system
  51601. */
  51602. name: string, emitter: any, scene: Scene);
  51603. /**
  51604. * Define if the lens flare system is enabled.
  51605. */
  51606. isEnabled: boolean;
  51607. /**
  51608. * Get the scene the effects belongs to.
  51609. * @returns the scene holding the lens flare system
  51610. */
  51611. getScene(): Scene;
  51612. /**
  51613. * Get the emitter of the lens flare system.
  51614. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51615. * @returns the emitter of the lens flare system
  51616. */
  51617. getEmitter(): any;
  51618. /**
  51619. * Set the emitter of the lens flare system.
  51620. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51621. * @param newEmitter Define the new emitter of the system
  51622. */
  51623. setEmitter(newEmitter: any): void;
  51624. /**
  51625. * Get the lens flare system emitter position.
  51626. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51627. * @returns the position
  51628. */
  51629. getEmitterPosition(): Vector3;
  51630. /**
  51631. * @hidden
  51632. */
  51633. computeEffectivePosition(globalViewport: Viewport): boolean;
  51634. /** @hidden */
  51635. _isVisible(): boolean;
  51636. /**
  51637. * @hidden
  51638. */
  51639. render(): boolean;
  51640. /**
  51641. * Dispose and release the lens flare with its associated resources.
  51642. */
  51643. dispose(): void;
  51644. /**
  51645. * Parse a lens flare system from a JSON repressentation
  51646. * @param parsedLensFlareSystem Define the JSON to parse
  51647. * @param scene Define the scene the parsed system should be instantiated in
  51648. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51649. * @returns the parsed system
  51650. */
  51651. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51652. /**
  51653. * Serialize the current Lens Flare System into a JSON representation.
  51654. * @returns the serialized JSON
  51655. */
  51656. serialize(): any;
  51657. }
  51658. }
  51659. declare module BABYLON {
  51660. /**
  51661. * This represents one of the lens effect in a `lensFlareSystem`.
  51662. * It controls one of the indiviual texture used in the effect.
  51663. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51664. */
  51665. export class LensFlare {
  51666. /**
  51667. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51668. */
  51669. size: number;
  51670. /**
  51671. * 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.
  51672. */
  51673. position: number;
  51674. /**
  51675. * Define the lens color.
  51676. */
  51677. color: Color3;
  51678. /**
  51679. * Define the lens texture.
  51680. */
  51681. texture: Nullable<Texture>;
  51682. /**
  51683. * Define the alpha mode to render this particular lens.
  51684. */
  51685. alphaMode: number;
  51686. private _system;
  51687. /**
  51688. * Creates a new Lens Flare.
  51689. * This represents one of the lens effect in a `lensFlareSystem`.
  51690. * It controls one of the indiviual texture used in the effect.
  51691. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51692. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51693. * @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.
  51694. * @param color Define the lens color
  51695. * @param imgUrl Define the lens texture url
  51696. * @param system Define the `lensFlareSystem` this flare is part of
  51697. * @returns The newly created Lens Flare
  51698. */
  51699. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51700. /**
  51701. * Instantiates a new Lens Flare.
  51702. * This represents one of the lens effect in a `lensFlareSystem`.
  51703. * It controls one of the indiviual texture used in the effect.
  51704. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51705. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51706. * @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.
  51707. * @param color Define the lens color
  51708. * @param imgUrl Define the lens texture url
  51709. * @param system Define the `lensFlareSystem` this flare is part of
  51710. */
  51711. constructor(
  51712. /**
  51713. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51714. */
  51715. size: number,
  51716. /**
  51717. * 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.
  51718. */
  51719. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51720. /**
  51721. * Dispose and release the lens flare with its associated resources.
  51722. */
  51723. dispose(): void;
  51724. }
  51725. }
  51726. declare module BABYLON {
  51727. interface AbstractScene {
  51728. /**
  51729. * The list of lens flare system added to the scene
  51730. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51731. */
  51732. lensFlareSystems: Array<LensFlareSystem>;
  51733. /**
  51734. * Removes the given lens flare system from this scene.
  51735. * @param toRemove The lens flare system to remove
  51736. * @returns The index of the removed lens flare system
  51737. */
  51738. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51739. /**
  51740. * Adds the given lens flare system to this scene
  51741. * @param newLensFlareSystem The lens flare system to add
  51742. */
  51743. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51744. /**
  51745. * Gets a lens flare system using its name
  51746. * @param name defines the name to look for
  51747. * @returns the lens flare system or null if not found
  51748. */
  51749. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51750. /**
  51751. * Gets a lens flare system using its id
  51752. * @param id defines the id to look for
  51753. * @returns the lens flare system or null if not found
  51754. */
  51755. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51756. }
  51757. /**
  51758. * Defines the lens flare scene component responsible to manage any lens flares
  51759. * in a given scene.
  51760. */
  51761. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51762. /**
  51763. * The component name helpfull to identify the component in the list of scene components.
  51764. */
  51765. readonly name: string;
  51766. /**
  51767. * The scene the component belongs to.
  51768. */
  51769. scene: Scene;
  51770. /**
  51771. * Creates a new instance of the component for the given scene
  51772. * @param scene Defines the scene to register the component in
  51773. */
  51774. constructor(scene: Scene);
  51775. /**
  51776. * Registers the component in a given scene
  51777. */
  51778. register(): void;
  51779. /**
  51780. * Rebuilds the elements related to this component in case of
  51781. * context lost for instance.
  51782. */
  51783. rebuild(): void;
  51784. /**
  51785. * Adds all the elements from the container to the scene
  51786. * @param container the container holding the elements
  51787. */
  51788. addFromContainer(container: AbstractScene): void;
  51789. /**
  51790. * Removes all the elements in the container from the scene
  51791. * @param container contains the elements to remove
  51792. * @param dispose if the removed element should be disposed (default: false)
  51793. */
  51794. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51795. /**
  51796. * Serializes the component data to the specified json object
  51797. * @param serializationObject The object to serialize to
  51798. */
  51799. serialize(serializationObject: any): void;
  51800. /**
  51801. * Disposes the component and the associated ressources.
  51802. */
  51803. dispose(): void;
  51804. private _draw;
  51805. }
  51806. }
  51807. declare module BABYLON {
  51808. /**
  51809. * Defines the shadow generator component responsible to manage any shadow generators
  51810. * in a given scene.
  51811. */
  51812. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51813. /**
  51814. * The component name helpfull to identify the component in the list of scene components.
  51815. */
  51816. readonly name: string;
  51817. /**
  51818. * The scene the component belongs to.
  51819. */
  51820. scene: Scene;
  51821. /**
  51822. * Creates a new instance of the component for the given scene
  51823. * @param scene Defines the scene to register the component in
  51824. */
  51825. constructor(scene: Scene);
  51826. /**
  51827. * Registers the component in a given scene
  51828. */
  51829. register(): void;
  51830. /**
  51831. * Rebuilds the elements related to this component in case of
  51832. * context lost for instance.
  51833. */
  51834. rebuild(): void;
  51835. /**
  51836. * Serializes the component data to the specified json object
  51837. * @param serializationObject The object to serialize to
  51838. */
  51839. serialize(serializationObject: any): void;
  51840. /**
  51841. * Adds all the elements from the container to the scene
  51842. * @param container the container holding the elements
  51843. */
  51844. addFromContainer(container: AbstractScene): void;
  51845. /**
  51846. * Removes all the elements in the container from the scene
  51847. * @param container contains the elements to remove
  51848. * @param dispose if the removed element should be disposed (default: false)
  51849. */
  51850. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51851. /**
  51852. * Rebuilds the elements related to this component in case of
  51853. * context lost for instance.
  51854. */
  51855. dispose(): void;
  51856. private _gatherRenderTargets;
  51857. }
  51858. }
  51859. declare module BABYLON {
  51860. /**
  51861. * A point light is a light defined by an unique point in world space.
  51862. * The light is emitted in every direction from this point.
  51863. * A good example of a point light is a standard light bulb.
  51864. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51865. */
  51866. export class PointLight extends ShadowLight {
  51867. private _shadowAngle;
  51868. /**
  51869. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51870. * This specifies what angle the shadow will use to be created.
  51871. *
  51872. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51873. */
  51874. /**
  51875. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51876. * This specifies what angle the shadow will use to be created.
  51877. *
  51878. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51879. */
  51880. shadowAngle: number;
  51881. /**
  51882. * Gets the direction if it has been set.
  51883. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51884. */
  51885. /**
  51886. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51887. */
  51888. direction: Vector3;
  51889. /**
  51890. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51891. * A PointLight emits the light in every direction.
  51892. * It can cast shadows.
  51893. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51894. * ```javascript
  51895. * var pointLight = new PointLight("pl", camera.position, scene);
  51896. * ```
  51897. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51898. * @param name The light friendly name
  51899. * @param position The position of the point light in the scene
  51900. * @param scene The scene the lights belongs to
  51901. */
  51902. constructor(name: string, position: Vector3, scene: Scene);
  51903. /**
  51904. * Returns the string "PointLight"
  51905. * @returns the class name
  51906. */
  51907. getClassName(): string;
  51908. /**
  51909. * Returns the integer 0.
  51910. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51911. */
  51912. getTypeID(): number;
  51913. /**
  51914. * Specifies wether or not the shadowmap should be a cube texture.
  51915. * @returns true if the shadowmap needs to be a cube texture.
  51916. */
  51917. needCube(): boolean;
  51918. /**
  51919. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51920. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51921. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51922. */
  51923. getShadowDirection(faceIndex?: number): Vector3;
  51924. /**
  51925. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51926. * - fov = PI / 2
  51927. * - aspect ratio : 1.0
  51928. * - z-near and far equal to the active camera minZ and maxZ.
  51929. * Returns the PointLight.
  51930. */
  51931. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51932. protected _buildUniformLayout(): void;
  51933. /**
  51934. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51935. * @param effect The effect to update
  51936. * @param lightIndex The index of the light in the effect to update
  51937. * @returns The point light
  51938. */
  51939. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51940. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51941. /**
  51942. * Prepares the list of defines specific to the light type.
  51943. * @param defines the list of defines
  51944. * @param lightIndex defines the index of the light for the effect
  51945. */
  51946. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51947. }
  51948. }
  51949. declare module BABYLON {
  51950. /**
  51951. * Header information of HDR texture files.
  51952. */
  51953. export interface HDRInfo {
  51954. /**
  51955. * The height of the texture in pixels.
  51956. */
  51957. height: number;
  51958. /**
  51959. * The width of the texture in pixels.
  51960. */
  51961. width: number;
  51962. /**
  51963. * The index of the beginning of the data in the binary file.
  51964. */
  51965. dataPosition: number;
  51966. }
  51967. /**
  51968. * This groups tools to convert HDR texture to native colors array.
  51969. */
  51970. export class HDRTools {
  51971. private static Ldexp;
  51972. private static Rgbe2float;
  51973. private static readStringLine;
  51974. /**
  51975. * Reads header information from an RGBE texture stored in a native array.
  51976. * More information on this format are available here:
  51977. * https://en.wikipedia.org/wiki/RGBE_image_format
  51978. *
  51979. * @param uint8array The binary file stored in native array.
  51980. * @return The header information.
  51981. */
  51982. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51983. /**
  51984. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51985. * This RGBE texture needs to store the information as a panorama.
  51986. *
  51987. * More information on this format are available here:
  51988. * https://en.wikipedia.org/wiki/RGBE_image_format
  51989. *
  51990. * @param buffer The binary file stored in an array buffer.
  51991. * @param size The expected size of the extracted cubemap.
  51992. * @return The Cube Map information.
  51993. */
  51994. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51995. /**
  51996. * Returns the pixels data extracted from an RGBE texture.
  51997. * This pixels will be stored left to right up to down in the R G B order in one array.
  51998. *
  51999. * More information on this format are available here:
  52000. * https://en.wikipedia.org/wiki/RGBE_image_format
  52001. *
  52002. * @param uint8array The binary file stored in an array buffer.
  52003. * @param hdrInfo The header information of the file.
  52004. * @return The pixels data in RGB right to left up to down order.
  52005. */
  52006. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52007. private static RGBE_ReadPixels_RLE;
  52008. }
  52009. }
  52010. declare module BABYLON {
  52011. /**
  52012. * This represents a texture coming from an HDR input.
  52013. *
  52014. * The only supported format is currently panorama picture stored in RGBE format.
  52015. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52016. */
  52017. export class HDRCubeTexture extends BaseTexture {
  52018. private static _facesMapping;
  52019. private _generateHarmonics;
  52020. private _noMipmap;
  52021. private _textureMatrix;
  52022. private _size;
  52023. private _onLoad;
  52024. private _onError;
  52025. /**
  52026. * The texture URL.
  52027. */
  52028. url: string;
  52029. /**
  52030. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52031. */
  52032. coordinatesMode: number;
  52033. protected _isBlocking: boolean;
  52034. /**
  52035. * Sets wether or not the texture is blocking during loading.
  52036. */
  52037. /**
  52038. * Gets wether or not the texture is blocking during loading.
  52039. */
  52040. isBlocking: boolean;
  52041. protected _rotationY: number;
  52042. /**
  52043. * Sets texture matrix rotation angle around Y axis in radians.
  52044. */
  52045. /**
  52046. * Gets texture matrix rotation angle around Y axis radians.
  52047. */
  52048. rotationY: number;
  52049. /**
  52050. * Gets or sets the center of the bounding box associated with the cube texture
  52051. * It must define where the camera used to render the texture was set
  52052. */
  52053. boundingBoxPosition: Vector3;
  52054. private _boundingBoxSize;
  52055. /**
  52056. * Gets or sets the size of the bounding box associated with the cube texture
  52057. * When defined, the cubemap will switch to local mode
  52058. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52059. * @example https://www.babylonjs-playground.com/#RNASML
  52060. */
  52061. boundingBoxSize: Vector3;
  52062. /**
  52063. * Instantiates an HDRTexture from the following parameters.
  52064. *
  52065. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52066. * @param scene The scene the texture will be used in
  52067. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52068. * @param noMipmap Forces to not generate the mipmap if true
  52069. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52070. * @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)
  52071. * @param reserved Reserved flag for internal use.
  52072. */
  52073. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52074. /**
  52075. * Get the current class name of the texture useful for serialization or dynamic coding.
  52076. * @returns "HDRCubeTexture"
  52077. */
  52078. getClassName(): string;
  52079. /**
  52080. * Occurs when the file is raw .hdr file.
  52081. */
  52082. private loadTexture;
  52083. clone(): HDRCubeTexture;
  52084. delayLoad(): void;
  52085. /**
  52086. * Get the texture reflection matrix used to rotate/transform the reflection.
  52087. * @returns the reflection matrix
  52088. */
  52089. getReflectionTextureMatrix(): Matrix;
  52090. /**
  52091. * Set the texture reflection matrix used to rotate/transform the reflection.
  52092. * @param value Define the reflection matrix to set
  52093. */
  52094. setReflectionTextureMatrix(value: Matrix): void;
  52095. /**
  52096. * Parses a JSON representation of an HDR Texture in order to create the texture
  52097. * @param parsedTexture Define the JSON representation
  52098. * @param scene Define the scene the texture should be created in
  52099. * @param rootUrl Define the root url in case we need to load relative dependencies
  52100. * @returns the newly created texture after parsing
  52101. */
  52102. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52103. serialize(): any;
  52104. }
  52105. }
  52106. declare module BABYLON {
  52107. /**
  52108. * Class used to control physics engine
  52109. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52110. */
  52111. export class PhysicsEngine implements IPhysicsEngine {
  52112. private _physicsPlugin;
  52113. /**
  52114. * Global value used to control the smallest number supported by the simulation
  52115. */
  52116. static Epsilon: number;
  52117. private _impostors;
  52118. private _joints;
  52119. private _subTimeStep;
  52120. /**
  52121. * Gets the gravity vector used by the simulation
  52122. */
  52123. gravity: Vector3;
  52124. /**
  52125. * Factory used to create the default physics plugin.
  52126. * @returns The default physics plugin
  52127. */
  52128. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52129. /**
  52130. * Creates a new Physics Engine
  52131. * @param gravity defines the gravity vector used by the simulation
  52132. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52133. */
  52134. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52135. /**
  52136. * Sets the gravity vector used by the simulation
  52137. * @param gravity defines the gravity vector to use
  52138. */
  52139. setGravity(gravity: Vector3): void;
  52140. /**
  52141. * Set the time step of the physics engine.
  52142. * Default is 1/60.
  52143. * To slow it down, enter 1/600 for example.
  52144. * To speed it up, 1/30
  52145. * @param newTimeStep defines the new timestep to apply to this world.
  52146. */
  52147. setTimeStep(newTimeStep?: number): void;
  52148. /**
  52149. * Get the time step of the physics engine.
  52150. * @returns the current time step
  52151. */
  52152. getTimeStep(): number;
  52153. /**
  52154. * Set the sub time step of the physics engine.
  52155. * Default is 0 meaning there is no sub steps
  52156. * To increase physics resolution precision, set a small value (like 1 ms)
  52157. * @param subTimeStep defines the new sub timestep used for physics resolution.
  52158. */
  52159. setSubTimeStep(subTimeStep?: number): void;
  52160. /**
  52161. * Get the sub time step of the physics engine.
  52162. * @returns the current sub time step
  52163. */
  52164. getSubTimeStep(): number;
  52165. /**
  52166. * Release all resources
  52167. */
  52168. dispose(): void;
  52169. /**
  52170. * Gets the name of the current physics plugin
  52171. * @returns the name of the plugin
  52172. */
  52173. getPhysicsPluginName(): string;
  52174. /**
  52175. * Adding a new impostor for the impostor tracking.
  52176. * This will be done by the impostor itself.
  52177. * @param impostor the impostor to add
  52178. */
  52179. addImpostor(impostor: PhysicsImpostor): void;
  52180. /**
  52181. * Remove an impostor from the engine.
  52182. * This impostor and its mesh will not longer be updated by the physics engine.
  52183. * @param impostor the impostor to remove
  52184. */
  52185. removeImpostor(impostor: PhysicsImpostor): void;
  52186. /**
  52187. * Add a joint to the physics engine
  52188. * @param mainImpostor defines the main impostor to which the joint is added.
  52189. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52190. * @param joint defines the joint that will connect both impostors.
  52191. */
  52192. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52193. /**
  52194. * Removes a joint from the simulation
  52195. * @param mainImpostor defines the impostor used with the joint
  52196. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52197. * @param joint defines the joint to remove
  52198. */
  52199. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52200. /**
  52201. * Called by the scene. No need to call it.
  52202. * @param delta defines the timespam between frames
  52203. */
  52204. _step(delta: number): void;
  52205. /**
  52206. * Gets the current plugin used to run the simulation
  52207. * @returns current plugin
  52208. */
  52209. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52210. /**
  52211. * Gets the list of physic impostors
  52212. * @returns an array of PhysicsImpostor
  52213. */
  52214. getImpostors(): Array<PhysicsImpostor>;
  52215. /**
  52216. * Gets the impostor for a physics enabled object
  52217. * @param object defines the object impersonated by the impostor
  52218. * @returns the PhysicsImpostor or null if not found
  52219. */
  52220. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52221. /**
  52222. * Gets the impostor for a physics body object
  52223. * @param body defines physics body used by the impostor
  52224. * @returns the PhysicsImpostor or null if not found
  52225. */
  52226. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52227. /**
  52228. * Does a raycast in the physics world
  52229. * @param from when should the ray start?
  52230. * @param to when should the ray end?
  52231. * @returns PhysicsRaycastResult
  52232. */
  52233. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52234. }
  52235. }
  52236. declare module BABYLON {
  52237. /** @hidden */
  52238. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52239. private _useDeltaForWorldStep;
  52240. world: any;
  52241. name: string;
  52242. private _physicsMaterials;
  52243. private _fixedTimeStep;
  52244. private _cannonRaycastResult;
  52245. private _raycastResult;
  52246. private _physicsBodysToRemoveAfterStep;
  52247. BJSCANNON: any;
  52248. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52249. setGravity(gravity: Vector3): void;
  52250. setTimeStep(timeStep: number): void;
  52251. getTimeStep(): number;
  52252. executeStep(delta: number): void;
  52253. private _removeMarkedPhysicsBodiesFromWorld;
  52254. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52255. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52256. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52257. private _processChildMeshes;
  52258. removePhysicsBody(impostor: PhysicsImpostor): void;
  52259. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52260. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52261. private _addMaterial;
  52262. private _checkWithEpsilon;
  52263. private _createShape;
  52264. private _createHeightmap;
  52265. private _minus90X;
  52266. private _plus90X;
  52267. private _tmpPosition;
  52268. private _tmpDeltaPosition;
  52269. private _tmpUnityRotation;
  52270. private _updatePhysicsBodyTransformation;
  52271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52273. isSupported(): boolean;
  52274. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52275. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52276. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52277. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52278. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52279. getBodyMass(impostor: PhysicsImpostor): number;
  52280. getBodyFriction(impostor: PhysicsImpostor): number;
  52281. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52282. getBodyRestitution(impostor: PhysicsImpostor): number;
  52283. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52284. sleepBody(impostor: PhysicsImpostor): void;
  52285. wakeUpBody(impostor: PhysicsImpostor): void;
  52286. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52287. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52289. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52290. getRadius(impostor: PhysicsImpostor): number;
  52291. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52292. dispose(): void;
  52293. private _extendNamespace;
  52294. /**
  52295. * Does a raycast in the physics world
  52296. * @param from when should the ray start?
  52297. * @param to when should the ray end?
  52298. * @returns PhysicsRaycastResult
  52299. */
  52300. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52301. }
  52302. }
  52303. declare module BABYLON {
  52304. /** @hidden */
  52305. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52306. world: any;
  52307. name: string;
  52308. BJSOIMO: any;
  52309. private _raycastResult;
  52310. constructor(iterations?: number, oimoInjection?: any);
  52311. setGravity(gravity: Vector3): void;
  52312. setTimeStep(timeStep: number): void;
  52313. getTimeStep(): number;
  52314. private _tmpImpostorsArray;
  52315. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52316. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52317. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52318. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52319. private _tmpPositionVector;
  52320. removePhysicsBody(impostor: PhysicsImpostor): void;
  52321. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52322. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52323. isSupported(): boolean;
  52324. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52325. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52326. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52327. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52328. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52329. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52330. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52331. getBodyMass(impostor: PhysicsImpostor): number;
  52332. getBodyFriction(impostor: PhysicsImpostor): number;
  52333. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52334. getBodyRestitution(impostor: PhysicsImpostor): number;
  52335. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52336. sleepBody(impostor: PhysicsImpostor): void;
  52337. wakeUpBody(impostor: PhysicsImpostor): void;
  52338. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52339. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52340. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52341. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52342. getRadius(impostor: PhysicsImpostor): number;
  52343. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52344. dispose(): void;
  52345. /**
  52346. * Does a raycast in the physics world
  52347. * @param from when should the ray start?
  52348. * @param to when should the ray end?
  52349. * @returns PhysicsRaycastResult
  52350. */
  52351. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52352. }
  52353. }
  52354. declare module BABYLON {
  52355. /**
  52356. * Class containing static functions to help procedurally build meshes
  52357. */
  52358. export class RibbonBuilder {
  52359. /**
  52360. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52361. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52362. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52363. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52364. * * 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
  52365. * * 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
  52366. * * 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
  52367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52368. * * 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
  52369. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52370. * * 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
  52371. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52372. * * 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
  52373. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52375. * @param name defines the name of the mesh
  52376. * @param options defines the options used to create the mesh
  52377. * @param scene defines the hosting scene
  52378. * @returns the ribbon mesh
  52379. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52381. */
  52382. static CreateRibbon(name: string, options: {
  52383. pathArray: Vector3[][];
  52384. closeArray?: boolean;
  52385. closePath?: boolean;
  52386. offset?: number;
  52387. updatable?: boolean;
  52388. sideOrientation?: number;
  52389. frontUVs?: Vector4;
  52390. backUVs?: Vector4;
  52391. instance?: Mesh;
  52392. invertUV?: boolean;
  52393. uvs?: Vector2[];
  52394. colors?: Color4[];
  52395. }, scene?: Nullable<Scene>): Mesh;
  52396. }
  52397. }
  52398. declare module BABYLON {
  52399. /**
  52400. * Class containing static functions to help procedurally build meshes
  52401. */
  52402. export class ShapeBuilder {
  52403. /**
  52404. * 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.
  52405. * * 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.
  52406. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52407. * * 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.
  52408. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52409. * * 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
  52410. * * 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
  52411. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52413. * * 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
  52414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52416. * @param name defines the name of the mesh
  52417. * @param options defines the options used to create the mesh
  52418. * @param scene defines the hosting scene
  52419. * @returns the extruded shape mesh
  52420. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52422. */
  52423. static ExtrudeShape(name: string, options: {
  52424. shape: Vector3[];
  52425. path: Vector3[];
  52426. scale?: number;
  52427. rotation?: number;
  52428. cap?: number;
  52429. updatable?: boolean;
  52430. sideOrientation?: number;
  52431. frontUVs?: Vector4;
  52432. backUVs?: Vector4;
  52433. instance?: Mesh;
  52434. invertUV?: boolean;
  52435. }, scene?: Nullable<Scene>): Mesh;
  52436. /**
  52437. * Creates an custom extruded shape mesh.
  52438. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52439. * * 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.
  52440. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52441. * * 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
  52442. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52443. * * 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
  52444. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52445. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52446. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52447. * * 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
  52448. * * 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
  52449. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52451. * * 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
  52452. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52454. * @param name defines the name of the mesh
  52455. * @param options defines the options used to create the mesh
  52456. * @param scene defines the hosting scene
  52457. * @returns the custom extruded shape mesh
  52458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52459. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52461. */
  52462. static ExtrudeShapeCustom(name: string, options: {
  52463. shape: Vector3[];
  52464. path: Vector3[];
  52465. scaleFunction?: any;
  52466. rotationFunction?: any;
  52467. ribbonCloseArray?: boolean;
  52468. ribbonClosePath?: boolean;
  52469. cap?: number;
  52470. updatable?: boolean;
  52471. sideOrientation?: number;
  52472. frontUVs?: Vector4;
  52473. backUVs?: Vector4;
  52474. instance?: Mesh;
  52475. invertUV?: boolean;
  52476. }, scene?: Nullable<Scene>): Mesh;
  52477. private static _ExtrudeShapeGeneric;
  52478. }
  52479. }
  52480. declare module BABYLON {
  52481. /**
  52482. * AmmoJS Physics plugin
  52483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52484. * @see https://github.com/kripken/ammo.js/
  52485. */
  52486. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52487. private _useDeltaForWorldStep;
  52488. /**
  52489. * Reference to the Ammo library
  52490. */
  52491. bjsAMMO: any;
  52492. /**
  52493. * Created ammoJS world which physics bodies are added to
  52494. */
  52495. world: any;
  52496. /**
  52497. * Name of the plugin
  52498. */
  52499. name: string;
  52500. private _timeStep;
  52501. private _fixedTimeStep;
  52502. private _maxSteps;
  52503. private _tmpQuaternion;
  52504. private _tmpAmmoTransform;
  52505. private _tmpAmmoQuaternion;
  52506. private _tmpAmmoConcreteContactResultCallback;
  52507. private _collisionConfiguration;
  52508. private _dispatcher;
  52509. private _overlappingPairCache;
  52510. private _solver;
  52511. private _softBodySolver;
  52512. private _tmpAmmoVectorA;
  52513. private _tmpAmmoVectorB;
  52514. private _tmpAmmoVectorC;
  52515. private _tmpAmmoVectorD;
  52516. private _tmpContactCallbackResult;
  52517. private _tmpAmmoVectorRCA;
  52518. private _tmpAmmoVectorRCB;
  52519. private _raycastResult;
  52520. private static readonly DISABLE_COLLISION_FLAG;
  52521. private static readonly KINEMATIC_FLAG;
  52522. private static readonly DISABLE_DEACTIVATION_FLAG;
  52523. /**
  52524. * Initializes the ammoJS plugin
  52525. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52526. * @param ammoInjection can be used to inject your own ammo reference
  52527. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52528. */
  52529. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52530. /**
  52531. * Sets the gravity of the physics world (m/(s^2))
  52532. * @param gravity Gravity to set
  52533. */
  52534. setGravity(gravity: Vector3): void;
  52535. /**
  52536. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52537. * @param timeStep timestep to use in seconds
  52538. */
  52539. setTimeStep(timeStep: number): void;
  52540. /**
  52541. * 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)
  52542. * @param fixedTimeStep fixedTimeStep to use in seconds
  52543. */
  52544. setFixedTimeStep(fixedTimeStep: number): void;
  52545. /**
  52546. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52547. * @param maxSteps the maximum number of steps by the physics engine per frame
  52548. */
  52549. setMaxSteps(maxSteps: number): void;
  52550. /**
  52551. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52552. * @returns the current timestep in seconds
  52553. */
  52554. getTimeStep(): number;
  52555. /**
  52556. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  52557. */
  52558. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  52559. private _isImpostorInContact;
  52560. private _isImpostorPairInContact;
  52561. private _stepSimulation;
  52562. /**
  52563. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52564. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52565. * After the step the babylon meshes are set to the position of the physics imposters
  52566. * @param delta amount of time to step forward
  52567. * @param impostors array of imposters to update before/after the step
  52568. */
  52569. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52570. /**
  52571. * Update babylon mesh to match physics world object
  52572. * @param impostor imposter to match
  52573. */
  52574. private _afterSoftStep;
  52575. /**
  52576. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52577. * @param impostor imposter to match
  52578. */
  52579. private _ropeStep;
  52580. /**
  52581. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52582. * @param impostor imposter to match
  52583. */
  52584. private _softbodyOrClothStep;
  52585. private _tmpVector;
  52586. private _tmpMatrix;
  52587. /**
  52588. * Applies an impulse on the imposter
  52589. * @param impostor imposter to apply impulse to
  52590. * @param force amount of force to be applied to the imposter
  52591. * @param contactPoint the location to apply the impulse on the imposter
  52592. */
  52593. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52594. /**
  52595. * Applies a force on the imposter
  52596. * @param impostor imposter to apply force
  52597. * @param force amount of force to be applied to the imposter
  52598. * @param contactPoint the location to apply the force on the imposter
  52599. */
  52600. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52601. /**
  52602. * Creates a physics body using the plugin
  52603. * @param impostor the imposter to create the physics body on
  52604. */
  52605. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52606. /**
  52607. * Removes the physics body from the imposter and disposes of the body's memory
  52608. * @param impostor imposter to remove the physics body from
  52609. */
  52610. removePhysicsBody(impostor: PhysicsImpostor): void;
  52611. /**
  52612. * Generates a joint
  52613. * @param impostorJoint the imposter joint to create the joint with
  52614. */
  52615. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52616. /**
  52617. * Removes a joint
  52618. * @param impostorJoint the imposter joint to remove the joint from
  52619. */
  52620. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52621. private _addMeshVerts;
  52622. /**
  52623. * Initialise the soft body vertices to match its object's (mesh) vertices
  52624. * Softbody vertices (nodes) are in world space and to match this
  52625. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52626. * @param impostor to create the softbody for
  52627. */
  52628. private _softVertexData;
  52629. /**
  52630. * Create an impostor's soft body
  52631. * @param impostor to create the softbody for
  52632. */
  52633. private _createSoftbody;
  52634. /**
  52635. * Create cloth for an impostor
  52636. * @param impostor to create the softbody for
  52637. */
  52638. private _createCloth;
  52639. /**
  52640. * Create rope for an impostor
  52641. * @param impostor to create the softbody for
  52642. */
  52643. private _createRope;
  52644. /**
  52645. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  52646. * @param impostor to create the custom physics shape for
  52647. */
  52648. private _createCustom;
  52649. private _addHullVerts;
  52650. private _createShape;
  52651. /**
  52652. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52653. * @param impostor imposter containing the physics body and babylon object
  52654. */
  52655. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52656. /**
  52657. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52658. * @param impostor imposter containing the physics body and babylon object
  52659. * @param newPosition new position
  52660. * @param newRotation new rotation
  52661. */
  52662. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52663. /**
  52664. * If this plugin is supported
  52665. * @returns true if its supported
  52666. */
  52667. isSupported(): boolean;
  52668. /**
  52669. * Sets the linear velocity of the physics body
  52670. * @param impostor imposter to set the velocity on
  52671. * @param velocity velocity to set
  52672. */
  52673. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52674. /**
  52675. * Sets the angular velocity of the physics body
  52676. * @param impostor imposter to set the velocity on
  52677. * @param velocity velocity to set
  52678. */
  52679. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52680. /**
  52681. * gets the linear velocity
  52682. * @param impostor imposter to get linear velocity from
  52683. * @returns linear velocity
  52684. */
  52685. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52686. /**
  52687. * gets the angular velocity
  52688. * @param impostor imposter to get angular velocity from
  52689. * @returns angular velocity
  52690. */
  52691. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52692. /**
  52693. * Sets the mass of physics body
  52694. * @param impostor imposter to set the mass on
  52695. * @param mass mass to set
  52696. */
  52697. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52698. /**
  52699. * Gets the mass of the physics body
  52700. * @param impostor imposter to get the mass from
  52701. * @returns mass
  52702. */
  52703. getBodyMass(impostor: PhysicsImpostor): number;
  52704. /**
  52705. * Gets friction of the impostor
  52706. * @param impostor impostor to get friction from
  52707. * @returns friction value
  52708. */
  52709. getBodyFriction(impostor: PhysicsImpostor): number;
  52710. /**
  52711. * Sets friction of the impostor
  52712. * @param impostor impostor to set friction on
  52713. * @param friction friction value
  52714. */
  52715. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52716. /**
  52717. * Gets restitution of the impostor
  52718. * @param impostor impostor to get restitution from
  52719. * @returns restitution value
  52720. */
  52721. getBodyRestitution(impostor: PhysicsImpostor): number;
  52722. /**
  52723. * Sets resitution of the impostor
  52724. * @param impostor impostor to set resitution on
  52725. * @param restitution resitution value
  52726. */
  52727. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52728. /**
  52729. * Gets pressure inside the impostor
  52730. * @param impostor impostor to get pressure from
  52731. * @returns pressure value
  52732. */
  52733. getBodyPressure(impostor: PhysicsImpostor): number;
  52734. /**
  52735. * Sets pressure inside a soft body impostor
  52736. * Cloth and rope must remain 0 pressure
  52737. * @param impostor impostor to set pressure on
  52738. * @param pressure pressure value
  52739. */
  52740. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52741. /**
  52742. * Gets stiffness of the impostor
  52743. * @param impostor impostor to get stiffness from
  52744. * @returns pressure value
  52745. */
  52746. getBodyStiffness(impostor: PhysicsImpostor): number;
  52747. /**
  52748. * Sets stiffness of the impostor
  52749. * @param impostor impostor to set stiffness on
  52750. * @param stiffness stiffness value from 0 to 1
  52751. */
  52752. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52753. /**
  52754. * Gets velocityIterations of the impostor
  52755. * @param impostor impostor to get velocity iterations from
  52756. * @returns velocityIterations value
  52757. */
  52758. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52759. /**
  52760. * Sets velocityIterations of the impostor
  52761. * @param impostor impostor to set velocity iterations on
  52762. * @param velocityIterations velocityIterations value
  52763. */
  52764. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52765. /**
  52766. * Gets positionIterations of the impostor
  52767. * @param impostor impostor to get position iterations from
  52768. * @returns positionIterations value
  52769. */
  52770. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52771. /**
  52772. * Sets positionIterations of the impostor
  52773. * @param impostor impostor to set position on
  52774. * @param positionIterations positionIterations value
  52775. */
  52776. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52777. /**
  52778. * Append an anchor to a cloth object
  52779. * @param impostor is the cloth impostor to add anchor to
  52780. * @param otherImpostor is the rigid impostor to anchor to
  52781. * @param width ratio across width from 0 to 1
  52782. * @param height ratio up height from 0 to 1
  52783. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52784. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52785. */
  52786. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52787. /**
  52788. * Append an hook to a rope object
  52789. * @param impostor is the rope impostor to add hook to
  52790. * @param otherImpostor is the rigid impostor to hook to
  52791. * @param length ratio along the rope from 0 to 1
  52792. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52793. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52794. */
  52795. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52796. /**
  52797. * Sleeps the physics body and stops it from being active
  52798. * @param impostor impostor to sleep
  52799. */
  52800. sleepBody(impostor: PhysicsImpostor): void;
  52801. /**
  52802. * Activates the physics body
  52803. * @param impostor impostor to activate
  52804. */
  52805. wakeUpBody(impostor: PhysicsImpostor): void;
  52806. /**
  52807. * Updates the distance parameters of the joint
  52808. * @param joint joint to update
  52809. * @param maxDistance maximum distance of the joint
  52810. * @param minDistance minimum distance of the joint
  52811. */
  52812. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52813. /**
  52814. * Sets a motor on the joint
  52815. * @param joint joint to set motor on
  52816. * @param speed speed of the motor
  52817. * @param maxForce maximum force of the motor
  52818. * @param motorIndex index of the motor
  52819. */
  52820. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52821. /**
  52822. * Sets the motors limit
  52823. * @param joint joint to set limit on
  52824. * @param upperLimit upper limit
  52825. * @param lowerLimit lower limit
  52826. */
  52827. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52828. /**
  52829. * Syncs the position and rotation of a mesh with the impostor
  52830. * @param mesh mesh to sync
  52831. * @param impostor impostor to update the mesh with
  52832. */
  52833. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52834. /**
  52835. * Gets the radius of the impostor
  52836. * @param impostor impostor to get radius from
  52837. * @returns the radius
  52838. */
  52839. getRadius(impostor: PhysicsImpostor): number;
  52840. /**
  52841. * Gets the box size of the impostor
  52842. * @param impostor impostor to get box size from
  52843. * @param result the resulting box size
  52844. */
  52845. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52846. /**
  52847. * Disposes of the impostor
  52848. */
  52849. dispose(): void;
  52850. /**
  52851. * Does a raycast in the physics world
  52852. * @param from when should the ray start?
  52853. * @param to when should the ray end?
  52854. * @returns PhysicsRaycastResult
  52855. */
  52856. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52857. }
  52858. }
  52859. declare module BABYLON {
  52860. interface AbstractScene {
  52861. /**
  52862. * The list of reflection probes added to the scene
  52863. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52864. */
  52865. reflectionProbes: Array<ReflectionProbe>;
  52866. /**
  52867. * Removes the given reflection probe from this scene.
  52868. * @param toRemove The reflection probe to remove
  52869. * @returns The index of the removed reflection probe
  52870. */
  52871. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52872. /**
  52873. * Adds the given reflection probe to this scene.
  52874. * @param newReflectionProbe The reflection probe to add
  52875. */
  52876. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52877. }
  52878. /**
  52879. * Class used to generate realtime reflection / refraction cube textures
  52880. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52881. */
  52882. export class ReflectionProbe {
  52883. /** defines the name of the probe */
  52884. name: string;
  52885. private _scene;
  52886. private _renderTargetTexture;
  52887. private _projectionMatrix;
  52888. private _viewMatrix;
  52889. private _target;
  52890. private _add;
  52891. private _attachedMesh;
  52892. private _invertYAxis;
  52893. /** Gets or sets probe position (center of the cube map) */
  52894. position: Vector3;
  52895. /**
  52896. * Creates a new reflection probe
  52897. * @param name defines the name of the probe
  52898. * @param size defines the texture resolution (for each face)
  52899. * @param scene defines the hosting scene
  52900. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52901. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52902. */
  52903. constructor(
  52904. /** defines the name of the probe */
  52905. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52906. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52907. samples: number;
  52908. /** Gets or sets the refresh rate to use (on every frame by default) */
  52909. refreshRate: number;
  52910. /**
  52911. * Gets the hosting scene
  52912. * @returns a Scene
  52913. */
  52914. getScene(): Scene;
  52915. /** Gets the internal CubeTexture used to render to */
  52916. readonly cubeTexture: RenderTargetTexture;
  52917. /** Gets the list of meshes to render */
  52918. readonly renderList: Nullable<AbstractMesh[]>;
  52919. /**
  52920. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52921. * @param mesh defines the mesh to attach to
  52922. */
  52923. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52924. /**
  52925. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52926. * @param renderingGroupId The rendering group id corresponding to its index
  52927. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52928. */
  52929. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52930. /**
  52931. * Clean all associated resources
  52932. */
  52933. dispose(): void;
  52934. /**
  52935. * Converts the reflection probe information to a readable string for debug purpose.
  52936. * @param fullDetails Supports for multiple levels of logging within scene loading
  52937. * @returns the human readable reflection probe info
  52938. */
  52939. toString(fullDetails?: boolean): string;
  52940. /**
  52941. * Get the class name of the relfection probe.
  52942. * @returns "ReflectionProbe"
  52943. */
  52944. getClassName(): string;
  52945. /**
  52946. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52947. * @returns The JSON representation of the texture
  52948. */
  52949. serialize(): any;
  52950. /**
  52951. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52952. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52953. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52954. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52955. * @returns The parsed reflection probe if successful
  52956. */
  52957. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52958. }
  52959. }
  52960. declare module BABYLON {
  52961. /** @hidden */
  52962. export var _BabylonLoaderRegistered: boolean;
  52963. /**
  52964. * Helps setting up some configuration for the babylon file loader.
  52965. */
  52966. export class BabylonFileLoaderConfiguration {
  52967. /**
  52968. * The loader does not allow injecting custom physix engine into the plugins.
  52969. * Unfortunately in ES6, we need to manually inject them into the plugin.
  52970. * So you could set this variable to your engine import to make it work.
  52971. */
  52972. static LoaderInjectedPhysicsEngine: any;
  52973. }
  52974. }
  52975. declare module BABYLON {
  52976. /**
  52977. * The Physically based simple base material of BJS.
  52978. *
  52979. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52980. * It is used as the base class for both the specGloss and metalRough conventions.
  52981. */
  52982. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52983. /**
  52984. * Number of Simultaneous lights allowed on the material.
  52985. */
  52986. maxSimultaneousLights: number;
  52987. /**
  52988. * If sets to true, disables all the lights affecting the material.
  52989. */
  52990. disableLighting: boolean;
  52991. /**
  52992. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52993. */
  52994. environmentTexture: BaseTexture;
  52995. /**
  52996. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52997. */
  52998. invertNormalMapX: boolean;
  52999. /**
  53000. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53001. */
  53002. invertNormalMapY: boolean;
  53003. /**
  53004. * Normal map used in the model.
  53005. */
  53006. normalTexture: BaseTexture;
  53007. /**
  53008. * Emissivie color used to self-illuminate the model.
  53009. */
  53010. emissiveColor: Color3;
  53011. /**
  53012. * Emissivie texture used to self-illuminate the model.
  53013. */
  53014. emissiveTexture: BaseTexture;
  53015. /**
  53016. * Occlusion Channel Strenght.
  53017. */
  53018. occlusionStrength: number;
  53019. /**
  53020. * Occlusion Texture of the material (adding extra occlusion effects).
  53021. */
  53022. occlusionTexture: BaseTexture;
  53023. /**
  53024. * Defines the alpha limits in alpha test mode.
  53025. */
  53026. alphaCutOff: number;
  53027. /**
  53028. * Gets the current double sided mode.
  53029. */
  53030. /**
  53031. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53032. */
  53033. doubleSided: boolean;
  53034. /**
  53035. * Stores the pre-calculated light information of a mesh in a texture.
  53036. */
  53037. lightmapTexture: BaseTexture;
  53038. /**
  53039. * If true, the light map contains occlusion information instead of lighting info.
  53040. */
  53041. useLightmapAsShadowmap: boolean;
  53042. /**
  53043. * Instantiates a new PBRMaterial instance.
  53044. *
  53045. * @param name The material name
  53046. * @param scene The scene the material will be use in.
  53047. */
  53048. constructor(name: string, scene: Scene);
  53049. getClassName(): string;
  53050. }
  53051. }
  53052. declare module BABYLON {
  53053. /**
  53054. * The PBR material of BJS following the metal roughness convention.
  53055. *
  53056. * This fits to the PBR convention in the GLTF definition:
  53057. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53058. */
  53059. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53060. /**
  53061. * The base color has two different interpretations depending on the value of metalness.
  53062. * When the material is a metal, the base color is the specific measured reflectance value
  53063. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53064. * of the material.
  53065. */
  53066. baseColor: Color3;
  53067. /**
  53068. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53069. * well as opacity information in the alpha channel.
  53070. */
  53071. baseTexture: BaseTexture;
  53072. /**
  53073. * Specifies the metallic scalar value of the material.
  53074. * Can also be used to scale the metalness values of the metallic texture.
  53075. */
  53076. metallic: number;
  53077. /**
  53078. * Specifies the roughness scalar value of the material.
  53079. * Can also be used to scale the roughness values of the metallic texture.
  53080. */
  53081. roughness: number;
  53082. /**
  53083. * Texture containing both the metallic value in the B channel and the
  53084. * roughness value in the G channel to keep better precision.
  53085. */
  53086. metallicRoughnessTexture: BaseTexture;
  53087. /**
  53088. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53089. *
  53090. * @param name The material name
  53091. * @param scene The scene the material will be use in.
  53092. */
  53093. constructor(name: string, scene: Scene);
  53094. /**
  53095. * Return the currrent class name of the material.
  53096. */
  53097. getClassName(): string;
  53098. /**
  53099. * Makes a duplicate of the current material.
  53100. * @param name - name to use for the new material.
  53101. */
  53102. clone(name: string): PBRMetallicRoughnessMaterial;
  53103. /**
  53104. * Serialize the material to a parsable JSON object.
  53105. */
  53106. serialize(): any;
  53107. /**
  53108. * Parses a JSON object correponding to the serialize function.
  53109. */
  53110. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53111. }
  53112. }
  53113. declare module BABYLON {
  53114. /**
  53115. * The PBR material of BJS following the specular glossiness convention.
  53116. *
  53117. * This fits to the PBR convention in the GLTF definition:
  53118. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53119. */
  53120. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53121. /**
  53122. * Specifies the diffuse color of the material.
  53123. */
  53124. diffuseColor: Color3;
  53125. /**
  53126. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53127. * channel.
  53128. */
  53129. diffuseTexture: BaseTexture;
  53130. /**
  53131. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53132. */
  53133. specularColor: Color3;
  53134. /**
  53135. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53136. */
  53137. glossiness: number;
  53138. /**
  53139. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53140. */
  53141. specularGlossinessTexture: BaseTexture;
  53142. /**
  53143. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53144. *
  53145. * @param name The material name
  53146. * @param scene The scene the material will be use in.
  53147. */
  53148. constructor(name: string, scene: Scene);
  53149. /**
  53150. * Return the currrent class name of the material.
  53151. */
  53152. getClassName(): string;
  53153. /**
  53154. * Makes a duplicate of the current material.
  53155. * @param name - name to use for the new material.
  53156. */
  53157. clone(name: string): PBRSpecularGlossinessMaterial;
  53158. /**
  53159. * Serialize the material to a parsable JSON object.
  53160. */
  53161. serialize(): any;
  53162. /**
  53163. * Parses a JSON object correponding to the serialize function.
  53164. */
  53165. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53166. }
  53167. }
  53168. declare module BABYLON {
  53169. /**
  53170. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53171. * It can help converting any input color in a desired output one. This can then be used to create effects
  53172. * from sepia, black and white to sixties or futuristic rendering...
  53173. *
  53174. * The only supported format is currently 3dl.
  53175. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53176. */
  53177. export class ColorGradingTexture extends BaseTexture {
  53178. /**
  53179. * The current texture matrix. (will always be identity in color grading texture)
  53180. */
  53181. private _textureMatrix;
  53182. /**
  53183. * The texture URL.
  53184. */
  53185. url: string;
  53186. /**
  53187. * Empty line regex stored for GC.
  53188. */
  53189. private static _noneEmptyLineRegex;
  53190. private _engine;
  53191. /**
  53192. * Instantiates a ColorGradingTexture from the following parameters.
  53193. *
  53194. * @param url The location of the color gradind data (currently only supporting 3dl)
  53195. * @param scene The scene the texture will be used in
  53196. */
  53197. constructor(url: string, scene: Scene);
  53198. /**
  53199. * Returns the texture matrix used in most of the material.
  53200. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53201. */
  53202. getTextureMatrix(): Matrix;
  53203. /**
  53204. * Occurs when the file being loaded is a .3dl LUT file.
  53205. */
  53206. private load3dlTexture;
  53207. /**
  53208. * Starts the loading process of the texture.
  53209. */
  53210. private loadTexture;
  53211. /**
  53212. * Clones the color gradind texture.
  53213. */
  53214. clone(): ColorGradingTexture;
  53215. /**
  53216. * Called during delayed load for textures.
  53217. */
  53218. delayLoad(): void;
  53219. /**
  53220. * Parses a color grading texture serialized by Babylon.
  53221. * @param parsedTexture The texture information being parsedTexture
  53222. * @param scene The scene to load the texture in
  53223. * @param rootUrl The root url of the data assets to load
  53224. * @return A color gradind texture
  53225. */
  53226. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53227. /**
  53228. * Serializes the LUT texture to json format.
  53229. */
  53230. serialize(): any;
  53231. }
  53232. }
  53233. declare module BABYLON {
  53234. /**
  53235. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53236. */
  53237. export class EquiRectangularCubeTexture extends BaseTexture {
  53238. /** The six faces of the cube. */
  53239. private static _FacesMapping;
  53240. private _noMipmap;
  53241. private _onLoad;
  53242. private _onError;
  53243. /** The size of the cubemap. */
  53244. private _size;
  53245. /** The buffer of the image. */
  53246. private _buffer;
  53247. /** The width of the input image. */
  53248. private _width;
  53249. /** The height of the input image. */
  53250. private _height;
  53251. /** The URL to the image. */
  53252. url: string;
  53253. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53254. coordinatesMode: number;
  53255. /**
  53256. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53257. * @param url The location of the image
  53258. * @param scene The scene the texture will be used in
  53259. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53260. * @param noMipmap Forces to not generate the mipmap if true
  53261. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53262. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53263. * @param onLoad — defines a callback called when texture is loaded
  53264. * @param onError — defines a callback called if there is an error
  53265. */
  53266. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53267. /**
  53268. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53269. */
  53270. private loadImage;
  53271. /**
  53272. * Convert the image buffer into a cubemap and create a CubeTexture.
  53273. */
  53274. private loadTexture;
  53275. /**
  53276. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53277. * @param buffer The ArrayBuffer that should be converted.
  53278. * @returns The buffer as Float32Array.
  53279. */
  53280. private getFloat32ArrayFromArrayBuffer;
  53281. /**
  53282. * Get the current class name of the texture useful for serialization or dynamic coding.
  53283. * @returns "EquiRectangularCubeTexture"
  53284. */
  53285. getClassName(): string;
  53286. /**
  53287. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53288. * @returns A clone of the current EquiRectangularCubeTexture.
  53289. */
  53290. clone(): EquiRectangularCubeTexture;
  53291. }
  53292. }
  53293. declare module BABYLON {
  53294. /**
  53295. * Based on jsTGALoader - Javascript loader for TGA file
  53296. * By Vincent Thibault
  53297. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53298. */
  53299. export class TGATools {
  53300. private static _TYPE_INDEXED;
  53301. private static _TYPE_RGB;
  53302. private static _TYPE_GREY;
  53303. private static _TYPE_RLE_INDEXED;
  53304. private static _TYPE_RLE_RGB;
  53305. private static _TYPE_RLE_GREY;
  53306. private static _ORIGIN_MASK;
  53307. private static _ORIGIN_SHIFT;
  53308. private static _ORIGIN_BL;
  53309. private static _ORIGIN_BR;
  53310. private static _ORIGIN_UL;
  53311. private static _ORIGIN_UR;
  53312. /**
  53313. * Gets the header of a TGA file
  53314. * @param data defines the TGA data
  53315. * @returns the header
  53316. */
  53317. static GetTGAHeader(data: Uint8Array): any;
  53318. /**
  53319. * Uploads TGA content to a Babylon Texture
  53320. * @hidden
  53321. */
  53322. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53323. /** @hidden */
  53324. 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;
  53325. /** @hidden */
  53326. 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;
  53327. /** @hidden */
  53328. 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;
  53329. /** @hidden */
  53330. 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;
  53331. /** @hidden */
  53332. 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;
  53333. /** @hidden */
  53334. 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;
  53335. }
  53336. }
  53337. declare module BABYLON {
  53338. /**
  53339. * Implementation of the TGA Texture Loader.
  53340. * @hidden
  53341. */
  53342. export class _TGATextureLoader implements IInternalTextureLoader {
  53343. /**
  53344. * Defines wether the loader supports cascade loading the different faces.
  53345. */
  53346. readonly supportCascades: boolean;
  53347. /**
  53348. * This returns if the loader support the current file information.
  53349. * @param extension defines the file extension of the file being loaded
  53350. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53351. * @param fallback defines the fallback internal texture if any
  53352. * @param isBase64 defines whether the texture is encoded as a base64
  53353. * @param isBuffer defines whether the texture data are stored as a buffer
  53354. * @returns true if the loader can load the specified file
  53355. */
  53356. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53357. /**
  53358. * Transform the url before loading if required.
  53359. * @param rootUrl the url of the texture
  53360. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53361. * @returns the transformed texture
  53362. */
  53363. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53364. /**
  53365. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53366. * @param rootUrl the url of the texture
  53367. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53368. * @returns the fallback texture
  53369. */
  53370. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53371. /**
  53372. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53373. * @param data contains the texture data
  53374. * @param texture defines the BabylonJS internal texture
  53375. * @param createPolynomials will be true if polynomials have been requested
  53376. * @param onLoad defines the callback to trigger once the texture is ready
  53377. * @param onError defines the callback to trigger in case of error
  53378. */
  53379. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53380. /**
  53381. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53382. * @param data contains the texture data
  53383. * @param texture defines the BabylonJS internal texture
  53384. * @param callback defines the method to call once ready to upload
  53385. */
  53386. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53387. }
  53388. }
  53389. declare module BABYLON {
  53390. /**
  53391. * Info about the .basis files
  53392. */
  53393. class BasisFileInfo {
  53394. /**
  53395. * If the file has alpha
  53396. */
  53397. hasAlpha: boolean;
  53398. /**
  53399. * Info about each image of the basis file
  53400. */
  53401. images: Array<{
  53402. levels: Array<{
  53403. width: number;
  53404. height: number;
  53405. transcodedPixels: ArrayBufferView;
  53406. }>;
  53407. }>;
  53408. }
  53409. /**
  53410. * Result of transcoding a basis file
  53411. */
  53412. class TranscodeResult {
  53413. /**
  53414. * Info about the .basis file
  53415. */
  53416. fileInfo: BasisFileInfo;
  53417. /**
  53418. * Format to use when loading the file
  53419. */
  53420. format: number;
  53421. }
  53422. /**
  53423. * Configuration options for the Basis transcoder
  53424. */
  53425. export class BasisTranscodeConfiguration {
  53426. /**
  53427. * Supported compression formats used to determine the supported output format of the transcoder
  53428. */
  53429. supportedCompressionFormats?: {
  53430. /**
  53431. * etc1 compression format
  53432. */
  53433. etc1?: boolean;
  53434. /**
  53435. * s3tc compression format
  53436. */
  53437. s3tc?: boolean;
  53438. /**
  53439. * pvrtc compression format
  53440. */
  53441. pvrtc?: boolean;
  53442. /**
  53443. * etc2 compression format
  53444. */
  53445. etc2?: boolean;
  53446. };
  53447. /**
  53448. * If mipmap levels should be loaded for transcoded images (Default: true)
  53449. */
  53450. loadMipmapLevels?: boolean;
  53451. /**
  53452. * Index of a single image to load (Default: all images)
  53453. */
  53454. loadSingleImage?: number;
  53455. }
  53456. /**
  53457. * Used to load .Basis files
  53458. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53459. */
  53460. export class BasisTools {
  53461. private static _IgnoreSupportedFormats;
  53462. /**
  53463. * URL to use when loading the basis transcoder
  53464. */
  53465. static JSModuleURL: string;
  53466. /**
  53467. * URL to use when loading the wasm module for the transcoder
  53468. */
  53469. static WasmModuleURL: string;
  53470. /**
  53471. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53472. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53473. * @returns internal format corresponding to the Basis format
  53474. */
  53475. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53476. private static _WorkerPromise;
  53477. private static _Worker;
  53478. private static _actionId;
  53479. private static _CreateWorkerAsync;
  53480. /**
  53481. * Transcodes a loaded image file to compressed pixel data
  53482. * @param imageData image data to transcode
  53483. * @param config configuration options for the transcoding
  53484. * @returns a promise resulting in the transcoded image
  53485. */
  53486. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53487. /**
  53488. * Loads a texture from the transcode result
  53489. * @param texture texture load to
  53490. * @param transcodeResult the result of transcoding the basis file to load from
  53491. */
  53492. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53493. }
  53494. }
  53495. declare module BABYLON {
  53496. /**
  53497. * Loader for .basis file format
  53498. */
  53499. export class _BasisTextureLoader implements IInternalTextureLoader {
  53500. /**
  53501. * Defines whether the loader supports cascade loading the different faces.
  53502. */
  53503. readonly supportCascades: boolean;
  53504. /**
  53505. * This returns if the loader support the current file information.
  53506. * @param extension defines the file extension of the file being loaded
  53507. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53508. * @param fallback defines the fallback internal texture if any
  53509. * @param isBase64 defines whether the texture is encoded as a base64
  53510. * @param isBuffer defines whether the texture data are stored as a buffer
  53511. * @returns true if the loader can load the specified file
  53512. */
  53513. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53514. /**
  53515. * Transform the url before loading if required.
  53516. * @param rootUrl the url of the texture
  53517. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53518. * @returns the transformed texture
  53519. */
  53520. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53521. /**
  53522. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53523. * @param rootUrl the url of the texture
  53524. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53525. * @returns the fallback texture
  53526. */
  53527. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53528. /**
  53529. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53530. * @param data contains the texture data
  53531. * @param texture defines the BabylonJS internal texture
  53532. * @param createPolynomials will be true if polynomials have been requested
  53533. * @param onLoad defines the callback to trigger once the texture is ready
  53534. * @param onError defines the callback to trigger in case of error
  53535. */
  53536. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53537. /**
  53538. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53539. * @param data contains the texture data
  53540. * @param texture defines the BabylonJS internal texture
  53541. * @param callback defines the method to call once ready to upload
  53542. */
  53543. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53544. }
  53545. }
  53546. declare module BABYLON {
  53547. /**
  53548. * 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.
  53549. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53550. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53551. */
  53552. export class CustomProceduralTexture extends ProceduralTexture {
  53553. private _animate;
  53554. private _time;
  53555. private _config;
  53556. private _texturePath;
  53557. /**
  53558. * Instantiates a new Custom Procedural Texture.
  53559. * 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.
  53560. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53561. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53562. * @param name Define the name of the texture
  53563. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53564. * @param size Define the size of the texture to create
  53565. * @param scene Define the scene the texture belongs to
  53566. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53567. * @param generateMipMaps Define if the texture should creates mip maps or not
  53568. */
  53569. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53570. private _loadJson;
  53571. /**
  53572. * Is the texture ready to be used ? (rendered at least once)
  53573. * @returns true if ready, otherwise, false.
  53574. */
  53575. isReady(): boolean;
  53576. /**
  53577. * Render the texture to its associated render target.
  53578. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53579. */
  53580. render(useCameraPostProcess?: boolean): void;
  53581. /**
  53582. * Update the list of dependant textures samplers in the shader.
  53583. */
  53584. updateTextures(): void;
  53585. /**
  53586. * Update the uniform values of the procedural texture in the shader.
  53587. */
  53588. updateShaderUniforms(): void;
  53589. /**
  53590. * Define if the texture animates or not.
  53591. */
  53592. animate: boolean;
  53593. }
  53594. }
  53595. declare module BABYLON {
  53596. /** @hidden */
  53597. export var noisePixelShader: {
  53598. name: string;
  53599. shader: string;
  53600. };
  53601. }
  53602. declare module BABYLON {
  53603. /**
  53604. * Class used to generate noise procedural textures
  53605. */
  53606. export class NoiseProceduralTexture extends ProceduralTexture {
  53607. private _time;
  53608. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53609. brightness: number;
  53610. /** Defines the number of octaves to process */
  53611. octaves: number;
  53612. /** Defines the level of persistence (0.8 by default) */
  53613. persistence: number;
  53614. /** Gets or sets animation speed factor (default is 1) */
  53615. animationSpeedFactor: number;
  53616. /**
  53617. * Creates a new NoiseProceduralTexture
  53618. * @param name defines the name fo the texture
  53619. * @param size defines the size of the texture (default is 256)
  53620. * @param scene defines the hosting scene
  53621. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53622. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53623. */
  53624. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53625. private _updateShaderUniforms;
  53626. protected _getDefines(): string;
  53627. /** Generate the current state of the procedural texture */
  53628. render(useCameraPostProcess?: boolean): void;
  53629. /**
  53630. * Serializes this noise procedural texture
  53631. * @returns a serialized noise procedural texture object
  53632. */
  53633. serialize(): any;
  53634. /**
  53635. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53636. * @param parsedTexture defines parsed texture data
  53637. * @param scene defines the current scene
  53638. * @param rootUrl defines the root URL containing noise procedural texture information
  53639. * @returns a parsed NoiseProceduralTexture
  53640. */
  53641. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53642. }
  53643. }
  53644. declare module BABYLON {
  53645. /**
  53646. * Raw cube texture where the raw buffers are passed in
  53647. */
  53648. export class RawCubeTexture extends CubeTexture {
  53649. /**
  53650. * Creates a cube texture where the raw buffers are passed in.
  53651. * @param scene defines the scene the texture is attached to
  53652. * @param data defines the array of data to use to create each face
  53653. * @param size defines the size of the textures
  53654. * @param format defines the format of the data
  53655. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53656. * @param generateMipMaps defines if the engine should generate the mip levels
  53657. * @param invertY defines if data must be stored with Y axis inverted
  53658. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53659. * @param compression defines the compression used (null by default)
  53660. */
  53661. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53662. /**
  53663. * Updates the raw cube texture.
  53664. * @param data defines the data to store
  53665. * @param format defines the data format
  53666. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53667. * @param invertY defines if data must be stored with Y axis inverted
  53668. * @param compression defines the compression used (null by default)
  53669. * @param level defines which level of the texture to update
  53670. */
  53671. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53672. /**
  53673. * Updates a raw cube texture with RGBD encoded data.
  53674. * @param data defines the array of data [mipmap][face] to use to create each face
  53675. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53676. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53677. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53678. * @returns a promsie that resolves when the operation is complete
  53679. */
  53680. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53681. /**
  53682. * Clones the raw cube texture.
  53683. * @return a new cube texture
  53684. */
  53685. clone(): CubeTexture;
  53686. /** @hidden */
  53687. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53688. }
  53689. }
  53690. declare module BABYLON {
  53691. /**
  53692. * Class used to store 3D textures containing user data
  53693. */
  53694. export class RawTexture3D extends Texture {
  53695. /** Gets or sets the texture format to use */
  53696. format: number;
  53697. private _engine;
  53698. /**
  53699. * Create a new RawTexture3D
  53700. * @param data defines the data of the texture
  53701. * @param width defines the width of the texture
  53702. * @param height defines the height of the texture
  53703. * @param depth defines the depth of the texture
  53704. * @param format defines the texture format to use
  53705. * @param scene defines the hosting scene
  53706. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53707. * @param invertY defines if texture must be stored with Y axis inverted
  53708. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53709. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53710. */
  53711. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53712. /** Gets or sets the texture format to use */
  53713. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53714. /**
  53715. * Update the texture with new data
  53716. * @param data defines the data to store in the texture
  53717. */
  53718. update(data: ArrayBufferView): void;
  53719. }
  53720. }
  53721. declare module BABYLON {
  53722. /**
  53723. * Class used to store 2D array textures containing user data
  53724. */
  53725. export class RawTexture2DArray extends Texture {
  53726. /** Gets or sets the texture format to use */
  53727. format: number;
  53728. private _engine;
  53729. /**
  53730. * Create a new RawTexture2DArray
  53731. * @param data defines the data of the texture
  53732. * @param width defines the width of the texture
  53733. * @param height defines the height of the texture
  53734. * @param depth defines the number of layers of the texture
  53735. * @param format defines the texture format to use
  53736. * @param scene defines the hosting scene
  53737. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53738. * @param invertY defines if texture must be stored with Y axis inverted
  53739. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53740. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53741. */
  53742. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53743. /** Gets or sets the texture format to use */
  53744. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53745. /**
  53746. * Update the texture with new data
  53747. * @param data defines the data to store in the texture
  53748. */
  53749. update(data: ArrayBufferView): void;
  53750. }
  53751. }
  53752. declare module BABYLON {
  53753. /**
  53754. * Creates a refraction texture used by refraction channel of the standard material.
  53755. * It is like a mirror but to see through a material.
  53756. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53757. */
  53758. export class RefractionTexture extends RenderTargetTexture {
  53759. /**
  53760. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53761. * 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.
  53762. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53763. */
  53764. refractionPlane: Plane;
  53765. /**
  53766. * Define how deep under the surface we should see.
  53767. */
  53768. depth: number;
  53769. /**
  53770. * Creates a refraction texture used by refraction channel of the standard material.
  53771. * It is like a mirror but to see through a material.
  53772. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53773. * @param name Define the texture name
  53774. * @param size Define the size of the underlying texture
  53775. * @param scene Define the scene the refraction belongs to
  53776. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53777. */
  53778. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53779. /**
  53780. * Clone the refraction texture.
  53781. * @returns the cloned texture
  53782. */
  53783. clone(): RefractionTexture;
  53784. /**
  53785. * Serialize the texture to a JSON representation you could use in Parse later on
  53786. * @returns the serialized JSON representation
  53787. */
  53788. serialize(): any;
  53789. }
  53790. }
  53791. declare module BABYLON {
  53792. /**
  53793. * Defines the options related to the creation of an HtmlElementTexture
  53794. */
  53795. export interface IHtmlElementTextureOptions {
  53796. /**
  53797. * Defines wether mip maps should be created or not.
  53798. */
  53799. generateMipMaps?: boolean;
  53800. /**
  53801. * Defines the sampling mode of the texture.
  53802. */
  53803. samplingMode?: number;
  53804. /**
  53805. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53806. */
  53807. engine: Nullable<ThinEngine>;
  53808. /**
  53809. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53810. */
  53811. scene: Nullable<Scene>;
  53812. }
  53813. /**
  53814. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53815. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53816. * is automatically managed.
  53817. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53818. * in your application.
  53819. *
  53820. * As the update is not automatic, you need to call them manually.
  53821. */
  53822. export class HtmlElementTexture extends BaseTexture {
  53823. /**
  53824. * The texture URL.
  53825. */
  53826. element: HTMLVideoElement | HTMLCanvasElement;
  53827. private static readonly DefaultOptions;
  53828. private _textureMatrix;
  53829. private _engine;
  53830. private _isVideo;
  53831. private _generateMipMaps;
  53832. private _samplingMode;
  53833. /**
  53834. * Instantiates a HtmlElementTexture from the following parameters.
  53835. *
  53836. * @param name Defines the name of the texture
  53837. * @param element Defines the video or canvas the texture is filled with
  53838. * @param options Defines the other none mandatory texture creation options
  53839. */
  53840. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53841. private _createInternalTexture;
  53842. /**
  53843. * Returns the texture matrix used in most of the material.
  53844. */
  53845. getTextureMatrix(): Matrix;
  53846. /**
  53847. * Updates the content of the texture.
  53848. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53849. */
  53850. update(invertY?: Nullable<boolean>): void;
  53851. }
  53852. }
  53853. declare module BABYLON {
  53854. /**
  53855. * Enum used to define the target of a block
  53856. */
  53857. export enum NodeMaterialBlockTargets {
  53858. /** Vertex shader */
  53859. Vertex = 1,
  53860. /** Fragment shader */
  53861. Fragment = 2,
  53862. /** Neutral */
  53863. Neutral = 4,
  53864. /** Vertex and Fragment */
  53865. VertexAndFragment = 3
  53866. }
  53867. }
  53868. declare module BABYLON {
  53869. /**
  53870. * Defines the kind of connection point for node based material
  53871. */
  53872. export enum NodeMaterialBlockConnectionPointTypes {
  53873. /** Float */
  53874. Float = 1,
  53875. /** Int */
  53876. Int = 2,
  53877. /** Vector2 */
  53878. Vector2 = 4,
  53879. /** Vector3 */
  53880. Vector3 = 8,
  53881. /** Vector4 */
  53882. Vector4 = 16,
  53883. /** Color3 */
  53884. Color3 = 32,
  53885. /** Color4 */
  53886. Color4 = 64,
  53887. /** Matrix */
  53888. Matrix = 128,
  53889. /** Detect type based on connection */
  53890. AutoDetect = 1024,
  53891. /** Output type that will be defined by input type */
  53892. BasedOnInput = 2048
  53893. }
  53894. }
  53895. declare module BABYLON {
  53896. /**
  53897. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53898. */
  53899. export enum NodeMaterialBlockConnectionPointMode {
  53900. /** Value is an uniform */
  53901. Uniform = 0,
  53902. /** Value is a mesh attribute */
  53903. Attribute = 1,
  53904. /** Value is a varying between vertex and fragment shaders */
  53905. Varying = 2,
  53906. /** Mode is undefined */
  53907. Undefined = 3
  53908. }
  53909. }
  53910. declare module BABYLON {
  53911. /**
  53912. * Enum used to define system values e.g. values automatically provided by the system
  53913. */
  53914. export enum NodeMaterialSystemValues {
  53915. /** World */
  53916. World = 1,
  53917. /** View */
  53918. View = 2,
  53919. /** Projection */
  53920. Projection = 3,
  53921. /** ViewProjection */
  53922. ViewProjection = 4,
  53923. /** WorldView */
  53924. WorldView = 5,
  53925. /** WorldViewProjection */
  53926. WorldViewProjection = 6,
  53927. /** CameraPosition */
  53928. CameraPosition = 7,
  53929. /** Fog Color */
  53930. FogColor = 8,
  53931. /** Delta time */
  53932. DeltaTime = 9
  53933. }
  53934. }
  53935. declare module BABYLON {
  53936. /**
  53937. * Root class for all node material optimizers
  53938. */
  53939. export class NodeMaterialOptimizer {
  53940. /**
  53941. * Function used to optimize a NodeMaterial graph
  53942. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53943. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53944. */
  53945. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53946. }
  53947. }
  53948. declare module BABYLON {
  53949. /**
  53950. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53951. */
  53952. export class TransformBlock extends NodeMaterialBlock {
  53953. /**
  53954. * Defines the value to use to complement W value to transform it to a Vector4
  53955. */
  53956. complementW: number;
  53957. /**
  53958. * Defines the value to use to complement z value to transform it to a Vector4
  53959. */
  53960. complementZ: number;
  53961. /**
  53962. * Creates a new TransformBlock
  53963. * @param name defines the block name
  53964. */
  53965. constructor(name: string);
  53966. /**
  53967. * Gets the current class name
  53968. * @returns the class name
  53969. */
  53970. getClassName(): string;
  53971. /**
  53972. * Gets the vector input
  53973. */
  53974. readonly vector: NodeMaterialConnectionPoint;
  53975. /**
  53976. * Gets the output component
  53977. */
  53978. readonly output: NodeMaterialConnectionPoint;
  53979. /**
  53980. * Gets the matrix transform input
  53981. */
  53982. readonly transform: NodeMaterialConnectionPoint;
  53983. protected _buildBlock(state: NodeMaterialBuildState): this;
  53984. serialize(): any;
  53985. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53986. protected _dumpPropertiesCode(): string;
  53987. }
  53988. }
  53989. declare module BABYLON {
  53990. /**
  53991. * Block used to output the vertex position
  53992. */
  53993. export class VertexOutputBlock extends NodeMaterialBlock {
  53994. /**
  53995. * Creates a new VertexOutputBlock
  53996. * @param name defines the block name
  53997. */
  53998. constructor(name: string);
  53999. /**
  54000. * Gets the current class name
  54001. * @returns the class name
  54002. */
  54003. getClassName(): string;
  54004. /**
  54005. * Gets the vector input component
  54006. */
  54007. readonly vector: NodeMaterialConnectionPoint;
  54008. protected _buildBlock(state: NodeMaterialBuildState): this;
  54009. }
  54010. }
  54011. declare module BABYLON {
  54012. /**
  54013. * Block used to output the final color
  54014. */
  54015. export class FragmentOutputBlock extends NodeMaterialBlock {
  54016. /**
  54017. * Create a new FragmentOutputBlock
  54018. * @param name defines the block name
  54019. */
  54020. constructor(name: string);
  54021. /**
  54022. * Gets the current class name
  54023. * @returns the class name
  54024. */
  54025. getClassName(): string;
  54026. /**
  54027. * Gets the rgba input component
  54028. */
  54029. readonly rgba: NodeMaterialConnectionPoint;
  54030. /**
  54031. * Gets the rgb input component
  54032. */
  54033. readonly rgb: NodeMaterialConnectionPoint;
  54034. /**
  54035. * Gets the a input component
  54036. */
  54037. readonly a: NodeMaterialConnectionPoint;
  54038. protected _buildBlock(state: NodeMaterialBuildState): this;
  54039. }
  54040. }
  54041. declare module BABYLON {
  54042. /**
  54043. * Block used to read a reflection texture from a sampler
  54044. */
  54045. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54046. private _define3DName;
  54047. private _defineCubicName;
  54048. private _defineExplicitName;
  54049. private _defineProjectionName;
  54050. private _defineLocalCubicName;
  54051. private _defineSphericalName;
  54052. private _definePlanarName;
  54053. private _defineEquirectangularName;
  54054. private _defineMirroredEquirectangularFixedName;
  54055. private _defineEquirectangularFixedName;
  54056. private _defineSkyboxName;
  54057. private _cubeSamplerName;
  54058. private _2DSamplerName;
  54059. private _positionUVWName;
  54060. private _directionWName;
  54061. private _reflectionCoordsName;
  54062. private _reflection2DCoordsName;
  54063. private _reflectionColorName;
  54064. private _reflectionMatrixName;
  54065. /**
  54066. * Gets or sets the texture associated with the node
  54067. */
  54068. texture: Nullable<BaseTexture>;
  54069. /**
  54070. * Create a new TextureBlock
  54071. * @param name defines the block name
  54072. */
  54073. constructor(name: string);
  54074. /**
  54075. * Gets the current class name
  54076. * @returns the class name
  54077. */
  54078. getClassName(): string;
  54079. /**
  54080. * Gets the world position input component
  54081. */
  54082. readonly position: NodeMaterialConnectionPoint;
  54083. /**
  54084. * Gets the world position input component
  54085. */
  54086. readonly worldPosition: NodeMaterialConnectionPoint;
  54087. /**
  54088. * Gets the world normal input component
  54089. */
  54090. readonly worldNormal: NodeMaterialConnectionPoint;
  54091. /**
  54092. * Gets the world input component
  54093. */
  54094. readonly world: NodeMaterialConnectionPoint;
  54095. /**
  54096. * Gets the camera (or eye) position component
  54097. */
  54098. readonly cameraPosition: NodeMaterialConnectionPoint;
  54099. /**
  54100. * Gets the view input component
  54101. */
  54102. readonly view: NodeMaterialConnectionPoint;
  54103. /**
  54104. * Gets the rgb output component
  54105. */
  54106. readonly rgb: NodeMaterialConnectionPoint;
  54107. /**
  54108. * Gets the r output component
  54109. */
  54110. readonly r: NodeMaterialConnectionPoint;
  54111. /**
  54112. * Gets the g output component
  54113. */
  54114. readonly g: NodeMaterialConnectionPoint;
  54115. /**
  54116. * Gets the b output component
  54117. */
  54118. readonly b: NodeMaterialConnectionPoint;
  54119. autoConfigure(material: NodeMaterial): void;
  54120. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54121. isReady(): boolean;
  54122. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54123. private _injectVertexCode;
  54124. private _writeOutput;
  54125. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54126. protected _dumpPropertiesCode(): string;
  54127. serialize(): any;
  54128. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54129. }
  54130. }
  54131. declare module BABYLON {
  54132. /**
  54133. * Interface used to configure the node material editor
  54134. */
  54135. export interface INodeMaterialEditorOptions {
  54136. /** Define the URl to load node editor script */
  54137. editorURL?: string;
  54138. }
  54139. /** @hidden */
  54140. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54141. /** BONES */
  54142. NUM_BONE_INFLUENCERS: number;
  54143. BonesPerMesh: number;
  54144. BONETEXTURE: boolean;
  54145. /** MORPH TARGETS */
  54146. MORPHTARGETS: boolean;
  54147. MORPHTARGETS_NORMAL: boolean;
  54148. MORPHTARGETS_TANGENT: boolean;
  54149. MORPHTARGETS_UV: boolean;
  54150. NUM_MORPH_INFLUENCERS: number;
  54151. /** IMAGE PROCESSING */
  54152. IMAGEPROCESSING: boolean;
  54153. VIGNETTE: boolean;
  54154. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54155. VIGNETTEBLENDMODEOPAQUE: boolean;
  54156. TONEMAPPING: boolean;
  54157. TONEMAPPING_ACES: boolean;
  54158. CONTRAST: boolean;
  54159. EXPOSURE: boolean;
  54160. COLORCURVES: boolean;
  54161. COLORGRADING: boolean;
  54162. COLORGRADING3D: boolean;
  54163. SAMPLER3DGREENDEPTH: boolean;
  54164. SAMPLER3DBGRMAP: boolean;
  54165. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54166. /** MISC. */
  54167. BUMPDIRECTUV: number;
  54168. constructor();
  54169. setValue(name: string, value: boolean): void;
  54170. }
  54171. /**
  54172. * Class used to configure NodeMaterial
  54173. */
  54174. export interface INodeMaterialOptions {
  54175. /**
  54176. * Defines if blocks should emit comments
  54177. */
  54178. emitComments: boolean;
  54179. }
  54180. /**
  54181. * Class used to create a node based material built by assembling shader blocks
  54182. */
  54183. export class NodeMaterial extends PushMaterial {
  54184. private static _BuildIdGenerator;
  54185. private _options;
  54186. private _vertexCompilationState;
  54187. private _fragmentCompilationState;
  54188. private _sharedData;
  54189. private _buildId;
  54190. private _buildWasSuccessful;
  54191. private _cachedWorldViewMatrix;
  54192. private _cachedWorldViewProjectionMatrix;
  54193. private _optimizers;
  54194. private _animationFrame;
  54195. /** Define the URl to load node editor script */
  54196. static EditorURL: string;
  54197. private BJSNODEMATERIALEDITOR;
  54198. /** Get the inspector from bundle or global */
  54199. private _getGlobalNodeMaterialEditor;
  54200. /**
  54201. * Gets or sets data used by visual editor
  54202. * @see https://nme.babylonjs.com
  54203. */
  54204. editorData: any;
  54205. /**
  54206. * 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)
  54207. */
  54208. ignoreAlpha: boolean;
  54209. /**
  54210. * Defines the maximum number of lights that can be used in the material
  54211. */
  54212. maxSimultaneousLights: number;
  54213. /**
  54214. * Observable raised when the material is built
  54215. */
  54216. onBuildObservable: Observable<NodeMaterial>;
  54217. /**
  54218. * Gets or sets the root nodes of the material vertex shader
  54219. */
  54220. _vertexOutputNodes: NodeMaterialBlock[];
  54221. /**
  54222. * Gets or sets the root nodes of the material fragment (pixel) shader
  54223. */
  54224. _fragmentOutputNodes: NodeMaterialBlock[];
  54225. /** Gets or sets options to control the node material overall behavior */
  54226. options: INodeMaterialOptions;
  54227. /**
  54228. * Default configuration related to image processing available in the standard Material.
  54229. */
  54230. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54231. /**
  54232. * Gets the image processing configuration used either in this material.
  54233. */
  54234. /**
  54235. * Sets the Default image processing configuration used either in the this material.
  54236. *
  54237. * If sets to null, the scene one is in use.
  54238. */
  54239. imageProcessingConfiguration: ImageProcessingConfiguration;
  54240. /**
  54241. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54242. */
  54243. attachedBlocks: NodeMaterialBlock[];
  54244. /**
  54245. * Create a new node based material
  54246. * @param name defines the material name
  54247. * @param scene defines the hosting scene
  54248. * @param options defines creation option
  54249. */
  54250. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54251. /**
  54252. * Gets the current class name of the material e.g. "NodeMaterial"
  54253. * @returns the class name
  54254. */
  54255. getClassName(): string;
  54256. /**
  54257. * Keep track of the image processing observer to allow dispose and replace.
  54258. */
  54259. private _imageProcessingObserver;
  54260. /**
  54261. * Attaches a new image processing configuration to the Standard Material.
  54262. * @param configuration
  54263. */
  54264. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54265. /**
  54266. * Get a block by its name
  54267. * @param name defines the name of the block to retrieve
  54268. * @returns the required block or null if not found
  54269. */
  54270. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54271. /**
  54272. * Get a block by its name
  54273. * @param predicate defines the predicate used to find the good candidate
  54274. * @returns the required block or null if not found
  54275. */
  54276. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54277. /**
  54278. * Get an input block by its name
  54279. * @param predicate defines the predicate used to find the good candidate
  54280. * @returns the required input block or null if not found
  54281. */
  54282. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54283. /**
  54284. * Gets the list of input blocks attached to this material
  54285. * @returns an array of InputBlocks
  54286. */
  54287. getInputBlocks(): InputBlock[];
  54288. /**
  54289. * Adds a new optimizer to the list of optimizers
  54290. * @param optimizer defines the optimizers to add
  54291. * @returns the current material
  54292. */
  54293. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54294. /**
  54295. * Remove an optimizer from the list of optimizers
  54296. * @param optimizer defines the optimizers to remove
  54297. * @returns the current material
  54298. */
  54299. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54300. /**
  54301. * Add a new block to the list of output nodes
  54302. * @param node defines the node to add
  54303. * @returns the current material
  54304. */
  54305. addOutputNode(node: NodeMaterialBlock): this;
  54306. /**
  54307. * Remove a block from the list of root nodes
  54308. * @param node defines the node to remove
  54309. * @returns the current material
  54310. */
  54311. removeOutputNode(node: NodeMaterialBlock): this;
  54312. private _addVertexOutputNode;
  54313. private _removeVertexOutputNode;
  54314. private _addFragmentOutputNode;
  54315. private _removeFragmentOutputNode;
  54316. /**
  54317. * Specifies if the material will require alpha blending
  54318. * @returns a boolean specifying if alpha blending is needed
  54319. */
  54320. needAlphaBlending(): boolean;
  54321. /**
  54322. * Specifies if this material should be rendered in alpha test mode
  54323. * @returns a boolean specifying if an alpha test is needed.
  54324. */
  54325. needAlphaTesting(): boolean;
  54326. private _initializeBlock;
  54327. private _resetDualBlocks;
  54328. /**
  54329. * Remove a block from the current node material
  54330. * @param block defines the block to remove
  54331. */
  54332. removeBlock(block: NodeMaterialBlock): void;
  54333. /**
  54334. * Build the material and generates the inner effect
  54335. * @param verbose defines if the build should log activity
  54336. */
  54337. build(verbose?: boolean): void;
  54338. /**
  54339. * Runs an otpimization phase to try to improve the shader code
  54340. */
  54341. optimize(): void;
  54342. private _prepareDefinesForAttributes;
  54343. /**
  54344. * Get if the submesh is ready to be used and all its information available.
  54345. * Child classes can use it to update shaders
  54346. * @param mesh defines the mesh to check
  54347. * @param subMesh defines which submesh to check
  54348. * @param useInstances specifies that instances should be used
  54349. * @returns a boolean indicating that the submesh is ready or not
  54350. */
  54351. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54352. /**
  54353. * Get a string representing the shaders built by the current node graph
  54354. */
  54355. readonly compiledShaders: string;
  54356. /**
  54357. * Binds the world matrix to the material
  54358. * @param world defines the world transformation matrix
  54359. */
  54360. bindOnlyWorldMatrix(world: Matrix): void;
  54361. /**
  54362. * Binds the submesh to this material by preparing the effect and shader to draw
  54363. * @param world defines the world transformation matrix
  54364. * @param mesh defines the mesh containing the submesh
  54365. * @param subMesh defines the submesh to bind the material to
  54366. */
  54367. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54368. /**
  54369. * Gets the active textures from the material
  54370. * @returns an array of textures
  54371. */
  54372. getActiveTextures(): BaseTexture[];
  54373. /**
  54374. * Gets the list of texture blocks
  54375. * @returns an array of texture blocks
  54376. */
  54377. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54378. /**
  54379. * Specifies if the material uses a texture
  54380. * @param texture defines the texture to check against the material
  54381. * @returns a boolean specifying if the material uses the texture
  54382. */
  54383. hasTexture(texture: BaseTexture): boolean;
  54384. /**
  54385. * Disposes the material
  54386. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54387. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54388. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54389. */
  54390. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54391. /** Creates the node editor window. */
  54392. private _createNodeEditor;
  54393. /**
  54394. * Launch the node material editor
  54395. * @param config Define the configuration of the editor
  54396. * @return a promise fulfilled when the node editor is visible
  54397. */
  54398. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54399. /**
  54400. * Clear the current material
  54401. */
  54402. clear(): void;
  54403. /**
  54404. * Clear the current material and set it to a default state
  54405. */
  54406. setToDefault(): void;
  54407. /**
  54408. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54409. * @param url defines the url to load from
  54410. * @returns a promise that will fullfil when the material is fully loaded
  54411. */
  54412. loadAsync(url: string): Promise<void>;
  54413. private _gatherBlocks;
  54414. /**
  54415. * Generate a string containing the code declaration required to create an equivalent of this material
  54416. * @returns a string
  54417. */
  54418. generateCode(): string;
  54419. /**
  54420. * Serializes this material in a JSON representation
  54421. * @returns the serialized material object
  54422. */
  54423. serialize(): any;
  54424. private _restoreConnections;
  54425. /**
  54426. * Clear the current graph and load a new one from a serialization object
  54427. * @param source defines the JSON representation of the material
  54428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54429. */
  54430. loadFromSerialization(source: any, rootUrl?: string): void;
  54431. /**
  54432. * Creates a node material from parsed material data
  54433. * @param source defines the JSON representation of the material
  54434. * @param scene defines the hosting scene
  54435. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54436. * @returns a new node material
  54437. */
  54438. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54439. /**
  54440. * Creates a new node material set to default basic configuration
  54441. * @param name defines the name of the material
  54442. * @param scene defines the hosting scene
  54443. * @returns a new NodeMaterial
  54444. */
  54445. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54446. }
  54447. }
  54448. declare module BABYLON {
  54449. /**
  54450. * Block used to read a texture from a sampler
  54451. */
  54452. export class TextureBlock extends NodeMaterialBlock {
  54453. private _defineName;
  54454. private _linearDefineName;
  54455. private _tempTextureRead;
  54456. private _samplerName;
  54457. private _transformedUVName;
  54458. private _textureTransformName;
  54459. private _textureInfoName;
  54460. private _mainUVName;
  54461. private _mainUVDefineName;
  54462. /**
  54463. * Gets or sets the texture associated with the node
  54464. */
  54465. texture: Nullable<Texture>;
  54466. /**
  54467. * Create a new TextureBlock
  54468. * @param name defines the block name
  54469. */
  54470. constructor(name: string);
  54471. /**
  54472. * Gets the current class name
  54473. * @returns the class name
  54474. */
  54475. getClassName(): string;
  54476. /**
  54477. * Gets the uv input component
  54478. */
  54479. readonly uv: NodeMaterialConnectionPoint;
  54480. /**
  54481. * Gets the rgba output component
  54482. */
  54483. readonly rgba: NodeMaterialConnectionPoint;
  54484. /**
  54485. * Gets the rgb output component
  54486. */
  54487. readonly rgb: NodeMaterialConnectionPoint;
  54488. /**
  54489. * Gets the r output component
  54490. */
  54491. readonly r: NodeMaterialConnectionPoint;
  54492. /**
  54493. * Gets the g output component
  54494. */
  54495. readonly g: NodeMaterialConnectionPoint;
  54496. /**
  54497. * Gets the b output component
  54498. */
  54499. readonly b: NodeMaterialConnectionPoint;
  54500. /**
  54501. * Gets the a output component
  54502. */
  54503. readonly a: NodeMaterialConnectionPoint;
  54504. readonly target: NodeMaterialBlockTargets;
  54505. autoConfigure(material: NodeMaterial): void;
  54506. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54507. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54508. private _getTextureBase;
  54509. isReady(): boolean;
  54510. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54511. private readonly _isMixed;
  54512. private _injectVertexCode;
  54513. private _writeTextureRead;
  54514. private _writeOutput;
  54515. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54516. protected _dumpPropertiesCode(): string;
  54517. serialize(): any;
  54518. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54519. }
  54520. }
  54521. declare module BABYLON {
  54522. /**
  54523. * Class used to store shared data between 2 NodeMaterialBuildState
  54524. */
  54525. export class NodeMaterialBuildStateSharedData {
  54526. /**
  54527. * Gets the list of emitted varyings
  54528. */
  54529. temps: string[];
  54530. /**
  54531. * Gets the list of emitted varyings
  54532. */
  54533. varyings: string[];
  54534. /**
  54535. * Gets the varying declaration string
  54536. */
  54537. varyingDeclaration: string;
  54538. /**
  54539. * Input blocks
  54540. */
  54541. inputBlocks: InputBlock[];
  54542. /**
  54543. * Input blocks
  54544. */
  54545. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  54546. /**
  54547. * Bindable blocks (Blocks that need to set data to the effect)
  54548. */
  54549. bindableBlocks: NodeMaterialBlock[];
  54550. /**
  54551. * List of blocks that can provide a compilation fallback
  54552. */
  54553. blocksWithFallbacks: NodeMaterialBlock[];
  54554. /**
  54555. * List of blocks that can provide a define update
  54556. */
  54557. blocksWithDefines: NodeMaterialBlock[];
  54558. /**
  54559. * List of blocks that can provide a repeatable content
  54560. */
  54561. repeatableContentBlocks: NodeMaterialBlock[];
  54562. /**
  54563. * List of blocks that can provide a dynamic list of uniforms
  54564. */
  54565. dynamicUniformBlocks: NodeMaterialBlock[];
  54566. /**
  54567. * List of blocks that can block the isReady function for the material
  54568. */
  54569. blockingBlocks: NodeMaterialBlock[];
  54570. /**
  54571. * Gets the list of animated inputs
  54572. */
  54573. animatedInputs: InputBlock[];
  54574. /**
  54575. * Build Id used to avoid multiple recompilations
  54576. */
  54577. buildId: number;
  54578. /** List of emitted variables */
  54579. variableNames: {
  54580. [key: string]: number;
  54581. };
  54582. /** List of emitted defines */
  54583. defineNames: {
  54584. [key: string]: number;
  54585. };
  54586. /** Should emit comments? */
  54587. emitComments: boolean;
  54588. /** Emit build activity */
  54589. verbose: boolean;
  54590. /** Gets or sets the hosting scene */
  54591. scene: Scene;
  54592. /**
  54593. * Gets the compilation hints emitted at compilation time
  54594. */
  54595. hints: {
  54596. needWorldViewMatrix: boolean;
  54597. needWorldViewProjectionMatrix: boolean;
  54598. needAlphaBlending: boolean;
  54599. needAlphaTesting: boolean;
  54600. };
  54601. /**
  54602. * List of compilation checks
  54603. */
  54604. checks: {
  54605. emitVertex: boolean;
  54606. emitFragment: boolean;
  54607. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54608. };
  54609. /** Creates a new shared data */
  54610. constructor();
  54611. /**
  54612. * Emits console errors and exceptions if there is a failing check
  54613. */
  54614. emitErrors(): void;
  54615. }
  54616. }
  54617. declare module BABYLON {
  54618. /**
  54619. * Class used to store node based material build state
  54620. */
  54621. export class NodeMaterialBuildState {
  54622. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54623. supportUniformBuffers: boolean;
  54624. /**
  54625. * Gets the list of emitted attributes
  54626. */
  54627. attributes: string[];
  54628. /**
  54629. * Gets the list of emitted uniforms
  54630. */
  54631. uniforms: string[];
  54632. /**
  54633. * Gets the list of emitted constants
  54634. */
  54635. constants: string[];
  54636. /**
  54637. * Gets the list of emitted samplers
  54638. */
  54639. samplers: string[];
  54640. /**
  54641. * Gets the list of emitted functions
  54642. */
  54643. functions: {
  54644. [key: string]: string;
  54645. };
  54646. /**
  54647. * Gets the list of emitted extensions
  54648. */
  54649. extensions: {
  54650. [key: string]: string;
  54651. };
  54652. /**
  54653. * Gets the target of the compilation state
  54654. */
  54655. target: NodeMaterialBlockTargets;
  54656. /**
  54657. * Gets the list of emitted counters
  54658. */
  54659. counters: {
  54660. [key: string]: number;
  54661. };
  54662. /**
  54663. * Shared data between multiple NodeMaterialBuildState instances
  54664. */
  54665. sharedData: NodeMaterialBuildStateSharedData;
  54666. /** @hidden */
  54667. _vertexState: NodeMaterialBuildState;
  54668. /** @hidden */
  54669. _attributeDeclaration: string;
  54670. /** @hidden */
  54671. _uniformDeclaration: string;
  54672. /** @hidden */
  54673. _constantDeclaration: string;
  54674. /** @hidden */
  54675. _samplerDeclaration: string;
  54676. /** @hidden */
  54677. _varyingTransfer: string;
  54678. private _repeatableContentAnchorIndex;
  54679. /** @hidden */
  54680. _builtCompilationString: string;
  54681. /**
  54682. * Gets the emitted compilation strings
  54683. */
  54684. compilationString: string;
  54685. /**
  54686. * Finalize the compilation strings
  54687. * @param state defines the current compilation state
  54688. */
  54689. finalize(state: NodeMaterialBuildState): void;
  54690. /** @hidden */
  54691. readonly _repeatableContentAnchor: string;
  54692. /** @hidden */
  54693. _getFreeVariableName(prefix: string): string;
  54694. /** @hidden */
  54695. _getFreeDefineName(prefix: string): string;
  54696. /** @hidden */
  54697. _excludeVariableName(name: string): void;
  54698. /** @hidden */
  54699. _emit2DSampler(name: string): void;
  54700. /** @hidden */
  54701. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54702. /** @hidden */
  54703. _emitExtension(name: string, extension: string): void;
  54704. /** @hidden */
  54705. _emitFunction(name: string, code: string, comments: string): void;
  54706. /** @hidden */
  54707. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54708. replaceStrings?: {
  54709. search: RegExp;
  54710. replace: string;
  54711. }[];
  54712. repeatKey?: string;
  54713. }): string;
  54714. /** @hidden */
  54715. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54716. repeatKey?: string;
  54717. removeAttributes?: boolean;
  54718. removeUniforms?: boolean;
  54719. removeVaryings?: boolean;
  54720. removeIfDef?: boolean;
  54721. replaceStrings?: {
  54722. search: RegExp;
  54723. replace: string;
  54724. }[];
  54725. }, storeKey?: string): void;
  54726. /** @hidden */
  54727. _registerTempVariable(name: string): boolean;
  54728. /** @hidden */
  54729. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54730. /** @hidden */
  54731. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54732. /** @hidden */
  54733. _emitFloat(value: number): string;
  54734. }
  54735. }
  54736. declare module BABYLON {
  54737. /**
  54738. * Defines a block that can be used inside a node based material
  54739. */
  54740. export class NodeMaterialBlock {
  54741. private _buildId;
  54742. private _buildTarget;
  54743. private _target;
  54744. private _isFinalMerger;
  54745. private _isInput;
  54746. protected _isUnique: boolean;
  54747. /** @hidden */
  54748. _codeVariableName: string;
  54749. /** @hidden */
  54750. _inputs: NodeMaterialConnectionPoint[];
  54751. /** @hidden */
  54752. _outputs: NodeMaterialConnectionPoint[];
  54753. /** @hidden */
  54754. _preparationId: number;
  54755. /**
  54756. * Gets or sets the name of the block
  54757. */
  54758. name: string;
  54759. /**
  54760. * Gets or sets the unique id of the node
  54761. */
  54762. uniqueId: number;
  54763. /**
  54764. * Gets or sets the comments associated with this block
  54765. */
  54766. comments: string;
  54767. /**
  54768. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  54769. */
  54770. readonly isUnique: boolean;
  54771. /**
  54772. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54773. */
  54774. readonly isFinalMerger: boolean;
  54775. /**
  54776. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54777. */
  54778. readonly isInput: boolean;
  54779. /**
  54780. * Gets or sets the build Id
  54781. */
  54782. buildId: number;
  54783. /**
  54784. * Gets or sets the target of the block
  54785. */
  54786. target: NodeMaterialBlockTargets;
  54787. /**
  54788. * Gets the list of input points
  54789. */
  54790. readonly inputs: NodeMaterialConnectionPoint[];
  54791. /** Gets the list of output points */
  54792. readonly outputs: NodeMaterialConnectionPoint[];
  54793. /**
  54794. * Find an input by its name
  54795. * @param name defines the name of the input to look for
  54796. * @returns the input or null if not found
  54797. */
  54798. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54799. /**
  54800. * Find an output by its name
  54801. * @param name defines the name of the outputto look for
  54802. * @returns the output or null if not found
  54803. */
  54804. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54805. /**
  54806. * Creates a new NodeMaterialBlock
  54807. * @param name defines the block name
  54808. * @param target defines the target of that block (Vertex by default)
  54809. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54810. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54811. */
  54812. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54813. /**
  54814. * Initialize the block and prepare the context for build
  54815. * @param state defines the state that will be used for the build
  54816. */
  54817. initialize(state: NodeMaterialBuildState): void;
  54818. /**
  54819. * Bind data to effect. Will only be called for blocks with isBindable === true
  54820. * @param effect defines the effect to bind data to
  54821. * @param nodeMaterial defines the hosting NodeMaterial
  54822. * @param mesh defines the mesh that will be rendered
  54823. */
  54824. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54825. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54826. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54827. protected _writeFloat(value: number): string;
  54828. /**
  54829. * Gets the current class name e.g. "NodeMaterialBlock"
  54830. * @returns the class name
  54831. */
  54832. getClassName(): string;
  54833. /**
  54834. * Register a new input. Must be called inside a block constructor
  54835. * @param name defines the connection point name
  54836. * @param type defines the connection point type
  54837. * @param isOptional defines a boolean indicating that this input can be omitted
  54838. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54839. * @returns the current block
  54840. */
  54841. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54842. /**
  54843. * Register a new output. Must be called inside a block constructor
  54844. * @param name defines the connection point name
  54845. * @param type defines the connection point type
  54846. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54847. * @returns the current block
  54848. */
  54849. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54850. /**
  54851. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54852. * @param forOutput defines an optional connection point to check compatibility with
  54853. * @returns the first available input or null
  54854. */
  54855. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54856. /**
  54857. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54858. * @param forBlock defines an optional block to check compatibility with
  54859. * @returns the first available input or null
  54860. */
  54861. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54862. /**
  54863. * Gets the sibling of the given output
  54864. * @param current defines the current output
  54865. * @returns the next output in the list or null
  54866. */
  54867. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54868. /**
  54869. * Connect current block with another block
  54870. * @param other defines the block to connect with
  54871. * @param options define the various options to help pick the right connections
  54872. * @returns the current block
  54873. */
  54874. connectTo(other: NodeMaterialBlock, options?: {
  54875. input?: string;
  54876. output?: string;
  54877. outputSwizzle?: string;
  54878. }): this | undefined;
  54879. protected _buildBlock(state: NodeMaterialBuildState): void;
  54880. /**
  54881. * Add uniforms, samplers and uniform buffers at compilation time
  54882. * @param state defines the state to update
  54883. * @param nodeMaterial defines the node material requesting the update
  54884. * @param defines defines the material defines to update
  54885. * @param uniformBuffers defines the list of uniform buffer names
  54886. */
  54887. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54888. /**
  54889. * Add potential fallbacks if shader compilation fails
  54890. * @param mesh defines the mesh to be rendered
  54891. * @param fallbacks defines the current prioritized list of fallbacks
  54892. */
  54893. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54894. /**
  54895. * Initialize defines for shader compilation
  54896. * @param mesh defines the mesh to be rendered
  54897. * @param nodeMaterial defines the node material requesting the update
  54898. * @param defines defines the material defines to update
  54899. * @param useInstances specifies that instances should be used
  54900. */
  54901. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54902. /**
  54903. * Update defines for shader compilation
  54904. * @param mesh defines the mesh to be rendered
  54905. * @param nodeMaterial defines the node material requesting the update
  54906. * @param defines defines the material defines to update
  54907. * @param useInstances specifies that instances should be used
  54908. */
  54909. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54910. /**
  54911. * Lets the block try to connect some inputs automatically
  54912. * @param material defines the hosting NodeMaterial
  54913. */
  54914. autoConfigure(material: NodeMaterial): void;
  54915. /**
  54916. * Function called when a block is declared as repeatable content generator
  54917. * @param vertexShaderState defines the current compilation state for the vertex shader
  54918. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54919. * @param mesh defines the mesh to be rendered
  54920. * @param defines defines the material defines to update
  54921. */
  54922. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54923. /**
  54924. * Checks if the block is ready
  54925. * @param mesh defines the mesh to be rendered
  54926. * @param nodeMaterial defines the node material requesting the update
  54927. * @param defines defines the material defines to update
  54928. * @param useInstances specifies that instances should be used
  54929. * @returns true if the block is ready
  54930. */
  54931. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54932. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  54933. private _processBuild;
  54934. /**
  54935. * Compile the current node and generate the shader code
  54936. * @param state defines the current compilation state (uniforms, samplers, current string)
  54937. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  54938. * @returns true if already built
  54939. */
  54940. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  54941. protected _inputRename(name: string): string;
  54942. protected _outputRename(name: string): string;
  54943. protected _dumpPropertiesCode(): string;
  54944. /** @hidden */
  54945. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  54946. /** @hidden */
  54947. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  54948. /**
  54949. * Clone the current block to a new identical block
  54950. * @param scene defines the hosting scene
  54951. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54952. * @returns a copy of the current block
  54953. */
  54954. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54955. /**
  54956. * Serializes this block in a JSON representation
  54957. * @returns the serialized block object
  54958. */
  54959. serialize(): any;
  54960. /** @hidden */
  54961. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54962. /**
  54963. * Release resources
  54964. */
  54965. dispose(): void;
  54966. }
  54967. }
  54968. declare module BABYLON {
  54969. /**
  54970. * Enum defining the type of animations supported by InputBlock
  54971. */
  54972. export enum AnimatedInputBlockTypes {
  54973. /** No animation */
  54974. None = 0,
  54975. /** Time based animation. Will only work for floats */
  54976. Time = 1
  54977. }
  54978. }
  54979. declare module BABYLON {
  54980. /**
  54981. * Block used to expose an input value
  54982. */
  54983. export class InputBlock extends NodeMaterialBlock {
  54984. private _mode;
  54985. private _associatedVariableName;
  54986. private _storedValue;
  54987. private _valueCallback;
  54988. private _type;
  54989. private _animationType;
  54990. /** Gets or set a value used to limit the range of float values */
  54991. min: number;
  54992. /** Gets or set a value used to limit the range of float values */
  54993. max: number;
  54994. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  54995. matrixMode: number;
  54996. /** @hidden */
  54997. _systemValue: Nullable<NodeMaterialSystemValues>;
  54998. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  54999. visibleInInspector: boolean;
  55000. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55001. isConstant: boolean;
  55002. /** Gets or sets the group to use to display this block in the Inspector */
  55003. groupInInspector: string;
  55004. /**
  55005. * Gets or sets the connection point type (default is float)
  55006. */
  55007. readonly type: NodeMaterialBlockConnectionPointTypes;
  55008. /**
  55009. * Creates a new InputBlock
  55010. * @param name defines the block name
  55011. * @param target defines the target of that block (Vertex by default)
  55012. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55013. */
  55014. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55015. /**
  55016. * Gets the output component
  55017. */
  55018. readonly output: NodeMaterialConnectionPoint;
  55019. /**
  55020. * Set the source of this connection point to a vertex attribute
  55021. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55022. * @returns the current connection point
  55023. */
  55024. setAsAttribute(attributeName?: string): InputBlock;
  55025. /**
  55026. * Set the source of this connection point to a system value
  55027. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55028. * @returns the current connection point
  55029. */
  55030. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55031. /**
  55032. * Gets or sets the value of that point.
  55033. * Please note that this value will be ignored if valueCallback is defined
  55034. */
  55035. value: any;
  55036. /**
  55037. * Gets or sets a callback used to get the value of that point.
  55038. * Please note that setting this value will force the connection point to ignore the value property
  55039. */
  55040. valueCallback: () => any;
  55041. /**
  55042. * Gets or sets the associated variable name in the shader
  55043. */
  55044. associatedVariableName: string;
  55045. /** Gets or sets the type of animation applied to the input */
  55046. animationType: AnimatedInputBlockTypes;
  55047. /**
  55048. * Gets a boolean indicating that this connection point not defined yet
  55049. */
  55050. readonly isUndefined: boolean;
  55051. /**
  55052. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55053. * In this case the connection point name must be the name of the uniform to use.
  55054. * Can only be set on inputs
  55055. */
  55056. isUniform: boolean;
  55057. /**
  55058. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55059. * In this case the connection point name must be the name of the attribute to use
  55060. * Can only be set on inputs
  55061. */
  55062. isAttribute: boolean;
  55063. /**
  55064. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55065. * Can only be set on exit points
  55066. */
  55067. isVarying: boolean;
  55068. /**
  55069. * Gets a boolean indicating that the current connection point is a system value
  55070. */
  55071. readonly isSystemValue: boolean;
  55072. /**
  55073. * Gets or sets the current well known value or null if not defined as a system value
  55074. */
  55075. systemValue: Nullable<NodeMaterialSystemValues>;
  55076. /**
  55077. * Gets the current class name
  55078. * @returns the class name
  55079. */
  55080. getClassName(): string;
  55081. /**
  55082. * Animate the input if animationType !== None
  55083. * @param scene defines the rendering scene
  55084. */
  55085. animate(scene: Scene): void;
  55086. private _emitDefine;
  55087. initialize(state: NodeMaterialBuildState): void;
  55088. /**
  55089. * Set the input block to its default value (based on its type)
  55090. */
  55091. setDefaultValue(): void;
  55092. private _emitConstant;
  55093. private _emit;
  55094. /** @hidden */
  55095. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55096. /** @hidden */
  55097. _transmit(effect: Effect, scene: Scene): void;
  55098. protected _buildBlock(state: NodeMaterialBuildState): void;
  55099. protected _dumpPropertiesCode(): string;
  55100. serialize(): any;
  55101. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55102. }
  55103. }
  55104. declare module BABYLON {
  55105. /**
  55106. * Enum used to define the compatibility state between two connection points
  55107. */
  55108. export enum NodeMaterialConnectionPointCompatibilityStates {
  55109. /** Points are compatibles */
  55110. Compatible = 0,
  55111. /** Points are incompatible because of their types */
  55112. TypeIncompatible = 1,
  55113. /** Points are incompatible because of their targets (vertex vs fragment) */
  55114. TargetIncompatible = 2
  55115. }
  55116. /**
  55117. * Defines the direction of a connection point
  55118. */
  55119. export enum NodeMaterialConnectionPointDirection {
  55120. /** Input */
  55121. Input = 0,
  55122. /** Output */
  55123. Output = 1
  55124. }
  55125. /**
  55126. * Defines a connection point for a block
  55127. */
  55128. export class NodeMaterialConnectionPoint {
  55129. /** @hidden */
  55130. _ownerBlock: NodeMaterialBlock;
  55131. /** @hidden */
  55132. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55133. private _endpoints;
  55134. private _associatedVariableName;
  55135. private _direction;
  55136. /** @hidden */
  55137. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55138. /** @hidden */
  55139. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55140. private _type;
  55141. /** @hidden */
  55142. _enforceAssociatedVariableName: boolean;
  55143. /** Gets the direction of the point */
  55144. readonly direction: NodeMaterialConnectionPointDirection;
  55145. /**
  55146. * Gets or sets the additional types supported by this connection point
  55147. */
  55148. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55149. /**
  55150. * Gets or sets the additional types excluded by this connection point
  55151. */
  55152. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55153. /**
  55154. * Observable triggered when this point is connected
  55155. */
  55156. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  55157. /**
  55158. * Gets or sets the associated variable name in the shader
  55159. */
  55160. associatedVariableName: string;
  55161. /**
  55162. * Gets or sets the connection point type (default is float)
  55163. */
  55164. type: NodeMaterialBlockConnectionPointTypes;
  55165. /**
  55166. * Gets or sets the connection point name
  55167. */
  55168. name: string;
  55169. /**
  55170. * Gets or sets a boolean indicating that this connection point can be omitted
  55171. */
  55172. isOptional: boolean;
  55173. /**
  55174. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55175. */
  55176. define: string;
  55177. /** @hidden */
  55178. _prioritizeVertex: boolean;
  55179. private _target;
  55180. /** Gets or sets the target of that connection point */
  55181. target: NodeMaterialBlockTargets;
  55182. /**
  55183. * Gets a boolean indicating that the current point is connected
  55184. */
  55185. readonly isConnected: boolean;
  55186. /**
  55187. * Gets a boolean indicating that the current point is connected to an input block
  55188. */
  55189. readonly isConnectedToInputBlock: boolean;
  55190. /**
  55191. * Gets a the connected input block (if any)
  55192. */
  55193. readonly connectInputBlock: Nullable<InputBlock>;
  55194. /** Get the other side of the connection (if any) */
  55195. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55196. /** Get the block that owns this connection point */
  55197. readonly ownerBlock: NodeMaterialBlock;
  55198. /** Get the block connected on the other side of this connection (if any) */
  55199. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55200. /** Get the block connected on the endpoints of this connection (if any) */
  55201. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55202. /** Gets the list of connected endpoints */
  55203. readonly endpoints: NodeMaterialConnectionPoint[];
  55204. /** Gets a boolean indicating if that output point is connected to at least one input */
  55205. readonly hasEndpoints: boolean;
  55206. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  55207. readonly isConnectedInVertexShader: boolean;
  55208. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  55209. readonly isConnectedInFragmentShader: boolean;
  55210. /**
  55211. * Creates a new connection point
  55212. * @param name defines the connection point name
  55213. * @param ownerBlock defines the block hosting this connection point
  55214. * @param direction defines the direction of the connection point
  55215. */
  55216. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  55217. /**
  55218. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55219. * @returns the class name
  55220. */
  55221. getClassName(): string;
  55222. /**
  55223. * Gets a boolean indicating if the current point can be connected to another point
  55224. * @param connectionPoint defines the other connection point
  55225. * @returns a boolean
  55226. */
  55227. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55228. /**
  55229. * Gets a number indicating if the current point can be connected to another point
  55230. * @param connectionPoint defines the other connection point
  55231. * @returns a number defining the compatibility state
  55232. */
  55233. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  55234. /**
  55235. * Connect this point to another connection point
  55236. * @param connectionPoint defines the other connection point
  55237. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55238. * @returns the current connection point
  55239. */
  55240. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55241. /**
  55242. * Disconnect this point from one of his endpoint
  55243. * @param endpoint defines the other connection point
  55244. * @returns the current connection point
  55245. */
  55246. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55247. /**
  55248. * Serializes this point in a JSON representation
  55249. * @returns the serialized point object
  55250. */
  55251. serialize(): any;
  55252. /**
  55253. * Release resources
  55254. */
  55255. dispose(): void;
  55256. }
  55257. }
  55258. declare module BABYLON {
  55259. /**
  55260. * Block used to add support for vertex skinning (bones)
  55261. */
  55262. export class BonesBlock extends NodeMaterialBlock {
  55263. /**
  55264. * Creates a new BonesBlock
  55265. * @param name defines the block name
  55266. */
  55267. constructor(name: string);
  55268. /**
  55269. * Initialize the block and prepare the context for build
  55270. * @param state defines the state that will be used for the build
  55271. */
  55272. initialize(state: NodeMaterialBuildState): void;
  55273. /**
  55274. * Gets the current class name
  55275. * @returns the class name
  55276. */
  55277. getClassName(): string;
  55278. /**
  55279. * Gets the matrix indices input component
  55280. */
  55281. readonly matricesIndices: NodeMaterialConnectionPoint;
  55282. /**
  55283. * Gets the matrix weights input component
  55284. */
  55285. readonly matricesWeights: NodeMaterialConnectionPoint;
  55286. /**
  55287. * Gets the extra matrix indices input component
  55288. */
  55289. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55290. /**
  55291. * Gets the extra matrix weights input component
  55292. */
  55293. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55294. /**
  55295. * Gets the world input component
  55296. */
  55297. readonly world: NodeMaterialConnectionPoint;
  55298. /**
  55299. * Gets the output component
  55300. */
  55301. readonly output: NodeMaterialConnectionPoint;
  55302. autoConfigure(material: NodeMaterial): void;
  55303. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55304. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55305. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55306. protected _buildBlock(state: NodeMaterialBuildState): this;
  55307. }
  55308. }
  55309. declare module BABYLON {
  55310. /**
  55311. * Block used to add support for instances
  55312. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55313. */
  55314. export class InstancesBlock extends NodeMaterialBlock {
  55315. /**
  55316. * Creates a new InstancesBlock
  55317. * @param name defines the block name
  55318. */
  55319. constructor(name: string);
  55320. /**
  55321. * Gets the current class name
  55322. * @returns the class name
  55323. */
  55324. getClassName(): string;
  55325. /**
  55326. * Gets the first world row input component
  55327. */
  55328. readonly world0: NodeMaterialConnectionPoint;
  55329. /**
  55330. * Gets the second world row input component
  55331. */
  55332. readonly world1: NodeMaterialConnectionPoint;
  55333. /**
  55334. * Gets the third world row input component
  55335. */
  55336. readonly world2: NodeMaterialConnectionPoint;
  55337. /**
  55338. * Gets the forth world row input component
  55339. */
  55340. readonly world3: NodeMaterialConnectionPoint;
  55341. /**
  55342. * Gets the world input component
  55343. */
  55344. readonly world: NodeMaterialConnectionPoint;
  55345. /**
  55346. * Gets the output component
  55347. */
  55348. readonly output: NodeMaterialConnectionPoint;
  55349. autoConfigure(material: NodeMaterial): void;
  55350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55351. protected _buildBlock(state: NodeMaterialBuildState): this;
  55352. }
  55353. }
  55354. declare module BABYLON {
  55355. /**
  55356. * Block used to add morph targets support to vertex shader
  55357. */
  55358. export class MorphTargetsBlock extends NodeMaterialBlock {
  55359. private _repeatableContentAnchor;
  55360. private _repeatebleContentGenerated;
  55361. /**
  55362. * Create a new MorphTargetsBlock
  55363. * @param name defines the block name
  55364. */
  55365. constructor(name: string);
  55366. /**
  55367. * Gets the current class name
  55368. * @returns the class name
  55369. */
  55370. getClassName(): string;
  55371. /**
  55372. * Gets the position input component
  55373. */
  55374. readonly position: NodeMaterialConnectionPoint;
  55375. /**
  55376. * Gets the normal input component
  55377. */
  55378. readonly normal: NodeMaterialConnectionPoint;
  55379. /**
  55380. * Gets the tangent input component
  55381. */
  55382. readonly tangent: NodeMaterialConnectionPoint;
  55383. /**
  55384. * Gets the tangent input component
  55385. */
  55386. readonly uv: NodeMaterialConnectionPoint;
  55387. /**
  55388. * Gets the position output component
  55389. */
  55390. readonly positionOutput: NodeMaterialConnectionPoint;
  55391. /**
  55392. * Gets the normal output component
  55393. */
  55394. readonly normalOutput: NodeMaterialConnectionPoint;
  55395. /**
  55396. * Gets the tangent output component
  55397. */
  55398. readonly tangentOutput: NodeMaterialConnectionPoint;
  55399. /**
  55400. * Gets the tangent output component
  55401. */
  55402. readonly uvOutput: NodeMaterialConnectionPoint;
  55403. initialize(state: NodeMaterialBuildState): void;
  55404. autoConfigure(material: NodeMaterial): void;
  55405. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55406. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55407. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55408. protected _buildBlock(state: NodeMaterialBuildState): this;
  55409. }
  55410. }
  55411. declare module BABYLON {
  55412. /**
  55413. * Block used to get data information from a light
  55414. */
  55415. export class LightInformationBlock extends NodeMaterialBlock {
  55416. private _lightDataUniformName;
  55417. private _lightColorUniformName;
  55418. private _lightTypeDefineName;
  55419. /**
  55420. * Gets or sets the light associated with this block
  55421. */
  55422. light: Nullable<Light>;
  55423. /**
  55424. * Creates a new LightInformationBlock
  55425. * @param name defines the block name
  55426. */
  55427. constructor(name: string);
  55428. /**
  55429. * Gets the current class name
  55430. * @returns the class name
  55431. */
  55432. getClassName(): string;
  55433. /**
  55434. * Gets the world position input component
  55435. */
  55436. readonly worldPosition: NodeMaterialConnectionPoint;
  55437. /**
  55438. * Gets the direction output component
  55439. */
  55440. readonly direction: NodeMaterialConnectionPoint;
  55441. /**
  55442. * Gets the direction output component
  55443. */
  55444. readonly color: NodeMaterialConnectionPoint;
  55445. /**
  55446. * Gets the direction output component
  55447. */
  55448. readonly intensity: NodeMaterialConnectionPoint;
  55449. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55450. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55451. protected _buildBlock(state: NodeMaterialBuildState): this;
  55452. serialize(): any;
  55453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55454. }
  55455. }
  55456. declare module BABYLON {
  55457. /**
  55458. * Block used to add image processing support to fragment shader
  55459. */
  55460. export class ImageProcessingBlock extends NodeMaterialBlock {
  55461. /**
  55462. * Create a new ImageProcessingBlock
  55463. * @param name defines the block name
  55464. */
  55465. constructor(name: string);
  55466. /**
  55467. * Gets the current class name
  55468. * @returns the class name
  55469. */
  55470. getClassName(): string;
  55471. /**
  55472. * Gets the color input component
  55473. */
  55474. readonly color: NodeMaterialConnectionPoint;
  55475. /**
  55476. * Gets the output component
  55477. */
  55478. readonly output: NodeMaterialConnectionPoint;
  55479. /**
  55480. * Initialize the block and prepare the context for build
  55481. * @param state defines the state that will be used for the build
  55482. */
  55483. initialize(state: NodeMaterialBuildState): void;
  55484. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55486. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55487. protected _buildBlock(state: NodeMaterialBuildState): this;
  55488. }
  55489. }
  55490. declare module BABYLON {
  55491. /**
  55492. * Block used to pertub normals based on a normal map
  55493. */
  55494. export class PerturbNormalBlock extends NodeMaterialBlock {
  55495. private _tangentSpaceParameterName;
  55496. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  55497. invertX: boolean;
  55498. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  55499. invertY: boolean;
  55500. /**
  55501. * Create a new PerturbNormalBlock
  55502. * @param name defines the block name
  55503. */
  55504. constructor(name: string);
  55505. /**
  55506. * Gets the current class name
  55507. * @returns the class name
  55508. */
  55509. getClassName(): string;
  55510. /**
  55511. * Gets the world position input component
  55512. */
  55513. readonly worldPosition: NodeMaterialConnectionPoint;
  55514. /**
  55515. * Gets the world normal input component
  55516. */
  55517. readonly worldNormal: NodeMaterialConnectionPoint;
  55518. /**
  55519. * Gets the uv input component
  55520. */
  55521. readonly uv: NodeMaterialConnectionPoint;
  55522. /**
  55523. * Gets the normal map color input component
  55524. */
  55525. readonly normalMapColor: NodeMaterialConnectionPoint;
  55526. /**
  55527. * Gets the strength input component
  55528. */
  55529. readonly strength: NodeMaterialConnectionPoint;
  55530. /**
  55531. * Gets the output component
  55532. */
  55533. readonly output: NodeMaterialConnectionPoint;
  55534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55535. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55536. autoConfigure(material: NodeMaterial): void;
  55537. protected _buildBlock(state: NodeMaterialBuildState): this;
  55538. protected _dumpPropertiesCode(): string;
  55539. serialize(): any;
  55540. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55541. }
  55542. }
  55543. declare module BABYLON {
  55544. /**
  55545. * Block used to discard a pixel if a value is smaller than a cutoff
  55546. */
  55547. export class DiscardBlock extends NodeMaterialBlock {
  55548. /**
  55549. * Create a new DiscardBlock
  55550. * @param name defines the block name
  55551. */
  55552. constructor(name: string);
  55553. /**
  55554. * Gets the current class name
  55555. * @returns the class name
  55556. */
  55557. getClassName(): string;
  55558. /**
  55559. * Gets the color input component
  55560. */
  55561. readonly value: NodeMaterialConnectionPoint;
  55562. /**
  55563. * Gets the cutoff input component
  55564. */
  55565. readonly cutoff: NodeMaterialConnectionPoint;
  55566. protected _buildBlock(state: NodeMaterialBuildState): this;
  55567. }
  55568. }
  55569. declare module BABYLON {
  55570. /**
  55571. * Block used to test if the fragment shader is front facing
  55572. */
  55573. export class FrontFacingBlock extends NodeMaterialBlock {
  55574. /**
  55575. * Creates a new FrontFacingBlock
  55576. * @param name defines the block name
  55577. */
  55578. constructor(name: string);
  55579. /**
  55580. * Gets the current class name
  55581. * @returns the class name
  55582. */
  55583. getClassName(): string;
  55584. /**
  55585. * Gets the output component
  55586. */
  55587. readonly output: NodeMaterialConnectionPoint;
  55588. protected _buildBlock(state: NodeMaterialBuildState): this;
  55589. }
  55590. }
  55591. declare module BABYLON {
  55592. /**
  55593. * Block used to get the derivative value on x and y of a given input
  55594. */
  55595. export class DerivativeBlock extends NodeMaterialBlock {
  55596. /**
  55597. * Create a new DerivativeBlock
  55598. * @param name defines the block name
  55599. */
  55600. constructor(name: string);
  55601. /**
  55602. * Gets the current class name
  55603. * @returns the class name
  55604. */
  55605. getClassName(): string;
  55606. /**
  55607. * Gets the input component
  55608. */
  55609. readonly input: NodeMaterialConnectionPoint;
  55610. /**
  55611. * Gets the derivative output on x
  55612. */
  55613. readonly dx: NodeMaterialConnectionPoint;
  55614. /**
  55615. * Gets the derivative output on y
  55616. */
  55617. readonly dy: NodeMaterialConnectionPoint;
  55618. protected _buildBlock(state: NodeMaterialBuildState): this;
  55619. }
  55620. }
  55621. declare module BABYLON {
  55622. /**
  55623. * Block used to add support for scene fog
  55624. */
  55625. export class FogBlock extends NodeMaterialBlock {
  55626. private _fogDistanceName;
  55627. private _fogParameters;
  55628. /**
  55629. * Create a new FogBlock
  55630. * @param name defines the block name
  55631. */
  55632. constructor(name: string);
  55633. /**
  55634. * Gets the current class name
  55635. * @returns the class name
  55636. */
  55637. getClassName(): string;
  55638. /**
  55639. * Gets the world position input component
  55640. */
  55641. readonly worldPosition: NodeMaterialConnectionPoint;
  55642. /**
  55643. * Gets the view input component
  55644. */
  55645. readonly view: NodeMaterialConnectionPoint;
  55646. /**
  55647. * Gets the color input component
  55648. */
  55649. readonly input: NodeMaterialConnectionPoint;
  55650. /**
  55651. * Gets the fog color input component
  55652. */
  55653. readonly fogColor: NodeMaterialConnectionPoint;
  55654. /**
  55655. * Gets the output component
  55656. */
  55657. readonly output: NodeMaterialConnectionPoint;
  55658. autoConfigure(material: NodeMaterial): void;
  55659. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55660. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55661. protected _buildBlock(state: NodeMaterialBuildState): this;
  55662. }
  55663. }
  55664. declare module BABYLON {
  55665. /**
  55666. * Block used to add light in the fragment shader
  55667. */
  55668. export class LightBlock extends NodeMaterialBlock {
  55669. private _lightId;
  55670. /**
  55671. * Gets or sets the light associated with this block
  55672. */
  55673. light: Nullable<Light>;
  55674. /**
  55675. * Create a new LightBlock
  55676. * @param name defines the block name
  55677. */
  55678. constructor(name: string);
  55679. /**
  55680. * Gets the current class name
  55681. * @returns the class name
  55682. */
  55683. getClassName(): string;
  55684. /**
  55685. * Gets the world position input component
  55686. */
  55687. readonly worldPosition: NodeMaterialConnectionPoint;
  55688. /**
  55689. * Gets the world normal input component
  55690. */
  55691. readonly worldNormal: NodeMaterialConnectionPoint;
  55692. /**
  55693. * Gets the camera (or eye) position component
  55694. */
  55695. readonly cameraPosition: NodeMaterialConnectionPoint;
  55696. /**
  55697. * Gets the glossiness component
  55698. */
  55699. readonly glossiness: NodeMaterialConnectionPoint;
  55700. /**
  55701. * Gets the glossinness power component
  55702. */
  55703. readonly glossPower: NodeMaterialConnectionPoint;
  55704. /**
  55705. * Gets the diffuse color component
  55706. */
  55707. readonly diffuseColor: NodeMaterialConnectionPoint;
  55708. /**
  55709. * Gets the specular color component
  55710. */
  55711. readonly specularColor: NodeMaterialConnectionPoint;
  55712. /**
  55713. * Gets the diffuse output component
  55714. */
  55715. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55716. /**
  55717. * Gets the specular output component
  55718. */
  55719. readonly specularOutput: NodeMaterialConnectionPoint;
  55720. autoConfigure(material: NodeMaterial): void;
  55721. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55722. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55723. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55724. private _injectVertexCode;
  55725. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55726. serialize(): any;
  55727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55728. }
  55729. }
  55730. declare module BABYLON {
  55731. /**
  55732. * Block used to multiply 2 values
  55733. */
  55734. export class MultiplyBlock extends NodeMaterialBlock {
  55735. /**
  55736. * Creates a new MultiplyBlock
  55737. * @param name defines the block name
  55738. */
  55739. constructor(name: string);
  55740. /**
  55741. * Gets the current class name
  55742. * @returns the class name
  55743. */
  55744. getClassName(): string;
  55745. /**
  55746. * Gets the left operand input component
  55747. */
  55748. readonly left: NodeMaterialConnectionPoint;
  55749. /**
  55750. * Gets the right operand input component
  55751. */
  55752. readonly right: NodeMaterialConnectionPoint;
  55753. /**
  55754. * Gets the output component
  55755. */
  55756. readonly output: NodeMaterialConnectionPoint;
  55757. protected _buildBlock(state: NodeMaterialBuildState): this;
  55758. }
  55759. }
  55760. declare module BABYLON {
  55761. /**
  55762. * Block used to add 2 vectors
  55763. */
  55764. export class AddBlock extends NodeMaterialBlock {
  55765. /**
  55766. * Creates a new AddBlock
  55767. * @param name defines the block name
  55768. */
  55769. constructor(name: string);
  55770. /**
  55771. * Gets the current class name
  55772. * @returns the class name
  55773. */
  55774. getClassName(): string;
  55775. /**
  55776. * Gets the left operand input component
  55777. */
  55778. readonly left: NodeMaterialConnectionPoint;
  55779. /**
  55780. * Gets the right operand input component
  55781. */
  55782. readonly right: NodeMaterialConnectionPoint;
  55783. /**
  55784. * Gets the output component
  55785. */
  55786. readonly output: NodeMaterialConnectionPoint;
  55787. protected _buildBlock(state: NodeMaterialBuildState): this;
  55788. }
  55789. }
  55790. declare module BABYLON {
  55791. /**
  55792. * Block used to scale a vector by a float
  55793. */
  55794. export class ScaleBlock extends NodeMaterialBlock {
  55795. /**
  55796. * Creates a new ScaleBlock
  55797. * @param name defines the block name
  55798. */
  55799. constructor(name: string);
  55800. /**
  55801. * Gets the current class name
  55802. * @returns the class name
  55803. */
  55804. getClassName(): string;
  55805. /**
  55806. * Gets the input component
  55807. */
  55808. readonly input: NodeMaterialConnectionPoint;
  55809. /**
  55810. * Gets the factor input component
  55811. */
  55812. readonly factor: NodeMaterialConnectionPoint;
  55813. /**
  55814. * Gets the output component
  55815. */
  55816. readonly output: NodeMaterialConnectionPoint;
  55817. protected _buildBlock(state: NodeMaterialBuildState): this;
  55818. }
  55819. }
  55820. declare module BABYLON {
  55821. /**
  55822. * Block used to clamp a float
  55823. */
  55824. export class ClampBlock extends NodeMaterialBlock {
  55825. /** Gets or sets the minimum range */
  55826. minimum: number;
  55827. /** Gets or sets the maximum range */
  55828. maximum: number;
  55829. /**
  55830. * Creates a new ClampBlock
  55831. * @param name defines the block name
  55832. */
  55833. constructor(name: string);
  55834. /**
  55835. * Gets the current class name
  55836. * @returns the class name
  55837. */
  55838. getClassName(): string;
  55839. /**
  55840. * Gets the value input component
  55841. */
  55842. readonly value: NodeMaterialConnectionPoint;
  55843. /**
  55844. * Gets the output component
  55845. */
  55846. readonly output: NodeMaterialConnectionPoint;
  55847. protected _buildBlock(state: NodeMaterialBuildState): this;
  55848. protected _dumpPropertiesCode(): string;
  55849. serialize(): any;
  55850. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55851. }
  55852. }
  55853. declare module BABYLON {
  55854. /**
  55855. * Block used to apply a cross product between 2 vectors
  55856. */
  55857. export class CrossBlock extends NodeMaterialBlock {
  55858. /**
  55859. * Creates a new CrossBlock
  55860. * @param name defines the block name
  55861. */
  55862. constructor(name: string);
  55863. /**
  55864. * Gets the current class name
  55865. * @returns the class name
  55866. */
  55867. getClassName(): string;
  55868. /**
  55869. * Gets the left operand input component
  55870. */
  55871. readonly left: NodeMaterialConnectionPoint;
  55872. /**
  55873. * Gets the right operand input component
  55874. */
  55875. readonly right: NodeMaterialConnectionPoint;
  55876. /**
  55877. * Gets the output component
  55878. */
  55879. readonly output: NodeMaterialConnectionPoint;
  55880. protected _buildBlock(state: NodeMaterialBuildState): this;
  55881. }
  55882. }
  55883. declare module BABYLON {
  55884. /**
  55885. * Block used to apply a dot product between 2 vectors
  55886. */
  55887. export class DotBlock extends NodeMaterialBlock {
  55888. /**
  55889. * Creates a new DotBlock
  55890. * @param name defines the block name
  55891. */
  55892. constructor(name: string);
  55893. /**
  55894. * Gets the current class name
  55895. * @returns the class name
  55896. */
  55897. getClassName(): string;
  55898. /**
  55899. * Gets the left operand input component
  55900. */
  55901. readonly left: NodeMaterialConnectionPoint;
  55902. /**
  55903. * Gets the right operand input component
  55904. */
  55905. readonly right: NodeMaterialConnectionPoint;
  55906. /**
  55907. * Gets the output component
  55908. */
  55909. readonly output: NodeMaterialConnectionPoint;
  55910. protected _buildBlock(state: NodeMaterialBuildState): this;
  55911. }
  55912. }
  55913. declare module BABYLON {
  55914. /**
  55915. * Block used to remap a float from a range to a new one
  55916. */
  55917. export class RemapBlock extends NodeMaterialBlock {
  55918. /**
  55919. * Gets or sets the source range
  55920. */
  55921. sourceRange: Vector2;
  55922. /**
  55923. * Gets or sets the target range
  55924. */
  55925. targetRange: Vector2;
  55926. /**
  55927. * Creates a new RemapBlock
  55928. * @param name defines the block name
  55929. */
  55930. constructor(name: string);
  55931. /**
  55932. * Gets the current class name
  55933. * @returns the class name
  55934. */
  55935. getClassName(): string;
  55936. /**
  55937. * Gets the input component
  55938. */
  55939. readonly input: NodeMaterialConnectionPoint;
  55940. /**
  55941. * Gets the source min input component
  55942. */
  55943. readonly sourceMin: NodeMaterialConnectionPoint;
  55944. /**
  55945. * Gets the source max input component
  55946. */
  55947. readonly sourceMax: NodeMaterialConnectionPoint;
  55948. /**
  55949. * Gets the target min input component
  55950. */
  55951. readonly targetMin: NodeMaterialConnectionPoint;
  55952. /**
  55953. * Gets the target max input component
  55954. */
  55955. readonly targetMax: NodeMaterialConnectionPoint;
  55956. /**
  55957. * Gets the output component
  55958. */
  55959. readonly output: NodeMaterialConnectionPoint;
  55960. protected _buildBlock(state: NodeMaterialBuildState): this;
  55961. protected _dumpPropertiesCode(): string;
  55962. serialize(): any;
  55963. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55964. }
  55965. }
  55966. declare module BABYLON {
  55967. /**
  55968. * Block used to normalize a vector
  55969. */
  55970. export class NormalizeBlock extends NodeMaterialBlock {
  55971. /**
  55972. * Creates a new NormalizeBlock
  55973. * @param name defines the block name
  55974. */
  55975. constructor(name: string);
  55976. /**
  55977. * Gets the current class name
  55978. * @returns the class name
  55979. */
  55980. getClassName(): string;
  55981. /**
  55982. * Gets the input component
  55983. */
  55984. readonly input: NodeMaterialConnectionPoint;
  55985. /**
  55986. * Gets the output component
  55987. */
  55988. readonly output: NodeMaterialConnectionPoint;
  55989. protected _buildBlock(state: NodeMaterialBuildState): this;
  55990. }
  55991. }
  55992. declare module BABYLON {
  55993. /**
  55994. * Operations supported by the Trigonometry block
  55995. */
  55996. export enum TrigonometryBlockOperations {
  55997. /** Cos */
  55998. Cos = 0,
  55999. /** Sin */
  56000. Sin = 1,
  56001. /** Abs */
  56002. Abs = 2,
  56003. /** Exp */
  56004. Exp = 3,
  56005. /** Exp2 */
  56006. Exp2 = 4,
  56007. /** Round */
  56008. Round = 5,
  56009. /** Floor */
  56010. Floor = 6,
  56011. /** Ceiling */
  56012. Ceiling = 7,
  56013. /** Square root */
  56014. Sqrt = 8,
  56015. /** Log */
  56016. Log = 9,
  56017. /** Tangent */
  56018. Tan = 10,
  56019. /** Arc tangent */
  56020. ArcTan = 11,
  56021. /** Arc cosinus */
  56022. ArcCos = 12,
  56023. /** Arc sinus */
  56024. ArcSin = 13,
  56025. /** Fraction */
  56026. Fract = 14,
  56027. /** Sign */
  56028. Sign = 15,
  56029. /** To radians (from degrees) */
  56030. Radians = 16,
  56031. /** To degrees (from radians) */
  56032. Degrees = 17
  56033. }
  56034. /**
  56035. * Block used to apply trigonometry operation to floats
  56036. */
  56037. export class TrigonometryBlock extends NodeMaterialBlock {
  56038. /**
  56039. * Gets or sets the operation applied by the block
  56040. */
  56041. operation: TrigonometryBlockOperations;
  56042. /**
  56043. * Creates a new TrigonometryBlock
  56044. * @param name defines the block name
  56045. */
  56046. constructor(name: string);
  56047. /**
  56048. * Gets the current class name
  56049. * @returns the class name
  56050. */
  56051. getClassName(): string;
  56052. /**
  56053. * Gets the input component
  56054. */
  56055. readonly input: NodeMaterialConnectionPoint;
  56056. /**
  56057. * Gets the output component
  56058. */
  56059. readonly output: NodeMaterialConnectionPoint;
  56060. protected _buildBlock(state: NodeMaterialBuildState): this;
  56061. serialize(): any;
  56062. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56063. protected _dumpPropertiesCode(): string;
  56064. }
  56065. }
  56066. declare module BABYLON {
  56067. /**
  56068. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56069. */
  56070. export class ColorMergerBlock extends NodeMaterialBlock {
  56071. /**
  56072. * Create a new ColorMergerBlock
  56073. * @param name defines the block name
  56074. */
  56075. constructor(name: string);
  56076. /**
  56077. * Gets the current class name
  56078. * @returns the class name
  56079. */
  56080. getClassName(): string;
  56081. /**
  56082. * Gets the rgb component (input)
  56083. */
  56084. readonly rgbIn: NodeMaterialConnectionPoint;
  56085. /**
  56086. * Gets the r component (input)
  56087. */
  56088. readonly r: NodeMaterialConnectionPoint;
  56089. /**
  56090. * Gets the g component (input)
  56091. */
  56092. readonly g: NodeMaterialConnectionPoint;
  56093. /**
  56094. * Gets the b component (input)
  56095. */
  56096. readonly b: NodeMaterialConnectionPoint;
  56097. /**
  56098. * Gets the a component (input)
  56099. */
  56100. readonly a: NodeMaterialConnectionPoint;
  56101. /**
  56102. * Gets the rgba component (output)
  56103. */
  56104. readonly rgba: NodeMaterialConnectionPoint;
  56105. /**
  56106. * Gets the rgb component (output)
  56107. */
  56108. readonly rgbOut: NodeMaterialConnectionPoint;
  56109. /**
  56110. * Gets the rgb component (output)
  56111. * @deprecated Please use rgbOut instead.
  56112. */
  56113. readonly rgb: NodeMaterialConnectionPoint;
  56114. protected _buildBlock(state: NodeMaterialBuildState): this;
  56115. }
  56116. }
  56117. declare module BABYLON {
  56118. /**
  56119. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56120. */
  56121. export class VectorMergerBlock extends NodeMaterialBlock {
  56122. /**
  56123. * Create a new VectorMergerBlock
  56124. * @param name defines the block name
  56125. */
  56126. constructor(name: string);
  56127. /**
  56128. * Gets the current class name
  56129. * @returns the class name
  56130. */
  56131. getClassName(): string;
  56132. /**
  56133. * Gets the xyz component (input)
  56134. */
  56135. readonly xyzIn: NodeMaterialConnectionPoint;
  56136. /**
  56137. * Gets the xy component (input)
  56138. */
  56139. readonly xyIn: NodeMaterialConnectionPoint;
  56140. /**
  56141. * Gets the x component (input)
  56142. */
  56143. readonly x: NodeMaterialConnectionPoint;
  56144. /**
  56145. * Gets the y component (input)
  56146. */
  56147. readonly y: NodeMaterialConnectionPoint;
  56148. /**
  56149. * Gets the z component (input)
  56150. */
  56151. readonly z: NodeMaterialConnectionPoint;
  56152. /**
  56153. * Gets the w component (input)
  56154. */
  56155. readonly w: NodeMaterialConnectionPoint;
  56156. /**
  56157. * Gets the xyzw component (output)
  56158. */
  56159. readonly xyzw: NodeMaterialConnectionPoint;
  56160. /**
  56161. * Gets the xyz component (output)
  56162. */
  56163. readonly xyzOut: NodeMaterialConnectionPoint;
  56164. /**
  56165. * Gets the xy component (output)
  56166. */
  56167. readonly xyOut: NodeMaterialConnectionPoint;
  56168. /**
  56169. * Gets the xy component (output)
  56170. * @deprecated Please use xyOut instead.
  56171. */
  56172. readonly xy: NodeMaterialConnectionPoint;
  56173. /**
  56174. * Gets the xyz component (output)
  56175. * @deprecated Please use xyzOut instead.
  56176. */
  56177. readonly xyz: NodeMaterialConnectionPoint;
  56178. protected _buildBlock(state: NodeMaterialBuildState): this;
  56179. }
  56180. }
  56181. declare module BABYLON {
  56182. /**
  56183. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56184. */
  56185. export class ColorSplitterBlock extends NodeMaterialBlock {
  56186. /**
  56187. * Create a new ColorSplitterBlock
  56188. * @param name defines the block name
  56189. */
  56190. constructor(name: string);
  56191. /**
  56192. * Gets the current class name
  56193. * @returns the class name
  56194. */
  56195. getClassName(): string;
  56196. /**
  56197. * Gets the rgba component (input)
  56198. */
  56199. readonly rgba: NodeMaterialConnectionPoint;
  56200. /**
  56201. * Gets the rgb component (input)
  56202. */
  56203. readonly rgbIn: NodeMaterialConnectionPoint;
  56204. /**
  56205. * Gets the rgb component (output)
  56206. */
  56207. readonly rgbOut: NodeMaterialConnectionPoint;
  56208. /**
  56209. * Gets the r component (output)
  56210. */
  56211. readonly r: NodeMaterialConnectionPoint;
  56212. /**
  56213. * Gets the g component (output)
  56214. */
  56215. readonly g: NodeMaterialConnectionPoint;
  56216. /**
  56217. * Gets the b component (output)
  56218. */
  56219. readonly b: NodeMaterialConnectionPoint;
  56220. /**
  56221. * Gets the a component (output)
  56222. */
  56223. readonly a: NodeMaterialConnectionPoint;
  56224. protected _inputRename(name: string): string;
  56225. protected _outputRename(name: string): string;
  56226. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56227. }
  56228. }
  56229. declare module BABYLON {
  56230. /**
  56231. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56232. */
  56233. export class VectorSplitterBlock extends NodeMaterialBlock {
  56234. /**
  56235. * Create a new VectorSplitterBlock
  56236. * @param name defines the block name
  56237. */
  56238. constructor(name: string);
  56239. /**
  56240. * Gets the current class name
  56241. * @returns the class name
  56242. */
  56243. getClassName(): string;
  56244. /**
  56245. * Gets the xyzw component (input)
  56246. */
  56247. readonly xyzw: NodeMaterialConnectionPoint;
  56248. /**
  56249. * Gets the xyz component (input)
  56250. */
  56251. readonly xyzIn: NodeMaterialConnectionPoint;
  56252. /**
  56253. * Gets the xy component (input)
  56254. */
  56255. readonly xyIn: NodeMaterialConnectionPoint;
  56256. /**
  56257. * Gets the xyz component (output)
  56258. */
  56259. readonly xyzOut: NodeMaterialConnectionPoint;
  56260. /**
  56261. * Gets the xy component (output)
  56262. */
  56263. readonly xyOut: NodeMaterialConnectionPoint;
  56264. /**
  56265. * Gets the x component (output)
  56266. */
  56267. readonly x: NodeMaterialConnectionPoint;
  56268. /**
  56269. * Gets the y component (output)
  56270. */
  56271. readonly y: NodeMaterialConnectionPoint;
  56272. /**
  56273. * Gets the z component (output)
  56274. */
  56275. readonly z: NodeMaterialConnectionPoint;
  56276. /**
  56277. * Gets the w component (output)
  56278. */
  56279. readonly w: NodeMaterialConnectionPoint;
  56280. protected _inputRename(name: string): string;
  56281. protected _outputRename(name: string): string;
  56282. protected _buildBlock(state: NodeMaterialBuildState): this;
  56283. }
  56284. }
  56285. declare module BABYLON {
  56286. /**
  56287. * Block used to lerp between 2 values
  56288. */
  56289. export class LerpBlock extends NodeMaterialBlock {
  56290. /**
  56291. * Creates a new LerpBlock
  56292. * @param name defines the block name
  56293. */
  56294. constructor(name: string);
  56295. /**
  56296. * Gets the current class name
  56297. * @returns the class name
  56298. */
  56299. getClassName(): string;
  56300. /**
  56301. * Gets the left operand input component
  56302. */
  56303. readonly left: NodeMaterialConnectionPoint;
  56304. /**
  56305. * Gets the right operand input component
  56306. */
  56307. readonly right: NodeMaterialConnectionPoint;
  56308. /**
  56309. * Gets the gradient operand input component
  56310. */
  56311. readonly gradient: NodeMaterialConnectionPoint;
  56312. /**
  56313. * Gets the output component
  56314. */
  56315. readonly output: NodeMaterialConnectionPoint;
  56316. protected _buildBlock(state: NodeMaterialBuildState): this;
  56317. }
  56318. }
  56319. declare module BABYLON {
  56320. /**
  56321. * Block used to divide 2 vectors
  56322. */
  56323. export class DivideBlock extends NodeMaterialBlock {
  56324. /**
  56325. * Creates a new DivideBlock
  56326. * @param name defines the block name
  56327. */
  56328. constructor(name: string);
  56329. /**
  56330. * Gets the current class name
  56331. * @returns the class name
  56332. */
  56333. getClassName(): string;
  56334. /**
  56335. * Gets the left operand input component
  56336. */
  56337. readonly left: NodeMaterialConnectionPoint;
  56338. /**
  56339. * Gets the right operand input component
  56340. */
  56341. readonly right: NodeMaterialConnectionPoint;
  56342. /**
  56343. * Gets the output component
  56344. */
  56345. readonly output: NodeMaterialConnectionPoint;
  56346. protected _buildBlock(state: NodeMaterialBuildState): this;
  56347. }
  56348. }
  56349. declare module BABYLON {
  56350. /**
  56351. * Block used to subtract 2 vectors
  56352. */
  56353. export class SubtractBlock extends NodeMaterialBlock {
  56354. /**
  56355. * Creates a new SubtractBlock
  56356. * @param name defines the block name
  56357. */
  56358. constructor(name: string);
  56359. /**
  56360. * Gets the current class name
  56361. * @returns the class name
  56362. */
  56363. getClassName(): string;
  56364. /**
  56365. * Gets the left operand input component
  56366. */
  56367. readonly left: NodeMaterialConnectionPoint;
  56368. /**
  56369. * Gets the right operand input component
  56370. */
  56371. readonly right: NodeMaterialConnectionPoint;
  56372. /**
  56373. * Gets the output component
  56374. */
  56375. readonly output: NodeMaterialConnectionPoint;
  56376. protected _buildBlock(state: NodeMaterialBuildState): this;
  56377. }
  56378. }
  56379. declare module BABYLON {
  56380. /**
  56381. * Block used to step a value
  56382. */
  56383. export class StepBlock extends NodeMaterialBlock {
  56384. /**
  56385. * Creates a new StepBlock
  56386. * @param name defines the block name
  56387. */
  56388. constructor(name: string);
  56389. /**
  56390. * Gets the current class name
  56391. * @returns the class name
  56392. */
  56393. getClassName(): string;
  56394. /**
  56395. * Gets the value operand input component
  56396. */
  56397. readonly value: NodeMaterialConnectionPoint;
  56398. /**
  56399. * Gets the edge operand input component
  56400. */
  56401. readonly edge: NodeMaterialConnectionPoint;
  56402. /**
  56403. * Gets the output component
  56404. */
  56405. readonly output: NodeMaterialConnectionPoint;
  56406. protected _buildBlock(state: NodeMaterialBuildState): this;
  56407. }
  56408. }
  56409. declare module BABYLON {
  56410. /**
  56411. * Block used to get the opposite (1 - x) of a value
  56412. */
  56413. export class OneMinusBlock extends NodeMaterialBlock {
  56414. /**
  56415. * Creates a new OneMinusBlock
  56416. * @param name defines the block name
  56417. */
  56418. constructor(name: string);
  56419. /**
  56420. * Gets the current class name
  56421. * @returns the class name
  56422. */
  56423. getClassName(): string;
  56424. /**
  56425. * Gets the input component
  56426. */
  56427. readonly input: NodeMaterialConnectionPoint;
  56428. /**
  56429. * Gets the output component
  56430. */
  56431. readonly output: NodeMaterialConnectionPoint;
  56432. protected _buildBlock(state: NodeMaterialBuildState): this;
  56433. }
  56434. }
  56435. declare module BABYLON {
  56436. /**
  56437. * Block used to get the view direction
  56438. */
  56439. export class ViewDirectionBlock extends NodeMaterialBlock {
  56440. /**
  56441. * Creates a new ViewDirectionBlock
  56442. * @param name defines the block name
  56443. */
  56444. constructor(name: string);
  56445. /**
  56446. * Gets the current class name
  56447. * @returns the class name
  56448. */
  56449. getClassName(): string;
  56450. /**
  56451. * Gets the world position component
  56452. */
  56453. readonly worldPosition: NodeMaterialConnectionPoint;
  56454. /**
  56455. * Gets the camera position component
  56456. */
  56457. readonly cameraPosition: NodeMaterialConnectionPoint;
  56458. /**
  56459. * Gets the output component
  56460. */
  56461. readonly output: NodeMaterialConnectionPoint;
  56462. autoConfigure(material: NodeMaterial): void;
  56463. protected _buildBlock(state: NodeMaterialBuildState): this;
  56464. }
  56465. }
  56466. declare module BABYLON {
  56467. /**
  56468. * Block used to compute fresnel value
  56469. */
  56470. export class FresnelBlock extends NodeMaterialBlock {
  56471. /**
  56472. * Create a new FresnelBlock
  56473. * @param name defines the block name
  56474. */
  56475. constructor(name: string);
  56476. /**
  56477. * Gets the current class name
  56478. * @returns the class name
  56479. */
  56480. getClassName(): string;
  56481. /**
  56482. * Gets the world normal input component
  56483. */
  56484. readonly worldNormal: NodeMaterialConnectionPoint;
  56485. /**
  56486. * Gets the view direction input component
  56487. */
  56488. readonly viewDirection: NodeMaterialConnectionPoint;
  56489. /**
  56490. * Gets the bias input component
  56491. */
  56492. readonly bias: NodeMaterialConnectionPoint;
  56493. /**
  56494. * Gets the camera (or eye) position component
  56495. */
  56496. readonly power: NodeMaterialConnectionPoint;
  56497. /**
  56498. * Gets the fresnel output component
  56499. */
  56500. readonly fresnel: NodeMaterialConnectionPoint;
  56501. autoConfigure(material: NodeMaterial): void;
  56502. protected _buildBlock(state: NodeMaterialBuildState): this;
  56503. }
  56504. }
  56505. declare module BABYLON {
  56506. /**
  56507. * Block used to get the max of 2 values
  56508. */
  56509. export class MaxBlock extends NodeMaterialBlock {
  56510. /**
  56511. * Creates a new MaxBlock
  56512. * @param name defines the block name
  56513. */
  56514. constructor(name: string);
  56515. /**
  56516. * Gets the current class name
  56517. * @returns the class name
  56518. */
  56519. getClassName(): string;
  56520. /**
  56521. * Gets the left operand input component
  56522. */
  56523. readonly left: NodeMaterialConnectionPoint;
  56524. /**
  56525. * Gets the right operand input component
  56526. */
  56527. readonly right: NodeMaterialConnectionPoint;
  56528. /**
  56529. * Gets the output component
  56530. */
  56531. readonly output: NodeMaterialConnectionPoint;
  56532. protected _buildBlock(state: NodeMaterialBuildState): this;
  56533. }
  56534. }
  56535. declare module BABYLON {
  56536. /**
  56537. * Block used to get the min of 2 values
  56538. */
  56539. export class MinBlock extends NodeMaterialBlock {
  56540. /**
  56541. * Creates a new MinBlock
  56542. * @param name defines the block name
  56543. */
  56544. constructor(name: string);
  56545. /**
  56546. * Gets the current class name
  56547. * @returns the class name
  56548. */
  56549. getClassName(): string;
  56550. /**
  56551. * Gets the left operand input component
  56552. */
  56553. readonly left: NodeMaterialConnectionPoint;
  56554. /**
  56555. * Gets the right operand input component
  56556. */
  56557. readonly right: NodeMaterialConnectionPoint;
  56558. /**
  56559. * Gets the output component
  56560. */
  56561. readonly output: NodeMaterialConnectionPoint;
  56562. protected _buildBlock(state: NodeMaterialBuildState): this;
  56563. }
  56564. }
  56565. declare module BABYLON {
  56566. /**
  56567. * Block used to get the distance between 2 values
  56568. */
  56569. export class DistanceBlock extends NodeMaterialBlock {
  56570. /**
  56571. * Creates a new DistanceBlock
  56572. * @param name defines the block name
  56573. */
  56574. constructor(name: string);
  56575. /**
  56576. * Gets the current class name
  56577. * @returns the class name
  56578. */
  56579. getClassName(): string;
  56580. /**
  56581. * Gets the left operand input component
  56582. */
  56583. readonly left: NodeMaterialConnectionPoint;
  56584. /**
  56585. * Gets the right operand input component
  56586. */
  56587. readonly right: NodeMaterialConnectionPoint;
  56588. /**
  56589. * Gets the output component
  56590. */
  56591. readonly output: NodeMaterialConnectionPoint;
  56592. protected _buildBlock(state: NodeMaterialBuildState): this;
  56593. }
  56594. }
  56595. declare module BABYLON {
  56596. /**
  56597. * Block used to get the length of a vector
  56598. */
  56599. export class LengthBlock extends NodeMaterialBlock {
  56600. /**
  56601. * Creates a new LengthBlock
  56602. * @param name defines the block name
  56603. */
  56604. constructor(name: string);
  56605. /**
  56606. * Gets the current class name
  56607. * @returns the class name
  56608. */
  56609. getClassName(): string;
  56610. /**
  56611. * Gets the value input component
  56612. */
  56613. readonly value: NodeMaterialConnectionPoint;
  56614. /**
  56615. * Gets the output component
  56616. */
  56617. readonly output: NodeMaterialConnectionPoint;
  56618. protected _buildBlock(state: NodeMaterialBuildState): this;
  56619. }
  56620. }
  56621. declare module BABYLON {
  56622. /**
  56623. * Block used to get negative version of a value (i.e. x * -1)
  56624. */
  56625. export class NegateBlock extends NodeMaterialBlock {
  56626. /**
  56627. * Creates a new NegateBlock
  56628. * @param name defines the block name
  56629. */
  56630. constructor(name: string);
  56631. /**
  56632. * Gets the current class name
  56633. * @returns the class name
  56634. */
  56635. getClassName(): string;
  56636. /**
  56637. * Gets the value input component
  56638. */
  56639. readonly value: NodeMaterialConnectionPoint;
  56640. /**
  56641. * Gets the output component
  56642. */
  56643. readonly output: NodeMaterialConnectionPoint;
  56644. protected _buildBlock(state: NodeMaterialBuildState): this;
  56645. }
  56646. }
  56647. declare module BABYLON {
  56648. /**
  56649. * Block used to get the value of the first parameter raised to the power of the second
  56650. */
  56651. export class PowBlock extends NodeMaterialBlock {
  56652. /**
  56653. * Creates a new PowBlock
  56654. * @param name defines the block name
  56655. */
  56656. constructor(name: string);
  56657. /**
  56658. * Gets the current class name
  56659. * @returns the class name
  56660. */
  56661. getClassName(): string;
  56662. /**
  56663. * Gets the value operand input component
  56664. */
  56665. readonly value: NodeMaterialConnectionPoint;
  56666. /**
  56667. * Gets the power operand input component
  56668. */
  56669. readonly power: NodeMaterialConnectionPoint;
  56670. /**
  56671. * Gets the output component
  56672. */
  56673. readonly output: NodeMaterialConnectionPoint;
  56674. protected _buildBlock(state: NodeMaterialBuildState): this;
  56675. }
  56676. }
  56677. declare module BABYLON {
  56678. /**
  56679. * Block used to get a random number
  56680. */
  56681. export class RandomNumberBlock extends NodeMaterialBlock {
  56682. /**
  56683. * Creates a new RandomNumberBlock
  56684. * @param name defines the block name
  56685. */
  56686. constructor(name: string);
  56687. /**
  56688. * Gets the current class name
  56689. * @returns the class name
  56690. */
  56691. getClassName(): string;
  56692. /**
  56693. * Gets the seed input component
  56694. */
  56695. readonly seed: NodeMaterialConnectionPoint;
  56696. /**
  56697. * Gets the output component
  56698. */
  56699. readonly output: NodeMaterialConnectionPoint;
  56700. protected _buildBlock(state: NodeMaterialBuildState): this;
  56701. }
  56702. }
  56703. declare module BABYLON {
  56704. /**
  56705. * Block used to compute arc tangent of 2 values
  56706. */
  56707. export class ArcTan2Block extends NodeMaterialBlock {
  56708. /**
  56709. * Creates a new ArcTan2Block
  56710. * @param name defines the block name
  56711. */
  56712. constructor(name: string);
  56713. /**
  56714. * Gets the current class name
  56715. * @returns the class name
  56716. */
  56717. getClassName(): string;
  56718. /**
  56719. * Gets the x operand input component
  56720. */
  56721. readonly x: NodeMaterialConnectionPoint;
  56722. /**
  56723. * Gets the y operand input component
  56724. */
  56725. readonly y: NodeMaterialConnectionPoint;
  56726. /**
  56727. * Gets the output component
  56728. */
  56729. readonly output: NodeMaterialConnectionPoint;
  56730. protected _buildBlock(state: NodeMaterialBuildState): this;
  56731. }
  56732. }
  56733. declare module BABYLON {
  56734. /**
  56735. * Block used to smooth step a value
  56736. */
  56737. export class SmoothStepBlock extends NodeMaterialBlock {
  56738. /**
  56739. * Creates a new SmoothStepBlock
  56740. * @param name defines the block name
  56741. */
  56742. constructor(name: string);
  56743. /**
  56744. * Gets the current class name
  56745. * @returns the class name
  56746. */
  56747. getClassName(): string;
  56748. /**
  56749. * Gets the value operand input component
  56750. */
  56751. readonly value: NodeMaterialConnectionPoint;
  56752. /**
  56753. * Gets the first edge operand input component
  56754. */
  56755. readonly edge0: NodeMaterialConnectionPoint;
  56756. /**
  56757. * Gets the second edge operand input component
  56758. */
  56759. readonly edge1: NodeMaterialConnectionPoint;
  56760. /**
  56761. * Gets the output component
  56762. */
  56763. readonly output: NodeMaterialConnectionPoint;
  56764. protected _buildBlock(state: NodeMaterialBuildState): this;
  56765. }
  56766. }
  56767. declare module BABYLON {
  56768. /**
  56769. * Block used to get the reciprocal (1 / x) of a value
  56770. */
  56771. export class ReciprocalBlock extends NodeMaterialBlock {
  56772. /**
  56773. * Creates a new ReciprocalBlock
  56774. * @param name defines the block name
  56775. */
  56776. constructor(name: string);
  56777. /**
  56778. * Gets the current class name
  56779. * @returns the class name
  56780. */
  56781. getClassName(): string;
  56782. /**
  56783. * Gets the input component
  56784. */
  56785. readonly input: NodeMaterialConnectionPoint;
  56786. /**
  56787. * Gets the output component
  56788. */
  56789. readonly output: NodeMaterialConnectionPoint;
  56790. protected _buildBlock(state: NodeMaterialBuildState): this;
  56791. }
  56792. }
  56793. declare module BABYLON {
  56794. /**
  56795. * Block used to replace a color by another one
  56796. */
  56797. export class ReplaceColorBlock extends NodeMaterialBlock {
  56798. /**
  56799. * Creates a new ReplaceColorBlock
  56800. * @param name defines the block name
  56801. */
  56802. constructor(name: string);
  56803. /**
  56804. * Gets the current class name
  56805. * @returns the class name
  56806. */
  56807. getClassName(): string;
  56808. /**
  56809. * Gets the value input component
  56810. */
  56811. readonly value: NodeMaterialConnectionPoint;
  56812. /**
  56813. * Gets the reference input component
  56814. */
  56815. readonly reference: NodeMaterialConnectionPoint;
  56816. /**
  56817. * Gets the distance input component
  56818. */
  56819. readonly distance: NodeMaterialConnectionPoint;
  56820. /**
  56821. * Gets the replacement input component
  56822. */
  56823. readonly replacement: NodeMaterialConnectionPoint;
  56824. /**
  56825. * Gets the output component
  56826. */
  56827. readonly output: NodeMaterialConnectionPoint;
  56828. protected _buildBlock(state: NodeMaterialBuildState): this;
  56829. }
  56830. }
  56831. declare module BABYLON {
  56832. /**
  56833. * Block used to posterize a value
  56834. * @see https://en.wikipedia.org/wiki/Posterization
  56835. */
  56836. export class PosterizeBlock extends NodeMaterialBlock {
  56837. /**
  56838. * Creates a new PosterizeBlock
  56839. * @param name defines the block name
  56840. */
  56841. constructor(name: string);
  56842. /**
  56843. * Gets the current class name
  56844. * @returns the class name
  56845. */
  56846. getClassName(): string;
  56847. /**
  56848. * Gets the value input component
  56849. */
  56850. readonly value: NodeMaterialConnectionPoint;
  56851. /**
  56852. * Gets the steps input component
  56853. */
  56854. readonly steps: NodeMaterialConnectionPoint;
  56855. /**
  56856. * Gets the output component
  56857. */
  56858. readonly output: NodeMaterialConnectionPoint;
  56859. protected _buildBlock(state: NodeMaterialBuildState): this;
  56860. }
  56861. }
  56862. declare module BABYLON {
  56863. /**
  56864. * Operations supported by the Wave block
  56865. */
  56866. export enum WaveBlockKind {
  56867. /** SawTooth */
  56868. SawTooth = 0,
  56869. /** Square */
  56870. Square = 1,
  56871. /** Triangle */
  56872. Triangle = 2
  56873. }
  56874. /**
  56875. * Block used to apply wave operation to floats
  56876. */
  56877. export class WaveBlock extends NodeMaterialBlock {
  56878. /**
  56879. * Gets or sets the kibnd of wave to be applied by the block
  56880. */
  56881. kind: WaveBlockKind;
  56882. /**
  56883. * Creates a new WaveBlock
  56884. * @param name defines the block name
  56885. */
  56886. constructor(name: string);
  56887. /**
  56888. * Gets the current class name
  56889. * @returns the class name
  56890. */
  56891. getClassName(): string;
  56892. /**
  56893. * Gets the input component
  56894. */
  56895. readonly input: NodeMaterialConnectionPoint;
  56896. /**
  56897. * Gets the output component
  56898. */
  56899. readonly output: NodeMaterialConnectionPoint;
  56900. protected _buildBlock(state: NodeMaterialBuildState): this;
  56901. serialize(): any;
  56902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56903. }
  56904. }
  56905. declare module BABYLON {
  56906. /**
  56907. * Class used to store a color step for the GradientBlock
  56908. */
  56909. export class GradientBlockColorStep {
  56910. /**
  56911. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56912. */
  56913. step: number;
  56914. /**
  56915. * Gets or sets the color associated with this step
  56916. */
  56917. color: Color3;
  56918. /**
  56919. * Creates a new GradientBlockColorStep
  56920. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  56921. * @param color defines the color associated with this step
  56922. */
  56923. constructor(
  56924. /**
  56925. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56926. */
  56927. step: number,
  56928. /**
  56929. * Gets or sets the color associated with this step
  56930. */
  56931. color: Color3);
  56932. }
  56933. /**
  56934. * Block used to return a color from a gradient based on an input value between 0 and 1
  56935. */
  56936. export class GradientBlock extends NodeMaterialBlock {
  56937. /**
  56938. * Gets or sets the list of color steps
  56939. */
  56940. colorSteps: GradientBlockColorStep[];
  56941. /**
  56942. * Creates a new GradientBlock
  56943. * @param name defines the block name
  56944. */
  56945. constructor(name: string);
  56946. /**
  56947. * Gets the current class name
  56948. * @returns the class name
  56949. */
  56950. getClassName(): string;
  56951. /**
  56952. * Gets the gradient input component
  56953. */
  56954. readonly gradient: NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the output component
  56957. */
  56958. readonly output: NodeMaterialConnectionPoint;
  56959. private _writeColorConstant;
  56960. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56961. serialize(): any;
  56962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56963. protected _dumpPropertiesCode(): string;
  56964. }
  56965. }
  56966. declare module BABYLON {
  56967. /**
  56968. * Block used to normalize lerp between 2 values
  56969. */
  56970. export class NLerpBlock extends NodeMaterialBlock {
  56971. /**
  56972. * Creates a new NLerpBlock
  56973. * @param name defines the block name
  56974. */
  56975. constructor(name: string);
  56976. /**
  56977. * Gets the current class name
  56978. * @returns the class name
  56979. */
  56980. getClassName(): string;
  56981. /**
  56982. * Gets the left operand input component
  56983. */
  56984. readonly left: NodeMaterialConnectionPoint;
  56985. /**
  56986. * Gets the right operand input component
  56987. */
  56988. readonly right: NodeMaterialConnectionPoint;
  56989. /**
  56990. * Gets the gradient operand input component
  56991. */
  56992. readonly gradient: NodeMaterialConnectionPoint;
  56993. /**
  56994. * Gets the output component
  56995. */
  56996. readonly output: NodeMaterialConnectionPoint;
  56997. protected _buildBlock(state: NodeMaterialBuildState): this;
  56998. }
  56999. }
  57000. declare module BABYLON {
  57001. /**
  57002. * block used to Generate a Worley Noise 3D Noise Pattern
  57003. */
  57004. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  57005. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57006. manhattanDistance: boolean;
  57007. /**
  57008. * Creates a new WorleyNoise3DBlock
  57009. * @param name defines the block name
  57010. */
  57011. constructor(name: string);
  57012. /**
  57013. * Gets the current class name
  57014. * @returns the class name
  57015. */
  57016. getClassName(): string;
  57017. /**
  57018. * Gets the seed input component
  57019. */
  57020. readonly seed: NodeMaterialConnectionPoint;
  57021. /**
  57022. * Gets the jitter input component
  57023. */
  57024. readonly jitter: NodeMaterialConnectionPoint;
  57025. /**
  57026. * Gets the output component
  57027. */
  57028. readonly output: NodeMaterialConnectionPoint;
  57029. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57030. /**
  57031. * Exposes the properties to the UI?
  57032. */
  57033. protected _dumpPropertiesCode(): string;
  57034. /**
  57035. * Exposes the properties to the Seralize?
  57036. */
  57037. serialize(): any;
  57038. /**
  57039. * Exposes the properties to the deseralize?
  57040. */
  57041. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57042. }
  57043. }
  57044. declare module BABYLON {
  57045. /**
  57046. * block used to Generate a Simplex Perlin 3d Noise Pattern
  57047. */
  57048. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  57049. /**
  57050. * Creates a new SimplexPerlin3DBlock
  57051. * @param name defines the block name
  57052. */
  57053. constructor(name: string);
  57054. /**
  57055. * Gets the current class name
  57056. * @returns the class name
  57057. */
  57058. getClassName(): string;
  57059. /**
  57060. * Gets the seed operand input component
  57061. */
  57062. readonly seed: NodeMaterialConnectionPoint;
  57063. /**
  57064. * Gets the output component
  57065. */
  57066. readonly output: NodeMaterialConnectionPoint;
  57067. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57068. }
  57069. }
  57070. declare module BABYLON {
  57071. /**
  57072. * Block used to blend normals
  57073. */
  57074. export class NormalBlendBlock extends NodeMaterialBlock {
  57075. /**
  57076. * Creates a new NormalBlendBlock
  57077. * @param name defines the block name
  57078. */
  57079. constructor(name: string);
  57080. /**
  57081. * Gets the current class name
  57082. * @returns the class name
  57083. */
  57084. getClassName(): string;
  57085. /**
  57086. * Gets the first input component
  57087. */
  57088. readonly normalMap0: NodeMaterialConnectionPoint;
  57089. /**
  57090. * Gets the second input component
  57091. */
  57092. readonly normalMap1: NodeMaterialConnectionPoint;
  57093. /**
  57094. * Gets the output component
  57095. */
  57096. readonly output: NodeMaterialConnectionPoint;
  57097. protected _buildBlock(state: NodeMaterialBuildState): this;
  57098. }
  57099. }
  57100. declare module BABYLON {
  57101. /**
  57102. * Block used to rotate a 2d vector by a given angle
  57103. */
  57104. export class Rotate2dBlock extends NodeMaterialBlock {
  57105. /**
  57106. * Creates a new Rotate2dBlock
  57107. * @param name defines the block name
  57108. */
  57109. constructor(name: string);
  57110. /**
  57111. * Gets the current class name
  57112. * @returns the class name
  57113. */
  57114. getClassName(): string;
  57115. /**
  57116. * Gets the input vector
  57117. */
  57118. readonly input: NodeMaterialConnectionPoint;
  57119. /**
  57120. * Gets the input angle
  57121. */
  57122. readonly angle: NodeMaterialConnectionPoint;
  57123. /**
  57124. * Gets the output component
  57125. */
  57126. readonly output: NodeMaterialConnectionPoint;
  57127. autoConfigure(material: NodeMaterial): void;
  57128. protected _buildBlock(state: NodeMaterialBuildState): this;
  57129. }
  57130. }
  57131. declare module BABYLON {
  57132. /**
  57133. * Block used to get the reflected vector from a direction and a normal
  57134. */
  57135. export class ReflectBlock extends NodeMaterialBlock {
  57136. /**
  57137. * Creates a new ReflectBlock
  57138. * @param name defines the block name
  57139. */
  57140. constructor(name: string);
  57141. /**
  57142. * Gets the current class name
  57143. * @returns the class name
  57144. */
  57145. getClassName(): string;
  57146. /**
  57147. * Gets the incident component
  57148. */
  57149. readonly incident: NodeMaterialConnectionPoint;
  57150. /**
  57151. * Gets the normal component
  57152. */
  57153. readonly normal: NodeMaterialConnectionPoint;
  57154. /**
  57155. * Gets the output component
  57156. */
  57157. readonly output: NodeMaterialConnectionPoint;
  57158. protected _buildBlock(state: NodeMaterialBuildState): this;
  57159. }
  57160. }
  57161. declare module BABYLON {
  57162. /**
  57163. * Block used to get the refracted vector from a direction and a normal
  57164. */
  57165. export class RefractBlock extends NodeMaterialBlock {
  57166. /**
  57167. * Creates a new RefractBlock
  57168. * @param name defines the block name
  57169. */
  57170. constructor(name: string);
  57171. /**
  57172. * Gets the current class name
  57173. * @returns the class name
  57174. */
  57175. getClassName(): string;
  57176. /**
  57177. * Gets the incident component
  57178. */
  57179. readonly incident: NodeMaterialConnectionPoint;
  57180. /**
  57181. * Gets the normal component
  57182. */
  57183. readonly normal: NodeMaterialConnectionPoint;
  57184. /**
  57185. * Gets the index of refraction component
  57186. */
  57187. readonly ior: NodeMaterialConnectionPoint;
  57188. /**
  57189. * Gets the output component
  57190. */
  57191. readonly output: NodeMaterialConnectionPoint;
  57192. protected _buildBlock(state: NodeMaterialBuildState): this;
  57193. }
  57194. }
  57195. declare module BABYLON {
  57196. /**
  57197. * Block used to desaturate a color
  57198. */
  57199. export class DesaturateBlock extends NodeMaterialBlock {
  57200. /**
  57201. * Creates a new DesaturateBlock
  57202. * @param name defines the block name
  57203. */
  57204. constructor(name: string);
  57205. /**
  57206. * Gets the current class name
  57207. * @returns the class name
  57208. */
  57209. getClassName(): string;
  57210. /**
  57211. * Gets the color operand input component
  57212. */
  57213. readonly color: NodeMaterialConnectionPoint;
  57214. /**
  57215. * Gets the level operand input component
  57216. */
  57217. readonly level: NodeMaterialConnectionPoint;
  57218. /**
  57219. * Gets the output component
  57220. */
  57221. readonly output: NodeMaterialConnectionPoint;
  57222. protected _buildBlock(state: NodeMaterialBuildState): this;
  57223. }
  57224. }
  57225. declare module BABYLON {
  57226. /**
  57227. * Effect Render Options
  57228. */
  57229. export interface IEffectRendererOptions {
  57230. /**
  57231. * Defines the vertices positions.
  57232. */
  57233. positions?: number[];
  57234. /**
  57235. * Defines the indices.
  57236. */
  57237. indices?: number[];
  57238. }
  57239. /**
  57240. * Helper class to render one or more effects
  57241. */
  57242. export class EffectRenderer {
  57243. private engine;
  57244. private static _DefaultOptions;
  57245. private _vertexBuffers;
  57246. private _indexBuffer;
  57247. private _ringBufferIndex;
  57248. private _ringScreenBuffer;
  57249. private _fullscreenViewport;
  57250. private _getNextFrameBuffer;
  57251. /**
  57252. * Creates an effect renderer
  57253. * @param engine the engine to use for rendering
  57254. * @param options defines the options of the effect renderer
  57255. */
  57256. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  57257. /**
  57258. * Sets the current viewport in normalized coordinates 0-1
  57259. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57260. */
  57261. setViewport(viewport?: Viewport): void;
  57262. /**
  57263. * Binds the embedded attributes buffer to the effect.
  57264. * @param effect Defines the effect to bind the attributes for
  57265. */
  57266. bindBuffers(effect: Effect): void;
  57267. /**
  57268. * Sets the current effect wrapper to use during draw.
  57269. * The effect needs to be ready before calling this api.
  57270. * This also sets the default full screen position attribute.
  57271. * @param effectWrapper Defines the effect to draw with
  57272. */
  57273. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57274. /**
  57275. * Draws a full screen quad.
  57276. */
  57277. draw(): void;
  57278. /**
  57279. * renders one or more effects to a specified texture
  57280. * @param effectWrappers list of effects to renderer
  57281. * @param outputTexture texture to draw to, if null it will render to the screen
  57282. */
  57283. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57284. /**
  57285. * Disposes of the effect renderer
  57286. */
  57287. dispose(): void;
  57288. }
  57289. /**
  57290. * Options to create an EffectWrapper
  57291. */
  57292. interface EffectWrapperCreationOptions {
  57293. /**
  57294. * Engine to use to create the effect
  57295. */
  57296. engine: ThinEngine;
  57297. /**
  57298. * Fragment shader for the effect
  57299. */
  57300. fragmentShader: string;
  57301. /**
  57302. * Vertex shader for the effect
  57303. */
  57304. vertexShader?: string;
  57305. /**
  57306. * Attributes to use in the shader
  57307. */
  57308. attributeNames?: Array<string>;
  57309. /**
  57310. * Uniforms to use in the shader
  57311. */
  57312. uniformNames?: Array<string>;
  57313. /**
  57314. * Texture sampler names to use in the shader
  57315. */
  57316. samplerNames?: Array<string>;
  57317. /**
  57318. * The friendly name of the effect displayed in Spector.
  57319. */
  57320. name?: string;
  57321. }
  57322. /**
  57323. * Wraps an effect to be used for rendering
  57324. */
  57325. export class EffectWrapper {
  57326. /**
  57327. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57328. */
  57329. onApplyObservable: Observable<{}>;
  57330. /**
  57331. * The underlying effect
  57332. */
  57333. effect: Effect;
  57334. /**
  57335. * Creates an effect to be renderer
  57336. * @param creationOptions options to create the effect
  57337. */
  57338. constructor(creationOptions: EffectWrapperCreationOptions);
  57339. /**
  57340. * Disposes of the effect wrapper
  57341. */
  57342. dispose(): void;
  57343. }
  57344. }
  57345. declare module BABYLON {
  57346. /**
  57347. * Helper class to push actions to a pool of workers.
  57348. */
  57349. export class WorkerPool implements IDisposable {
  57350. private _workerInfos;
  57351. private _pendingActions;
  57352. /**
  57353. * Constructor
  57354. * @param workers Array of workers to use for actions
  57355. */
  57356. constructor(workers: Array<Worker>);
  57357. /**
  57358. * Terminates all workers and clears any pending actions.
  57359. */
  57360. dispose(): void;
  57361. /**
  57362. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57363. * pended until a worker has completed its action.
  57364. * @param action The action to perform. Call onComplete when the action is complete.
  57365. */
  57366. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57367. private _execute;
  57368. }
  57369. }
  57370. declare module BABYLON {
  57371. /**
  57372. * Configuration for Draco compression
  57373. */
  57374. export interface IDracoCompressionConfiguration {
  57375. /**
  57376. * Configuration for the decoder.
  57377. */
  57378. decoder: {
  57379. /**
  57380. * The url to the WebAssembly module.
  57381. */
  57382. wasmUrl?: string;
  57383. /**
  57384. * The url to the WebAssembly binary.
  57385. */
  57386. wasmBinaryUrl?: string;
  57387. /**
  57388. * The url to the fallback JavaScript module.
  57389. */
  57390. fallbackUrl?: string;
  57391. };
  57392. }
  57393. /**
  57394. * Draco compression (https://google.github.io/draco/)
  57395. *
  57396. * This class wraps the Draco module.
  57397. *
  57398. * **Encoder**
  57399. *
  57400. * The encoder is not currently implemented.
  57401. *
  57402. * **Decoder**
  57403. *
  57404. * 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.
  57405. *
  57406. * To update the configuration, use the following code:
  57407. * ```javascript
  57408. * DracoCompression.Configuration = {
  57409. * decoder: {
  57410. * wasmUrl: "<url to the WebAssembly library>",
  57411. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57412. * fallbackUrl: "<url to the fallback JavaScript library>",
  57413. * }
  57414. * };
  57415. * ```
  57416. *
  57417. * 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.
  57418. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57419. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57420. *
  57421. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57422. * ```javascript
  57423. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57424. * ```
  57425. *
  57426. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57427. */
  57428. export class DracoCompression implements IDisposable {
  57429. private _workerPoolPromise?;
  57430. private _decoderModulePromise?;
  57431. /**
  57432. * The configuration. Defaults to the following urls:
  57433. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57434. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57435. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57436. */
  57437. static Configuration: IDracoCompressionConfiguration;
  57438. /**
  57439. * Returns true if the decoder configuration is available.
  57440. */
  57441. static readonly DecoderAvailable: boolean;
  57442. /**
  57443. * Default number of workers to create when creating the draco compression object.
  57444. */
  57445. static DefaultNumWorkers: number;
  57446. private static GetDefaultNumWorkers;
  57447. private static _Default;
  57448. /**
  57449. * Default instance for the draco compression object.
  57450. */
  57451. static readonly Default: DracoCompression;
  57452. /**
  57453. * Constructor
  57454. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57455. */
  57456. constructor(numWorkers?: number);
  57457. /**
  57458. * Stop all async operations and release resources.
  57459. */
  57460. dispose(): void;
  57461. /**
  57462. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57463. * @returns a promise that resolves when ready
  57464. */
  57465. whenReadyAsync(): Promise<void>;
  57466. /**
  57467. * Decode Draco compressed mesh data to vertex data.
  57468. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57469. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57470. * @returns A promise that resolves with the decoded vertex data
  57471. */
  57472. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57473. [kind: string]: number;
  57474. }): Promise<VertexData>;
  57475. }
  57476. }
  57477. declare module BABYLON {
  57478. /**
  57479. * Class for building Constructive Solid Geometry
  57480. */
  57481. export class CSG {
  57482. private polygons;
  57483. /**
  57484. * The world matrix
  57485. */
  57486. matrix: Matrix;
  57487. /**
  57488. * Stores the position
  57489. */
  57490. position: Vector3;
  57491. /**
  57492. * Stores the rotation
  57493. */
  57494. rotation: Vector3;
  57495. /**
  57496. * Stores the rotation quaternion
  57497. */
  57498. rotationQuaternion: Nullable<Quaternion>;
  57499. /**
  57500. * Stores the scaling vector
  57501. */
  57502. scaling: Vector3;
  57503. /**
  57504. * Convert the Mesh to CSG
  57505. * @param mesh The Mesh to convert to CSG
  57506. * @returns A new CSG from the Mesh
  57507. */
  57508. static FromMesh(mesh: Mesh): CSG;
  57509. /**
  57510. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57511. * @param polygons Polygons used to construct a CSG solid
  57512. */
  57513. private static FromPolygons;
  57514. /**
  57515. * Clones, or makes a deep copy, of the CSG
  57516. * @returns A new CSG
  57517. */
  57518. clone(): CSG;
  57519. /**
  57520. * Unions this CSG with another CSG
  57521. * @param csg The CSG to union against this CSG
  57522. * @returns The unioned CSG
  57523. */
  57524. union(csg: CSG): CSG;
  57525. /**
  57526. * Unions this CSG with another CSG in place
  57527. * @param csg The CSG to union against this CSG
  57528. */
  57529. unionInPlace(csg: CSG): void;
  57530. /**
  57531. * Subtracts this CSG with another CSG
  57532. * @param csg The CSG to subtract against this CSG
  57533. * @returns A new CSG
  57534. */
  57535. subtract(csg: CSG): CSG;
  57536. /**
  57537. * Subtracts this CSG with another CSG in place
  57538. * @param csg The CSG to subtact against this CSG
  57539. */
  57540. subtractInPlace(csg: CSG): void;
  57541. /**
  57542. * Intersect this CSG with another CSG
  57543. * @param csg The CSG to intersect against this CSG
  57544. * @returns A new CSG
  57545. */
  57546. intersect(csg: CSG): CSG;
  57547. /**
  57548. * Intersects this CSG with another CSG in place
  57549. * @param csg The CSG to intersect against this CSG
  57550. */
  57551. intersectInPlace(csg: CSG): void;
  57552. /**
  57553. * Return a new CSG solid with solid and empty space switched. This solid is
  57554. * not modified.
  57555. * @returns A new CSG solid with solid and empty space switched
  57556. */
  57557. inverse(): CSG;
  57558. /**
  57559. * Inverses the CSG in place
  57560. */
  57561. inverseInPlace(): void;
  57562. /**
  57563. * This is used to keep meshes transformations so they can be restored
  57564. * when we build back a Babylon Mesh
  57565. * NB : All CSG operations are performed in world coordinates
  57566. * @param csg The CSG to copy the transform attributes from
  57567. * @returns This CSG
  57568. */
  57569. copyTransformAttributes(csg: CSG): CSG;
  57570. /**
  57571. * Build Raw mesh from CSG
  57572. * Coordinates here are in world space
  57573. * @param name The name of the mesh geometry
  57574. * @param scene The Scene
  57575. * @param keepSubMeshes Specifies if the submeshes should be kept
  57576. * @returns A new Mesh
  57577. */
  57578. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57579. /**
  57580. * Build Mesh from CSG taking material and transforms into account
  57581. * @param name The name of the Mesh
  57582. * @param material The material of the Mesh
  57583. * @param scene The Scene
  57584. * @param keepSubMeshes Specifies if submeshes should be kept
  57585. * @returns The new Mesh
  57586. */
  57587. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57588. }
  57589. }
  57590. declare module BABYLON {
  57591. /**
  57592. * Class used to create a trail following a mesh
  57593. */
  57594. export class TrailMesh extends Mesh {
  57595. private _generator;
  57596. private _autoStart;
  57597. private _running;
  57598. private _diameter;
  57599. private _length;
  57600. private _sectionPolygonPointsCount;
  57601. private _sectionVectors;
  57602. private _sectionNormalVectors;
  57603. private _beforeRenderObserver;
  57604. /**
  57605. * @constructor
  57606. * @param name The value used by scene.getMeshByName() to do a lookup.
  57607. * @param generator The mesh to generate a trail.
  57608. * @param scene The scene to add this mesh to.
  57609. * @param diameter Diameter of trailing mesh. Default is 1.
  57610. * @param length Length of trailing mesh. Default is 60.
  57611. * @param autoStart Automatically start trailing mesh. Default true.
  57612. */
  57613. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57614. /**
  57615. * "TrailMesh"
  57616. * @returns "TrailMesh"
  57617. */
  57618. getClassName(): string;
  57619. private _createMesh;
  57620. /**
  57621. * Start trailing mesh.
  57622. */
  57623. start(): void;
  57624. /**
  57625. * Stop trailing mesh.
  57626. */
  57627. stop(): void;
  57628. /**
  57629. * Update trailing mesh geometry.
  57630. */
  57631. update(): void;
  57632. /**
  57633. * Returns a new TrailMesh object.
  57634. * @param name is a string, the name given to the new mesh
  57635. * @param newGenerator use new generator object for cloned trail mesh
  57636. * @returns a new mesh
  57637. */
  57638. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57639. /**
  57640. * Serializes this trail mesh
  57641. * @param serializationObject object to write serialization to
  57642. */
  57643. serialize(serializationObject: any): void;
  57644. /**
  57645. * Parses a serialized trail mesh
  57646. * @param parsedMesh the serialized mesh
  57647. * @param scene the scene to create the trail mesh in
  57648. * @returns the created trail mesh
  57649. */
  57650. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57651. }
  57652. }
  57653. declare module BABYLON {
  57654. /**
  57655. * Class containing static functions to help procedurally build meshes
  57656. */
  57657. export class TiledBoxBuilder {
  57658. /**
  57659. * Creates a box mesh
  57660. * 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)
  57661. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57663. * * 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
  57664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57665. * @param name defines the name of the mesh
  57666. * @param options defines the options used to create the mesh
  57667. * @param scene defines the hosting scene
  57668. * @returns the box mesh
  57669. */
  57670. static CreateTiledBox(name: string, options: {
  57671. pattern?: number;
  57672. width?: number;
  57673. height?: number;
  57674. depth?: number;
  57675. tileSize?: number;
  57676. tileWidth?: number;
  57677. tileHeight?: number;
  57678. alignHorizontal?: number;
  57679. alignVertical?: number;
  57680. faceUV?: Vector4[];
  57681. faceColors?: Color4[];
  57682. sideOrientation?: number;
  57683. updatable?: boolean;
  57684. }, scene?: Nullable<Scene>): Mesh;
  57685. }
  57686. }
  57687. declare module BABYLON {
  57688. /**
  57689. * Class containing static functions to help procedurally build meshes
  57690. */
  57691. export class TorusKnotBuilder {
  57692. /**
  57693. * Creates a torus knot mesh
  57694. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57695. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57696. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57697. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57699. * * 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
  57700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57701. * @param name defines the name of the mesh
  57702. * @param options defines the options used to create the mesh
  57703. * @param scene defines the hosting scene
  57704. * @returns the torus knot mesh
  57705. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57706. */
  57707. static CreateTorusKnot(name: string, options: {
  57708. radius?: number;
  57709. tube?: number;
  57710. radialSegments?: number;
  57711. tubularSegments?: number;
  57712. p?: number;
  57713. q?: number;
  57714. updatable?: boolean;
  57715. sideOrientation?: number;
  57716. frontUVs?: Vector4;
  57717. backUVs?: Vector4;
  57718. }, scene: any): Mesh;
  57719. }
  57720. }
  57721. declare module BABYLON {
  57722. /**
  57723. * Polygon
  57724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57725. */
  57726. export class Polygon {
  57727. /**
  57728. * Creates a rectangle
  57729. * @param xmin bottom X coord
  57730. * @param ymin bottom Y coord
  57731. * @param xmax top X coord
  57732. * @param ymax top Y coord
  57733. * @returns points that make the resulting rectation
  57734. */
  57735. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57736. /**
  57737. * Creates a circle
  57738. * @param radius radius of circle
  57739. * @param cx scale in x
  57740. * @param cy scale in y
  57741. * @param numberOfSides number of sides that make up the circle
  57742. * @returns points that make the resulting circle
  57743. */
  57744. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57745. /**
  57746. * Creates a polygon from input string
  57747. * @param input Input polygon data
  57748. * @returns the parsed points
  57749. */
  57750. static Parse(input: string): Vector2[];
  57751. /**
  57752. * Starts building a polygon from x and y coordinates
  57753. * @param x x coordinate
  57754. * @param y y coordinate
  57755. * @returns the started path2
  57756. */
  57757. static StartingAt(x: number, y: number): Path2;
  57758. }
  57759. /**
  57760. * Builds a polygon
  57761. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57762. */
  57763. export class PolygonMeshBuilder {
  57764. private _points;
  57765. private _outlinepoints;
  57766. private _holes;
  57767. private _name;
  57768. private _scene;
  57769. private _epoints;
  57770. private _eholes;
  57771. private _addToepoint;
  57772. /**
  57773. * Babylon reference to the earcut plugin.
  57774. */
  57775. bjsEarcut: any;
  57776. /**
  57777. * Creates a PolygonMeshBuilder
  57778. * @param name name of the builder
  57779. * @param contours Path of the polygon
  57780. * @param scene scene to add to when creating the mesh
  57781. * @param earcutInjection can be used to inject your own earcut reference
  57782. */
  57783. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57784. /**
  57785. * Adds a whole within the polygon
  57786. * @param hole Array of points defining the hole
  57787. * @returns this
  57788. */
  57789. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57790. /**
  57791. * Creates the polygon
  57792. * @param updatable If the mesh should be updatable
  57793. * @param depth The depth of the mesh created
  57794. * @returns the created mesh
  57795. */
  57796. build(updatable?: boolean, depth?: number): Mesh;
  57797. /**
  57798. * Creates the polygon
  57799. * @param depth The depth of the mesh created
  57800. * @returns the created VertexData
  57801. */
  57802. buildVertexData(depth?: number): VertexData;
  57803. /**
  57804. * Adds a side to the polygon
  57805. * @param positions points that make the polygon
  57806. * @param normals normals of the polygon
  57807. * @param uvs uvs of the polygon
  57808. * @param indices indices of the polygon
  57809. * @param bounds bounds of the polygon
  57810. * @param points points of the polygon
  57811. * @param depth depth of the polygon
  57812. * @param flip flip of the polygon
  57813. */
  57814. private addSide;
  57815. }
  57816. }
  57817. declare module BABYLON {
  57818. /**
  57819. * Class containing static functions to help procedurally build meshes
  57820. */
  57821. export class PolygonBuilder {
  57822. /**
  57823. * Creates a polygon mesh
  57824. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57825. * * 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
  57826. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57828. * * 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)
  57829. * * Remember you can only change the shape positions, not their number when updating a polygon
  57830. * @param name defines the name of the mesh
  57831. * @param options defines the options used to create the mesh
  57832. * @param scene defines the hosting scene
  57833. * @param earcutInjection can be used to inject your own earcut reference
  57834. * @returns the polygon mesh
  57835. */
  57836. static CreatePolygon(name: string, options: {
  57837. shape: Vector3[];
  57838. holes?: Vector3[][];
  57839. depth?: number;
  57840. faceUV?: Vector4[];
  57841. faceColors?: Color4[];
  57842. updatable?: boolean;
  57843. sideOrientation?: number;
  57844. frontUVs?: Vector4;
  57845. backUVs?: Vector4;
  57846. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57847. /**
  57848. * Creates an extruded polygon mesh, with depth in the Y direction.
  57849. * * 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)
  57850. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57851. * @param name defines the name of the mesh
  57852. * @param options defines the options used to create the mesh
  57853. * @param scene defines the hosting scene
  57854. * @param earcutInjection can be used to inject your own earcut reference
  57855. * @returns the polygon mesh
  57856. */
  57857. static ExtrudePolygon(name: string, options: {
  57858. shape: Vector3[];
  57859. holes?: Vector3[][];
  57860. depth?: number;
  57861. faceUV?: Vector4[];
  57862. faceColors?: Color4[];
  57863. updatable?: boolean;
  57864. sideOrientation?: number;
  57865. frontUVs?: Vector4;
  57866. backUVs?: Vector4;
  57867. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57868. }
  57869. }
  57870. declare module BABYLON {
  57871. /**
  57872. * Class containing static functions to help procedurally build meshes
  57873. */
  57874. export class LatheBuilder {
  57875. /**
  57876. * Creates lathe mesh.
  57877. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57878. * * 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
  57879. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57880. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57881. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57882. * * 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
  57883. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57884. * * 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
  57885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57886. * * 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
  57887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57889. * @param name defines the name of the mesh
  57890. * @param options defines the options used to create the mesh
  57891. * @param scene defines the hosting scene
  57892. * @returns the lathe mesh
  57893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57894. */
  57895. static CreateLathe(name: string, options: {
  57896. shape: Vector3[];
  57897. radius?: number;
  57898. tessellation?: number;
  57899. clip?: number;
  57900. arc?: number;
  57901. closed?: boolean;
  57902. updatable?: boolean;
  57903. sideOrientation?: number;
  57904. frontUVs?: Vector4;
  57905. backUVs?: Vector4;
  57906. cap?: number;
  57907. invertUV?: boolean;
  57908. }, scene?: Nullable<Scene>): Mesh;
  57909. }
  57910. }
  57911. declare module BABYLON {
  57912. /**
  57913. * Class containing static functions to help procedurally build meshes
  57914. */
  57915. export class TiledPlaneBuilder {
  57916. /**
  57917. * Creates a tiled plane mesh
  57918. * * The parameter `pattern` will, depending on value, do nothing or
  57919. * * * flip (reflect about central vertical) alternate tiles across and up
  57920. * * * flip every tile on alternate rows
  57921. * * * rotate (180 degs) alternate tiles across and up
  57922. * * * rotate every tile on alternate rows
  57923. * * * flip and rotate alternate tiles across and up
  57924. * * * flip and rotate every tile on alternate rows
  57925. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57926. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57927. * * 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
  57928. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57929. * * 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)
  57930. * * 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)
  57931. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57932. * @param name defines the name of the mesh
  57933. * @param options defines the options used to create the mesh
  57934. * @param scene defines the hosting scene
  57935. * @returns the box mesh
  57936. */
  57937. static CreateTiledPlane(name: string, options: {
  57938. pattern?: number;
  57939. tileSize?: number;
  57940. tileWidth?: number;
  57941. tileHeight?: number;
  57942. size?: number;
  57943. width?: number;
  57944. height?: number;
  57945. alignHorizontal?: number;
  57946. alignVertical?: number;
  57947. sideOrientation?: number;
  57948. frontUVs?: Vector4;
  57949. backUVs?: Vector4;
  57950. updatable?: boolean;
  57951. }, scene?: Nullable<Scene>): Mesh;
  57952. }
  57953. }
  57954. declare module BABYLON {
  57955. /**
  57956. * Class containing static functions to help procedurally build meshes
  57957. */
  57958. export class TubeBuilder {
  57959. /**
  57960. * Creates a tube mesh.
  57961. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57962. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57963. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57964. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57965. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57966. * * 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)
  57967. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57968. * * 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
  57969. * * 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
  57970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57971. * * 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
  57972. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57974. * @param name defines the name of the mesh
  57975. * @param options defines the options used to create the mesh
  57976. * @param scene defines the hosting scene
  57977. * @returns the tube mesh
  57978. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57979. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57980. */
  57981. static CreateTube(name: string, options: {
  57982. path: Vector3[];
  57983. radius?: number;
  57984. tessellation?: number;
  57985. radiusFunction?: {
  57986. (i: number, distance: number): number;
  57987. };
  57988. cap?: number;
  57989. arc?: number;
  57990. updatable?: boolean;
  57991. sideOrientation?: number;
  57992. frontUVs?: Vector4;
  57993. backUVs?: Vector4;
  57994. instance?: Mesh;
  57995. invertUV?: boolean;
  57996. }, scene?: Nullable<Scene>): Mesh;
  57997. }
  57998. }
  57999. declare module BABYLON {
  58000. /**
  58001. * Class containing static functions to help procedurally build meshes
  58002. */
  58003. export class IcoSphereBuilder {
  58004. /**
  58005. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58006. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58007. * * 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`)
  58008. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58009. * * 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
  58010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58011. * * 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
  58012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58013. * @param name defines the name of the mesh
  58014. * @param options defines the options used to create the mesh
  58015. * @param scene defines the hosting scene
  58016. * @returns the icosahedron mesh
  58017. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58018. */
  58019. static CreateIcoSphere(name: string, options: {
  58020. radius?: number;
  58021. radiusX?: number;
  58022. radiusY?: number;
  58023. radiusZ?: number;
  58024. flat?: boolean;
  58025. subdivisions?: number;
  58026. sideOrientation?: number;
  58027. frontUVs?: Vector4;
  58028. backUVs?: Vector4;
  58029. updatable?: boolean;
  58030. }, scene?: Nullable<Scene>): Mesh;
  58031. }
  58032. }
  58033. declare module BABYLON {
  58034. /**
  58035. * Class containing static functions to help procedurally build meshes
  58036. */
  58037. export class DecalBuilder {
  58038. /**
  58039. * Creates a decal mesh.
  58040. * 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
  58041. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58042. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58043. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58044. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58045. * @param name defines the name of the mesh
  58046. * @param sourceMesh defines the mesh where the decal must be applied
  58047. * @param options defines the options used to create the mesh
  58048. * @param scene defines the hosting scene
  58049. * @returns the decal mesh
  58050. * @see https://doc.babylonjs.com/how_to/decals
  58051. */
  58052. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58053. position?: Vector3;
  58054. normal?: Vector3;
  58055. size?: Vector3;
  58056. angle?: number;
  58057. }): Mesh;
  58058. }
  58059. }
  58060. declare module BABYLON {
  58061. /**
  58062. * Class containing static functions to help procedurally build meshes
  58063. */
  58064. export class MeshBuilder {
  58065. /**
  58066. * Creates a box mesh
  58067. * * The parameter `size` sets the size (float) of each box side (default 1)
  58068. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58069. * * 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)
  58070. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58072. * * 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
  58073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58074. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58075. * @param name defines the name of the mesh
  58076. * @param options defines the options used to create the mesh
  58077. * @param scene defines the hosting scene
  58078. * @returns the box mesh
  58079. */
  58080. static CreateBox(name: string, options: {
  58081. size?: number;
  58082. width?: number;
  58083. height?: number;
  58084. depth?: number;
  58085. faceUV?: Vector4[];
  58086. faceColors?: Color4[];
  58087. sideOrientation?: number;
  58088. frontUVs?: Vector4;
  58089. backUVs?: Vector4;
  58090. updatable?: boolean;
  58091. }, scene?: Nullable<Scene>): Mesh;
  58092. /**
  58093. * Creates a tiled box mesh
  58094. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58096. * @param name defines the name of the mesh
  58097. * @param options defines the options used to create the mesh
  58098. * @param scene defines the hosting scene
  58099. * @returns the tiled box mesh
  58100. */
  58101. static CreateTiledBox(name: string, options: {
  58102. pattern?: number;
  58103. size?: number;
  58104. width?: number;
  58105. height?: number;
  58106. depth: number;
  58107. tileSize?: number;
  58108. tileWidth?: number;
  58109. tileHeight?: number;
  58110. faceUV?: Vector4[];
  58111. faceColors?: Color4[];
  58112. alignHorizontal?: number;
  58113. alignVertical?: number;
  58114. sideOrientation?: number;
  58115. updatable?: boolean;
  58116. }, scene?: Nullable<Scene>): Mesh;
  58117. /**
  58118. * Creates a sphere mesh
  58119. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58120. * * 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`)
  58121. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58122. * * 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
  58123. * * 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)
  58124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58125. * * 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
  58126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58127. * @param name defines the name of the mesh
  58128. * @param options defines the options used to create the mesh
  58129. * @param scene defines the hosting scene
  58130. * @returns the sphere mesh
  58131. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58132. */
  58133. static CreateSphere(name: string, options: {
  58134. segments?: number;
  58135. diameter?: number;
  58136. diameterX?: number;
  58137. diameterY?: number;
  58138. diameterZ?: number;
  58139. arc?: number;
  58140. slice?: number;
  58141. sideOrientation?: number;
  58142. frontUVs?: Vector4;
  58143. backUVs?: Vector4;
  58144. updatable?: boolean;
  58145. }, scene?: Nullable<Scene>): Mesh;
  58146. /**
  58147. * Creates a plane polygonal mesh. By default, this is a disc
  58148. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58149. * * 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
  58150. * * 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
  58151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58152. * * 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
  58153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58154. * @param name defines the name of the mesh
  58155. * @param options defines the options used to create the mesh
  58156. * @param scene defines the hosting scene
  58157. * @returns the plane polygonal mesh
  58158. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58159. */
  58160. static CreateDisc(name: string, options: {
  58161. radius?: number;
  58162. tessellation?: number;
  58163. arc?: number;
  58164. updatable?: boolean;
  58165. sideOrientation?: number;
  58166. frontUVs?: Vector4;
  58167. backUVs?: Vector4;
  58168. }, scene?: Nullable<Scene>): Mesh;
  58169. /**
  58170. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58171. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58172. * * 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`)
  58173. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58174. * * 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
  58175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58176. * * 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
  58177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58178. * @param name defines the name of the mesh
  58179. * @param options defines the options used to create the mesh
  58180. * @param scene defines the hosting scene
  58181. * @returns the icosahedron mesh
  58182. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58183. */
  58184. static CreateIcoSphere(name: string, options: {
  58185. radius?: number;
  58186. radiusX?: number;
  58187. radiusY?: number;
  58188. radiusZ?: number;
  58189. flat?: boolean;
  58190. subdivisions?: number;
  58191. sideOrientation?: number;
  58192. frontUVs?: Vector4;
  58193. backUVs?: Vector4;
  58194. updatable?: boolean;
  58195. }, scene?: Nullable<Scene>): Mesh;
  58196. /**
  58197. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58198. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58199. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58200. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58201. * * 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
  58202. * * 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
  58203. * * 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
  58204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58205. * * 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
  58206. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58207. * * 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
  58208. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58209. * * 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
  58210. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58212. * @param name defines the name of the mesh
  58213. * @param options defines the options used to create the mesh
  58214. * @param scene defines the hosting scene
  58215. * @returns the ribbon mesh
  58216. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58217. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58218. */
  58219. static CreateRibbon(name: string, options: {
  58220. pathArray: Vector3[][];
  58221. closeArray?: boolean;
  58222. closePath?: boolean;
  58223. offset?: number;
  58224. updatable?: boolean;
  58225. sideOrientation?: number;
  58226. frontUVs?: Vector4;
  58227. backUVs?: Vector4;
  58228. instance?: Mesh;
  58229. invertUV?: boolean;
  58230. uvs?: Vector2[];
  58231. colors?: Color4[];
  58232. }, scene?: Nullable<Scene>): Mesh;
  58233. /**
  58234. * Creates a cylinder or a cone mesh
  58235. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58236. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58237. * * 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.
  58238. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58239. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58240. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58241. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58242. * * 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).
  58243. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58244. * * 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).
  58245. * * 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
  58246. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58247. * * 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
  58248. * * 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.
  58249. * * If `enclose` is false, a ring surface is one element.
  58250. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58251. * * 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
  58252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58253. * * 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
  58254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58255. * @param name defines the name of the mesh
  58256. * @param options defines the options used to create the mesh
  58257. * @param scene defines the hosting scene
  58258. * @returns the cylinder mesh
  58259. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58260. */
  58261. static CreateCylinder(name: string, options: {
  58262. height?: number;
  58263. diameterTop?: number;
  58264. diameterBottom?: number;
  58265. diameter?: number;
  58266. tessellation?: number;
  58267. subdivisions?: number;
  58268. arc?: number;
  58269. faceColors?: Color4[];
  58270. faceUV?: Vector4[];
  58271. updatable?: boolean;
  58272. hasRings?: boolean;
  58273. enclose?: boolean;
  58274. cap?: number;
  58275. sideOrientation?: number;
  58276. frontUVs?: Vector4;
  58277. backUVs?: Vector4;
  58278. }, scene?: Nullable<Scene>): Mesh;
  58279. /**
  58280. * Creates a torus mesh
  58281. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58282. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58283. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58285. * * 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
  58286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58287. * @param name defines the name of the mesh
  58288. * @param options defines the options used to create the mesh
  58289. * @param scene defines the hosting scene
  58290. * @returns the torus mesh
  58291. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58292. */
  58293. static CreateTorus(name: string, options: {
  58294. diameter?: number;
  58295. thickness?: number;
  58296. tessellation?: number;
  58297. updatable?: boolean;
  58298. sideOrientation?: number;
  58299. frontUVs?: Vector4;
  58300. backUVs?: Vector4;
  58301. }, scene?: Nullable<Scene>): Mesh;
  58302. /**
  58303. * Creates a torus knot mesh
  58304. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58305. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58306. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58307. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58309. * * 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
  58310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58311. * @param name defines the name of the mesh
  58312. * @param options defines the options used to create the mesh
  58313. * @param scene defines the hosting scene
  58314. * @returns the torus knot mesh
  58315. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58316. */
  58317. static CreateTorusKnot(name: string, options: {
  58318. radius?: number;
  58319. tube?: number;
  58320. radialSegments?: number;
  58321. tubularSegments?: number;
  58322. p?: number;
  58323. q?: number;
  58324. updatable?: boolean;
  58325. sideOrientation?: number;
  58326. frontUVs?: Vector4;
  58327. backUVs?: Vector4;
  58328. }, scene?: Nullable<Scene>): Mesh;
  58329. /**
  58330. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58331. * * 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
  58332. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58333. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58334. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58335. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58336. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58337. * * 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
  58338. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58341. * @param name defines the name of the new line system
  58342. * @param options defines the options used to create the line system
  58343. * @param scene defines the hosting scene
  58344. * @returns a new line system mesh
  58345. */
  58346. static CreateLineSystem(name: string, options: {
  58347. lines: Vector3[][];
  58348. updatable?: boolean;
  58349. instance?: Nullable<LinesMesh>;
  58350. colors?: Nullable<Color4[][]>;
  58351. useVertexAlpha?: boolean;
  58352. }, scene: Nullable<Scene>): LinesMesh;
  58353. /**
  58354. * Creates a line mesh
  58355. * 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
  58356. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58357. * * The parameter `points` is an array successive Vector3
  58358. * * 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
  58359. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58360. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58361. * * When updating an instance, remember that only point positions can change, not the number of points
  58362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58364. * @param name defines the name of the new line system
  58365. * @param options defines the options used to create the line system
  58366. * @param scene defines the hosting scene
  58367. * @returns a new line mesh
  58368. */
  58369. static CreateLines(name: string, options: {
  58370. points: Vector3[];
  58371. updatable?: boolean;
  58372. instance?: Nullable<LinesMesh>;
  58373. colors?: Color4[];
  58374. useVertexAlpha?: boolean;
  58375. }, scene?: Nullable<Scene>): LinesMesh;
  58376. /**
  58377. * Creates a dashed line mesh
  58378. * * 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
  58379. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58380. * * The parameter `points` is an array successive Vector3
  58381. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58382. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58383. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58384. * * 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
  58385. * * When updating an instance, remember that only point positions can change, not the number of points
  58386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58387. * @param name defines the name of the mesh
  58388. * @param options defines the options used to create the mesh
  58389. * @param scene defines the hosting scene
  58390. * @returns the dashed line mesh
  58391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58392. */
  58393. static CreateDashedLines(name: string, options: {
  58394. points: Vector3[];
  58395. dashSize?: number;
  58396. gapSize?: number;
  58397. dashNb?: number;
  58398. updatable?: boolean;
  58399. instance?: LinesMesh;
  58400. }, scene?: Nullable<Scene>): LinesMesh;
  58401. /**
  58402. * 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.
  58403. * * 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.
  58404. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58405. * * 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.
  58406. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58407. * * 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
  58408. * * 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
  58409. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58411. * * 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
  58412. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58414. * @param name defines the name of the mesh
  58415. * @param options defines the options used to create the mesh
  58416. * @param scene defines the hosting scene
  58417. * @returns the extruded shape mesh
  58418. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58419. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58420. */
  58421. static ExtrudeShape(name: string, options: {
  58422. shape: Vector3[];
  58423. path: Vector3[];
  58424. scale?: number;
  58425. rotation?: number;
  58426. cap?: number;
  58427. updatable?: boolean;
  58428. sideOrientation?: number;
  58429. frontUVs?: Vector4;
  58430. backUVs?: Vector4;
  58431. instance?: Mesh;
  58432. invertUV?: boolean;
  58433. }, scene?: Nullable<Scene>): Mesh;
  58434. /**
  58435. * Creates an custom extruded shape mesh.
  58436. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58437. * * 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.
  58438. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58439. * * 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
  58440. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58441. * * 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
  58442. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58443. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58444. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58445. * * 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
  58446. * * 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
  58447. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58449. * * 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
  58450. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58452. * @param name defines the name of the mesh
  58453. * @param options defines the options used to create the mesh
  58454. * @param scene defines the hosting scene
  58455. * @returns the custom extruded shape mesh
  58456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58459. */
  58460. static ExtrudeShapeCustom(name: string, options: {
  58461. shape: Vector3[];
  58462. path: Vector3[];
  58463. scaleFunction?: any;
  58464. rotationFunction?: any;
  58465. ribbonCloseArray?: boolean;
  58466. ribbonClosePath?: boolean;
  58467. cap?: number;
  58468. updatable?: boolean;
  58469. sideOrientation?: number;
  58470. frontUVs?: Vector4;
  58471. backUVs?: Vector4;
  58472. instance?: Mesh;
  58473. invertUV?: boolean;
  58474. }, scene?: Nullable<Scene>): Mesh;
  58475. /**
  58476. * Creates lathe mesh.
  58477. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58478. * * 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
  58479. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58480. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58481. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58482. * * 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
  58483. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58484. * * 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
  58485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58486. * * 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
  58487. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58489. * @param name defines the name of the mesh
  58490. * @param options defines the options used to create the mesh
  58491. * @param scene defines the hosting scene
  58492. * @returns the lathe mesh
  58493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58494. */
  58495. static CreateLathe(name: string, options: {
  58496. shape: Vector3[];
  58497. radius?: number;
  58498. tessellation?: number;
  58499. clip?: number;
  58500. arc?: number;
  58501. closed?: boolean;
  58502. updatable?: boolean;
  58503. sideOrientation?: number;
  58504. frontUVs?: Vector4;
  58505. backUVs?: Vector4;
  58506. cap?: number;
  58507. invertUV?: boolean;
  58508. }, scene?: Nullable<Scene>): Mesh;
  58509. /**
  58510. * Creates a tiled plane mesh
  58511. * * You can set a limited pattern arrangement with the tiles
  58512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58513. * * 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
  58514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58515. * @param name defines the name of the mesh
  58516. * @param options defines the options used to create the mesh
  58517. * @param scene defines the hosting scene
  58518. * @returns the plane mesh
  58519. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58520. */
  58521. static CreateTiledPlane(name: string, options: {
  58522. pattern?: number;
  58523. tileSize?: number;
  58524. tileWidth?: number;
  58525. tileHeight?: number;
  58526. size?: number;
  58527. width?: number;
  58528. height?: number;
  58529. alignHorizontal?: number;
  58530. alignVertical?: number;
  58531. sideOrientation?: number;
  58532. frontUVs?: Vector4;
  58533. backUVs?: Vector4;
  58534. updatable?: boolean;
  58535. }, scene?: Nullable<Scene>): Mesh;
  58536. /**
  58537. * Creates a plane mesh
  58538. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58539. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58540. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58542. * * 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
  58543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58544. * @param name defines the name of the mesh
  58545. * @param options defines the options used to create the mesh
  58546. * @param scene defines the hosting scene
  58547. * @returns the plane mesh
  58548. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58549. */
  58550. static CreatePlane(name: string, options: {
  58551. size?: number;
  58552. width?: number;
  58553. height?: number;
  58554. sideOrientation?: number;
  58555. frontUVs?: Vector4;
  58556. backUVs?: Vector4;
  58557. updatable?: boolean;
  58558. sourcePlane?: Plane;
  58559. }, scene?: Nullable<Scene>): Mesh;
  58560. /**
  58561. * Creates a ground mesh
  58562. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58563. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58565. * @param name defines the name of the mesh
  58566. * @param options defines the options used to create the mesh
  58567. * @param scene defines the hosting scene
  58568. * @returns the ground mesh
  58569. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58570. */
  58571. static CreateGround(name: string, options: {
  58572. width?: number;
  58573. height?: number;
  58574. subdivisions?: number;
  58575. subdivisionsX?: number;
  58576. subdivisionsY?: number;
  58577. updatable?: boolean;
  58578. }, scene?: Nullable<Scene>): Mesh;
  58579. /**
  58580. * Creates a tiled ground mesh
  58581. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58582. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58583. * * 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
  58584. * * 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
  58585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58586. * @param name defines the name of the mesh
  58587. * @param options defines the options used to create the mesh
  58588. * @param scene defines the hosting scene
  58589. * @returns the tiled ground mesh
  58590. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58591. */
  58592. static CreateTiledGround(name: string, options: {
  58593. xmin: number;
  58594. zmin: number;
  58595. xmax: number;
  58596. zmax: number;
  58597. subdivisions?: {
  58598. w: number;
  58599. h: number;
  58600. };
  58601. precision?: {
  58602. w: number;
  58603. h: number;
  58604. };
  58605. updatable?: boolean;
  58606. }, scene?: Nullable<Scene>): Mesh;
  58607. /**
  58608. * Creates a ground mesh from a height map
  58609. * * The parameter `url` sets the URL of the height map image resource.
  58610. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58611. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58612. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58613. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58614. * * 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.
  58615. * * 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).
  58616. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58618. * @param name defines the name of the mesh
  58619. * @param url defines the url to the height map
  58620. * @param options defines the options used to create the mesh
  58621. * @param scene defines the hosting scene
  58622. * @returns the ground mesh
  58623. * @see https://doc.babylonjs.com/babylon101/height_map
  58624. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58625. */
  58626. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58627. width?: number;
  58628. height?: number;
  58629. subdivisions?: number;
  58630. minHeight?: number;
  58631. maxHeight?: number;
  58632. colorFilter?: Color3;
  58633. alphaFilter?: number;
  58634. updatable?: boolean;
  58635. onReady?: (mesh: GroundMesh) => void;
  58636. }, scene?: Nullable<Scene>): GroundMesh;
  58637. /**
  58638. * Creates a polygon mesh
  58639. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58640. * * 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
  58641. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58643. * * 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)
  58644. * * Remember you can only change the shape positions, not their number when updating a polygon
  58645. * @param name defines the name of the mesh
  58646. * @param options defines the options used to create the mesh
  58647. * @param scene defines the hosting scene
  58648. * @param earcutInjection can be used to inject your own earcut reference
  58649. * @returns the polygon mesh
  58650. */
  58651. static CreatePolygon(name: string, options: {
  58652. shape: Vector3[];
  58653. holes?: Vector3[][];
  58654. depth?: number;
  58655. faceUV?: Vector4[];
  58656. faceColors?: Color4[];
  58657. updatable?: boolean;
  58658. sideOrientation?: number;
  58659. frontUVs?: Vector4;
  58660. backUVs?: Vector4;
  58661. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58662. /**
  58663. * Creates an extruded polygon mesh, with depth in the Y direction.
  58664. * * 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)
  58665. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58666. * @param name defines the name of the mesh
  58667. * @param options defines the options used to create the mesh
  58668. * @param scene defines the hosting scene
  58669. * @param earcutInjection can be used to inject your own earcut reference
  58670. * @returns the polygon mesh
  58671. */
  58672. static ExtrudePolygon(name: string, options: {
  58673. shape: Vector3[];
  58674. holes?: Vector3[][];
  58675. depth?: number;
  58676. faceUV?: Vector4[];
  58677. faceColors?: Color4[];
  58678. updatable?: boolean;
  58679. sideOrientation?: number;
  58680. frontUVs?: Vector4;
  58681. backUVs?: Vector4;
  58682. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58683. /**
  58684. * Creates a tube mesh.
  58685. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58686. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58687. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58688. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58689. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58690. * * 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)
  58691. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58692. * * 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
  58693. * * 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
  58694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58695. * * 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
  58696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58698. * @param name defines the name of the mesh
  58699. * @param options defines the options used to create the mesh
  58700. * @param scene defines the hosting scene
  58701. * @returns the tube mesh
  58702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58703. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58704. */
  58705. static CreateTube(name: string, options: {
  58706. path: Vector3[];
  58707. radius?: number;
  58708. tessellation?: number;
  58709. radiusFunction?: {
  58710. (i: number, distance: number): number;
  58711. };
  58712. cap?: number;
  58713. arc?: number;
  58714. updatable?: boolean;
  58715. sideOrientation?: number;
  58716. frontUVs?: Vector4;
  58717. backUVs?: Vector4;
  58718. instance?: Mesh;
  58719. invertUV?: boolean;
  58720. }, scene?: Nullable<Scene>): Mesh;
  58721. /**
  58722. * Creates a polyhedron mesh
  58723. * * 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
  58724. * * The parameter `size` (positive float, default 1) sets the polygon size
  58725. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58726. * * 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`
  58727. * * 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
  58728. * * 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)`)
  58729. * * 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
  58730. * * 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
  58731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58732. * * 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
  58733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58734. * @param name defines the name of the mesh
  58735. * @param options defines the options used to create the mesh
  58736. * @param scene defines the hosting scene
  58737. * @returns the polyhedron mesh
  58738. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58739. */
  58740. static CreatePolyhedron(name: string, options: {
  58741. type?: number;
  58742. size?: number;
  58743. sizeX?: number;
  58744. sizeY?: number;
  58745. sizeZ?: number;
  58746. custom?: any;
  58747. faceUV?: Vector4[];
  58748. faceColors?: Color4[];
  58749. flat?: boolean;
  58750. updatable?: boolean;
  58751. sideOrientation?: number;
  58752. frontUVs?: Vector4;
  58753. backUVs?: Vector4;
  58754. }, scene?: Nullable<Scene>): Mesh;
  58755. /**
  58756. * Creates a decal mesh.
  58757. * 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
  58758. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58759. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58760. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58761. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58762. * @param name defines the name of the mesh
  58763. * @param sourceMesh defines the mesh where the decal must be applied
  58764. * @param options defines the options used to create the mesh
  58765. * @param scene defines the hosting scene
  58766. * @returns the decal mesh
  58767. * @see https://doc.babylonjs.com/how_to/decals
  58768. */
  58769. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58770. position?: Vector3;
  58771. normal?: Vector3;
  58772. size?: Vector3;
  58773. angle?: number;
  58774. }): Mesh;
  58775. }
  58776. }
  58777. declare module BABYLON {
  58778. /**
  58779. * A simplifier interface for future simplification implementations
  58780. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58781. */
  58782. export interface ISimplifier {
  58783. /**
  58784. * Simplification of a given mesh according to the given settings.
  58785. * Since this requires computation, it is assumed that the function runs async.
  58786. * @param settings The settings of the simplification, including quality and distance
  58787. * @param successCallback A callback that will be called after the mesh was simplified.
  58788. * @param errorCallback in case of an error, this callback will be called. optional.
  58789. */
  58790. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58791. }
  58792. /**
  58793. * Expected simplification settings.
  58794. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58795. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58796. */
  58797. export interface ISimplificationSettings {
  58798. /**
  58799. * Gets or sets the expected quality
  58800. */
  58801. quality: number;
  58802. /**
  58803. * Gets or sets the distance when this optimized version should be used
  58804. */
  58805. distance: number;
  58806. /**
  58807. * Gets an already optimized mesh
  58808. */
  58809. optimizeMesh?: boolean;
  58810. }
  58811. /**
  58812. * Class used to specify simplification options
  58813. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58814. */
  58815. export class SimplificationSettings implements ISimplificationSettings {
  58816. /** expected quality */
  58817. quality: number;
  58818. /** distance when this optimized version should be used */
  58819. distance: number;
  58820. /** already optimized mesh */
  58821. optimizeMesh?: boolean | undefined;
  58822. /**
  58823. * Creates a SimplificationSettings
  58824. * @param quality expected quality
  58825. * @param distance distance when this optimized version should be used
  58826. * @param optimizeMesh already optimized mesh
  58827. */
  58828. constructor(
  58829. /** expected quality */
  58830. quality: number,
  58831. /** distance when this optimized version should be used */
  58832. distance: number,
  58833. /** already optimized mesh */
  58834. optimizeMesh?: boolean | undefined);
  58835. }
  58836. /**
  58837. * Interface used to define a simplification task
  58838. */
  58839. export interface ISimplificationTask {
  58840. /**
  58841. * Array of settings
  58842. */
  58843. settings: Array<ISimplificationSettings>;
  58844. /**
  58845. * Simplification type
  58846. */
  58847. simplificationType: SimplificationType;
  58848. /**
  58849. * Mesh to simplify
  58850. */
  58851. mesh: Mesh;
  58852. /**
  58853. * Callback called on success
  58854. */
  58855. successCallback?: () => void;
  58856. /**
  58857. * Defines if parallel processing can be used
  58858. */
  58859. parallelProcessing: boolean;
  58860. }
  58861. /**
  58862. * Queue used to order the simplification tasks
  58863. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58864. */
  58865. export class SimplificationQueue {
  58866. private _simplificationArray;
  58867. /**
  58868. * Gets a boolean indicating that the process is still running
  58869. */
  58870. running: boolean;
  58871. /**
  58872. * Creates a new queue
  58873. */
  58874. constructor();
  58875. /**
  58876. * Adds a new simplification task
  58877. * @param task defines a task to add
  58878. */
  58879. addTask(task: ISimplificationTask): void;
  58880. /**
  58881. * Execute next task
  58882. */
  58883. executeNext(): void;
  58884. /**
  58885. * Execute a simplification task
  58886. * @param task defines the task to run
  58887. */
  58888. runSimplification(task: ISimplificationTask): void;
  58889. private getSimplifier;
  58890. }
  58891. /**
  58892. * The implemented types of simplification
  58893. * At the moment only Quadratic Error Decimation is implemented
  58894. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58895. */
  58896. export enum SimplificationType {
  58897. /** Quadratic error decimation */
  58898. QUADRATIC = 0
  58899. }
  58900. }
  58901. declare module BABYLON {
  58902. interface Scene {
  58903. /** @hidden (Backing field) */
  58904. _simplificationQueue: SimplificationQueue;
  58905. /**
  58906. * Gets or sets the simplification queue attached to the scene
  58907. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58908. */
  58909. simplificationQueue: SimplificationQueue;
  58910. }
  58911. interface Mesh {
  58912. /**
  58913. * Simplify the mesh according to the given array of settings.
  58914. * Function will return immediately and will simplify async
  58915. * @param settings a collection of simplification settings
  58916. * @param parallelProcessing should all levels calculate parallel or one after the other
  58917. * @param simplificationType the type of simplification to run
  58918. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58919. * @returns the current mesh
  58920. */
  58921. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58922. }
  58923. /**
  58924. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58925. * created in a scene
  58926. */
  58927. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58928. /**
  58929. * The component name helpfull to identify the component in the list of scene components.
  58930. */
  58931. readonly name: string;
  58932. /**
  58933. * The scene the component belongs to.
  58934. */
  58935. scene: Scene;
  58936. /**
  58937. * Creates a new instance of the component for the given scene
  58938. * @param scene Defines the scene to register the component in
  58939. */
  58940. constructor(scene: Scene);
  58941. /**
  58942. * Registers the component in a given scene
  58943. */
  58944. register(): void;
  58945. /**
  58946. * Rebuilds the elements related to this component in case of
  58947. * context lost for instance.
  58948. */
  58949. rebuild(): void;
  58950. /**
  58951. * Disposes the component and the associated ressources
  58952. */
  58953. dispose(): void;
  58954. private _beforeCameraUpdate;
  58955. }
  58956. }
  58957. declare module BABYLON {
  58958. /**
  58959. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58960. */
  58961. export interface INavigationEnginePlugin {
  58962. /**
  58963. * plugin name
  58964. */
  58965. name: string;
  58966. /**
  58967. * Creates a navigation mesh
  58968. * @param meshes array of all the geometry used to compute the navigatio mesh
  58969. * @param parameters bunch of parameters used to filter geometry
  58970. */
  58971. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58972. /**
  58973. * Create a navigation mesh debug mesh
  58974. * @param scene is where the mesh will be added
  58975. * @returns debug display mesh
  58976. */
  58977. createDebugNavMesh(scene: Scene): Mesh;
  58978. /**
  58979. * Get a navigation mesh constrained position, closest to the parameter position
  58980. * @param position world position
  58981. * @returns the closest point to position constrained by the navigation mesh
  58982. */
  58983. getClosestPoint(position: Vector3): Vector3;
  58984. /**
  58985. * Get a navigation mesh constrained position, within a particular radius
  58986. * @param position world position
  58987. * @param maxRadius the maximum distance to the constrained world position
  58988. * @returns the closest point to position constrained by the navigation mesh
  58989. */
  58990. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58991. /**
  58992. * Compute the final position from a segment made of destination-position
  58993. * @param position world position
  58994. * @param destination world position
  58995. * @returns the resulting point along the navmesh
  58996. */
  58997. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58998. /**
  58999. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59000. * @param start world position
  59001. * @param end world position
  59002. * @returns array containing world position composing the path
  59003. */
  59004. computePath(start: Vector3, end: Vector3): Vector3[];
  59005. /**
  59006. * If this plugin is supported
  59007. * @returns true if plugin is supported
  59008. */
  59009. isSupported(): boolean;
  59010. /**
  59011. * Create a new Crowd so you can add agents
  59012. * @param maxAgents the maximum agent count in the crowd
  59013. * @param maxAgentRadius the maximum radius an agent can have
  59014. * @param scene to attach the crowd to
  59015. * @returns the crowd you can add agents to
  59016. */
  59017. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59018. /**
  59019. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59020. * The queries will try to find a solution within those bounds
  59021. * default is (1,1,1)
  59022. * @param extent x,y,z value that define the extent around the queries point of reference
  59023. */
  59024. setDefaultQueryExtent(extent: Vector3): void;
  59025. /**
  59026. * Get the Bounding box extent specified by setDefaultQueryExtent
  59027. * @returns the box extent values
  59028. */
  59029. getDefaultQueryExtent(): Vector3;
  59030. /**
  59031. * Release all resources
  59032. */
  59033. dispose(): void;
  59034. }
  59035. /**
  59036. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59037. */
  59038. export interface ICrowd {
  59039. /**
  59040. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59041. * You can attach anything to that node. The node position is updated in the scene update tick.
  59042. * @param pos world position that will be constrained by the navigation mesh
  59043. * @param parameters agent parameters
  59044. * @param transform hooked to the agent that will be update by the scene
  59045. * @returns agent index
  59046. */
  59047. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59048. /**
  59049. * Returns the agent position in world space
  59050. * @param index agent index returned by addAgent
  59051. * @returns world space position
  59052. */
  59053. getAgentPosition(index: number): Vector3;
  59054. /**
  59055. * Gets the agent velocity in world space
  59056. * @param index agent index returned by addAgent
  59057. * @returns world space velocity
  59058. */
  59059. getAgentVelocity(index: number): Vector3;
  59060. /**
  59061. * remove a particular agent previously created
  59062. * @param index agent index returned by addAgent
  59063. */
  59064. removeAgent(index: number): void;
  59065. /**
  59066. * get the list of all agents attached to this crowd
  59067. * @returns list of agent indices
  59068. */
  59069. getAgents(): number[];
  59070. /**
  59071. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59072. * @param deltaTime in seconds
  59073. */
  59074. update(deltaTime: number): void;
  59075. /**
  59076. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59077. * @param index agent index returned by addAgent
  59078. * @param destination targeted world position
  59079. */
  59080. agentGoto(index: number, destination: Vector3): void;
  59081. /**
  59082. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59083. * The queries will try to find a solution within those bounds
  59084. * default is (1,1,1)
  59085. * @param extent x,y,z value that define the extent around the queries point of reference
  59086. */
  59087. setDefaultQueryExtent(extent: Vector3): void;
  59088. /**
  59089. * Get the Bounding box extent specified by setDefaultQueryExtent
  59090. * @returns the box extent values
  59091. */
  59092. getDefaultQueryExtent(): Vector3;
  59093. /**
  59094. * Release all resources
  59095. */
  59096. dispose(): void;
  59097. }
  59098. /**
  59099. * Configures an agent
  59100. */
  59101. export interface IAgentParameters {
  59102. /**
  59103. * Agent radius. [Limit: >= 0]
  59104. */
  59105. radius: number;
  59106. /**
  59107. * Agent height. [Limit: > 0]
  59108. */
  59109. height: number;
  59110. /**
  59111. * Maximum allowed acceleration. [Limit: >= 0]
  59112. */
  59113. maxAcceleration: number;
  59114. /**
  59115. * Maximum allowed speed. [Limit: >= 0]
  59116. */
  59117. maxSpeed: number;
  59118. /**
  59119. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59120. */
  59121. collisionQueryRange: number;
  59122. /**
  59123. * The path visibility optimization range. [Limit: > 0]
  59124. */
  59125. pathOptimizationRange: number;
  59126. /**
  59127. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59128. */
  59129. separationWeight: number;
  59130. }
  59131. /**
  59132. * Configures the navigation mesh creation
  59133. */
  59134. export interface INavMeshParameters {
  59135. /**
  59136. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59137. */
  59138. cs: number;
  59139. /**
  59140. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59141. */
  59142. ch: number;
  59143. /**
  59144. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59145. */
  59146. walkableSlopeAngle: number;
  59147. /**
  59148. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59149. * be considered walkable. [Limit: >= 3] [Units: vx]
  59150. */
  59151. walkableHeight: number;
  59152. /**
  59153. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59154. */
  59155. walkableClimb: number;
  59156. /**
  59157. * The distance to erode/shrink the walkable area of the heightfield away from
  59158. * obstructions. [Limit: >=0] [Units: vx]
  59159. */
  59160. walkableRadius: number;
  59161. /**
  59162. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59163. */
  59164. maxEdgeLen: number;
  59165. /**
  59166. * The maximum distance a simplfied contour's border edges should deviate
  59167. * the original raw contour. [Limit: >=0] [Units: vx]
  59168. */
  59169. maxSimplificationError: number;
  59170. /**
  59171. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59172. */
  59173. minRegionArea: number;
  59174. /**
  59175. * Any regions with a span count smaller than this value will, if possible,
  59176. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59177. */
  59178. mergeRegionArea: number;
  59179. /**
  59180. * The maximum number of vertices allowed for polygons generated during the
  59181. * contour to polygon conversion process. [Limit: >= 3]
  59182. */
  59183. maxVertsPerPoly: number;
  59184. /**
  59185. * Sets the sampling distance to use when generating the detail mesh.
  59186. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59187. */
  59188. detailSampleDist: number;
  59189. /**
  59190. * The maximum distance the detail mesh surface should deviate from heightfield
  59191. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59192. */
  59193. detailSampleMaxError: number;
  59194. }
  59195. }
  59196. declare module BABYLON {
  59197. /**
  59198. * RecastJS navigation plugin
  59199. */
  59200. export class RecastJSPlugin implements INavigationEnginePlugin {
  59201. /**
  59202. * Reference to the Recast library
  59203. */
  59204. bjsRECAST: any;
  59205. /**
  59206. * plugin name
  59207. */
  59208. name: string;
  59209. /**
  59210. * the first navmesh created. We might extend this to support multiple navmeshes
  59211. */
  59212. navMesh: any;
  59213. /**
  59214. * Initializes the recastJS plugin
  59215. * @param recastInjection can be used to inject your own recast reference
  59216. */
  59217. constructor(recastInjection?: any);
  59218. /**
  59219. * Creates a navigation mesh
  59220. * @param meshes array of all the geometry used to compute the navigatio mesh
  59221. * @param parameters bunch of parameters used to filter geometry
  59222. */
  59223. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59224. /**
  59225. * Create a navigation mesh debug mesh
  59226. * @param scene is where the mesh will be added
  59227. * @returns debug display mesh
  59228. */
  59229. createDebugNavMesh(scene: Scene): Mesh;
  59230. /**
  59231. * Get a navigation mesh constrained position, closest to the parameter position
  59232. * @param position world position
  59233. * @returns the closest point to position constrained by the navigation mesh
  59234. */
  59235. getClosestPoint(position: Vector3): Vector3;
  59236. /**
  59237. * Get a navigation mesh constrained position, within a particular radius
  59238. * @param position world position
  59239. * @param maxRadius the maximum distance to the constrained world position
  59240. * @returns the closest point to position constrained by the navigation mesh
  59241. */
  59242. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59243. /**
  59244. * Compute the final position from a segment made of destination-position
  59245. * @param position world position
  59246. * @param destination world position
  59247. * @returns the resulting point along the navmesh
  59248. */
  59249. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59250. /**
  59251. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59252. * @param start world position
  59253. * @param end world position
  59254. * @returns array containing world position composing the path
  59255. */
  59256. computePath(start: Vector3, end: Vector3): Vector3[];
  59257. /**
  59258. * Create a new Crowd so you can add agents
  59259. * @param maxAgents the maximum agent count in the crowd
  59260. * @param maxAgentRadius the maximum radius an agent can have
  59261. * @param scene to attach the crowd to
  59262. * @returns the crowd you can add agents to
  59263. */
  59264. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59265. /**
  59266. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59267. * The queries will try to find a solution within those bounds
  59268. * default is (1,1,1)
  59269. * @param extent x,y,z value that define the extent around the queries point of reference
  59270. */
  59271. setDefaultQueryExtent(extent: Vector3): void;
  59272. /**
  59273. * Get the Bounding box extent specified by setDefaultQueryExtent
  59274. * @returns the box extent values
  59275. */
  59276. getDefaultQueryExtent(): Vector3;
  59277. /**
  59278. * Disposes
  59279. */
  59280. dispose(): void;
  59281. /**
  59282. * If this plugin is supported
  59283. * @returns true if plugin is supported
  59284. */
  59285. isSupported(): boolean;
  59286. }
  59287. /**
  59288. * Recast detour crowd implementation
  59289. */
  59290. export class RecastJSCrowd implements ICrowd {
  59291. /**
  59292. * Recast/detour plugin
  59293. */
  59294. bjsRECASTPlugin: RecastJSPlugin;
  59295. /**
  59296. * Link to the detour crowd
  59297. */
  59298. recastCrowd: any;
  59299. /**
  59300. * One transform per agent
  59301. */
  59302. transforms: TransformNode[];
  59303. /**
  59304. * All agents created
  59305. */
  59306. agents: number[];
  59307. /**
  59308. * Link to the scene is kept to unregister the crowd from the scene
  59309. */
  59310. private _scene;
  59311. /**
  59312. * Observer for crowd updates
  59313. */
  59314. private _onBeforeAnimationsObserver;
  59315. /**
  59316. * Constructor
  59317. * @param plugin recastJS plugin
  59318. * @param maxAgents the maximum agent count in the crowd
  59319. * @param maxAgentRadius the maximum radius an agent can have
  59320. * @param scene to attach the crowd to
  59321. * @returns the crowd you can add agents to
  59322. */
  59323. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59324. /**
  59325. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59326. * You can attach anything to that node. The node position is updated in the scene update tick.
  59327. * @param pos world position that will be constrained by the navigation mesh
  59328. * @param parameters agent parameters
  59329. * @param transform hooked to the agent that will be update by the scene
  59330. * @returns agent index
  59331. */
  59332. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59333. /**
  59334. * Returns the agent position in world space
  59335. * @param index agent index returned by addAgent
  59336. * @returns world space position
  59337. */
  59338. getAgentPosition(index: number): Vector3;
  59339. /**
  59340. * Returns the agent velocity in world space
  59341. * @param index agent index returned by addAgent
  59342. * @returns world space velocity
  59343. */
  59344. getAgentVelocity(index: number): Vector3;
  59345. /**
  59346. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59347. * @param index agent index returned by addAgent
  59348. * @param destination targeted world position
  59349. */
  59350. agentGoto(index: number, destination: Vector3): void;
  59351. /**
  59352. * remove a particular agent previously created
  59353. * @param index agent index returned by addAgent
  59354. */
  59355. removeAgent(index: number): void;
  59356. /**
  59357. * get the list of all agents attached to this crowd
  59358. * @returns list of agent indices
  59359. */
  59360. getAgents(): number[];
  59361. /**
  59362. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59363. * @param deltaTime in seconds
  59364. */
  59365. update(deltaTime: number): void;
  59366. /**
  59367. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59368. * The queries will try to find a solution within those bounds
  59369. * default is (1,1,1)
  59370. * @param extent x,y,z value that define the extent around the queries point of reference
  59371. */
  59372. setDefaultQueryExtent(extent: Vector3): void;
  59373. /**
  59374. * Get the Bounding box extent specified by setDefaultQueryExtent
  59375. * @returns the box extent values
  59376. */
  59377. getDefaultQueryExtent(): Vector3;
  59378. /**
  59379. * Release all resources
  59380. */
  59381. dispose(): void;
  59382. }
  59383. }
  59384. declare module BABYLON {
  59385. /**
  59386. * Class used to enable access to IndexedDB
  59387. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59388. */
  59389. export class Database implements IOfflineProvider {
  59390. private _callbackManifestChecked;
  59391. private _currentSceneUrl;
  59392. private _db;
  59393. private _enableSceneOffline;
  59394. private _enableTexturesOffline;
  59395. private _manifestVersionFound;
  59396. private _mustUpdateRessources;
  59397. private _hasReachedQuota;
  59398. private _isSupported;
  59399. private _idbFactory;
  59400. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59401. private static IsUASupportingBlobStorage;
  59402. /**
  59403. * Gets a boolean indicating if Database storate is enabled (off by default)
  59404. */
  59405. static IDBStorageEnabled: boolean;
  59406. /**
  59407. * Gets a boolean indicating if scene must be saved in the database
  59408. */
  59409. readonly enableSceneOffline: boolean;
  59410. /**
  59411. * Gets a boolean indicating if textures must be saved in the database
  59412. */
  59413. readonly enableTexturesOffline: boolean;
  59414. /**
  59415. * Creates a new Database
  59416. * @param urlToScene defines the url to load the scene
  59417. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59418. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59419. */
  59420. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59421. private static _ParseURL;
  59422. private static _ReturnFullUrlLocation;
  59423. private _checkManifestFile;
  59424. /**
  59425. * Open the database and make it available
  59426. * @param successCallback defines the callback to call on success
  59427. * @param errorCallback defines the callback to call on error
  59428. */
  59429. open(successCallback: () => void, errorCallback: () => void): void;
  59430. /**
  59431. * Loads an image from the database
  59432. * @param url defines the url to load from
  59433. * @param image defines the target DOM image
  59434. */
  59435. loadImage(url: string, image: HTMLImageElement): void;
  59436. private _loadImageFromDBAsync;
  59437. private _saveImageIntoDBAsync;
  59438. private _checkVersionFromDB;
  59439. private _loadVersionFromDBAsync;
  59440. private _saveVersionIntoDBAsync;
  59441. /**
  59442. * Loads a file from database
  59443. * @param url defines the URL to load from
  59444. * @param sceneLoaded defines a callback to call on success
  59445. * @param progressCallBack defines a callback to call when progress changed
  59446. * @param errorCallback defines a callback to call on error
  59447. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59448. */
  59449. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59450. private _loadFileAsync;
  59451. private _saveFileAsync;
  59452. /**
  59453. * Validates if xhr data is correct
  59454. * @param xhr defines the request to validate
  59455. * @param dataType defines the expected data type
  59456. * @returns true if data is correct
  59457. */
  59458. private static _ValidateXHRData;
  59459. }
  59460. }
  59461. declare module BABYLON {
  59462. /** @hidden */
  59463. export var gpuUpdateParticlesPixelShader: {
  59464. name: string;
  59465. shader: string;
  59466. };
  59467. }
  59468. declare module BABYLON {
  59469. /** @hidden */
  59470. export var gpuUpdateParticlesVertexShader: {
  59471. name: string;
  59472. shader: string;
  59473. };
  59474. }
  59475. declare module BABYLON {
  59476. /** @hidden */
  59477. export var clipPlaneFragmentDeclaration2: {
  59478. name: string;
  59479. shader: string;
  59480. };
  59481. }
  59482. declare module BABYLON {
  59483. /** @hidden */
  59484. export var gpuRenderParticlesPixelShader: {
  59485. name: string;
  59486. shader: string;
  59487. };
  59488. }
  59489. declare module BABYLON {
  59490. /** @hidden */
  59491. export var clipPlaneVertexDeclaration2: {
  59492. name: string;
  59493. shader: string;
  59494. };
  59495. }
  59496. declare module BABYLON {
  59497. /** @hidden */
  59498. export var gpuRenderParticlesVertexShader: {
  59499. name: string;
  59500. shader: string;
  59501. };
  59502. }
  59503. declare module BABYLON {
  59504. /**
  59505. * This represents a GPU particle system in Babylon
  59506. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59507. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59508. */
  59509. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59510. /**
  59511. * The layer mask we are rendering the particles through.
  59512. */
  59513. layerMask: number;
  59514. private _capacity;
  59515. private _activeCount;
  59516. private _currentActiveCount;
  59517. private _accumulatedCount;
  59518. private _renderEffect;
  59519. private _updateEffect;
  59520. private _buffer0;
  59521. private _buffer1;
  59522. private _spriteBuffer;
  59523. private _updateVAO;
  59524. private _renderVAO;
  59525. private _targetIndex;
  59526. private _sourceBuffer;
  59527. private _targetBuffer;
  59528. private _engine;
  59529. private _currentRenderId;
  59530. private _started;
  59531. private _stopped;
  59532. private _timeDelta;
  59533. private _randomTexture;
  59534. private _randomTexture2;
  59535. private _attributesStrideSize;
  59536. private _updateEffectOptions;
  59537. private _randomTextureSize;
  59538. private _actualFrame;
  59539. private readonly _rawTextureWidth;
  59540. /**
  59541. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59542. */
  59543. static readonly IsSupported: boolean;
  59544. /**
  59545. * An event triggered when the system is disposed.
  59546. */
  59547. onDisposeObservable: Observable<GPUParticleSystem>;
  59548. /**
  59549. * Gets the maximum number of particles active at the same time.
  59550. * @returns The max number of active particles.
  59551. */
  59552. getCapacity(): number;
  59553. /**
  59554. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59555. * to override the particles.
  59556. */
  59557. forceDepthWrite: boolean;
  59558. /**
  59559. * Gets or set the number of active particles
  59560. */
  59561. activeParticleCount: number;
  59562. private _preWarmDone;
  59563. /**
  59564. * Is this system ready to be used/rendered
  59565. * @return true if the system is ready
  59566. */
  59567. isReady(): boolean;
  59568. /**
  59569. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59570. * @returns True if it has been started, otherwise false.
  59571. */
  59572. isStarted(): boolean;
  59573. /**
  59574. * Starts the particle system and begins to emit
  59575. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59576. */
  59577. start(delay?: number): void;
  59578. /**
  59579. * Stops the particle system.
  59580. */
  59581. stop(): void;
  59582. /**
  59583. * Remove all active particles
  59584. */
  59585. reset(): void;
  59586. /**
  59587. * Returns the string "GPUParticleSystem"
  59588. * @returns a string containing the class name
  59589. */
  59590. getClassName(): string;
  59591. private _colorGradientsTexture;
  59592. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59593. /**
  59594. * Adds a new color gradient
  59595. * @param gradient defines the gradient to use (between 0 and 1)
  59596. * @param color1 defines the color to affect to the specified gradient
  59597. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59598. * @returns the current particle system
  59599. */
  59600. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59601. /**
  59602. * Remove a specific color gradient
  59603. * @param gradient defines the gradient to remove
  59604. * @returns the current particle system
  59605. */
  59606. removeColorGradient(gradient: number): GPUParticleSystem;
  59607. private _angularSpeedGradientsTexture;
  59608. private _sizeGradientsTexture;
  59609. private _velocityGradientsTexture;
  59610. private _limitVelocityGradientsTexture;
  59611. private _dragGradientsTexture;
  59612. private _addFactorGradient;
  59613. /**
  59614. * Adds a new size gradient
  59615. * @param gradient defines the gradient to use (between 0 and 1)
  59616. * @param factor defines the size factor to affect to the specified gradient
  59617. * @returns the current particle system
  59618. */
  59619. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59620. /**
  59621. * Remove a specific size gradient
  59622. * @param gradient defines the gradient to remove
  59623. * @returns the current particle system
  59624. */
  59625. removeSizeGradient(gradient: number): GPUParticleSystem;
  59626. /**
  59627. * Adds a new angular speed gradient
  59628. * @param gradient defines the gradient to use (between 0 and 1)
  59629. * @param factor defines the angular speed to affect to the specified gradient
  59630. * @returns the current particle system
  59631. */
  59632. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59633. /**
  59634. * Remove a specific angular speed gradient
  59635. * @param gradient defines the gradient to remove
  59636. * @returns the current particle system
  59637. */
  59638. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59639. /**
  59640. * Adds a new velocity gradient
  59641. * @param gradient defines the gradient to use (between 0 and 1)
  59642. * @param factor defines the velocity to affect to the specified gradient
  59643. * @returns the current particle system
  59644. */
  59645. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59646. /**
  59647. * Remove a specific velocity gradient
  59648. * @param gradient defines the gradient to remove
  59649. * @returns the current particle system
  59650. */
  59651. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59652. /**
  59653. * Adds a new limit velocity gradient
  59654. * @param gradient defines the gradient to use (between 0 and 1)
  59655. * @param factor defines the limit velocity value to affect to the specified gradient
  59656. * @returns the current particle system
  59657. */
  59658. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59659. /**
  59660. * Remove a specific limit velocity gradient
  59661. * @param gradient defines the gradient to remove
  59662. * @returns the current particle system
  59663. */
  59664. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59665. /**
  59666. * Adds a new drag gradient
  59667. * @param gradient defines the gradient to use (between 0 and 1)
  59668. * @param factor defines the drag value to affect to the specified gradient
  59669. * @returns the current particle system
  59670. */
  59671. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59672. /**
  59673. * Remove a specific drag gradient
  59674. * @param gradient defines the gradient to remove
  59675. * @returns the current particle system
  59676. */
  59677. removeDragGradient(gradient: number): GPUParticleSystem;
  59678. /**
  59679. * Not supported by GPUParticleSystem
  59680. * @param gradient defines the gradient to use (between 0 and 1)
  59681. * @param factor defines the emit rate value to affect to the specified gradient
  59682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59683. * @returns the current particle system
  59684. */
  59685. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59686. /**
  59687. * Not supported by GPUParticleSystem
  59688. * @param gradient defines the gradient to remove
  59689. * @returns the current particle system
  59690. */
  59691. removeEmitRateGradient(gradient: number): IParticleSystem;
  59692. /**
  59693. * Not supported by GPUParticleSystem
  59694. * @param gradient defines the gradient to use (between 0 and 1)
  59695. * @param factor defines the start size value to affect to the specified gradient
  59696. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59697. * @returns the current particle system
  59698. */
  59699. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59700. /**
  59701. * Not supported by GPUParticleSystem
  59702. * @param gradient defines the gradient to remove
  59703. * @returns the current particle system
  59704. */
  59705. removeStartSizeGradient(gradient: number): IParticleSystem;
  59706. /**
  59707. * Not supported by GPUParticleSystem
  59708. * @param gradient defines the gradient to use (between 0 and 1)
  59709. * @param min defines the color remap minimal range
  59710. * @param max defines the color remap maximal range
  59711. * @returns the current particle system
  59712. */
  59713. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59714. /**
  59715. * Not supported by GPUParticleSystem
  59716. * @param gradient defines the gradient to remove
  59717. * @returns the current particle system
  59718. */
  59719. removeColorRemapGradient(): IParticleSystem;
  59720. /**
  59721. * Not supported by GPUParticleSystem
  59722. * @param gradient defines the gradient to use (between 0 and 1)
  59723. * @param min defines the alpha remap minimal range
  59724. * @param max defines the alpha remap maximal range
  59725. * @returns the current particle system
  59726. */
  59727. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59728. /**
  59729. * Not supported by GPUParticleSystem
  59730. * @param gradient defines the gradient to remove
  59731. * @returns the current particle system
  59732. */
  59733. removeAlphaRemapGradient(): IParticleSystem;
  59734. /**
  59735. * Not supported by GPUParticleSystem
  59736. * @param gradient defines the gradient to use (between 0 and 1)
  59737. * @param color defines the color to affect to the specified gradient
  59738. * @returns the current particle system
  59739. */
  59740. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59741. /**
  59742. * Not supported by GPUParticleSystem
  59743. * @param gradient defines the gradient to remove
  59744. * @returns the current particle system
  59745. */
  59746. removeRampGradient(): IParticleSystem;
  59747. /**
  59748. * Not supported by GPUParticleSystem
  59749. * @returns the list of ramp gradients
  59750. */
  59751. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59752. /**
  59753. * Not supported by GPUParticleSystem
  59754. * Gets or sets a boolean indicating that ramp gradients must be used
  59755. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59756. */
  59757. useRampGradients: boolean;
  59758. /**
  59759. * Not supported by GPUParticleSystem
  59760. * @param gradient defines the gradient to use (between 0 and 1)
  59761. * @param factor defines the life time factor to affect to the specified gradient
  59762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59763. * @returns the current particle system
  59764. */
  59765. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59766. /**
  59767. * Not supported by GPUParticleSystem
  59768. * @param gradient defines the gradient to remove
  59769. * @returns the current particle system
  59770. */
  59771. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59772. /**
  59773. * Instantiates a GPU particle system.
  59774. * 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.
  59775. * @param name The name of the particle system
  59776. * @param options The options used to create the system
  59777. * @param scene The scene the particle system belongs to
  59778. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59779. */
  59780. constructor(name: string, options: Partial<{
  59781. capacity: number;
  59782. randomTextureSize: number;
  59783. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59784. protected _reset(): void;
  59785. private _createUpdateVAO;
  59786. private _createRenderVAO;
  59787. private _initialize;
  59788. /** @hidden */
  59789. _recreateUpdateEffect(): void;
  59790. /** @hidden */
  59791. _recreateRenderEffect(): void;
  59792. /**
  59793. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59794. * @param preWarm defines if we are in the pre-warmimg phase
  59795. */
  59796. animate(preWarm?: boolean): void;
  59797. private _createFactorGradientTexture;
  59798. private _createSizeGradientTexture;
  59799. private _createAngularSpeedGradientTexture;
  59800. private _createVelocityGradientTexture;
  59801. private _createLimitVelocityGradientTexture;
  59802. private _createDragGradientTexture;
  59803. private _createColorGradientTexture;
  59804. /**
  59805. * Renders the particle system in its current state
  59806. * @param preWarm defines if the system should only update the particles but not render them
  59807. * @returns the current number of particles
  59808. */
  59809. render(preWarm?: boolean): number;
  59810. /**
  59811. * Rebuilds the particle system
  59812. */
  59813. rebuild(): void;
  59814. private _releaseBuffers;
  59815. private _releaseVAOs;
  59816. /**
  59817. * Disposes the particle system and free the associated resources
  59818. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59819. */
  59820. dispose(disposeTexture?: boolean): void;
  59821. /**
  59822. * Clones the particle system.
  59823. * @param name The name of the cloned object
  59824. * @param newEmitter The new emitter to use
  59825. * @returns the cloned particle system
  59826. */
  59827. clone(name: string, newEmitter: any): GPUParticleSystem;
  59828. /**
  59829. * Serializes the particle system to a JSON object.
  59830. * @returns the JSON object
  59831. */
  59832. serialize(): any;
  59833. /**
  59834. * Parses a JSON object to create a GPU particle system.
  59835. * @param parsedParticleSystem The JSON object to parse
  59836. * @param scene The scene to create the particle system in
  59837. * @param rootUrl The root url to use to load external dependencies like texture
  59838. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59839. * @returns the parsed GPU particle system
  59840. */
  59841. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59842. }
  59843. }
  59844. declare module BABYLON {
  59845. /**
  59846. * Represents a set of particle systems working together to create a specific effect
  59847. */
  59848. export class ParticleSystemSet implements IDisposable {
  59849. /**
  59850. * Gets or sets base Assets URL
  59851. */
  59852. static BaseAssetsUrl: string;
  59853. private _emitterCreationOptions;
  59854. private _emitterNode;
  59855. /**
  59856. * Gets the particle system list
  59857. */
  59858. systems: IParticleSystem[];
  59859. /**
  59860. * Gets the emitter node used with this set
  59861. */
  59862. readonly emitterNode: Nullable<TransformNode>;
  59863. /**
  59864. * Creates a new emitter mesh as a sphere
  59865. * @param options defines the options used to create the sphere
  59866. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59867. * @param scene defines the hosting scene
  59868. */
  59869. setEmitterAsSphere(options: {
  59870. diameter: number;
  59871. segments: number;
  59872. color: Color3;
  59873. }, renderingGroupId: number, scene: Scene): void;
  59874. /**
  59875. * Starts all particle systems of the set
  59876. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59877. */
  59878. start(emitter?: AbstractMesh): void;
  59879. /**
  59880. * Release all associated resources
  59881. */
  59882. dispose(): void;
  59883. /**
  59884. * Serialize the set into a JSON compatible object
  59885. * @returns a JSON compatible representation of the set
  59886. */
  59887. serialize(): any;
  59888. /**
  59889. * Parse a new ParticleSystemSet from a serialized source
  59890. * @param data defines a JSON compatible representation of the set
  59891. * @param scene defines the hosting scene
  59892. * @param gpu defines if we want GPU particles or CPU particles
  59893. * @returns a new ParticleSystemSet
  59894. */
  59895. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59896. }
  59897. }
  59898. declare module BABYLON {
  59899. /**
  59900. * This class is made for on one-liner static method to help creating particle system set.
  59901. */
  59902. export class ParticleHelper {
  59903. /**
  59904. * Gets or sets base Assets URL
  59905. */
  59906. static BaseAssetsUrl: string;
  59907. /**
  59908. * Create a default particle system that you can tweak
  59909. * @param emitter defines the emitter to use
  59910. * @param capacity defines the system capacity (default is 500 particles)
  59911. * @param scene defines the hosting scene
  59912. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59913. * @returns the new Particle system
  59914. */
  59915. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59916. /**
  59917. * This is the main static method (one-liner) of this helper to create different particle systems
  59918. * @param type This string represents the type to the particle system to create
  59919. * @param scene The scene where the particle system should live
  59920. * @param gpu If the system will use gpu
  59921. * @returns the ParticleSystemSet created
  59922. */
  59923. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59924. /**
  59925. * Static function used to export a particle system to a ParticleSystemSet variable.
  59926. * Please note that the emitter shape is not exported
  59927. * @param systems defines the particle systems to export
  59928. * @returns the created particle system set
  59929. */
  59930. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59931. }
  59932. }
  59933. declare module BABYLON {
  59934. interface Engine {
  59935. /**
  59936. * Create an effect to use with particle systems.
  59937. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59938. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59939. * @param uniformsNames defines a list of attribute names
  59940. * @param samplers defines an array of string used to represent textures
  59941. * @param defines defines the string containing the defines to use to compile the shaders
  59942. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59943. * @param onCompiled defines a function to call when the effect creation is successful
  59944. * @param onError defines a function to call when the effect creation has failed
  59945. * @returns the new Effect
  59946. */
  59947. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59948. }
  59949. interface Mesh {
  59950. /**
  59951. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59952. * @returns an array of IParticleSystem
  59953. */
  59954. getEmittedParticleSystems(): IParticleSystem[];
  59955. /**
  59956. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59957. * @returns an array of IParticleSystem
  59958. */
  59959. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59960. }
  59961. /**
  59962. * @hidden
  59963. */
  59964. export var _IDoNeedToBeInTheBuild: number;
  59965. }
  59966. declare module BABYLON {
  59967. /** Defines the 4 color options */
  59968. export enum PointColor {
  59969. /** color value */
  59970. Color = 2,
  59971. /** uv value */
  59972. UV = 1,
  59973. /** random value */
  59974. Random = 0,
  59975. /** stated value */
  59976. Stated = 3
  59977. }
  59978. /**
  59979. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  59980. * 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.
  59981. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  59982. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  59983. *
  59984. * Full documentation here : TO BE ENTERED
  59985. */
  59986. export class PointsCloudSystem implements IDisposable {
  59987. /**
  59988. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  59989. * Example : var p = SPS.particles[i];
  59990. */
  59991. particles: CloudPoint[];
  59992. /**
  59993. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  59994. */
  59995. nbParticles: number;
  59996. /**
  59997. * This a counter for your own usage. It's not set by any SPS functions.
  59998. */
  59999. counter: number;
  60000. /**
  60001. * The PCS name. This name is also given to the underlying mesh.
  60002. */
  60003. name: string;
  60004. /**
  60005. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  60006. */
  60007. mesh: Mesh;
  60008. /**
  60009. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  60010. * Please read :
  60011. */
  60012. vars: any;
  60013. /**
  60014. * @hidden
  60015. */
  60016. _size: number;
  60017. private _scene;
  60018. private _promises;
  60019. private _positions;
  60020. private _indices;
  60021. private _normals;
  60022. private _colors;
  60023. private _uvs;
  60024. private _indices32;
  60025. private _positions32;
  60026. private _colors32;
  60027. private _uvs32;
  60028. private _updatable;
  60029. private _isVisibilityBoxLocked;
  60030. private _alwaysVisible;
  60031. private _groups;
  60032. private _groupCounter;
  60033. private _computeParticleColor;
  60034. private _computeParticleTexture;
  60035. private _computeParticleRotation;
  60036. private _computeBoundingBox;
  60037. private _isReady;
  60038. /**
  60039. * Creates a PCS (Points Cloud System) object
  60040. * @param name (String) is the PCS name, this will be the underlying mesh name
  60041. * @param pointSize (number) is the size for each point
  60042. * @param scene (Scene) is the scene in which the PCS is added
  60043. * @param options defines the options of the PCS e.g.
  60044. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  60045. */
  60046. constructor(name: string, pointSize: number, scene: Scene, options?: {
  60047. updatable?: boolean;
  60048. });
  60049. /**
  60050. * Builds the PCS underlying mesh. Returns a standard Mesh.
  60051. * If no points were added to the PCS, the returned mesh is just a single point.
  60052. * @returns a promise for the created mesh
  60053. */
  60054. buildMeshAsync(): Promise<Mesh>;
  60055. /**
  60056. * @hidden
  60057. */
  60058. private _buildMesh;
  60059. private _addParticle;
  60060. private _randomUnitVector;
  60061. private _getColorIndicesForCoord;
  60062. private _setPointsColorOrUV;
  60063. private _colorFromTexture;
  60064. private _calculateDensity;
  60065. /**
  60066. * Adds points to the PCS in random positions within a unit sphere
  60067. * @param nb (positive integer) the number of particles to be created from this model
  60068. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  60069. * @returns the number of groups in the system
  60070. */
  60071. addPoints(nb: number, pointFunction?: any): number;
  60072. /**
  60073. * Adds points to the PCS from the surface of the model shape
  60074. * @param mesh is any Mesh object that will be used as a surface model for the points
  60075. * @param nb (positive integer) the number of particles to be created from this model
  60076. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  60077. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  60078. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  60079. * @returns the number of groups in the system
  60080. */
  60081. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  60082. /**
  60083. * Adds points to the PCS inside the model shape
  60084. * @param mesh is any Mesh object that will be used as a surface model for the points
  60085. * @param nb (positive integer) the number of particles to be created from this model
  60086. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  60087. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  60088. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  60089. * @returns the number of groups in the system
  60090. */
  60091. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  60092. /**
  60093. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  60094. * This method calls `updateParticle()` for each particle of the SPS.
  60095. * For an animated SPS, it is usually called within the render loop.
  60096. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  60097. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  60098. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  60099. * @returns the PCS.
  60100. */
  60101. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  60102. /**
  60103. * Disposes the PCS.
  60104. */
  60105. dispose(): void;
  60106. /**
  60107. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  60108. * doc :
  60109. * @returns the PCS.
  60110. */
  60111. refreshVisibleSize(): PointsCloudSystem;
  60112. /**
  60113. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  60114. * @param size the size (float) of the visibility box
  60115. * note : this doesn't lock the PCS mesh bounding box.
  60116. * doc :
  60117. */
  60118. setVisibilityBox(size: number): void;
  60119. /**
  60120. * Gets whether the PCS is always visible or not
  60121. * doc :
  60122. */
  60123. /**
  60124. * Sets the PCS as always visible or not
  60125. * doc :
  60126. */
  60127. isAlwaysVisible: boolean;
  60128. /**
  60129. * Tells to `setParticles()` to compute the particle rotations or not
  60130. * Default value : false. The PCS is faster when it's set to false
  60131. * Note : particle rotations are only applied to parent particles
  60132. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  60133. */
  60134. computeParticleRotation: boolean;
  60135. /**
  60136. * Tells to `setParticles()` to compute the particle colors or not.
  60137. * Default value : true. The PCS is faster when it's set to false.
  60138. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  60139. */
  60140. /**
  60141. * Gets if `setParticles()` computes the particle colors or not.
  60142. * Default value : false. The PCS is faster when it's set to false.
  60143. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  60144. */
  60145. computeParticleColor: boolean;
  60146. /**
  60147. * Gets if `setParticles()` computes the particle textures or not.
  60148. * Default value : false. The PCS is faster when it's set to false.
  60149. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  60150. */
  60151. computeParticleTexture: boolean;
  60152. /**
  60153. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  60154. */
  60155. /**
  60156. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  60157. */
  60158. computeBoundingBox: boolean;
  60159. /**
  60160. * This function does nothing. It may be overwritten to set all the particle first values.
  60161. * The PCS doesn't call this function, you may have to call it by your own.
  60162. * doc :
  60163. */
  60164. initParticles(): void;
  60165. /**
  60166. * This function does nothing. It may be overwritten to recycle a particle
  60167. * The PCS doesn't call this function, you can to call it
  60168. * doc :
  60169. * @param particle The particle to recycle
  60170. * @returns the recycled particle
  60171. */
  60172. recycleParticle(particle: CloudPoint): CloudPoint;
  60173. /**
  60174. * Updates a particle : this function should be overwritten by the user.
  60175. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  60176. * doc :
  60177. * @example : just set a particle position or velocity and recycle conditions
  60178. * @param particle The particle to update
  60179. * @returns the updated particle
  60180. */
  60181. updateParticle(particle: CloudPoint): CloudPoint;
  60182. /**
  60183. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  60184. * This does nothing and may be overwritten by the user.
  60185. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60186. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60187. * @param update the boolean update value actually passed to setParticles()
  60188. */
  60189. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60190. /**
  60191. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  60192. * This will be passed three parameters.
  60193. * This does nothing and may be overwritten by the user.
  60194. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60195. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60196. * @param update the boolean update value actually passed to setParticles()
  60197. */
  60198. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60199. }
  60200. }
  60201. declare module BABYLON {
  60202. /**
  60203. * Represents one particle of a points cloud system.
  60204. */
  60205. export class CloudPoint {
  60206. /**
  60207. * particle global index
  60208. */
  60209. idx: number;
  60210. /**
  60211. * The color of the particle
  60212. */
  60213. color: Nullable<Color4>;
  60214. /**
  60215. * The world space position of the particle.
  60216. */
  60217. position: Vector3;
  60218. /**
  60219. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  60220. */
  60221. rotation: Vector3;
  60222. /**
  60223. * The world space rotation quaternion of the particle.
  60224. */
  60225. rotationQuaternion: Nullable<Quaternion>;
  60226. /**
  60227. * The uv of the particle.
  60228. */
  60229. uv: Nullable<Vector2>;
  60230. /**
  60231. * The current speed of the particle.
  60232. */
  60233. velocity: Vector3;
  60234. /**
  60235. * The pivot point in the particle local space.
  60236. */
  60237. pivot: Vector3;
  60238. /**
  60239. * Must the particle be translated from its pivot point in its local space ?
  60240. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  60241. * Default : false
  60242. */
  60243. translateFromPivot: boolean;
  60244. /**
  60245. * Index of this particle in the global "positions" array (Internal use)
  60246. * @hidden
  60247. */
  60248. _pos: number;
  60249. /**
  60250. * @hidden Index of this particle in the global "indices" array (Internal use)
  60251. */
  60252. _ind: number;
  60253. /**
  60254. * Group this particle belongs to
  60255. */
  60256. _group: PointsGroup;
  60257. /**
  60258. * Group id of this particle
  60259. */
  60260. groupId: number;
  60261. /**
  60262. * Index of the particle in its group id (Internal use)
  60263. */
  60264. idxInGroup: number;
  60265. /**
  60266. * @hidden Particle BoundingInfo object (Internal use)
  60267. */
  60268. _boundingInfo: BoundingInfo;
  60269. /**
  60270. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  60271. */
  60272. _pcs: PointsCloudSystem;
  60273. /**
  60274. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  60275. */
  60276. _stillInvisible: boolean;
  60277. /**
  60278. * @hidden Last computed particle rotation matrix
  60279. */
  60280. _rotationMatrix: number[];
  60281. /**
  60282. * Parent particle Id, if any.
  60283. * Default null.
  60284. */
  60285. parentId: Nullable<number>;
  60286. /**
  60287. * @hidden Internal global position in the PCS.
  60288. */
  60289. _globalPosition: Vector3;
  60290. /**
  60291. * Creates a Point Cloud object.
  60292. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  60293. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  60294. * @param group (PointsGroup) is the group the particle belongs to
  60295. * @param groupId (integer) is the group identifier in the PCS.
  60296. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  60297. * @param pcs defines the PCS it is associated to
  60298. */
  60299. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  60300. /**
  60301. * get point size
  60302. */
  60303. /**
  60304. * Set point size
  60305. */
  60306. size: Vector3;
  60307. /**
  60308. * Legacy support, changed quaternion to rotationQuaternion
  60309. */
  60310. /**
  60311. * Legacy support, changed quaternion to rotationQuaternion
  60312. */
  60313. quaternion: Nullable<Quaternion>;
  60314. /**
  60315. * Returns a boolean. True if the particle intersects a mesh, else false
  60316. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  60317. * @param target is the object (point or mesh) what the intersection is computed against
  60318. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  60319. * @returns true if it intersects
  60320. */
  60321. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  60322. /**
  60323. * get the rotation matrix of the particle
  60324. * @hidden
  60325. */
  60326. getRotationMatrix(m: Matrix): void;
  60327. }
  60328. /**
  60329. * Represents a group of points in a points cloud system
  60330. * * PCS internal tool, don't use it manually.
  60331. */
  60332. export class PointsGroup {
  60333. /**
  60334. * The group id
  60335. * @hidden
  60336. */
  60337. groupID: number;
  60338. /**
  60339. * image data for group (internal use)
  60340. * @hidden
  60341. */
  60342. _groupImageData: Nullable<ArrayBufferView>;
  60343. /**
  60344. * Image Width (internal use)
  60345. * @hidden
  60346. */
  60347. _groupImgWidth: number;
  60348. /**
  60349. * Image Height (internal use)
  60350. * @hidden
  60351. */
  60352. _groupImgHeight: number;
  60353. /**
  60354. * Custom position function (internal use)
  60355. * @hidden
  60356. */
  60357. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  60358. /**
  60359. * density per facet for surface points
  60360. * @hidden
  60361. */
  60362. _groupDensity: number[];
  60363. /**
  60364. * Only when points are colored by texture carries pointer to texture list array
  60365. * @hidden
  60366. */
  60367. _textureNb: number;
  60368. /**
  60369. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  60370. * PCS internal tool, don't use it manually.
  60371. * @hidden
  60372. */
  60373. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  60374. }
  60375. }
  60376. declare module BABYLON {
  60377. interface Scene {
  60378. /** @hidden (Backing field) */
  60379. _physicsEngine: Nullable<IPhysicsEngine>;
  60380. /** @hidden */
  60381. _physicsTimeAccumulator: number;
  60382. /**
  60383. * Gets the current physics engine
  60384. * @returns a IPhysicsEngine or null if none attached
  60385. */
  60386. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60387. /**
  60388. * Enables physics to the current scene
  60389. * @param gravity defines the scene's gravity for the physics engine
  60390. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60391. * @return a boolean indicating if the physics engine was initialized
  60392. */
  60393. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60394. /**
  60395. * Disables and disposes the physics engine associated with the scene
  60396. */
  60397. disablePhysicsEngine(): void;
  60398. /**
  60399. * Gets a boolean indicating if there is an active physics engine
  60400. * @returns a boolean indicating if there is an active physics engine
  60401. */
  60402. isPhysicsEnabled(): boolean;
  60403. /**
  60404. * Deletes a physics compound impostor
  60405. * @param compound defines the compound to delete
  60406. */
  60407. deleteCompoundImpostor(compound: any): void;
  60408. /**
  60409. * An event triggered when physic simulation is about to be run
  60410. */
  60411. onBeforePhysicsObservable: Observable<Scene>;
  60412. /**
  60413. * An event triggered when physic simulation has been done
  60414. */
  60415. onAfterPhysicsObservable: Observable<Scene>;
  60416. }
  60417. interface AbstractMesh {
  60418. /** @hidden */
  60419. _physicsImpostor: Nullable<PhysicsImpostor>;
  60420. /**
  60421. * Gets or sets impostor used for physic simulation
  60422. * @see http://doc.babylonjs.com/features/physics_engine
  60423. */
  60424. physicsImpostor: Nullable<PhysicsImpostor>;
  60425. /**
  60426. * Gets the current physics impostor
  60427. * @see http://doc.babylonjs.com/features/physics_engine
  60428. * @returns a physics impostor or null
  60429. */
  60430. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60431. /** Apply a physic impulse to the mesh
  60432. * @param force defines the force to apply
  60433. * @param contactPoint defines where to apply the force
  60434. * @returns the current mesh
  60435. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60436. */
  60437. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60438. /**
  60439. * Creates a physic joint between two meshes
  60440. * @param otherMesh defines the other mesh to use
  60441. * @param pivot1 defines the pivot to use on this mesh
  60442. * @param pivot2 defines the pivot to use on the other mesh
  60443. * @param options defines additional options (can be plugin dependent)
  60444. * @returns the current mesh
  60445. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60446. */
  60447. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60448. /** @hidden */
  60449. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60450. }
  60451. /**
  60452. * Defines the physics engine scene component responsible to manage a physics engine
  60453. */
  60454. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60455. /**
  60456. * The component name helpful to identify the component in the list of scene components.
  60457. */
  60458. readonly name: string;
  60459. /**
  60460. * The scene the component belongs to.
  60461. */
  60462. scene: Scene;
  60463. /**
  60464. * Creates a new instance of the component for the given scene
  60465. * @param scene Defines the scene to register the component in
  60466. */
  60467. constructor(scene: Scene);
  60468. /**
  60469. * Registers the component in a given scene
  60470. */
  60471. register(): void;
  60472. /**
  60473. * Rebuilds the elements related to this component in case of
  60474. * context lost for instance.
  60475. */
  60476. rebuild(): void;
  60477. /**
  60478. * Disposes the component and the associated ressources
  60479. */
  60480. dispose(): void;
  60481. }
  60482. }
  60483. declare module BABYLON {
  60484. /**
  60485. * A helper for physics simulations
  60486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60487. */
  60488. export class PhysicsHelper {
  60489. private _scene;
  60490. private _physicsEngine;
  60491. /**
  60492. * Initializes the Physics helper
  60493. * @param scene Babylon.js scene
  60494. */
  60495. constructor(scene: Scene);
  60496. /**
  60497. * Applies a radial explosion impulse
  60498. * @param origin the origin of the explosion
  60499. * @param radiusOrEventOptions the radius or the options of radial explosion
  60500. * @param strength the explosion strength
  60501. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60502. * @returns A physics radial explosion event, or null
  60503. */
  60504. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60505. /**
  60506. * Applies a radial explosion force
  60507. * @param origin the origin of the explosion
  60508. * @param radiusOrEventOptions the radius or the options of radial explosion
  60509. * @param strength the explosion strength
  60510. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60511. * @returns A physics radial explosion event, or null
  60512. */
  60513. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60514. /**
  60515. * Creates a gravitational field
  60516. * @param origin the origin of the explosion
  60517. * @param radiusOrEventOptions the radius or the options of radial explosion
  60518. * @param strength the explosion strength
  60519. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60520. * @returns A physics gravitational field event, or null
  60521. */
  60522. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60523. /**
  60524. * Creates a physics updraft event
  60525. * @param origin the origin of the updraft
  60526. * @param radiusOrEventOptions the radius or the options of the updraft
  60527. * @param strength the strength of the updraft
  60528. * @param height the height of the updraft
  60529. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60530. * @returns A physics updraft event, or null
  60531. */
  60532. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60533. /**
  60534. * Creates a physics vortex event
  60535. * @param origin the of the vortex
  60536. * @param radiusOrEventOptions the radius or the options of the vortex
  60537. * @param strength the strength of the vortex
  60538. * @param height the height of the vortex
  60539. * @returns a Physics vortex event, or null
  60540. * A physics vortex event or null
  60541. */
  60542. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60543. }
  60544. /**
  60545. * Represents a physics radial explosion event
  60546. */
  60547. class PhysicsRadialExplosionEvent {
  60548. private _scene;
  60549. private _options;
  60550. private _sphere;
  60551. private _dataFetched;
  60552. /**
  60553. * Initializes a radial explosioin event
  60554. * @param _scene BabylonJS scene
  60555. * @param _options The options for the vortex event
  60556. */
  60557. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60558. /**
  60559. * Returns the data related to the radial explosion event (sphere).
  60560. * @returns The radial explosion event data
  60561. */
  60562. getData(): PhysicsRadialExplosionEventData;
  60563. /**
  60564. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60565. * @param impostor A physics imposter
  60566. * @param origin the origin of the explosion
  60567. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60568. */
  60569. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60570. /**
  60571. * Triggers affecterd impostors callbacks
  60572. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60573. */
  60574. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60575. /**
  60576. * Disposes the sphere.
  60577. * @param force Specifies if the sphere should be disposed by force
  60578. */
  60579. dispose(force?: boolean): void;
  60580. /*** Helpers ***/
  60581. private _prepareSphere;
  60582. private _intersectsWithSphere;
  60583. }
  60584. /**
  60585. * Represents a gravitational field event
  60586. */
  60587. class PhysicsGravitationalFieldEvent {
  60588. private _physicsHelper;
  60589. private _scene;
  60590. private _origin;
  60591. private _options;
  60592. private _tickCallback;
  60593. private _sphere;
  60594. private _dataFetched;
  60595. /**
  60596. * Initializes the physics gravitational field event
  60597. * @param _physicsHelper A physics helper
  60598. * @param _scene BabylonJS scene
  60599. * @param _origin The origin position of the gravitational field event
  60600. * @param _options The options for the vortex event
  60601. */
  60602. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60603. /**
  60604. * Returns the data related to the gravitational field event (sphere).
  60605. * @returns A gravitational field event
  60606. */
  60607. getData(): PhysicsGravitationalFieldEventData;
  60608. /**
  60609. * Enables the gravitational field.
  60610. */
  60611. enable(): void;
  60612. /**
  60613. * Disables the gravitational field.
  60614. */
  60615. disable(): void;
  60616. /**
  60617. * Disposes the sphere.
  60618. * @param force The force to dispose from the gravitational field event
  60619. */
  60620. dispose(force?: boolean): void;
  60621. private _tick;
  60622. }
  60623. /**
  60624. * Represents a physics updraft event
  60625. */
  60626. class PhysicsUpdraftEvent {
  60627. private _scene;
  60628. private _origin;
  60629. private _options;
  60630. private _physicsEngine;
  60631. private _originTop;
  60632. private _originDirection;
  60633. private _tickCallback;
  60634. private _cylinder;
  60635. private _cylinderPosition;
  60636. private _dataFetched;
  60637. /**
  60638. * Initializes the physics updraft event
  60639. * @param _scene BabylonJS scene
  60640. * @param _origin The origin position of the updraft
  60641. * @param _options The options for the updraft event
  60642. */
  60643. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60644. /**
  60645. * Returns the data related to the updraft event (cylinder).
  60646. * @returns A physics updraft event
  60647. */
  60648. getData(): PhysicsUpdraftEventData;
  60649. /**
  60650. * Enables the updraft.
  60651. */
  60652. enable(): void;
  60653. /**
  60654. * Disables the updraft.
  60655. */
  60656. disable(): void;
  60657. /**
  60658. * Disposes the cylinder.
  60659. * @param force Specifies if the updraft should be disposed by force
  60660. */
  60661. dispose(force?: boolean): void;
  60662. private getImpostorHitData;
  60663. private _tick;
  60664. /*** Helpers ***/
  60665. private _prepareCylinder;
  60666. private _intersectsWithCylinder;
  60667. }
  60668. /**
  60669. * Represents a physics vortex event
  60670. */
  60671. class PhysicsVortexEvent {
  60672. private _scene;
  60673. private _origin;
  60674. private _options;
  60675. private _physicsEngine;
  60676. private _originTop;
  60677. private _tickCallback;
  60678. private _cylinder;
  60679. private _cylinderPosition;
  60680. private _dataFetched;
  60681. /**
  60682. * Initializes the physics vortex event
  60683. * @param _scene The BabylonJS scene
  60684. * @param _origin The origin position of the vortex
  60685. * @param _options The options for the vortex event
  60686. */
  60687. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60688. /**
  60689. * Returns the data related to the vortex event (cylinder).
  60690. * @returns The physics vortex event data
  60691. */
  60692. getData(): PhysicsVortexEventData;
  60693. /**
  60694. * Enables the vortex.
  60695. */
  60696. enable(): void;
  60697. /**
  60698. * Disables the cortex.
  60699. */
  60700. disable(): void;
  60701. /**
  60702. * Disposes the sphere.
  60703. * @param force
  60704. */
  60705. dispose(force?: boolean): void;
  60706. private getImpostorHitData;
  60707. private _tick;
  60708. /*** Helpers ***/
  60709. private _prepareCylinder;
  60710. private _intersectsWithCylinder;
  60711. }
  60712. /**
  60713. * Options fot the radial explosion event
  60714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60715. */
  60716. export class PhysicsRadialExplosionEventOptions {
  60717. /**
  60718. * The radius of the sphere for the radial explosion.
  60719. */
  60720. radius: number;
  60721. /**
  60722. * The strenth of the explosion.
  60723. */
  60724. strength: number;
  60725. /**
  60726. * The strenght of the force in correspondence to the distance of the affected object
  60727. */
  60728. falloff: PhysicsRadialImpulseFalloff;
  60729. /**
  60730. * Sphere options for the radial explosion.
  60731. */
  60732. sphere: {
  60733. segments: number;
  60734. diameter: number;
  60735. };
  60736. /**
  60737. * Sphere options for the radial explosion.
  60738. */
  60739. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60740. }
  60741. /**
  60742. * Options fot the updraft event
  60743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60744. */
  60745. export class PhysicsUpdraftEventOptions {
  60746. /**
  60747. * The radius of the cylinder for the vortex
  60748. */
  60749. radius: number;
  60750. /**
  60751. * The strenth of the updraft.
  60752. */
  60753. strength: number;
  60754. /**
  60755. * The height of the cylinder for the updraft.
  60756. */
  60757. height: number;
  60758. /**
  60759. * The mode for the the updraft.
  60760. */
  60761. updraftMode: PhysicsUpdraftMode;
  60762. }
  60763. /**
  60764. * Options fot the vortex event
  60765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60766. */
  60767. export class PhysicsVortexEventOptions {
  60768. /**
  60769. * The radius of the cylinder for the vortex
  60770. */
  60771. radius: number;
  60772. /**
  60773. * The strenth of the vortex.
  60774. */
  60775. strength: number;
  60776. /**
  60777. * The height of the cylinder for the vortex.
  60778. */
  60779. height: number;
  60780. /**
  60781. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60782. */
  60783. centripetalForceThreshold: number;
  60784. /**
  60785. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60786. */
  60787. centripetalForceMultiplier: number;
  60788. /**
  60789. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60790. */
  60791. centrifugalForceMultiplier: number;
  60792. /**
  60793. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60794. */
  60795. updraftForceMultiplier: number;
  60796. }
  60797. /**
  60798. * The strenght of the force in correspondence to the distance of the affected object
  60799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60800. */
  60801. export enum PhysicsRadialImpulseFalloff {
  60802. /** Defines that impulse is constant in strength across it's whole radius */
  60803. Constant = 0,
  60804. /** Defines that impulse gets weaker if it's further from the origin */
  60805. Linear = 1
  60806. }
  60807. /**
  60808. * The strength of the force in correspondence to the distance of the affected object
  60809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60810. */
  60811. export enum PhysicsUpdraftMode {
  60812. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60813. Center = 0,
  60814. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60815. Perpendicular = 1
  60816. }
  60817. /**
  60818. * Interface for a physics hit data
  60819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60820. */
  60821. export interface PhysicsHitData {
  60822. /**
  60823. * The force applied at the contact point
  60824. */
  60825. force: Vector3;
  60826. /**
  60827. * The contact point
  60828. */
  60829. contactPoint: Vector3;
  60830. /**
  60831. * The distance from the origin to the contact point
  60832. */
  60833. distanceFromOrigin: number;
  60834. }
  60835. /**
  60836. * Interface for radial explosion event data
  60837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60838. */
  60839. export interface PhysicsRadialExplosionEventData {
  60840. /**
  60841. * A sphere used for the radial explosion event
  60842. */
  60843. sphere: Mesh;
  60844. }
  60845. /**
  60846. * Interface for gravitational field event data
  60847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60848. */
  60849. export interface PhysicsGravitationalFieldEventData {
  60850. /**
  60851. * A sphere mesh used for the gravitational field event
  60852. */
  60853. sphere: Mesh;
  60854. }
  60855. /**
  60856. * Interface for updraft event data
  60857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60858. */
  60859. export interface PhysicsUpdraftEventData {
  60860. /**
  60861. * A cylinder used for the updraft event
  60862. */
  60863. cylinder: Mesh;
  60864. }
  60865. /**
  60866. * Interface for vortex event data
  60867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60868. */
  60869. export interface PhysicsVortexEventData {
  60870. /**
  60871. * A cylinder used for the vortex event
  60872. */
  60873. cylinder: Mesh;
  60874. }
  60875. /**
  60876. * Interface for an affected physics impostor
  60877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60878. */
  60879. export interface PhysicsAffectedImpostorWithData {
  60880. /**
  60881. * The impostor affected by the effect
  60882. */
  60883. impostor: PhysicsImpostor;
  60884. /**
  60885. * The data about the hit/horce from the explosion
  60886. */
  60887. hitData: PhysicsHitData;
  60888. }
  60889. }
  60890. declare module BABYLON {
  60891. /** @hidden */
  60892. export var blackAndWhitePixelShader: {
  60893. name: string;
  60894. shader: string;
  60895. };
  60896. }
  60897. declare module BABYLON {
  60898. /**
  60899. * Post process used to render in black and white
  60900. */
  60901. export class BlackAndWhitePostProcess extends PostProcess {
  60902. /**
  60903. * Linear about to convert he result to black and white (default: 1)
  60904. */
  60905. degree: number;
  60906. /**
  60907. * Creates a black and white post process
  60908. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60909. * @param name The name of the effect.
  60910. * @param options The required width/height ratio to downsize to before computing the render pass.
  60911. * @param camera The camera to apply the render pass to.
  60912. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60913. * @param engine The engine which the post process will be applied. (default: current engine)
  60914. * @param reusable If the post process can be reused on the same frame. (default: false)
  60915. */
  60916. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60917. }
  60918. }
  60919. declare module BABYLON {
  60920. /**
  60921. * This represents a set of one or more post processes in Babylon.
  60922. * A post process can be used to apply a shader to a texture after it is rendered.
  60923. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60924. */
  60925. export class PostProcessRenderEffect {
  60926. private _postProcesses;
  60927. private _getPostProcesses;
  60928. private _singleInstance;
  60929. private _cameras;
  60930. private _indicesForCamera;
  60931. /**
  60932. * Name of the effect
  60933. * @hidden
  60934. */
  60935. _name: string;
  60936. /**
  60937. * Instantiates a post process render effect.
  60938. * A post process can be used to apply a shader to a texture after it is rendered.
  60939. * @param engine The engine the effect is tied to
  60940. * @param name The name of the effect
  60941. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60942. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60943. */
  60944. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60945. /**
  60946. * Checks if all the post processes in the effect are supported.
  60947. */
  60948. readonly isSupported: boolean;
  60949. /**
  60950. * Updates the current state of the effect
  60951. * @hidden
  60952. */
  60953. _update(): void;
  60954. /**
  60955. * Attaches the effect on cameras
  60956. * @param cameras The camera to attach to.
  60957. * @hidden
  60958. */
  60959. _attachCameras(cameras: Camera): void;
  60960. /**
  60961. * Attaches the effect on cameras
  60962. * @param cameras The camera to attach to.
  60963. * @hidden
  60964. */
  60965. _attachCameras(cameras: Camera[]): void;
  60966. /**
  60967. * Detaches the effect on cameras
  60968. * @param cameras The camera to detatch from.
  60969. * @hidden
  60970. */
  60971. _detachCameras(cameras: Camera): void;
  60972. /**
  60973. * Detatches the effect on cameras
  60974. * @param cameras The camera to detatch from.
  60975. * @hidden
  60976. */
  60977. _detachCameras(cameras: Camera[]): void;
  60978. /**
  60979. * Enables the effect on given cameras
  60980. * @param cameras The camera to enable.
  60981. * @hidden
  60982. */
  60983. _enable(cameras: Camera): void;
  60984. /**
  60985. * Enables the effect on given cameras
  60986. * @param cameras The camera to enable.
  60987. * @hidden
  60988. */
  60989. _enable(cameras: Nullable<Camera[]>): void;
  60990. /**
  60991. * Disables the effect on the given cameras
  60992. * @param cameras The camera to disable.
  60993. * @hidden
  60994. */
  60995. _disable(cameras: Camera): void;
  60996. /**
  60997. * Disables the effect on the given cameras
  60998. * @param cameras The camera to disable.
  60999. * @hidden
  61000. */
  61001. _disable(cameras: Nullable<Camera[]>): void;
  61002. /**
  61003. * Gets a list of the post processes contained in the effect.
  61004. * @param camera The camera to get the post processes on.
  61005. * @returns The list of the post processes in the effect.
  61006. */
  61007. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61008. }
  61009. }
  61010. declare module BABYLON {
  61011. /** @hidden */
  61012. export var extractHighlightsPixelShader: {
  61013. name: string;
  61014. shader: string;
  61015. };
  61016. }
  61017. declare module BABYLON {
  61018. /**
  61019. * 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.
  61020. */
  61021. export class ExtractHighlightsPostProcess extends PostProcess {
  61022. /**
  61023. * The luminance threshold, pixels below this value will be set to black.
  61024. */
  61025. threshold: number;
  61026. /** @hidden */
  61027. _exposure: number;
  61028. /**
  61029. * Post process which has the input texture to be used when performing highlight extraction
  61030. * @hidden
  61031. */
  61032. _inputPostProcess: Nullable<PostProcess>;
  61033. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61034. }
  61035. }
  61036. declare module BABYLON {
  61037. /** @hidden */
  61038. export var bloomMergePixelShader: {
  61039. name: string;
  61040. shader: string;
  61041. };
  61042. }
  61043. declare module BABYLON {
  61044. /**
  61045. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61046. */
  61047. export class BloomMergePostProcess extends PostProcess {
  61048. /** Weight of the bloom to be added to the original input. */
  61049. weight: number;
  61050. /**
  61051. * Creates a new instance of @see BloomMergePostProcess
  61052. * @param name The name of the effect.
  61053. * @param originalFromInput Post process which's input will be used for the merge.
  61054. * @param blurred Blurred highlights post process which's output will be used.
  61055. * @param weight Weight of the bloom to be added to the original input.
  61056. * @param options The required width/height ratio to downsize to before computing the render pass.
  61057. * @param camera The camera to apply the render pass to.
  61058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61059. * @param engine The engine which the post process will be applied. (default: current engine)
  61060. * @param reusable If the post process can be reused on the same frame. (default: false)
  61061. * @param textureType Type of textures used when performing the post process. (default: 0)
  61062. * @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)
  61063. */
  61064. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61065. /** Weight of the bloom to be added to the original input. */
  61066. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61067. }
  61068. }
  61069. declare module BABYLON {
  61070. /**
  61071. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61072. */
  61073. export class BloomEffect extends PostProcessRenderEffect {
  61074. private bloomScale;
  61075. /**
  61076. * @hidden Internal
  61077. */
  61078. _effects: Array<PostProcess>;
  61079. /**
  61080. * @hidden Internal
  61081. */
  61082. _downscale: ExtractHighlightsPostProcess;
  61083. private _blurX;
  61084. private _blurY;
  61085. private _merge;
  61086. /**
  61087. * The luminance threshold to find bright areas of the image to bloom.
  61088. */
  61089. threshold: number;
  61090. /**
  61091. * The strength of the bloom.
  61092. */
  61093. weight: number;
  61094. /**
  61095. * Specifies the size of the bloom blur kernel, relative to the final output size
  61096. */
  61097. kernel: number;
  61098. /**
  61099. * Creates a new instance of @see BloomEffect
  61100. * @param scene The scene the effect belongs to.
  61101. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61102. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61103. * @param bloomWeight The the strength of bloom.
  61104. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61105. * @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)
  61106. */
  61107. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61108. /**
  61109. * Disposes each of the internal effects for a given camera.
  61110. * @param camera The camera to dispose the effect on.
  61111. */
  61112. disposeEffects(camera: Camera): void;
  61113. /**
  61114. * @hidden Internal
  61115. */
  61116. _updateEffects(): void;
  61117. /**
  61118. * Internal
  61119. * @returns if all the contained post processes are ready.
  61120. * @hidden
  61121. */
  61122. _isReady(): boolean;
  61123. }
  61124. }
  61125. declare module BABYLON {
  61126. /** @hidden */
  61127. export var chromaticAberrationPixelShader: {
  61128. name: string;
  61129. shader: string;
  61130. };
  61131. }
  61132. declare module BABYLON {
  61133. /**
  61134. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61135. */
  61136. export class ChromaticAberrationPostProcess extends PostProcess {
  61137. /**
  61138. * The amount of seperation of rgb channels (default: 30)
  61139. */
  61140. aberrationAmount: number;
  61141. /**
  61142. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61143. */
  61144. radialIntensity: number;
  61145. /**
  61146. * 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))
  61147. */
  61148. direction: Vector2;
  61149. /**
  61150. * 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))
  61151. */
  61152. centerPosition: Vector2;
  61153. /**
  61154. * Creates a new instance ChromaticAberrationPostProcess
  61155. * @param name The name of the effect.
  61156. * @param screenWidth The width of the screen to apply the effect on.
  61157. * @param screenHeight The height of the screen to apply the effect on.
  61158. * @param options The required width/height ratio to downsize to before computing the render pass.
  61159. * @param camera The camera to apply the render pass to.
  61160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61161. * @param engine The engine which the post process will be applied. (default: current engine)
  61162. * @param reusable If the post process can be reused on the same frame. (default: false)
  61163. * @param textureType Type of textures used when performing the post process. (default: 0)
  61164. * @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)
  61165. */
  61166. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61167. }
  61168. }
  61169. declare module BABYLON {
  61170. /** @hidden */
  61171. export var circleOfConfusionPixelShader: {
  61172. name: string;
  61173. shader: string;
  61174. };
  61175. }
  61176. declare module BABYLON {
  61177. /**
  61178. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61179. */
  61180. export class CircleOfConfusionPostProcess extends PostProcess {
  61181. /**
  61182. * 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.
  61183. */
  61184. lensSize: number;
  61185. /**
  61186. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61187. */
  61188. fStop: number;
  61189. /**
  61190. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61191. */
  61192. focusDistance: number;
  61193. /**
  61194. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61195. */
  61196. focalLength: number;
  61197. private _depthTexture;
  61198. /**
  61199. * Creates a new instance CircleOfConfusionPostProcess
  61200. * @param name The name of the effect.
  61201. * @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.
  61202. * @param options The required width/height ratio to downsize to before computing the render pass.
  61203. * @param camera The camera to apply the render pass to.
  61204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61205. * @param engine The engine which the post process will be applied. (default: current engine)
  61206. * @param reusable If the post process can be reused on the same frame. (default: false)
  61207. * @param textureType Type of textures used when performing the post process. (default: 0)
  61208. * @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)
  61209. */
  61210. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61211. /**
  61212. * 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.
  61213. */
  61214. depthTexture: RenderTargetTexture;
  61215. }
  61216. }
  61217. declare module BABYLON {
  61218. /** @hidden */
  61219. export var colorCorrectionPixelShader: {
  61220. name: string;
  61221. shader: string;
  61222. };
  61223. }
  61224. declare module BABYLON {
  61225. /**
  61226. *
  61227. * This post-process allows the modification of rendered colors by using
  61228. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61229. *
  61230. * The object needs to be provided an url to a texture containing the color
  61231. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61232. * Use an image editing software to tweak the LUT to match your needs.
  61233. *
  61234. * For an example of a color LUT, see here:
  61235. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61236. * For explanations on color grading, see here:
  61237. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61238. *
  61239. */
  61240. export class ColorCorrectionPostProcess extends PostProcess {
  61241. private _colorTableTexture;
  61242. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61243. }
  61244. }
  61245. declare module BABYLON {
  61246. /** @hidden */
  61247. export var convolutionPixelShader: {
  61248. name: string;
  61249. shader: string;
  61250. };
  61251. }
  61252. declare module BABYLON {
  61253. /**
  61254. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61255. * input texture to perform effects such as edge detection or sharpening
  61256. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61257. */
  61258. export class ConvolutionPostProcess extends PostProcess {
  61259. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61260. kernel: number[];
  61261. /**
  61262. * Creates a new instance ConvolutionPostProcess
  61263. * @param name The name of the effect.
  61264. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61265. * @param options The required width/height ratio to downsize to before computing the render pass.
  61266. * @param camera The camera to apply the render pass to.
  61267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61268. * @param engine The engine which the post process will be applied. (default: current engine)
  61269. * @param reusable If the post process can be reused on the same frame. (default: false)
  61270. * @param textureType Type of textures used when performing the post process. (default: 0)
  61271. */
  61272. constructor(name: string,
  61273. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61274. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61275. /**
  61276. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61277. */
  61278. static EdgeDetect0Kernel: number[];
  61279. /**
  61280. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61281. */
  61282. static EdgeDetect1Kernel: number[];
  61283. /**
  61284. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61285. */
  61286. static EdgeDetect2Kernel: number[];
  61287. /**
  61288. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61289. */
  61290. static SharpenKernel: number[];
  61291. /**
  61292. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61293. */
  61294. static EmbossKernel: number[];
  61295. /**
  61296. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61297. */
  61298. static GaussianKernel: number[];
  61299. }
  61300. }
  61301. declare module BABYLON {
  61302. /**
  61303. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61304. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61305. * based on samples that have a large difference in distance than the center pixel.
  61306. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61307. */
  61308. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61309. direction: Vector2;
  61310. /**
  61311. * Creates a new instance CircleOfConfusionPostProcess
  61312. * @param name The name of the effect.
  61313. * @param scene The scene the effect belongs to.
  61314. * @param direction The direction the blur should be applied.
  61315. * @param kernel The size of the kernel used to blur.
  61316. * @param options The required width/height ratio to downsize to before computing the render pass.
  61317. * @param camera The camera to apply the render pass to.
  61318. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61319. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61321. * @param engine The engine which the post process will be applied. (default: current engine)
  61322. * @param reusable If the post process can be reused on the same frame. (default: false)
  61323. * @param textureType Type of textures used when performing the post process. (default: 0)
  61324. * @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)
  61325. */
  61326. 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);
  61327. }
  61328. }
  61329. declare module BABYLON {
  61330. /** @hidden */
  61331. export var depthOfFieldMergePixelShader: {
  61332. name: string;
  61333. shader: string;
  61334. };
  61335. }
  61336. declare module BABYLON {
  61337. /**
  61338. * Options to be set when merging outputs from the default pipeline.
  61339. */
  61340. export class DepthOfFieldMergePostProcessOptions {
  61341. /**
  61342. * The original image to merge on top of
  61343. */
  61344. originalFromInput: PostProcess;
  61345. /**
  61346. * Parameters to perform the merge of the depth of field effect
  61347. */
  61348. depthOfField?: {
  61349. circleOfConfusion: PostProcess;
  61350. blurSteps: Array<PostProcess>;
  61351. };
  61352. /**
  61353. * Parameters to perform the merge of bloom effect
  61354. */
  61355. bloom?: {
  61356. blurred: PostProcess;
  61357. weight: number;
  61358. };
  61359. }
  61360. /**
  61361. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61362. */
  61363. export class DepthOfFieldMergePostProcess extends PostProcess {
  61364. private blurSteps;
  61365. /**
  61366. * Creates a new instance of DepthOfFieldMergePostProcess
  61367. * @param name The name of the effect.
  61368. * @param originalFromInput Post process which's input will be used for the merge.
  61369. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61370. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61371. * @param options The required width/height ratio to downsize to before computing the render pass.
  61372. * @param camera The camera to apply the render pass to.
  61373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61374. * @param engine The engine which the post process will be applied. (default: current engine)
  61375. * @param reusable If the post process can be reused on the same frame. (default: false)
  61376. * @param textureType Type of textures used when performing the post process. (default: 0)
  61377. * @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)
  61378. */
  61379. 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);
  61380. /**
  61381. * Updates the effect with the current post process compile time values and recompiles the shader.
  61382. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61383. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61384. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61385. * @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
  61386. * @param onCompiled Called when the shader has been compiled.
  61387. * @param onError Called if there is an error when compiling a shader.
  61388. */
  61389. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61390. }
  61391. }
  61392. declare module BABYLON {
  61393. /**
  61394. * Specifies the level of max blur that should be applied when using the depth of field effect
  61395. */
  61396. export enum DepthOfFieldEffectBlurLevel {
  61397. /**
  61398. * Subtle blur
  61399. */
  61400. Low = 0,
  61401. /**
  61402. * Medium blur
  61403. */
  61404. Medium = 1,
  61405. /**
  61406. * Large blur
  61407. */
  61408. High = 2
  61409. }
  61410. /**
  61411. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61412. */
  61413. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61414. private _circleOfConfusion;
  61415. /**
  61416. * @hidden Internal, blurs from high to low
  61417. */
  61418. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61419. private _depthOfFieldBlurY;
  61420. private _dofMerge;
  61421. /**
  61422. * @hidden Internal post processes in depth of field effect
  61423. */
  61424. _effects: Array<PostProcess>;
  61425. /**
  61426. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61427. */
  61428. focalLength: number;
  61429. /**
  61430. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61431. */
  61432. fStop: number;
  61433. /**
  61434. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61435. */
  61436. focusDistance: number;
  61437. /**
  61438. * 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.
  61439. */
  61440. lensSize: number;
  61441. /**
  61442. * Creates a new instance DepthOfFieldEffect
  61443. * @param scene The scene the effect belongs to.
  61444. * @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.
  61445. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61446. * @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)
  61447. */
  61448. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61449. /**
  61450. * Get the current class name of the current effet
  61451. * @returns "DepthOfFieldEffect"
  61452. */
  61453. getClassName(): string;
  61454. /**
  61455. * 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.
  61456. */
  61457. depthTexture: RenderTargetTexture;
  61458. /**
  61459. * Disposes each of the internal effects for a given camera.
  61460. * @param camera The camera to dispose the effect on.
  61461. */
  61462. disposeEffects(camera: Camera): void;
  61463. /**
  61464. * @hidden Internal
  61465. */
  61466. _updateEffects(): void;
  61467. /**
  61468. * Internal
  61469. * @returns if all the contained post processes are ready.
  61470. * @hidden
  61471. */
  61472. _isReady(): boolean;
  61473. }
  61474. }
  61475. declare module BABYLON {
  61476. /** @hidden */
  61477. export var displayPassPixelShader: {
  61478. name: string;
  61479. shader: string;
  61480. };
  61481. }
  61482. declare module BABYLON {
  61483. /**
  61484. * DisplayPassPostProcess which produces an output the same as it's input
  61485. */
  61486. export class DisplayPassPostProcess extends PostProcess {
  61487. /**
  61488. * Creates the DisplayPassPostProcess
  61489. * @param name The name of the effect.
  61490. * @param options The required width/height ratio to downsize to before computing the render pass.
  61491. * @param camera The camera to apply the render pass to.
  61492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61493. * @param engine The engine which the post process will be applied. (default: current engine)
  61494. * @param reusable If the post process can be reused on the same frame. (default: false)
  61495. */
  61496. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61497. }
  61498. }
  61499. declare module BABYLON {
  61500. /** @hidden */
  61501. export var filterPixelShader: {
  61502. name: string;
  61503. shader: string;
  61504. };
  61505. }
  61506. declare module BABYLON {
  61507. /**
  61508. * Applies a kernel filter to the image
  61509. */
  61510. export class FilterPostProcess extends PostProcess {
  61511. /** The matrix to be applied to the image */
  61512. kernelMatrix: Matrix;
  61513. /**
  61514. *
  61515. * @param name The name of the effect.
  61516. * @param kernelMatrix The matrix to be applied to the image
  61517. * @param options The required width/height ratio to downsize to before computing the render pass.
  61518. * @param camera The camera to apply the render pass to.
  61519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61520. * @param engine The engine which the post process will be applied. (default: current engine)
  61521. * @param reusable If the post process can be reused on the same frame. (default: false)
  61522. */
  61523. constructor(name: string,
  61524. /** The matrix to be applied to the image */
  61525. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61526. }
  61527. }
  61528. declare module BABYLON {
  61529. /** @hidden */
  61530. export var fxaaPixelShader: {
  61531. name: string;
  61532. shader: string;
  61533. };
  61534. }
  61535. declare module BABYLON {
  61536. /** @hidden */
  61537. export var fxaaVertexShader: {
  61538. name: string;
  61539. shader: string;
  61540. };
  61541. }
  61542. declare module BABYLON {
  61543. /**
  61544. * Fxaa post process
  61545. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61546. */
  61547. export class FxaaPostProcess extends PostProcess {
  61548. /** @hidden */
  61549. texelWidth: number;
  61550. /** @hidden */
  61551. texelHeight: number;
  61552. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61553. private _getDefines;
  61554. }
  61555. }
  61556. declare module BABYLON {
  61557. /** @hidden */
  61558. export var grainPixelShader: {
  61559. name: string;
  61560. shader: string;
  61561. };
  61562. }
  61563. declare module BABYLON {
  61564. /**
  61565. * The GrainPostProcess adds noise to the image at mid luminance levels
  61566. */
  61567. export class GrainPostProcess extends PostProcess {
  61568. /**
  61569. * The intensity of the grain added (default: 30)
  61570. */
  61571. intensity: number;
  61572. /**
  61573. * If the grain should be randomized on every frame
  61574. */
  61575. animated: boolean;
  61576. /**
  61577. * Creates a new instance of @see GrainPostProcess
  61578. * @param name The name of the effect.
  61579. * @param options The required width/height ratio to downsize to before computing the render pass.
  61580. * @param camera The camera to apply the render pass to.
  61581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61582. * @param engine The engine which the post process will be applied. (default: current engine)
  61583. * @param reusable If the post process can be reused on the same frame. (default: false)
  61584. * @param textureType Type of textures used when performing the post process. (default: 0)
  61585. * @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)
  61586. */
  61587. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61588. }
  61589. }
  61590. declare module BABYLON {
  61591. /** @hidden */
  61592. export var highlightsPixelShader: {
  61593. name: string;
  61594. shader: string;
  61595. };
  61596. }
  61597. declare module BABYLON {
  61598. /**
  61599. * Extracts highlights from the image
  61600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61601. */
  61602. export class HighlightsPostProcess extends PostProcess {
  61603. /**
  61604. * Extracts highlights from the image
  61605. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61606. * @param name The name of the effect.
  61607. * @param options The required width/height ratio to downsize to before computing the render pass.
  61608. * @param camera The camera to apply the render pass to.
  61609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61610. * @param engine The engine which the post process will be applied. (default: current engine)
  61611. * @param reusable If the post process can be reused on the same frame. (default: false)
  61612. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61613. */
  61614. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61615. }
  61616. }
  61617. declare module BABYLON {
  61618. /** @hidden */
  61619. export var mrtFragmentDeclaration: {
  61620. name: string;
  61621. shader: string;
  61622. };
  61623. }
  61624. declare module BABYLON {
  61625. /** @hidden */
  61626. export var geometryPixelShader: {
  61627. name: string;
  61628. shader: string;
  61629. };
  61630. }
  61631. declare module BABYLON {
  61632. /** @hidden */
  61633. export var geometryVertexShader: {
  61634. name: string;
  61635. shader: string;
  61636. };
  61637. }
  61638. declare module BABYLON {
  61639. /** @hidden */
  61640. interface ISavedTransformationMatrix {
  61641. world: Matrix;
  61642. viewProjection: Matrix;
  61643. }
  61644. /**
  61645. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61646. */
  61647. export class GeometryBufferRenderer {
  61648. /**
  61649. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61650. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61651. */
  61652. static readonly POSITION_TEXTURE_TYPE: number;
  61653. /**
  61654. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61655. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61656. */
  61657. static readonly VELOCITY_TEXTURE_TYPE: number;
  61658. /**
  61659. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61660. * in order to compute objects velocities when enableVelocity is set to "true"
  61661. * @hidden
  61662. */
  61663. _previousTransformationMatrices: {
  61664. [index: number]: ISavedTransformationMatrix;
  61665. };
  61666. /**
  61667. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61668. * in order to compute objects velocities when enableVelocity is set to "true"
  61669. * @hidden
  61670. */
  61671. _previousBonesTransformationMatrices: {
  61672. [index: number]: Float32Array;
  61673. };
  61674. /**
  61675. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61676. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61677. */
  61678. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61679. private _scene;
  61680. private _multiRenderTarget;
  61681. private _ratio;
  61682. private _enablePosition;
  61683. private _enableVelocity;
  61684. private _positionIndex;
  61685. private _velocityIndex;
  61686. protected _effect: Effect;
  61687. protected _cachedDefines: string;
  61688. /**
  61689. * Set the render list (meshes to be rendered) used in the G buffer.
  61690. */
  61691. renderList: Mesh[];
  61692. /**
  61693. * Gets wether or not G buffer are supported by the running hardware.
  61694. * This requires draw buffer supports
  61695. */
  61696. readonly isSupported: boolean;
  61697. /**
  61698. * Returns the index of the given texture type in the G-Buffer textures array
  61699. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61700. * @returns the index of the given texture type in the G-Buffer textures array
  61701. */
  61702. getTextureIndex(textureType: number): number;
  61703. /**
  61704. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61705. */
  61706. /**
  61707. * Sets whether or not objects positions are enabled for the G buffer.
  61708. */
  61709. enablePosition: boolean;
  61710. /**
  61711. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61712. */
  61713. /**
  61714. * Sets wether or not objects velocities are enabled for the G buffer.
  61715. */
  61716. enableVelocity: boolean;
  61717. /**
  61718. * Gets the scene associated with the buffer.
  61719. */
  61720. readonly scene: Scene;
  61721. /**
  61722. * Gets the ratio used by the buffer during its creation.
  61723. * How big is the buffer related to the main canvas.
  61724. */
  61725. readonly ratio: number;
  61726. /** @hidden */
  61727. static _SceneComponentInitialization: (scene: Scene) => void;
  61728. /**
  61729. * Creates a new G Buffer for the scene
  61730. * @param scene The scene the buffer belongs to
  61731. * @param ratio How big is the buffer related to the main canvas.
  61732. */
  61733. constructor(scene: Scene, ratio?: number);
  61734. /**
  61735. * Checks wether everything is ready to render a submesh to the G buffer.
  61736. * @param subMesh the submesh to check readiness for
  61737. * @param useInstances is the mesh drawn using instance or not
  61738. * @returns true if ready otherwise false
  61739. */
  61740. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61741. /**
  61742. * Gets the current underlying G Buffer.
  61743. * @returns the buffer
  61744. */
  61745. getGBuffer(): MultiRenderTarget;
  61746. /**
  61747. * Gets the number of samples used to render the buffer (anti aliasing).
  61748. */
  61749. /**
  61750. * Sets the number of samples used to render the buffer (anti aliasing).
  61751. */
  61752. samples: number;
  61753. /**
  61754. * Disposes the renderer and frees up associated resources.
  61755. */
  61756. dispose(): void;
  61757. protected _createRenderTargets(): void;
  61758. private _copyBonesTransformationMatrices;
  61759. }
  61760. }
  61761. declare module BABYLON {
  61762. interface Scene {
  61763. /** @hidden (Backing field) */
  61764. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61765. /**
  61766. * Gets or Sets the current geometry buffer associated to the scene.
  61767. */
  61768. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61769. /**
  61770. * Enables a GeometryBufferRender and associates it with the scene
  61771. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61772. * @returns the GeometryBufferRenderer
  61773. */
  61774. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61775. /**
  61776. * Disables the GeometryBufferRender associated with the scene
  61777. */
  61778. disableGeometryBufferRenderer(): void;
  61779. }
  61780. /**
  61781. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61782. * in several rendering techniques.
  61783. */
  61784. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61785. /**
  61786. * The component name helpful to identify the component in the list of scene components.
  61787. */
  61788. readonly name: string;
  61789. /**
  61790. * The scene the component belongs to.
  61791. */
  61792. scene: Scene;
  61793. /**
  61794. * Creates a new instance of the component for the given scene
  61795. * @param scene Defines the scene to register the component in
  61796. */
  61797. constructor(scene: Scene);
  61798. /**
  61799. * Registers the component in a given scene
  61800. */
  61801. register(): void;
  61802. /**
  61803. * Rebuilds the elements related to this component in case of
  61804. * context lost for instance.
  61805. */
  61806. rebuild(): void;
  61807. /**
  61808. * Disposes the component and the associated ressources
  61809. */
  61810. dispose(): void;
  61811. private _gatherRenderTargets;
  61812. }
  61813. }
  61814. declare module BABYLON {
  61815. /** @hidden */
  61816. export var motionBlurPixelShader: {
  61817. name: string;
  61818. shader: string;
  61819. };
  61820. }
  61821. declare module BABYLON {
  61822. /**
  61823. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61824. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61825. * As an example, all you have to do is to create the post-process:
  61826. * var mb = new BABYLON.MotionBlurPostProcess(
  61827. * 'mb', // The name of the effect.
  61828. * scene, // The scene containing the objects to blur according to their velocity.
  61829. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61830. * camera // The camera to apply the render pass to.
  61831. * );
  61832. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61833. */
  61834. export class MotionBlurPostProcess extends PostProcess {
  61835. /**
  61836. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61837. */
  61838. motionStrength: number;
  61839. /**
  61840. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61841. */
  61842. /**
  61843. * Sets the number of iterations to be used for motion blur quality
  61844. */
  61845. motionBlurSamples: number;
  61846. private _motionBlurSamples;
  61847. private _geometryBufferRenderer;
  61848. /**
  61849. * Creates a new instance MotionBlurPostProcess
  61850. * @param name The name of the effect.
  61851. * @param scene The scene containing the objects to blur according to their velocity.
  61852. * @param options The required width/height ratio to downsize to before computing the render pass.
  61853. * @param camera The camera to apply the render pass to.
  61854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61855. * @param engine The engine which the post process will be applied. (default: current engine)
  61856. * @param reusable If the post process can be reused on the same frame. (default: false)
  61857. * @param textureType Type of textures used when performing the post process. (default: 0)
  61858. * @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)
  61859. */
  61860. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61861. /**
  61862. * Excludes the given skinned mesh from computing bones velocities.
  61863. * 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.
  61864. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61865. */
  61866. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61867. /**
  61868. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61869. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61870. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61871. */
  61872. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61873. /**
  61874. * Disposes the post process.
  61875. * @param camera The camera to dispose the post process on.
  61876. */
  61877. dispose(camera?: Camera): void;
  61878. }
  61879. }
  61880. declare module BABYLON {
  61881. /** @hidden */
  61882. export var refractionPixelShader: {
  61883. name: string;
  61884. shader: string;
  61885. };
  61886. }
  61887. declare module BABYLON {
  61888. /**
  61889. * Post process which applies a refractin texture
  61890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61891. */
  61892. export class RefractionPostProcess extends PostProcess {
  61893. /** the base color of the refraction (used to taint the rendering) */
  61894. color: Color3;
  61895. /** simulated refraction depth */
  61896. depth: number;
  61897. /** the coefficient of the base color (0 to remove base color tainting) */
  61898. colorLevel: number;
  61899. private _refTexture;
  61900. private _ownRefractionTexture;
  61901. /**
  61902. * Gets or sets the refraction texture
  61903. * Please note that you are responsible for disposing the texture if you set it manually
  61904. */
  61905. refractionTexture: Texture;
  61906. /**
  61907. * Initializes the RefractionPostProcess
  61908. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61909. * @param name The name of the effect.
  61910. * @param refractionTextureUrl Url of the refraction texture to use
  61911. * @param color the base color of the refraction (used to taint the rendering)
  61912. * @param depth simulated refraction depth
  61913. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61914. * @param camera The camera to apply the render pass to.
  61915. * @param options The required width/height ratio to downsize to before computing the render pass.
  61916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61917. * @param engine The engine which the post process will be applied. (default: current engine)
  61918. * @param reusable If the post process can be reused on the same frame. (default: false)
  61919. */
  61920. constructor(name: string, refractionTextureUrl: string,
  61921. /** the base color of the refraction (used to taint the rendering) */
  61922. color: Color3,
  61923. /** simulated refraction depth */
  61924. depth: number,
  61925. /** the coefficient of the base color (0 to remove base color tainting) */
  61926. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61927. /**
  61928. * Disposes of the post process
  61929. * @param camera Camera to dispose post process on
  61930. */
  61931. dispose(camera: Camera): void;
  61932. }
  61933. }
  61934. declare module BABYLON {
  61935. /** @hidden */
  61936. export var sharpenPixelShader: {
  61937. name: string;
  61938. shader: string;
  61939. };
  61940. }
  61941. declare module BABYLON {
  61942. /**
  61943. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61944. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61945. */
  61946. export class SharpenPostProcess extends PostProcess {
  61947. /**
  61948. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61949. */
  61950. colorAmount: number;
  61951. /**
  61952. * How much sharpness should be applied (default: 0.3)
  61953. */
  61954. edgeAmount: number;
  61955. /**
  61956. * Creates a new instance ConvolutionPostProcess
  61957. * @param name The name of the effect.
  61958. * @param options The required width/height ratio to downsize to before computing the render pass.
  61959. * @param camera The camera to apply the render pass to.
  61960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61961. * @param engine The engine which the post process will be applied. (default: current engine)
  61962. * @param reusable If the post process can be reused on the same frame. (default: false)
  61963. * @param textureType Type of textures used when performing the post process. (default: 0)
  61964. * @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)
  61965. */
  61966. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61967. }
  61968. }
  61969. declare module BABYLON {
  61970. /**
  61971. * PostProcessRenderPipeline
  61972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61973. */
  61974. export class PostProcessRenderPipeline {
  61975. private engine;
  61976. private _renderEffects;
  61977. private _renderEffectsForIsolatedPass;
  61978. /**
  61979. * List of inspectable custom properties (used by the Inspector)
  61980. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61981. */
  61982. inspectableCustomProperties: IInspectable[];
  61983. /**
  61984. * @hidden
  61985. */
  61986. protected _cameras: Camera[];
  61987. /** @hidden */
  61988. _name: string;
  61989. /**
  61990. * Gets pipeline name
  61991. */
  61992. readonly name: string;
  61993. /** Gets the list of attached cameras */
  61994. readonly cameras: Camera[];
  61995. /**
  61996. * Initializes a PostProcessRenderPipeline
  61997. * @param engine engine to add the pipeline to
  61998. * @param name name of the pipeline
  61999. */
  62000. constructor(engine: Engine, name: string);
  62001. /**
  62002. * Gets the class name
  62003. * @returns "PostProcessRenderPipeline"
  62004. */
  62005. getClassName(): string;
  62006. /**
  62007. * If all the render effects in the pipeline are supported
  62008. */
  62009. readonly isSupported: boolean;
  62010. /**
  62011. * Adds an effect to the pipeline
  62012. * @param renderEffect the effect to add
  62013. */
  62014. addEffect(renderEffect: PostProcessRenderEffect): void;
  62015. /** @hidden */
  62016. _rebuild(): void;
  62017. /** @hidden */
  62018. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62019. /** @hidden */
  62020. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62021. /** @hidden */
  62022. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62023. /** @hidden */
  62024. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62025. /** @hidden */
  62026. _attachCameras(cameras: Camera, unique: boolean): void;
  62027. /** @hidden */
  62028. _attachCameras(cameras: Camera[], unique: boolean): void;
  62029. /** @hidden */
  62030. _detachCameras(cameras: Camera): void;
  62031. /** @hidden */
  62032. _detachCameras(cameras: Nullable<Camera[]>): void;
  62033. /** @hidden */
  62034. _update(): void;
  62035. /** @hidden */
  62036. _reset(): void;
  62037. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62038. /**
  62039. * Disposes of the pipeline
  62040. */
  62041. dispose(): void;
  62042. }
  62043. }
  62044. declare module BABYLON {
  62045. /**
  62046. * PostProcessRenderPipelineManager class
  62047. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62048. */
  62049. export class PostProcessRenderPipelineManager {
  62050. private _renderPipelines;
  62051. /**
  62052. * Initializes a PostProcessRenderPipelineManager
  62053. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62054. */
  62055. constructor();
  62056. /**
  62057. * Gets the list of supported render pipelines
  62058. */
  62059. readonly supportedPipelines: PostProcessRenderPipeline[];
  62060. /**
  62061. * Adds a pipeline to the manager
  62062. * @param renderPipeline The pipeline to add
  62063. */
  62064. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62065. /**
  62066. * Attaches a camera to the pipeline
  62067. * @param renderPipelineName The name of the pipeline to attach to
  62068. * @param cameras the camera to attach
  62069. * @param unique if the camera can be attached multiple times to the pipeline
  62070. */
  62071. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62072. /**
  62073. * Detaches a camera from the pipeline
  62074. * @param renderPipelineName The name of the pipeline to detach from
  62075. * @param cameras the camera to detach
  62076. */
  62077. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62078. /**
  62079. * Enables an effect by name on a pipeline
  62080. * @param renderPipelineName the name of the pipeline to enable the effect in
  62081. * @param renderEffectName the name of the effect to enable
  62082. * @param cameras the cameras that the effect should be enabled on
  62083. */
  62084. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62085. /**
  62086. * Disables an effect by name on a pipeline
  62087. * @param renderPipelineName the name of the pipeline to disable the effect in
  62088. * @param renderEffectName the name of the effect to disable
  62089. * @param cameras the cameras that the effect should be disabled on
  62090. */
  62091. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62092. /**
  62093. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62094. */
  62095. update(): void;
  62096. /** @hidden */
  62097. _rebuild(): void;
  62098. /**
  62099. * Disposes of the manager and pipelines
  62100. */
  62101. dispose(): void;
  62102. }
  62103. }
  62104. declare module BABYLON {
  62105. interface Scene {
  62106. /** @hidden (Backing field) */
  62107. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62108. /**
  62109. * Gets the postprocess render pipeline manager
  62110. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62111. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62112. */
  62113. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62114. }
  62115. /**
  62116. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62117. */
  62118. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62119. /**
  62120. * The component name helpfull to identify the component in the list of scene components.
  62121. */
  62122. readonly name: string;
  62123. /**
  62124. * The scene the component belongs to.
  62125. */
  62126. scene: Scene;
  62127. /**
  62128. * Creates a new instance of the component for the given scene
  62129. * @param scene Defines the scene to register the component in
  62130. */
  62131. constructor(scene: Scene);
  62132. /**
  62133. * Registers the component in a given scene
  62134. */
  62135. register(): void;
  62136. /**
  62137. * Rebuilds the elements related to this component in case of
  62138. * context lost for instance.
  62139. */
  62140. rebuild(): void;
  62141. /**
  62142. * Disposes the component and the associated ressources
  62143. */
  62144. dispose(): void;
  62145. private _gatherRenderTargets;
  62146. }
  62147. }
  62148. declare module BABYLON {
  62149. /**
  62150. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62151. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62152. */
  62153. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62154. private _scene;
  62155. private _camerasToBeAttached;
  62156. /**
  62157. * ID of the sharpen post process,
  62158. */
  62159. private readonly SharpenPostProcessId;
  62160. /**
  62161. * @ignore
  62162. * ID of the image processing post process;
  62163. */
  62164. readonly ImageProcessingPostProcessId: string;
  62165. /**
  62166. * @ignore
  62167. * ID of the Fast Approximate Anti-Aliasing post process;
  62168. */
  62169. readonly FxaaPostProcessId: string;
  62170. /**
  62171. * ID of the chromatic aberration post process,
  62172. */
  62173. private readonly ChromaticAberrationPostProcessId;
  62174. /**
  62175. * ID of the grain post process
  62176. */
  62177. private readonly GrainPostProcessId;
  62178. /**
  62179. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62180. */
  62181. sharpen: SharpenPostProcess;
  62182. private _sharpenEffect;
  62183. private bloom;
  62184. /**
  62185. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62186. */
  62187. depthOfField: DepthOfFieldEffect;
  62188. /**
  62189. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62190. */
  62191. fxaa: FxaaPostProcess;
  62192. /**
  62193. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62194. */
  62195. imageProcessing: ImageProcessingPostProcess;
  62196. /**
  62197. * Chromatic aberration post process which will shift rgb colors in the image
  62198. */
  62199. chromaticAberration: ChromaticAberrationPostProcess;
  62200. private _chromaticAberrationEffect;
  62201. /**
  62202. * Grain post process which add noise to the image
  62203. */
  62204. grain: GrainPostProcess;
  62205. private _grainEffect;
  62206. /**
  62207. * Glow post process which adds a glow to emissive areas of the image
  62208. */
  62209. private _glowLayer;
  62210. /**
  62211. * Animations which can be used to tweak settings over a period of time
  62212. */
  62213. animations: Animation[];
  62214. private _imageProcessingConfigurationObserver;
  62215. private _sharpenEnabled;
  62216. private _bloomEnabled;
  62217. private _depthOfFieldEnabled;
  62218. private _depthOfFieldBlurLevel;
  62219. private _fxaaEnabled;
  62220. private _imageProcessingEnabled;
  62221. private _defaultPipelineTextureType;
  62222. private _bloomScale;
  62223. private _chromaticAberrationEnabled;
  62224. private _grainEnabled;
  62225. private _buildAllowed;
  62226. /**
  62227. * Gets active scene
  62228. */
  62229. readonly scene: Scene;
  62230. /**
  62231. * Enable or disable the sharpen process from the pipeline
  62232. */
  62233. sharpenEnabled: boolean;
  62234. private _resizeObserver;
  62235. private _hardwareScaleLevel;
  62236. private _bloomKernel;
  62237. /**
  62238. * Specifies the size of the bloom blur kernel, relative to the final output size
  62239. */
  62240. bloomKernel: number;
  62241. /**
  62242. * Specifies the weight of the bloom in the final rendering
  62243. */
  62244. private _bloomWeight;
  62245. /**
  62246. * Specifies the luma threshold for the area that will be blurred by the bloom
  62247. */
  62248. private _bloomThreshold;
  62249. private _hdr;
  62250. /**
  62251. * The strength of the bloom.
  62252. */
  62253. bloomWeight: number;
  62254. /**
  62255. * The strength of the bloom.
  62256. */
  62257. bloomThreshold: number;
  62258. /**
  62259. * The scale of the bloom, lower value will provide better performance.
  62260. */
  62261. bloomScale: number;
  62262. /**
  62263. * Enable or disable the bloom from the pipeline
  62264. */
  62265. bloomEnabled: boolean;
  62266. private _rebuildBloom;
  62267. /**
  62268. * If the depth of field is enabled.
  62269. */
  62270. depthOfFieldEnabled: boolean;
  62271. /**
  62272. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62273. */
  62274. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62275. /**
  62276. * If the anti aliasing is enabled.
  62277. */
  62278. fxaaEnabled: boolean;
  62279. private _samples;
  62280. /**
  62281. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62282. */
  62283. samples: number;
  62284. /**
  62285. * If image processing is enabled.
  62286. */
  62287. imageProcessingEnabled: boolean;
  62288. /**
  62289. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62290. */
  62291. glowLayerEnabled: boolean;
  62292. /**
  62293. * Gets the glow layer (or null if not defined)
  62294. */
  62295. readonly glowLayer: Nullable<GlowLayer>;
  62296. /**
  62297. * Enable or disable the chromaticAberration process from the pipeline
  62298. */
  62299. chromaticAberrationEnabled: boolean;
  62300. /**
  62301. * Enable or disable the grain process from the pipeline
  62302. */
  62303. grainEnabled: boolean;
  62304. /**
  62305. * @constructor
  62306. * @param name - The rendering pipeline name (default: "")
  62307. * @param hdr - If high dynamic range textures should be used (default: true)
  62308. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62309. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62310. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62311. */
  62312. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62313. /**
  62314. * Get the class name
  62315. * @returns "DefaultRenderingPipeline"
  62316. */
  62317. getClassName(): string;
  62318. /**
  62319. * Force the compilation of the entire pipeline.
  62320. */
  62321. prepare(): void;
  62322. private _hasCleared;
  62323. private _prevPostProcess;
  62324. private _prevPrevPostProcess;
  62325. private _setAutoClearAndTextureSharing;
  62326. private _depthOfFieldSceneObserver;
  62327. private _buildPipeline;
  62328. private _disposePostProcesses;
  62329. /**
  62330. * Adds a camera to the pipeline
  62331. * @param camera the camera to be added
  62332. */
  62333. addCamera(camera: Camera): void;
  62334. /**
  62335. * Removes a camera from the pipeline
  62336. * @param camera the camera to remove
  62337. */
  62338. removeCamera(camera: Camera): void;
  62339. /**
  62340. * Dispose of the pipeline and stop all post processes
  62341. */
  62342. dispose(): void;
  62343. /**
  62344. * Serialize the rendering pipeline (Used when exporting)
  62345. * @returns the serialized object
  62346. */
  62347. serialize(): any;
  62348. /**
  62349. * Parse the serialized pipeline
  62350. * @param source Source pipeline.
  62351. * @param scene The scene to load the pipeline to.
  62352. * @param rootUrl The URL of the serialized pipeline.
  62353. * @returns An instantiated pipeline from the serialized object.
  62354. */
  62355. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62356. }
  62357. }
  62358. declare module BABYLON {
  62359. /** @hidden */
  62360. export var lensHighlightsPixelShader: {
  62361. name: string;
  62362. shader: string;
  62363. };
  62364. }
  62365. declare module BABYLON {
  62366. /** @hidden */
  62367. export var depthOfFieldPixelShader: {
  62368. name: string;
  62369. shader: string;
  62370. };
  62371. }
  62372. declare module BABYLON {
  62373. /**
  62374. * BABYLON.JS Chromatic Aberration GLSL Shader
  62375. * Author: Olivier Guyot
  62376. * Separates very slightly R, G and B colors on the edges of the screen
  62377. * Inspired by Francois Tarlier & Martins Upitis
  62378. */
  62379. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62380. /**
  62381. * @ignore
  62382. * The chromatic aberration PostProcess id in the pipeline
  62383. */
  62384. LensChromaticAberrationEffect: string;
  62385. /**
  62386. * @ignore
  62387. * The highlights enhancing PostProcess id in the pipeline
  62388. */
  62389. HighlightsEnhancingEffect: string;
  62390. /**
  62391. * @ignore
  62392. * The depth-of-field PostProcess id in the pipeline
  62393. */
  62394. LensDepthOfFieldEffect: string;
  62395. private _scene;
  62396. private _depthTexture;
  62397. private _grainTexture;
  62398. private _chromaticAberrationPostProcess;
  62399. private _highlightsPostProcess;
  62400. private _depthOfFieldPostProcess;
  62401. private _edgeBlur;
  62402. private _grainAmount;
  62403. private _chromaticAberration;
  62404. private _distortion;
  62405. private _highlightsGain;
  62406. private _highlightsThreshold;
  62407. private _dofDistance;
  62408. private _dofAperture;
  62409. private _dofDarken;
  62410. private _dofPentagon;
  62411. private _blurNoise;
  62412. /**
  62413. * @constructor
  62414. *
  62415. * Effect parameters are as follow:
  62416. * {
  62417. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62418. * edge_blur: number; // from 0 to x (1 for realism)
  62419. * distortion: number; // from 0 to x (1 for realism)
  62420. * grain_amount: number; // from 0 to 1
  62421. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62422. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62423. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62424. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62425. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62426. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62427. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62428. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62429. * }
  62430. * Note: if an effect parameter is unset, effect is disabled
  62431. *
  62432. * @param name The rendering pipeline name
  62433. * @param parameters - An object containing all parameters (see above)
  62434. * @param scene The scene linked to this pipeline
  62435. * @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)
  62436. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62437. */
  62438. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62439. /**
  62440. * Get the class name
  62441. * @returns "LensRenderingPipeline"
  62442. */
  62443. getClassName(): string;
  62444. /**
  62445. * Gets associated scene
  62446. */
  62447. readonly scene: Scene;
  62448. /**
  62449. * Gets or sets the edge blur
  62450. */
  62451. edgeBlur: number;
  62452. /**
  62453. * Gets or sets the grain amount
  62454. */
  62455. grainAmount: number;
  62456. /**
  62457. * Gets or sets the chromatic aberration amount
  62458. */
  62459. chromaticAberration: number;
  62460. /**
  62461. * Gets or sets the depth of field aperture
  62462. */
  62463. dofAperture: number;
  62464. /**
  62465. * Gets or sets the edge distortion
  62466. */
  62467. edgeDistortion: number;
  62468. /**
  62469. * Gets or sets the depth of field distortion
  62470. */
  62471. dofDistortion: number;
  62472. /**
  62473. * Gets or sets the darken out of focus amount
  62474. */
  62475. darkenOutOfFocus: number;
  62476. /**
  62477. * Gets or sets a boolean indicating if blur noise is enabled
  62478. */
  62479. blurNoise: boolean;
  62480. /**
  62481. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62482. */
  62483. pentagonBokeh: boolean;
  62484. /**
  62485. * Gets or sets the highlight grain amount
  62486. */
  62487. highlightsGain: number;
  62488. /**
  62489. * Gets or sets the highlight threshold
  62490. */
  62491. highlightsThreshold: number;
  62492. /**
  62493. * Sets the amount of blur at the edges
  62494. * @param amount blur amount
  62495. */
  62496. setEdgeBlur(amount: number): void;
  62497. /**
  62498. * Sets edge blur to 0
  62499. */
  62500. disableEdgeBlur(): void;
  62501. /**
  62502. * Sets the amout of grain
  62503. * @param amount Amount of grain
  62504. */
  62505. setGrainAmount(amount: number): void;
  62506. /**
  62507. * Set grain amount to 0
  62508. */
  62509. disableGrain(): void;
  62510. /**
  62511. * Sets the chromatic aberration amount
  62512. * @param amount amount of chromatic aberration
  62513. */
  62514. setChromaticAberration(amount: number): void;
  62515. /**
  62516. * Sets chromatic aberration amount to 0
  62517. */
  62518. disableChromaticAberration(): void;
  62519. /**
  62520. * Sets the EdgeDistortion amount
  62521. * @param amount amount of EdgeDistortion
  62522. */
  62523. setEdgeDistortion(amount: number): void;
  62524. /**
  62525. * Sets edge distortion to 0
  62526. */
  62527. disableEdgeDistortion(): void;
  62528. /**
  62529. * Sets the FocusDistance amount
  62530. * @param amount amount of FocusDistance
  62531. */
  62532. setFocusDistance(amount: number): void;
  62533. /**
  62534. * Disables depth of field
  62535. */
  62536. disableDepthOfField(): void;
  62537. /**
  62538. * Sets the Aperture amount
  62539. * @param amount amount of Aperture
  62540. */
  62541. setAperture(amount: number): void;
  62542. /**
  62543. * Sets the DarkenOutOfFocus amount
  62544. * @param amount amount of DarkenOutOfFocus
  62545. */
  62546. setDarkenOutOfFocus(amount: number): void;
  62547. private _pentagonBokehIsEnabled;
  62548. /**
  62549. * Creates a pentagon bokeh effect
  62550. */
  62551. enablePentagonBokeh(): void;
  62552. /**
  62553. * Disables the pentagon bokeh effect
  62554. */
  62555. disablePentagonBokeh(): void;
  62556. /**
  62557. * Enables noise blur
  62558. */
  62559. enableNoiseBlur(): void;
  62560. /**
  62561. * Disables noise blur
  62562. */
  62563. disableNoiseBlur(): void;
  62564. /**
  62565. * Sets the HighlightsGain amount
  62566. * @param amount amount of HighlightsGain
  62567. */
  62568. setHighlightsGain(amount: number): void;
  62569. /**
  62570. * Sets the HighlightsThreshold amount
  62571. * @param amount amount of HighlightsThreshold
  62572. */
  62573. setHighlightsThreshold(amount: number): void;
  62574. /**
  62575. * Disables highlights
  62576. */
  62577. disableHighlights(): void;
  62578. /**
  62579. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62580. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62581. */
  62582. dispose(disableDepthRender?: boolean): void;
  62583. private _createChromaticAberrationPostProcess;
  62584. private _createHighlightsPostProcess;
  62585. private _createDepthOfFieldPostProcess;
  62586. private _createGrainTexture;
  62587. }
  62588. }
  62589. declare module BABYLON {
  62590. /** @hidden */
  62591. export var ssao2PixelShader: {
  62592. name: string;
  62593. shader: string;
  62594. };
  62595. }
  62596. declare module BABYLON {
  62597. /** @hidden */
  62598. export var ssaoCombinePixelShader: {
  62599. name: string;
  62600. shader: string;
  62601. };
  62602. }
  62603. declare module BABYLON {
  62604. /**
  62605. * Render pipeline to produce ssao effect
  62606. */
  62607. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62608. /**
  62609. * @ignore
  62610. * The PassPostProcess id in the pipeline that contains the original scene color
  62611. */
  62612. SSAOOriginalSceneColorEffect: string;
  62613. /**
  62614. * @ignore
  62615. * The SSAO PostProcess id in the pipeline
  62616. */
  62617. SSAORenderEffect: string;
  62618. /**
  62619. * @ignore
  62620. * The horizontal blur PostProcess id in the pipeline
  62621. */
  62622. SSAOBlurHRenderEffect: string;
  62623. /**
  62624. * @ignore
  62625. * The vertical blur PostProcess id in the pipeline
  62626. */
  62627. SSAOBlurVRenderEffect: string;
  62628. /**
  62629. * @ignore
  62630. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62631. */
  62632. SSAOCombineRenderEffect: string;
  62633. /**
  62634. * The output strength of the SSAO post-process. Default value is 1.0.
  62635. */
  62636. totalStrength: number;
  62637. /**
  62638. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62639. */
  62640. maxZ: number;
  62641. /**
  62642. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62643. */
  62644. minZAspect: number;
  62645. private _samples;
  62646. /**
  62647. * Number of samples used for the SSAO calculations. Default value is 8
  62648. */
  62649. samples: number;
  62650. private _textureSamples;
  62651. /**
  62652. * Number of samples to use for antialiasing
  62653. */
  62654. textureSamples: number;
  62655. /**
  62656. * Ratio object used for SSAO ratio and blur ratio
  62657. */
  62658. private _ratio;
  62659. /**
  62660. * Dynamically generated sphere sampler.
  62661. */
  62662. private _sampleSphere;
  62663. /**
  62664. * Blur filter offsets
  62665. */
  62666. private _samplerOffsets;
  62667. private _expensiveBlur;
  62668. /**
  62669. * If bilateral blur should be used
  62670. */
  62671. expensiveBlur: boolean;
  62672. /**
  62673. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62674. */
  62675. radius: number;
  62676. /**
  62677. * The base color of the SSAO post-process
  62678. * The final result is "base + ssao" between [0, 1]
  62679. */
  62680. base: number;
  62681. /**
  62682. * Support test.
  62683. */
  62684. static readonly IsSupported: boolean;
  62685. private _scene;
  62686. private _depthTexture;
  62687. private _normalTexture;
  62688. private _randomTexture;
  62689. private _originalColorPostProcess;
  62690. private _ssaoPostProcess;
  62691. private _blurHPostProcess;
  62692. private _blurVPostProcess;
  62693. private _ssaoCombinePostProcess;
  62694. /**
  62695. * Gets active scene
  62696. */
  62697. readonly scene: Scene;
  62698. /**
  62699. * @constructor
  62700. * @param name The rendering pipeline name
  62701. * @param scene The scene linked to this pipeline
  62702. * @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 }
  62703. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62704. */
  62705. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62706. /**
  62707. * Get the class name
  62708. * @returns "SSAO2RenderingPipeline"
  62709. */
  62710. getClassName(): string;
  62711. /**
  62712. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62713. */
  62714. dispose(disableGeometryBufferRenderer?: boolean): void;
  62715. private _createBlurPostProcess;
  62716. /** @hidden */
  62717. _rebuild(): void;
  62718. private _bits;
  62719. private _radicalInverse_VdC;
  62720. private _hammersley;
  62721. private _hemisphereSample_uniform;
  62722. private _generateHemisphere;
  62723. private _createSSAOPostProcess;
  62724. private _createSSAOCombinePostProcess;
  62725. private _createRandomTexture;
  62726. /**
  62727. * Serialize the rendering pipeline (Used when exporting)
  62728. * @returns the serialized object
  62729. */
  62730. serialize(): any;
  62731. /**
  62732. * Parse the serialized pipeline
  62733. * @param source Source pipeline.
  62734. * @param scene The scene to load the pipeline to.
  62735. * @param rootUrl The URL of the serialized pipeline.
  62736. * @returns An instantiated pipeline from the serialized object.
  62737. */
  62738. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62739. }
  62740. }
  62741. declare module BABYLON {
  62742. /** @hidden */
  62743. export var ssaoPixelShader: {
  62744. name: string;
  62745. shader: string;
  62746. };
  62747. }
  62748. declare module BABYLON {
  62749. /**
  62750. * Render pipeline to produce ssao effect
  62751. */
  62752. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62753. /**
  62754. * @ignore
  62755. * The PassPostProcess id in the pipeline that contains the original scene color
  62756. */
  62757. SSAOOriginalSceneColorEffect: string;
  62758. /**
  62759. * @ignore
  62760. * The SSAO PostProcess id in the pipeline
  62761. */
  62762. SSAORenderEffect: string;
  62763. /**
  62764. * @ignore
  62765. * The horizontal blur PostProcess id in the pipeline
  62766. */
  62767. SSAOBlurHRenderEffect: string;
  62768. /**
  62769. * @ignore
  62770. * The vertical blur PostProcess id in the pipeline
  62771. */
  62772. SSAOBlurVRenderEffect: string;
  62773. /**
  62774. * @ignore
  62775. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62776. */
  62777. SSAOCombineRenderEffect: string;
  62778. /**
  62779. * The output strength of the SSAO post-process. Default value is 1.0.
  62780. */
  62781. totalStrength: number;
  62782. /**
  62783. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62784. */
  62785. radius: number;
  62786. /**
  62787. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62788. * Must not be equal to fallOff and superior to fallOff.
  62789. * Default value is 0.0075
  62790. */
  62791. area: number;
  62792. /**
  62793. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62794. * Must not be equal to area and inferior to area.
  62795. * Default value is 0.000001
  62796. */
  62797. fallOff: number;
  62798. /**
  62799. * The base color of the SSAO post-process
  62800. * The final result is "base + ssao" between [0, 1]
  62801. */
  62802. base: number;
  62803. private _scene;
  62804. private _depthTexture;
  62805. private _randomTexture;
  62806. private _originalColorPostProcess;
  62807. private _ssaoPostProcess;
  62808. private _blurHPostProcess;
  62809. private _blurVPostProcess;
  62810. private _ssaoCombinePostProcess;
  62811. private _firstUpdate;
  62812. /**
  62813. * Gets active scene
  62814. */
  62815. readonly scene: Scene;
  62816. /**
  62817. * @constructor
  62818. * @param name - The rendering pipeline name
  62819. * @param scene - The scene linked to this pipeline
  62820. * @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 }
  62821. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62822. */
  62823. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62824. /**
  62825. * Get the class name
  62826. * @returns "SSAORenderingPipeline"
  62827. */
  62828. getClassName(): string;
  62829. /**
  62830. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62831. */
  62832. dispose(disableDepthRender?: boolean): void;
  62833. private _createBlurPostProcess;
  62834. /** @hidden */
  62835. _rebuild(): void;
  62836. private _createSSAOPostProcess;
  62837. private _createSSAOCombinePostProcess;
  62838. private _createRandomTexture;
  62839. }
  62840. }
  62841. declare module BABYLON {
  62842. /** @hidden */
  62843. export var standardPixelShader: {
  62844. name: string;
  62845. shader: string;
  62846. };
  62847. }
  62848. declare module BABYLON {
  62849. /**
  62850. * Standard rendering pipeline
  62851. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62852. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62853. */
  62854. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62855. /**
  62856. * Public members
  62857. */
  62858. /**
  62859. * Post-process which contains the original scene color before the pipeline applies all the effects
  62860. */
  62861. originalPostProcess: Nullable<PostProcess>;
  62862. /**
  62863. * Post-process used to down scale an image x4
  62864. */
  62865. downSampleX4PostProcess: Nullable<PostProcess>;
  62866. /**
  62867. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62868. */
  62869. brightPassPostProcess: Nullable<PostProcess>;
  62870. /**
  62871. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62872. */
  62873. blurHPostProcesses: PostProcess[];
  62874. /**
  62875. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62876. */
  62877. blurVPostProcesses: PostProcess[];
  62878. /**
  62879. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62880. */
  62881. textureAdderPostProcess: Nullable<PostProcess>;
  62882. /**
  62883. * Post-process used to create volumetric lighting effect
  62884. */
  62885. volumetricLightPostProcess: Nullable<PostProcess>;
  62886. /**
  62887. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62888. */
  62889. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62890. /**
  62891. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62892. */
  62893. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62894. /**
  62895. * Post-process used to merge the volumetric light effect and the real scene color
  62896. */
  62897. volumetricLightMergePostProces: Nullable<PostProcess>;
  62898. /**
  62899. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62900. */
  62901. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62902. /**
  62903. * Base post-process used to calculate the average luminance of the final image for HDR
  62904. */
  62905. luminancePostProcess: Nullable<PostProcess>;
  62906. /**
  62907. * Post-processes used to create down sample post-processes in order to get
  62908. * the average luminance of the final image for HDR
  62909. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62910. */
  62911. luminanceDownSamplePostProcesses: PostProcess[];
  62912. /**
  62913. * Post-process used to create a HDR effect (light adaptation)
  62914. */
  62915. hdrPostProcess: Nullable<PostProcess>;
  62916. /**
  62917. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62918. */
  62919. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62920. /**
  62921. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62922. */
  62923. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62924. /**
  62925. * Post-process used to merge the final HDR post-process and the real scene color
  62926. */
  62927. hdrFinalPostProcess: Nullable<PostProcess>;
  62928. /**
  62929. * Post-process used to create a lens flare effect
  62930. */
  62931. lensFlarePostProcess: Nullable<PostProcess>;
  62932. /**
  62933. * Post-process that merges the result of the lens flare post-process and the real scene color
  62934. */
  62935. lensFlareComposePostProcess: Nullable<PostProcess>;
  62936. /**
  62937. * Post-process used to create a motion blur effect
  62938. */
  62939. motionBlurPostProcess: Nullable<PostProcess>;
  62940. /**
  62941. * Post-process used to create a depth of field effect
  62942. */
  62943. depthOfFieldPostProcess: Nullable<PostProcess>;
  62944. /**
  62945. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62946. */
  62947. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62948. /**
  62949. * Represents the brightness threshold in order to configure the illuminated surfaces
  62950. */
  62951. brightThreshold: number;
  62952. /**
  62953. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62954. */
  62955. blurWidth: number;
  62956. /**
  62957. * Sets if the blur for highlighted surfaces must be only horizontal
  62958. */
  62959. horizontalBlur: boolean;
  62960. /**
  62961. * Gets the overall exposure used by the pipeline
  62962. */
  62963. /**
  62964. * Sets the overall exposure used by the pipeline
  62965. */
  62966. exposure: number;
  62967. /**
  62968. * Texture used typically to simulate "dirty" on camera lens
  62969. */
  62970. lensTexture: Nullable<Texture>;
  62971. /**
  62972. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62973. */
  62974. volumetricLightCoefficient: number;
  62975. /**
  62976. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62977. */
  62978. volumetricLightPower: number;
  62979. /**
  62980. * Used the set the blur intensity to smooth the volumetric lights
  62981. */
  62982. volumetricLightBlurScale: number;
  62983. /**
  62984. * Light (spot or directional) used to generate the volumetric lights rays
  62985. * The source light must have a shadow generate so the pipeline can get its
  62986. * depth map
  62987. */
  62988. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62989. /**
  62990. * For eye adaptation, represents the minimum luminance the eye can see
  62991. */
  62992. hdrMinimumLuminance: number;
  62993. /**
  62994. * For eye adaptation, represents the decrease luminance speed
  62995. */
  62996. hdrDecreaseRate: number;
  62997. /**
  62998. * For eye adaptation, represents the increase luminance speed
  62999. */
  63000. hdrIncreaseRate: number;
  63001. /**
  63002. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63003. */
  63004. /**
  63005. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63006. */
  63007. hdrAutoExposure: boolean;
  63008. /**
  63009. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63010. */
  63011. lensColorTexture: Nullable<Texture>;
  63012. /**
  63013. * The overall strengh for the lens flare effect
  63014. */
  63015. lensFlareStrength: number;
  63016. /**
  63017. * Dispersion coefficient for lens flare ghosts
  63018. */
  63019. lensFlareGhostDispersal: number;
  63020. /**
  63021. * Main lens flare halo width
  63022. */
  63023. lensFlareHaloWidth: number;
  63024. /**
  63025. * Based on the lens distortion effect, defines how much the lens flare result
  63026. * is distorted
  63027. */
  63028. lensFlareDistortionStrength: number;
  63029. /**
  63030. * Configures the blur intensity used for for lens flare (halo)
  63031. */
  63032. lensFlareBlurWidth: number;
  63033. /**
  63034. * Lens star texture must be used to simulate rays on the flares and is available
  63035. * in the documentation
  63036. */
  63037. lensStarTexture: Nullable<Texture>;
  63038. /**
  63039. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63040. * flare effect by taking account of the dirt texture
  63041. */
  63042. lensFlareDirtTexture: Nullable<Texture>;
  63043. /**
  63044. * Represents the focal length for the depth of field effect
  63045. */
  63046. depthOfFieldDistance: number;
  63047. /**
  63048. * Represents the blur intensity for the blurred part of the depth of field effect
  63049. */
  63050. depthOfFieldBlurWidth: number;
  63051. /**
  63052. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63053. */
  63054. /**
  63055. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63056. */
  63057. motionStrength: number;
  63058. /**
  63059. * Gets wether or not the motion blur post-process is object based or screen based.
  63060. */
  63061. /**
  63062. * Sets wether or not the motion blur post-process should be object based or screen based
  63063. */
  63064. objectBasedMotionBlur: boolean;
  63065. /**
  63066. * List of animations for the pipeline (IAnimatable implementation)
  63067. */
  63068. animations: Animation[];
  63069. /**
  63070. * Private members
  63071. */
  63072. private _scene;
  63073. private _currentDepthOfFieldSource;
  63074. private _basePostProcess;
  63075. private _fixedExposure;
  63076. private _currentExposure;
  63077. private _hdrAutoExposure;
  63078. private _hdrCurrentLuminance;
  63079. private _motionStrength;
  63080. private _isObjectBasedMotionBlur;
  63081. private _floatTextureType;
  63082. private _camerasToBeAttached;
  63083. private _ratio;
  63084. private _bloomEnabled;
  63085. private _depthOfFieldEnabled;
  63086. private _vlsEnabled;
  63087. private _lensFlareEnabled;
  63088. private _hdrEnabled;
  63089. private _motionBlurEnabled;
  63090. private _fxaaEnabled;
  63091. private _motionBlurSamples;
  63092. private _volumetricLightStepsCount;
  63093. private _samples;
  63094. /**
  63095. * @ignore
  63096. * Specifies if the bloom pipeline is enabled
  63097. */
  63098. BloomEnabled: boolean;
  63099. /**
  63100. * @ignore
  63101. * Specifies if the depth of field pipeline is enabed
  63102. */
  63103. DepthOfFieldEnabled: boolean;
  63104. /**
  63105. * @ignore
  63106. * Specifies if the lens flare pipeline is enabed
  63107. */
  63108. LensFlareEnabled: boolean;
  63109. /**
  63110. * @ignore
  63111. * Specifies if the HDR pipeline is enabled
  63112. */
  63113. HDREnabled: boolean;
  63114. /**
  63115. * @ignore
  63116. * Specifies if the volumetric lights scattering effect is enabled
  63117. */
  63118. VLSEnabled: boolean;
  63119. /**
  63120. * @ignore
  63121. * Specifies if the motion blur effect is enabled
  63122. */
  63123. MotionBlurEnabled: boolean;
  63124. /**
  63125. * Specifies if anti-aliasing is enabled
  63126. */
  63127. fxaaEnabled: boolean;
  63128. /**
  63129. * Specifies the number of steps used to calculate the volumetric lights
  63130. * Typically in interval [50, 200]
  63131. */
  63132. volumetricLightStepsCount: number;
  63133. /**
  63134. * Specifies the number of samples used for the motion blur effect
  63135. * Typically in interval [16, 64]
  63136. */
  63137. motionBlurSamples: number;
  63138. /**
  63139. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63140. */
  63141. samples: number;
  63142. /**
  63143. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63144. * @constructor
  63145. * @param name The rendering pipeline name
  63146. * @param scene The scene linked to this pipeline
  63147. * @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)
  63148. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63149. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63150. */
  63151. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63152. private _buildPipeline;
  63153. private _createDownSampleX4PostProcess;
  63154. private _createBrightPassPostProcess;
  63155. private _createBlurPostProcesses;
  63156. private _createTextureAdderPostProcess;
  63157. private _createVolumetricLightPostProcess;
  63158. private _createLuminancePostProcesses;
  63159. private _createHdrPostProcess;
  63160. private _createLensFlarePostProcess;
  63161. private _createDepthOfFieldPostProcess;
  63162. private _createMotionBlurPostProcess;
  63163. private _getDepthTexture;
  63164. private _disposePostProcesses;
  63165. /**
  63166. * Dispose of the pipeline and stop all post processes
  63167. */
  63168. dispose(): void;
  63169. /**
  63170. * Serialize the rendering pipeline (Used when exporting)
  63171. * @returns the serialized object
  63172. */
  63173. serialize(): any;
  63174. /**
  63175. * Parse the serialized pipeline
  63176. * @param source Source pipeline.
  63177. * @param scene The scene to load the pipeline to.
  63178. * @param rootUrl The URL of the serialized pipeline.
  63179. * @returns An instantiated pipeline from the serialized object.
  63180. */
  63181. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63182. /**
  63183. * Luminance steps
  63184. */
  63185. static LuminanceSteps: number;
  63186. }
  63187. }
  63188. declare module BABYLON {
  63189. /** @hidden */
  63190. export var tonemapPixelShader: {
  63191. name: string;
  63192. shader: string;
  63193. };
  63194. }
  63195. declare module BABYLON {
  63196. /** Defines operator used for tonemapping */
  63197. export enum TonemappingOperator {
  63198. /** Hable */
  63199. Hable = 0,
  63200. /** Reinhard */
  63201. Reinhard = 1,
  63202. /** HejiDawson */
  63203. HejiDawson = 2,
  63204. /** Photographic */
  63205. Photographic = 3
  63206. }
  63207. /**
  63208. * Defines a post process to apply tone mapping
  63209. */
  63210. export class TonemapPostProcess extends PostProcess {
  63211. private _operator;
  63212. /** Defines the required exposure adjustement */
  63213. exposureAdjustment: number;
  63214. /**
  63215. * Creates a new TonemapPostProcess
  63216. * @param name defines the name of the postprocess
  63217. * @param _operator defines the operator to use
  63218. * @param exposureAdjustment defines the required exposure adjustement
  63219. * @param camera defines the camera to use (can be null)
  63220. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63221. * @param engine defines the hosting engine (can be ignore if camera is set)
  63222. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63223. */
  63224. constructor(name: string, _operator: TonemappingOperator,
  63225. /** Defines the required exposure adjustement */
  63226. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63227. }
  63228. }
  63229. declare module BABYLON {
  63230. /** @hidden */
  63231. export var depthVertexShader: {
  63232. name: string;
  63233. shader: string;
  63234. };
  63235. }
  63236. declare module BABYLON {
  63237. /** @hidden */
  63238. export var volumetricLightScatteringPixelShader: {
  63239. name: string;
  63240. shader: string;
  63241. };
  63242. }
  63243. declare module BABYLON {
  63244. /** @hidden */
  63245. export var volumetricLightScatteringPassVertexShader: {
  63246. name: string;
  63247. shader: string;
  63248. };
  63249. }
  63250. declare module BABYLON {
  63251. /** @hidden */
  63252. export var volumetricLightScatteringPassPixelShader: {
  63253. name: string;
  63254. shader: string;
  63255. };
  63256. }
  63257. declare module BABYLON {
  63258. /**
  63259. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63260. */
  63261. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63262. private _volumetricLightScatteringPass;
  63263. private _volumetricLightScatteringRTT;
  63264. private _viewPort;
  63265. private _screenCoordinates;
  63266. private _cachedDefines;
  63267. /**
  63268. * If not undefined, the mesh position is computed from the attached node position
  63269. */
  63270. attachedNode: {
  63271. position: Vector3;
  63272. };
  63273. /**
  63274. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63275. */
  63276. customMeshPosition: Vector3;
  63277. /**
  63278. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63279. */
  63280. useCustomMeshPosition: boolean;
  63281. /**
  63282. * If the post-process should inverse the light scattering direction
  63283. */
  63284. invert: boolean;
  63285. /**
  63286. * The internal mesh used by the post-process
  63287. */
  63288. mesh: Mesh;
  63289. /**
  63290. * @hidden
  63291. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63292. */
  63293. useDiffuseColor: boolean;
  63294. /**
  63295. * Array containing the excluded meshes not rendered in the internal pass
  63296. */
  63297. excludedMeshes: AbstractMesh[];
  63298. /**
  63299. * Controls the overall intensity of the post-process
  63300. */
  63301. exposure: number;
  63302. /**
  63303. * Dissipates each sample's contribution in range [0, 1]
  63304. */
  63305. decay: number;
  63306. /**
  63307. * Controls the overall intensity of each sample
  63308. */
  63309. weight: number;
  63310. /**
  63311. * Controls the density of each sample
  63312. */
  63313. density: number;
  63314. /**
  63315. * @constructor
  63316. * @param name The post-process name
  63317. * @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)
  63318. * @param camera The camera that the post-process will be attached to
  63319. * @param mesh The mesh used to create the light scattering
  63320. * @param samples The post-process quality, default 100
  63321. * @param samplingModeThe post-process filtering mode
  63322. * @param engine The babylon engine
  63323. * @param reusable If the post-process is reusable
  63324. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63325. */
  63326. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63327. /**
  63328. * Returns the string "VolumetricLightScatteringPostProcess"
  63329. * @returns "VolumetricLightScatteringPostProcess"
  63330. */
  63331. getClassName(): string;
  63332. private _isReady;
  63333. /**
  63334. * Sets the new light position for light scattering effect
  63335. * @param position The new custom light position
  63336. */
  63337. setCustomMeshPosition(position: Vector3): void;
  63338. /**
  63339. * Returns the light position for light scattering effect
  63340. * @return Vector3 The custom light position
  63341. */
  63342. getCustomMeshPosition(): Vector3;
  63343. /**
  63344. * Disposes the internal assets and detaches the post-process from the camera
  63345. */
  63346. dispose(camera: Camera): void;
  63347. /**
  63348. * Returns the render target texture used by the post-process
  63349. * @return the render target texture used by the post-process
  63350. */
  63351. getPass(): RenderTargetTexture;
  63352. private _meshExcluded;
  63353. private _createPass;
  63354. private _updateMeshScreenCoordinates;
  63355. /**
  63356. * Creates a default mesh for the Volumeric Light Scattering post-process
  63357. * @param name The mesh name
  63358. * @param scene The scene where to create the mesh
  63359. * @return the default mesh
  63360. */
  63361. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63362. }
  63363. }
  63364. declare module BABYLON {
  63365. interface Scene {
  63366. /** @hidden (Backing field) */
  63367. _boundingBoxRenderer: BoundingBoxRenderer;
  63368. /** @hidden (Backing field) */
  63369. _forceShowBoundingBoxes: boolean;
  63370. /**
  63371. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63372. */
  63373. forceShowBoundingBoxes: boolean;
  63374. /**
  63375. * Gets the bounding box renderer associated with the scene
  63376. * @returns a BoundingBoxRenderer
  63377. */
  63378. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63379. }
  63380. interface AbstractMesh {
  63381. /** @hidden (Backing field) */
  63382. _showBoundingBox: boolean;
  63383. /**
  63384. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63385. */
  63386. showBoundingBox: boolean;
  63387. }
  63388. /**
  63389. * Component responsible of rendering the bounding box of the meshes in a scene.
  63390. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63391. */
  63392. export class BoundingBoxRenderer implements ISceneComponent {
  63393. /**
  63394. * The component name helpfull to identify the component in the list of scene components.
  63395. */
  63396. readonly name: string;
  63397. /**
  63398. * The scene the component belongs to.
  63399. */
  63400. scene: Scene;
  63401. /**
  63402. * Color of the bounding box lines placed in front of an object
  63403. */
  63404. frontColor: Color3;
  63405. /**
  63406. * Color of the bounding box lines placed behind an object
  63407. */
  63408. backColor: Color3;
  63409. /**
  63410. * Defines if the renderer should show the back lines or not
  63411. */
  63412. showBackLines: boolean;
  63413. /**
  63414. * @hidden
  63415. */
  63416. renderList: SmartArray<BoundingBox>;
  63417. private _colorShader;
  63418. private _vertexBuffers;
  63419. private _indexBuffer;
  63420. private _fillIndexBuffer;
  63421. private _fillIndexData;
  63422. /**
  63423. * Instantiates a new bounding box renderer in a scene.
  63424. * @param scene the scene the renderer renders in
  63425. */
  63426. constructor(scene: Scene);
  63427. /**
  63428. * Registers the component in a given scene
  63429. */
  63430. register(): void;
  63431. private _evaluateSubMesh;
  63432. private _activeMesh;
  63433. private _prepareRessources;
  63434. private _createIndexBuffer;
  63435. /**
  63436. * Rebuilds the elements related to this component in case of
  63437. * context lost for instance.
  63438. */
  63439. rebuild(): void;
  63440. /**
  63441. * @hidden
  63442. */
  63443. reset(): void;
  63444. /**
  63445. * Render the bounding boxes of a specific rendering group
  63446. * @param renderingGroupId defines the rendering group to render
  63447. */
  63448. render(renderingGroupId: number): void;
  63449. /**
  63450. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63451. * @param mesh Define the mesh to render the occlusion bounding box for
  63452. */
  63453. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63454. /**
  63455. * Dispose and release the resources attached to this renderer.
  63456. */
  63457. dispose(): void;
  63458. }
  63459. }
  63460. declare module BABYLON {
  63461. /** @hidden */
  63462. export var depthPixelShader: {
  63463. name: string;
  63464. shader: string;
  63465. };
  63466. }
  63467. declare module BABYLON {
  63468. /**
  63469. * This represents a depth renderer in Babylon.
  63470. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63471. */
  63472. export class DepthRenderer {
  63473. private _scene;
  63474. private _depthMap;
  63475. private _effect;
  63476. private readonly _storeNonLinearDepth;
  63477. private readonly _clearColor;
  63478. /** Get if the depth renderer is using packed depth or not */
  63479. readonly isPacked: boolean;
  63480. private _cachedDefines;
  63481. private _camera;
  63482. /**
  63483. * Specifiess that the depth renderer will only be used within
  63484. * the camera it is created for.
  63485. * This can help forcing its rendering during the camera processing.
  63486. */
  63487. useOnlyInActiveCamera: boolean;
  63488. /** @hidden */
  63489. static _SceneComponentInitialization: (scene: Scene) => void;
  63490. /**
  63491. * Instantiates a depth renderer
  63492. * @param scene The scene the renderer belongs to
  63493. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63494. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63495. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63496. */
  63497. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63498. /**
  63499. * Creates the depth rendering effect and checks if the effect is ready.
  63500. * @param subMesh The submesh to be used to render the depth map of
  63501. * @param useInstances If multiple world instances should be used
  63502. * @returns if the depth renderer is ready to render the depth map
  63503. */
  63504. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63505. /**
  63506. * Gets the texture which the depth map will be written to.
  63507. * @returns The depth map texture
  63508. */
  63509. getDepthMap(): RenderTargetTexture;
  63510. /**
  63511. * Disposes of the depth renderer.
  63512. */
  63513. dispose(): void;
  63514. }
  63515. }
  63516. declare module BABYLON {
  63517. interface Scene {
  63518. /** @hidden (Backing field) */
  63519. _depthRenderer: {
  63520. [id: string]: DepthRenderer;
  63521. };
  63522. /**
  63523. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63524. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63525. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63526. * @returns the created depth renderer
  63527. */
  63528. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63529. /**
  63530. * Disables a depth renderer for a given camera
  63531. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63532. */
  63533. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63534. }
  63535. /**
  63536. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63537. * in several rendering techniques.
  63538. */
  63539. export class DepthRendererSceneComponent implements ISceneComponent {
  63540. /**
  63541. * The component name helpfull to identify the component in the list of scene components.
  63542. */
  63543. readonly name: string;
  63544. /**
  63545. * The scene the component belongs to.
  63546. */
  63547. scene: Scene;
  63548. /**
  63549. * Creates a new instance of the component for the given scene
  63550. * @param scene Defines the scene to register the component in
  63551. */
  63552. constructor(scene: Scene);
  63553. /**
  63554. * Registers the component in a given scene
  63555. */
  63556. register(): void;
  63557. /**
  63558. * Rebuilds the elements related to this component in case of
  63559. * context lost for instance.
  63560. */
  63561. rebuild(): void;
  63562. /**
  63563. * Disposes the component and the associated ressources
  63564. */
  63565. dispose(): void;
  63566. private _gatherRenderTargets;
  63567. private _gatherActiveCameraRenderTargets;
  63568. }
  63569. }
  63570. declare module BABYLON {
  63571. /** @hidden */
  63572. export var outlinePixelShader: {
  63573. name: string;
  63574. shader: string;
  63575. };
  63576. }
  63577. declare module BABYLON {
  63578. /** @hidden */
  63579. export var outlineVertexShader: {
  63580. name: string;
  63581. shader: string;
  63582. };
  63583. }
  63584. declare module BABYLON {
  63585. interface Scene {
  63586. /** @hidden */
  63587. _outlineRenderer: OutlineRenderer;
  63588. /**
  63589. * Gets the outline renderer associated with the scene
  63590. * @returns a OutlineRenderer
  63591. */
  63592. getOutlineRenderer(): OutlineRenderer;
  63593. }
  63594. interface AbstractMesh {
  63595. /** @hidden (Backing field) */
  63596. _renderOutline: boolean;
  63597. /**
  63598. * Gets or sets a boolean indicating if the outline must be rendered as well
  63599. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63600. */
  63601. renderOutline: boolean;
  63602. /** @hidden (Backing field) */
  63603. _renderOverlay: boolean;
  63604. /**
  63605. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63606. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63607. */
  63608. renderOverlay: boolean;
  63609. }
  63610. /**
  63611. * This class is responsible to draw bothe outline/overlay of meshes.
  63612. * It should not be used directly but through the available method on mesh.
  63613. */
  63614. export class OutlineRenderer implements ISceneComponent {
  63615. /**
  63616. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63617. */
  63618. private static _StencilReference;
  63619. /**
  63620. * The name of the component. Each component must have a unique name.
  63621. */
  63622. name: string;
  63623. /**
  63624. * The scene the component belongs to.
  63625. */
  63626. scene: Scene;
  63627. /**
  63628. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63629. */
  63630. zOffset: number;
  63631. private _engine;
  63632. private _effect;
  63633. private _cachedDefines;
  63634. private _savedDepthWrite;
  63635. /**
  63636. * Instantiates a new outline renderer. (There could be only one per scene).
  63637. * @param scene Defines the scene it belongs to
  63638. */
  63639. constructor(scene: Scene);
  63640. /**
  63641. * Register the component to one instance of a scene.
  63642. */
  63643. register(): void;
  63644. /**
  63645. * Rebuilds the elements related to this component in case of
  63646. * context lost for instance.
  63647. */
  63648. rebuild(): void;
  63649. /**
  63650. * Disposes the component and the associated ressources.
  63651. */
  63652. dispose(): void;
  63653. /**
  63654. * Renders the outline in the canvas.
  63655. * @param subMesh Defines the sumesh to render
  63656. * @param batch Defines the batch of meshes in case of instances
  63657. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63658. */
  63659. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63660. /**
  63661. * Returns whether or not the outline renderer is ready for a given submesh.
  63662. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63663. * @param subMesh Defines the submesh to check readyness for
  63664. * @param useInstances Defines wheter wee are trying to render instances or not
  63665. * @returns true if ready otherwise false
  63666. */
  63667. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63668. private _beforeRenderingMesh;
  63669. private _afterRenderingMesh;
  63670. }
  63671. }
  63672. declare module BABYLON {
  63673. /**
  63674. * Defines the basic options interface of a Sprite Frame Source Size.
  63675. */
  63676. export interface ISpriteJSONSpriteSourceSize {
  63677. /**
  63678. * number of the original width of the Frame
  63679. */
  63680. w: number;
  63681. /**
  63682. * number of the original height of the Frame
  63683. */
  63684. h: number;
  63685. }
  63686. /**
  63687. * Defines the basic options interface of a Sprite Frame Data.
  63688. */
  63689. export interface ISpriteJSONSpriteFrameData {
  63690. /**
  63691. * number of the x offset of the Frame
  63692. */
  63693. x: number;
  63694. /**
  63695. * number of the y offset of the Frame
  63696. */
  63697. y: number;
  63698. /**
  63699. * number of the width of the Frame
  63700. */
  63701. w: number;
  63702. /**
  63703. * number of the height of the Frame
  63704. */
  63705. h: number;
  63706. }
  63707. /**
  63708. * Defines the basic options interface of a JSON Sprite.
  63709. */
  63710. export interface ISpriteJSONSprite {
  63711. /**
  63712. * string name of the Frame
  63713. */
  63714. filename: string;
  63715. /**
  63716. * ISpriteJSONSpriteFrame basic object of the frame data
  63717. */
  63718. frame: ISpriteJSONSpriteFrameData;
  63719. /**
  63720. * boolean to flag is the frame was rotated.
  63721. */
  63722. rotated: boolean;
  63723. /**
  63724. * boolean to flag is the frame was trimmed.
  63725. */
  63726. trimmed: boolean;
  63727. /**
  63728. * ISpriteJSONSpriteFrame basic object of the source data
  63729. */
  63730. spriteSourceSize: ISpriteJSONSpriteFrameData;
  63731. /**
  63732. * ISpriteJSONSpriteFrame basic object of the source data
  63733. */
  63734. sourceSize: ISpriteJSONSpriteSourceSize;
  63735. }
  63736. /**
  63737. * Defines the basic options interface of a JSON atlas.
  63738. */
  63739. export interface ISpriteJSONAtlas {
  63740. /**
  63741. * Array of objects that contain the frame data.
  63742. */
  63743. frames: Array<ISpriteJSONSprite>;
  63744. /**
  63745. * object basic object containing the sprite meta data.
  63746. */
  63747. meta?: object;
  63748. }
  63749. }
  63750. declare module BABYLON {
  63751. /** @hidden */
  63752. export var spriteMapPixelShader: {
  63753. name: string;
  63754. shader: string;
  63755. };
  63756. }
  63757. declare module BABYLON {
  63758. /** @hidden */
  63759. export var spriteMapVertexShader: {
  63760. name: string;
  63761. shader: string;
  63762. };
  63763. }
  63764. declare module BABYLON {
  63765. /**
  63766. * Defines the basic options interface of a SpriteMap
  63767. */
  63768. export interface ISpriteMapOptions {
  63769. /**
  63770. * Vector2 of the number of cells in the grid.
  63771. */
  63772. stageSize?: Vector2;
  63773. /**
  63774. * Vector2 of the size of the output plane in World Units.
  63775. */
  63776. outputSize?: Vector2;
  63777. /**
  63778. * Vector3 of the position of the output plane in World Units.
  63779. */
  63780. outputPosition?: Vector3;
  63781. /**
  63782. * Vector3 of the rotation of the output plane.
  63783. */
  63784. outputRotation?: Vector3;
  63785. /**
  63786. * number of layers that the system will reserve in resources.
  63787. */
  63788. layerCount?: number;
  63789. /**
  63790. * number of max animation frames a single cell will reserve in resources.
  63791. */
  63792. maxAnimationFrames?: number;
  63793. /**
  63794. * number cell index of the base tile when the system compiles.
  63795. */
  63796. baseTile?: number;
  63797. /**
  63798. * boolean flip the sprite after its been repositioned by the framing data.
  63799. */
  63800. flipU?: boolean;
  63801. /**
  63802. * Vector3 scalar of the global RGB values of the SpriteMap.
  63803. */
  63804. colorMultiply?: Vector3;
  63805. }
  63806. /**
  63807. * Defines the IDisposable interface in order to be cleanable from resources.
  63808. */
  63809. export interface ISpriteMap extends IDisposable {
  63810. /**
  63811. * String name of the SpriteMap.
  63812. */
  63813. name: string;
  63814. /**
  63815. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  63816. */
  63817. atlasJSON: ISpriteJSONAtlas;
  63818. /**
  63819. * Texture of the SpriteMap.
  63820. */
  63821. spriteSheet: Texture;
  63822. /**
  63823. * The parameters to initialize the SpriteMap with.
  63824. */
  63825. options: ISpriteMapOptions;
  63826. }
  63827. /**
  63828. * Class used to manage a grid restricted sprite deployment on an Output plane.
  63829. */
  63830. export class SpriteMap implements ISpriteMap {
  63831. /** The Name of the spriteMap */
  63832. name: string;
  63833. /** The JSON file with the frame and meta data */
  63834. atlasJSON: ISpriteJSONAtlas;
  63835. /** The systems Sprite Sheet Texture */
  63836. spriteSheet: Texture;
  63837. /** Arguments passed with the Constructor */
  63838. options: ISpriteMapOptions;
  63839. /** Public Sprite Storage array, parsed from atlasJSON */
  63840. sprites: Array<ISpriteJSONSprite>;
  63841. /** Returns the Number of Sprites in the System */
  63842. readonly spriteCount: number;
  63843. /** Returns the Position of Output Plane*/
  63844. /** Returns the Position of Output Plane*/
  63845. position: Vector3;
  63846. /** Returns the Rotation of Output Plane*/
  63847. /** Returns the Rotation of Output Plane*/
  63848. rotation: Vector3;
  63849. /** Sets the AnimationMap*/
  63850. /** Sets the AnimationMap*/
  63851. animationMap: RawTexture;
  63852. /** Scene that the SpriteMap was created in */
  63853. private _scene;
  63854. /** Texture Buffer of Float32 that holds tile frame data*/
  63855. private _frameMap;
  63856. /** Texture Buffers of Float32 that holds tileMap data*/
  63857. private _tileMaps;
  63858. /** Texture Buffer of Float32 that holds Animation Data*/
  63859. private _animationMap;
  63860. /** Custom ShaderMaterial Central to the System*/
  63861. private _material;
  63862. /** Custom ShaderMaterial Central to the System*/
  63863. private _output;
  63864. /** Systems Time Ticker*/
  63865. private _time;
  63866. /**
  63867. * Creates a new SpriteMap
  63868. * @param name defines the SpriteMaps Name
  63869. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  63870. * @param spriteSheet is the Texture that the Sprites are on.
  63871. * @param options a basic deployment configuration
  63872. * @param scene The Scene that the map is deployed on
  63873. */
  63874. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  63875. /**
  63876. * Returns tileID location
  63877. * @returns Vector2 the cell position ID
  63878. */
  63879. getTileID(): Vector2;
  63880. /**
  63881. * Gets the UV location of the mouse over the SpriteMap.
  63882. * @returns Vector2 the UV position of the mouse interaction
  63883. */
  63884. getMousePosition(): Vector2;
  63885. /**
  63886. * Creates the "frame" texture Buffer
  63887. * -------------------------------------
  63888. * Structure of frames
  63889. * "filename": "Falling-Water-2.png",
  63890. * "frame": {"x":69,"y":103,"w":24,"h":32},
  63891. * "rotated": true,
  63892. * "trimmed": true,
  63893. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  63894. * "sourceSize": {"w":32,"h":32}
  63895. * @returns RawTexture of the frameMap
  63896. */
  63897. private _createFrameBuffer;
  63898. /**
  63899. * Creates the tileMap texture Buffer
  63900. * @param buffer normally and array of numbers, or a false to generate from scratch
  63901. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  63902. * @returns RawTexture of the tileMap
  63903. */
  63904. private _createTileBuffer;
  63905. /**
  63906. * Modifies the data of the tileMaps
  63907. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  63908. * @param pos is the iVector2 Coordinates of the Tile
  63909. * @param tile The SpriteIndex of the new Tile
  63910. */
  63911. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  63912. /**
  63913. * Creates the animationMap texture Buffer
  63914. * @param buffer normally and array of numbers, or a false to generate from scratch
  63915. * @returns RawTexture of the animationMap
  63916. */
  63917. private _createTileAnimationBuffer;
  63918. /**
  63919. * Modifies the data of the animationMap
  63920. * @param cellID is the Index of the Sprite
  63921. * @param _frame is the target Animation frame
  63922. * @param toCell is the Target Index of the next frame of the animation
  63923. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  63924. * @param speed is a global scalar of the time variable on the map.
  63925. */
  63926. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  63927. /**
  63928. * Exports the .tilemaps file
  63929. */
  63930. saveTileMaps(): void;
  63931. /**
  63932. * Imports the .tilemaps file
  63933. * @param url of the .tilemaps file
  63934. */
  63935. loadTileMaps(url: string): void;
  63936. /**
  63937. * Release associated resources
  63938. */
  63939. dispose(): void;
  63940. }
  63941. }
  63942. declare module BABYLON {
  63943. /**
  63944. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63945. * @see http://doc.babylonjs.com/babylon101/sprites
  63946. */
  63947. export class SpritePackedManager extends SpriteManager {
  63948. /** defines the packed manager's name */
  63949. name: string;
  63950. /**
  63951. * Creates a new sprite manager from a packed sprite sheet
  63952. * @param name defines the manager's name
  63953. * @param imgUrl defines the sprite sheet url
  63954. * @param capacity defines the maximum allowed number of sprites
  63955. * @param scene defines the hosting scene
  63956. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63957. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63958. * @param samplingMode defines the smapling mode to use with spritesheet
  63959. * @param fromPacked set to true; do not alter
  63960. */
  63961. constructor(
  63962. /** defines the packed manager's name */
  63963. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63964. }
  63965. }
  63966. declare module BABYLON {
  63967. /**
  63968. * Defines the list of states available for a task inside a AssetsManager
  63969. */
  63970. export enum AssetTaskState {
  63971. /**
  63972. * Initialization
  63973. */
  63974. INIT = 0,
  63975. /**
  63976. * Running
  63977. */
  63978. RUNNING = 1,
  63979. /**
  63980. * Done
  63981. */
  63982. DONE = 2,
  63983. /**
  63984. * Error
  63985. */
  63986. ERROR = 3
  63987. }
  63988. /**
  63989. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63990. */
  63991. export abstract class AbstractAssetTask {
  63992. /**
  63993. * Task name
  63994. */ name: string;
  63995. /**
  63996. * Callback called when the task is successful
  63997. */
  63998. onSuccess: (task: any) => void;
  63999. /**
  64000. * Callback called when the task is not successful
  64001. */
  64002. onError: (task: any, message?: string, exception?: any) => void;
  64003. /**
  64004. * Creates a new AssetsManager
  64005. * @param name defines the name of the task
  64006. */
  64007. constructor(
  64008. /**
  64009. * Task name
  64010. */ name: string);
  64011. private _isCompleted;
  64012. private _taskState;
  64013. private _errorObject;
  64014. /**
  64015. * Get if the task is completed
  64016. */
  64017. readonly isCompleted: boolean;
  64018. /**
  64019. * Gets the current state of the task
  64020. */
  64021. readonly taskState: AssetTaskState;
  64022. /**
  64023. * Gets the current error object (if task is in error)
  64024. */
  64025. readonly errorObject: {
  64026. message?: string;
  64027. exception?: any;
  64028. };
  64029. /**
  64030. * Internal only
  64031. * @hidden
  64032. */
  64033. _setErrorObject(message?: string, exception?: any): void;
  64034. /**
  64035. * Execute the current task
  64036. * @param scene defines the scene where you want your assets to be loaded
  64037. * @param onSuccess is a callback called when the task is successfully executed
  64038. * @param onError is a callback called if an error occurs
  64039. */
  64040. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64041. /**
  64042. * Execute the current task
  64043. * @param scene defines the scene where you want your assets to be loaded
  64044. * @param onSuccess is a callback called when the task is successfully executed
  64045. * @param onError is a callback called if an error occurs
  64046. */
  64047. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64048. /**
  64049. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64050. * This can be used with failed tasks that have the reason for failure fixed.
  64051. */
  64052. reset(): void;
  64053. private onErrorCallback;
  64054. private onDoneCallback;
  64055. }
  64056. /**
  64057. * Define the interface used by progress events raised during assets loading
  64058. */
  64059. export interface IAssetsProgressEvent {
  64060. /**
  64061. * Defines the number of remaining tasks to process
  64062. */
  64063. remainingCount: number;
  64064. /**
  64065. * Defines the total number of tasks
  64066. */
  64067. totalCount: number;
  64068. /**
  64069. * Defines the task that was just processed
  64070. */
  64071. task: AbstractAssetTask;
  64072. }
  64073. /**
  64074. * Class used to share progress information about assets loading
  64075. */
  64076. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64077. /**
  64078. * Defines the number of remaining tasks to process
  64079. */
  64080. remainingCount: number;
  64081. /**
  64082. * Defines the total number of tasks
  64083. */
  64084. totalCount: number;
  64085. /**
  64086. * Defines the task that was just processed
  64087. */
  64088. task: AbstractAssetTask;
  64089. /**
  64090. * Creates a AssetsProgressEvent
  64091. * @param remainingCount defines the number of remaining tasks to process
  64092. * @param totalCount defines the total number of tasks
  64093. * @param task defines the task that was just processed
  64094. */
  64095. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64096. }
  64097. /**
  64098. * Define a task used by AssetsManager to load meshes
  64099. */
  64100. export class MeshAssetTask extends AbstractAssetTask {
  64101. /**
  64102. * Defines the name of the task
  64103. */
  64104. name: string;
  64105. /**
  64106. * Defines the list of mesh's names you want to load
  64107. */
  64108. meshesNames: any;
  64109. /**
  64110. * Defines the root url to use as a base to load your meshes and associated resources
  64111. */
  64112. rootUrl: string;
  64113. /**
  64114. * Defines the filename of the scene to load from
  64115. */
  64116. sceneFilename: string;
  64117. /**
  64118. * Gets the list of loaded meshes
  64119. */
  64120. loadedMeshes: Array<AbstractMesh>;
  64121. /**
  64122. * Gets the list of loaded particle systems
  64123. */
  64124. loadedParticleSystems: Array<IParticleSystem>;
  64125. /**
  64126. * Gets the list of loaded skeletons
  64127. */
  64128. loadedSkeletons: Array<Skeleton>;
  64129. /**
  64130. * Gets the list of loaded animation groups
  64131. */
  64132. loadedAnimationGroups: Array<AnimationGroup>;
  64133. /**
  64134. * Callback called when the task is successful
  64135. */
  64136. onSuccess: (task: MeshAssetTask) => void;
  64137. /**
  64138. * Callback called when the task is successful
  64139. */
  64140. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64141. /**
  64142. * Creates a new MeshAssetTask
  64143. * @param name defines the name of the task
  64144. * @param meshesNames defines the list of mesh's names you want to load
  64145. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64146. * @param sceneFilename defines the filename of the scene to load from
  64147. */
  64148. constructor(
  64149. /**
  64150. * Defines the name of the task
  64151. */
  64152. name: string,
  64153. /**
  64154. * Defines the list of mesh's names you want to load
  64155. */
  64156. meshesNames: any,
  64157. /**
  64158. * Defines the root url to use as a base to load your meshes and associated resources
  64159. */
  64160. rootUrl: string,
  64161. /**
  64162. * Defines the filename of the scene to load from
  64163. */
  64164. sceneFilename: string);
  64165. /**
  64166. * Execute the current task
  64167. * @param scene defines the scene where you want your assets to be loaded
  64168. * @param onSuccess is a callback called when the task is successfully executed
  64169. * @param onError is a callback called if an error occurs
  64170. */
  64171. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64172. }
  64173. /**
  64174. * Define a task used by AssetsManager to load text content
  64175. */
  64176. export class TextFileAssetTask extends AbstractAssetTask {
  64177. /**
  64178. * Defines the name of the task
  64179. */
  64180. name: string;
  64181. /**
  64182. * Defines the location of the file to load
  64183. */
  64184. url: string;
  64185. /**
  64186. * Gets the loaded text string
  64187. */
  64188. text: string;
  64189. /**
  64190. * Callback called when the task is successful
  64191. */
  64192. onSuccess: (task: TextFileAssetTask) => void;
  64193. /**
  64194. * Callback called when the task is successful
  64195. */
  64196. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64197. /**
  64198. * Creates a new TextFileAssetTask object
  64199. * @param name defines the name of the task
  64200. * @param url defines the location of the file to load
  64201. */
  64202. constructor(
  64203. /**
  64204. * Defines the name of the task
  64205. */
  64206. name: string,
  64207. /**
  64208. * Defines the location of the file to load
  64209. */
  64210. url: string);
  64211. /**
  64212. * Execute the current task
  64213. * @param scene defines the scene where you want your assets to be loaded
  64214. * @param onSuccess is a callback called when the task is successfully executed
  64215. * @param onError is a callback called if an error occurs
  64216. */
  64217. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64218. }
  64219. /**
  64220. * Define a task used by AssetsManager to load binary data
  64221. */
  64222. export class BinaryFileAssetTask extends AbstractAssetTask {
  64223. /**
  64224. * Defines the name of the task
  64225. */
  64226. name: string;
  64227. /**
  64228. * Defines the location of the file to load
  64229. */
  64230. url: string;
  64231. /**
  64232. * Gets the lodaded data (as an array buffer)
  64233. */
  64234. data: ArrayBuffer;
  64235. /**
  64236. * Callback called when the task is successful
  64237. */
  64238. onSuccess: (task: BinaryFileAssetTask) => void;
  64239. /**
  64240. * Callback called when the task is successful
  64241. */
  64242. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64243. /**
  64244. * Creates a new BinaryFileAssetTask object
  64245. * @param name defines the name of the new task
  64246. * @param url defines the location of the file to load
  64247. */
  64248. constructor(
  64249. /**
  64250. * Defines the name of the task
  64251. */
  64252. name: string,
  64253. /**
  64254. * Defines the location of the file to load
  64255. */
  64256. url: string);
  64257. /**
  64258. * Execute the current task
  64259. * @param scene defines the scene where you want your assets to be loaded
  64260. * @param onSuccess is a callback called when the task is successfully executed
  64261. * @param onError is a callback called if an error occurs
  64262. */
  64263. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64264. }
  64265. /**
  64266. * Define a task used by AssetsManager to load images
  64267. */
  64268. export class ImageAssetTask extends AbstractAssetTask {
  64269. /**
  64270. * Defines the name of the task
  64271. */
  64272. name: string;
  64273. /**
  64274. * Defines the location of the image to load
  64275. */
  64276. url: string;
  64277. /**
  64278. * Gets the loaded images
  64279. */
  64280. image: HTMLImageElement;
  64281. /**
  64282. * Callback called when the task is successful
  64283. */
  64284. onSuccess: (task: ImageAssetTask) => void;
  64285. /**
  64286. * Callback called when the task is successful
  64287. */
  64288. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64289. /**
  64290. * Creates a new ImageAssetTask
  64291. * @param name defines the name of the task
  64292. * @param url defines the location of the image to load
  64293. */
  64294. constructor(
  64295. /**
  64296. * Defines the name of the task
  64297. */
  64298. name: string,
  64299. /**
  64300. * Defines the location of the image to load
  64301. */
  64302. url: string);
  64303. /**
  64304. * Execute the current task
  64305. * @param scene defines the scene where you want your assets to be loaded
  64306. * @param onSuccess is a callback called when the task is successfully executed
  64307. * @param onError is a callback called if an error occurs
  64308. */
  64309. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64310. }
  64311. /**
  64312. * Defines the interface used by texture loading tasks
  64313. */
  64314. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64315. /**
  64316. * Gets the loaded texture
  64317. */
  64318. texture: TEX;
  64319. }
  64320. /**
  64321. * Define a task used by AssetsManager to load 2D textures
  64322. */
  64323. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64324. /**
  64325. * Defines the name of the task
  64326. */
  64327. name: string;
  64328. /**
  64329. * Defines the location of the file to load
  64330. */
  64331. url: string;
  64332. /**
  64333. * Defines if mipmap should not be generated (default is false)
  64334. */
  64335. noMipmap?: boolean | undefined;
  64336. /**
  64337. * Defines if texture must be inverted on Y axis (default is false)
  64338. */
  64339. invertY?: boolean | undefined;
  64340. /**
  64341. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64342. */
  64343. samplingMode: number;
  64344. /**
  64345. * Gets the loaded texture
  64346. */
  64347. texture: Texture;
  64348. /**
  64349. * Callback called when the task is successful
  64350. */
  64351. onSuccess: (task: TextureAssetTask) => void;
  64352. /**
  64353. * Callback called when the task is successful
  64354. */
  64355. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64356. /**
  64357. * Creates a new TextureAssetTask object
  64358. * @param name defines the name of the task
  64359. * @param url defines the location of the file to load
  64360. * @param noMipmap defines if mipmap should not be generated (default is false)
  64361. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64362. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64363. */
  64364. constructor(
  64365. /**
  64366. * Defines the name of the task
  64367. */
  64368. name: string,
  64369. /**
  64370. * Defines the location of the file to load
  64371. */
  64372. url: string,
  64373. /**
  64374. * Defines if mipmap should not be generated (default is false)
  64375. */
  64376. noMipmap?: boolean | undefined,
  64377. /**
  64378. * Defines if texture must be inverted on Y axis (default is false)
  64379. */
  64380. invertY?: boolean | undefined,
  64381. /**
  64382. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64383. */
  64384. samplingMode?: number);
  64385. /**
  64386. * Execute the current task
  64387. * @param scene defines the scene where you want your assets to be loaded
  64388. * @param onSuccess is a callback called when the task is successfully executed
  64389. * @param onError is a callback called if an error occurs
  64390. */
  64391. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64392. }
  64393. /**
  64394. * Define a task used by AssetsManager to load cube textures
  64395. */
  64396. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64397. /**
  64398. * Defines the name of the task
  64399. */
  64400. name: string;
  64401. /**
  64402. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64403. */
  64404. url: string;
  64405. /**
  64406. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64407. */
  64408. extensions?: string[] | undefined;
  64409. /**
  64410. * Defines if mipmaps should not be generated (default is false)
  64411. */
  64412. noMipmap?: boolean | undefined;
  64413. /**
  64414. * Defines the explicit list of files (undefined by default)
  64415. */
  64416. files?: string[] | undefined;
  64417. /**
  64418. * Gets the loaded texture
  64419. */
  64420. texture: CubeTexture;
  64421. /**
  64422. * Callback called when the task is successful
  64423. */
  64424. onSuccess: (task: CubeTextureAssetTask) => void;
  64425. /**
  64426. * Callback called when the task is successful
  64427. */
  64428. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64429. /**
  64430. * Creates a new CubeTextureAssetTask
  64431. * @param name defines the name of the task
  64432. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64433. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64434. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64435. * @param files defines the explicit list of files (undefined by default)
  64436. */
  64437. constructor(
  64438. /**
  64439. * Defines the name of the task
  64440. */
  64441. name: string,
  64442. /**
  64443. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64444. */
  64445. url: string,
  64446. /**
  64447. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64448. */
  64449. extensions?: string[] | undefined,
  64450. /**
  64451. * Defines if mipmaps should not be generated (default is false)
  64452. */
  64453. noMipmap?: boolean | undefined,
  64454. /**
  64455. * Defines the explicit list of files (undefined by default)
  64456. */
  64457. files?: string[] | undefined);
  64458. /**
  64459. * Execute the current task
  64460. * @param scene defines the scene where you want your assets to be loaded
  64461. * @param onSuccess is a callback called when the task is successfully executed
  64462. * @param onError is a callback called if an error occurs
  64463. */
  64464. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64465. }
  64466. /**
  64467. * Define a task used by AssetsManager to load HDR cube textures
  64468. */
  64469. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64470. /**
  64471. * Defines the name of the task
  64472. */
  64473. name: string;
  64474. /**
  64475. * Defines the location of the file to load
  64476. */
  64477. url: string;
  64478. /**
  64479. * Defines the desired size (the more it increases the longer the generation will be)
  64480. */
  64481. size: number;
  64482. /**
  64483. * Defines if mipmaps should not be generated (default is false)
  64484. */
  64485. noMipmap: boolean;
  64486. /**
  64487. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64488. */
  64489. generateHarmonics: boolean;
  64490. /**
  64491. * 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)
  64492. */
  64493. gammaSpace: boolean;
  64494. /**
  64495. * Internal Use Only
  64496. */
  64497. reserved: boolean;
  64498. /**
  64499. * Gets the loaded texture
  64500. */
  64501. texture: HDRCubeTexture;
  64502. /**
  64503. * Callback called when the task is successful
  64504. */
  64505. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64506. /**
  64507. * Callback called when the task is successful
  64508. */
  64509. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64510. /**
  64511. * Creates a new HDRCubeTextureAssetTask object
  64512. * @param name defines the name of the task
  64513. * @param url defines the location of the file to load
  64514. * @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.
  64515. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64516. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64517. * @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)
  64518. * @param reserved Internal use only
  64519. */
  64520. constructor(
  64521. /**
  64522. * Defines the name of the task
  64523. */
  64524. name: string,
  64525. /**
  64526. * Defines the location of the file to load
  64527. */
  64528. url: string,
  64529. /**
  64530. * Defines the desired size (the more it increases the longer the generation will be)
  64531. */
  64532. size: number,
  64533. /**
  64534. * Defines if mipmaps should not be generated (default is false)
  64535. */
  64536. noMipmap?: boolean,
  64537. /**
  64538. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64539. */
  64540. generateHarmonics?: boolean,
  64541. /**
  64542. * 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)
  64543. */
  64544. gammaSpace?: boolean,
  64545. /**
  64546. * Internal Use Only
  64547. */
  64548. reserved?: boolean);
  64549. /**
  64550. * Execute the current task
  64551. * @param scene defines the scene where you want your assets to be loaded
  64552. * @param onSuccess is a callback called when the task is successfully executed
  64553. * @param onError is a callback called if an error occurs
  64554. */
  64555. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64556. }
  64557. /**
  64558. * Define a task used by AssetsManager to load Equirectangular cube textures
  64559. */
  64560. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64561. /**
  64562. * Defines the name of the task
  64563. */
  64564. name: string;
  64565. /**
  64566. * Defines the location of the file to load
  64567. */
  64568. url: string;
  64569. /**
  64570. * Defines the desired size (the more it increases the longer the generation will be)
  64571. */
  64572. size: number;
  64573. /**
  64574. * Defines if mipmaps should not be generated (default is false)
  64575. */
  64576. noMipmap: boolean;
  64577. /**
  64578. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64579. * but the standard material would require them in Gamma space) (default is true)
  64580. */
  64581. gammaSpace: boolean;
  64582. /**
  64583. * Gets the loaded texture
  64584. */
  64585. texture: EquiRectangularCubeTexture;
  64586. /**
  64587. * Callback called when the task is successful
  64588. */
  64589. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64590. /**
  64591. * Callback called when the task is successful
  64592. */
  64593. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64594. /**
  64595. * Creates a new EquiRectangularCubeTextureAssetTask object
  64596. * @param name defines the name of the task
  64597. * @param url defines the location of the file to load
  64598. * @param size defines the desired size (the more it increases the longer the generation will be)
  64599. * If the size is omitted this implies you are using a preprocessed cubemap.
  64600. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64601. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64602. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64603. * (default is true)
  64604. */
  64605. constructor(
  64606. /**
  64607. * Defines the name of the task
  64608. */
  64609. name: string,
  64610. /**
  64611. * Defines the location of the file to load
  64612. */
  64613. url: string,
  64614. /**
  64615. * Defines the desired size (the more it increases the longer the generation will be)
  64616. */
  64617. size: number,
  64618. /**
  64619. * Defines if mipmaps should not be generated (default is false)
  64620. */
  64621. noMipmap?: boolean,
  64622. /**
  64623. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64624. * but the standard material would require them in Gamma space) (default is true)
  64625. */
  64626. gammaSpace?: boolean);
  64627. /**
  64628. * Execute the current task
  64629. * @param scene defines the scene where you want your assets to be loaded
  64630. * @param onSuccess is a callback called when the task is successfully executed
  64631. * @param onError is a callback called if an error occurs
  64632. */
  64633. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64634. }
  64635. /**
  64636. * This class can be used to easily import assets into a scene
  64637. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64638. */
  64639. export class AssetsManager {
  64640. private _scene;
  64641. private _isLoading;
  64642. protected _tasks: AbstractAssetTask[];
  64643. protected _waitingTasksCount: number;
  64644. protected _totalTasksCount: number;
  64645. /**
  64646. * Callback called when all tasks are processed
  64647. */
  64648. onFinish: (tasks: AbstractAssetTask[]) => void;
  64649. /**
  64650. * Callback called when a task is successful
  64651. */
  64652. onTaskSuccess: (task: AbstractAssetTask) => void;
  64653. /**
  64654. * Callback called when a task had an error
  64655. */
  64656. onTaskError: (task: AbstractAssetTask) => void;
  64657. /**
  64658. * Callback called when a task is done (whatever the result is)
  64659. */
  64660. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64661. /**
  64662. * Observable called when all tasks are processed
  64663. */
  64664. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64665. /**
  64666. * Observable called when a task had an error
  64667. */
  64668. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64669. /**
  64670. * Observable called when all tasks were executed
  64671. */
  64672. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64673. /**
  64674. * Observable called when a task is done (whatever the result is)
  64675. */
  64676. onProgressObservable: Observable<IAssetsProgressEvent>;
  64677. /**
  64678. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64679. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64680. */
  64681. useDefaultLoadingScreen: boolean;
  64682. /**
  64683. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64684. * when all assets have been downloaded.
  64685. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64686. */
  64687. autoHideLoadingUI: boolean;
  64688. /**
  64689. * Creates a new AssetsManager
  64690. * @param scene defines the scene to work on
  64691. */
  64692. constructor(scene: Scene);
  64693. /**
  64694. * Add a MeshAssetTask to the list of active tasks
  64695. * @param taskName defines the name of the new task
  64696. * @param meshesNames defines the name of meshes to load
  64697. * @param rootUrl defines the root url to use to locate files
  64698. * @param sceneFilename defines the filename of the scene file
  64699. * @returns a new MeshAssetTask object
  64700. */
  64701. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64702. /**
  64703. * Add a TextFileAssetTask to the list of active tasks
  64704. * @param taskName defines the name of the new task
  64705. * @param url defines the url of the file to load
  64706. * @returns a new TextFileAssetTask object
  64707. */
  64708. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64709. /**
  64710. * Add a BinaryFileAssetTask to the list of active tasks
  64711. * @param taskName defines the name of the new task
  64712. * @param url defines the url of the file to load
  64713. * @returns a new BinaryFileAssetTask object
  64714. */
  64715. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64716. /**
  64717. * Add a ImageAssetTask to the list of active tasks
  64718. * @param taskName defines the name of the new task
  64719. * @param url defines the url of the file to load
  64720. * @returns a new ImageAssetTask object
  64721. */
  64722. addImageTask(taskName: string, url: string): ImageAssetTask;
  64723. /**
  64724. * Add a TextureAssetTask to the list of active tasks
  64725. * @param taskName defines the name of the new task
  64726. * @param url defines the url of the file to load
  64727. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64728. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64729. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64730. * @returns a new TextureAssetTask object
  64731. */
  64732. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64733. /**
  64734. * Add a CubeTextureAssetTask to the list of active tasks
  64735. * @param taskName defines the name of the new task
  64736. * @param url defines the url of the file to load
  64737. * @param extensions defines the extension to use to load the cube map (can be null)
  64738. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64739. * @param files defines the list of files to load (can be null)
  64740. * @returns a new CubeTextureAssetTask object
  64741. */
  64742. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64743. /**
  64744. *
  64745. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64746. * @param taskName defines the name of the new task
  64747. * @param url defines the url of the file to load
  64748. * @param size defines the size you want for the cubemap (can be null)
  64749. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64750. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64751. * @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)
  64752. * @param reserved Internal use only
  64753. * @returns a new HDRCubeTextureAssetTask object
  64754. */
  64755. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64756. /**
  64757. *
  64758. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64759. * @param taskName defines the name of the new task
  64760. * @param url defines the url of the file to load
  64761. * @param size defines the size you want for the cubemap (can be null)
  64762. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64763. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64764. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64765. * @returns a new EquiRectangularCubeTextureAssetTask object
  64766. */
  64767. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64768. /**
  64769. * Remove a task from the assets manager.
  64770. * @param task the task to remove
  64771. */
  64772. removeTask(task: AbstractAssetTask): void;
  64773. private _decreaseWaitingTasksCount;
  64774. private _runTask;
  64775. /**
  64776. * Reset the AssetsManager and remove all tasks
  64777. * @return the current instance of the AssetsManager
  64778. */
  64779. reset(): AssetsManager;
  64780. /**
  64781. * Start the loading process
  64782. * @return the current instance of the AssetsManager
  64783. */
  64784. load(): AssetsManager;
  64785. /**
  64786. * Start the loading process as an async operation
  64787. * @return a promise returning the list of failed tasks
  64788. */
  64789. loadAsync(): Promise<void>;
  64790. }
  64791. }
  64792. declare module BABYLON {
  64793. /**
  64794. * Wrapper class for promise with external resolve and reject.
  64795. */
  64796. export class Deferred<T> {
  64797. /**
  64798. * The promise associated with this deferred object.
  64799. */
  64800. readonly promise: Promise<T>;
  64801. private _resolve;
  64802. private _reject;
  64803. /**
  64804. * The resolve method of the promise associated with this deferred object.
  64805. */
  64806. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64807. /**
  64808. * The reject method of the promise associated with this deferred object.
  64809. */
  64810. readonly reject: (reason?: any) => void;
  64811. /**
  64812. * Constructor for this deferred object.
  64813. */
  64814. constructor();
  64815. }
  64816. }
  64817. declare module BABYLON {
  64818. /**
  64819. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64820. */
  64821. export class MeshExploder {
  64822. private _centerMesh;
  64823. private _meshes;
  64824. private _meshesOrigins;
  64825. private _toCenterVectors;
  64826. private _scaledDirection;
  64827. private _newPosition;
  64828. private _centerPosition;
  64829. /**
  64830. * Explodes meshes from a center mesh.
  64831. * @param meshes The meshes to explode.
  64832. * @param centerMesh The mesh to be center of explosion.
  64833. */
  64834. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64835. private _setCenterMesh;
  64836. /**
  64837. * Get class name
  64838. * @returns "MeshExploder"
  64839. */
  64840. getClassName(): string;
  64841. /**
  64842. * "Exploded meshes"
  64843. * @returns Array of meshes with the centerMesh at index 0.
  64844. */
  64845. getMeshes(): Array<Mesh>;
  64846. /**
  64847. * Explodes meshes giving a specific direction
  64848. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64849. */
  64850. explode(direction?: number): void;
  64851. }
  64852. }
  64853. declare module BABYLON {
  64854. /**
  64855. * Class used to help managing file picking and drag'n'drop
  64856. */
  64857. export class FilesInput {
  64858. /**
  64859. * List of files ready to be loaded
  64860. */
  64861. static readonly FilesToLoad: {
  64862. [key: string]: File;
  64863. };
  64864. /**
  64865. * Callback called when a file is processed
  64866. */
  64867. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64868. private _engine;
  64869. private _currentScene;
  64870. private _sceneLoadedCallback;
  64871. private _progressCallback;
  64872. private _additionalRenderLoopLogicCallback;
  64873. private _textureLoadingCallback;
  64874. private _startingProcessingFilesCallback;
  64875. private _onReloadCallback;
  64876. private _errorCallback;
  64877. private _elementToMonitor;
  64878. private _sceneFileToLoad;
  64879. private _filesToLoad;
  64880. /**
  64881. * Creates a new FilesInput
  64882. * @param engine defines the rendering engine
  64883. * @param scene defines the hosting scene
  64884. * @param sceneLoadedCallback callback called when scene is loaded
  64885. * @param progressCallback callback called to track progress
  64886. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64887. * @param textureLoadingCallback callback called when a texture is loading
  64888. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64889. * @param onReloadCallback callback called when a reload is requested
  64890. * @param errorCallback callback call if an error occurs
  64891. */
  64892. 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);
  64893. private _dragEnterHandler;
  64894. private _dragOverHandler;
  64895. private _dropHandler;
  64896. /**
  64897. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64898. * @param elementToMonitor defines the DOM element to track
  64899. */
  64900. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64901. /**
  64902. * Release all associated resources
  64903. */
  64904. dispose(): void;
  64905. private renderFunction;
  64906. private drag;
  64907. private drop;
  64908. private _traverseFolder;
  64909. private _processFiles;
  64910. /**
  64911. * Load files from a drop event
  64912. * @param event defines the drop event to use as source
  64913. */
  64914. loadFiles(event: any): void;
  64915. private _processReload;
  64916. /**
  64917. * Reload the current scene from the loaded files
  64918. */
  64919. reload(): void;
  64920. }
  64921. }
  64922. declare module BABYLON {
  64923. /**
  64924. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64925. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64926. */
  64927. export class SceneOptimization {
  64928. /**
  64929. * Defines the priority of this optimization (0 by default which means first in the list)
  64930. */
  64931. priority: number;
  64932. /**
  64933. * Gets a string describing the action executed by the current optimization
  64934. * @returns description string
  64935. */
  64936. getDescription(): string;
  64937. /**
  64938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64939. * @param scene defines the current scene where to apply this optimization
  64940. * @param optimizer defines the current optimizer
  64941. * @returns true if everything that can be done was applied
  64942. */
  64943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64944. /**
  64945. * Creates the SceneOptimization object
  64946. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64947. * @param desc defines the description associated with the optimization
  64948. */
  64949. constructor(
  64950. /**
  64951. * Defines the priority of this optimization (0 by default which means first in the list)
  64952. */
  64953. priority?: number);
  64954. }
  64955. /**
  64956. * Defines an optimization used to reduce the size of render target textures
  64957. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64958. */
  64959. export class TextureOptimization extends SceneOptimization {
  64960. /**
  64961. * Defines the priority of this optimization (0 by default which means first in the list)
  64962. */
  64963. priority: number;
  64964. /**
  64965. * 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
  64966. */
  64967. maximumSize: number;
  64968. /**
  64969. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64970. */
  64971. step: number;
  64972. /**
  64973. * Gets a string describing the action executed by the current optimization
  64974. * @returns description string
  64975. */
  64976. getDescription(): string;
  64977. /**
  64978. * Creates the TextureOptimization object
  64979. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64980. * @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
  64981. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64982. */
  64983. constructor(
  64984. /**
  64985. * Defines the priority of this optimization (0 by default which means first in the list)
  64986. */
  64987. priority?: number,
  64988. /**
  64989. * 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
  64990. */
  64991. maximumSize?: number,
  64992. /**
  64993. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64994. */
  64995. step?: number);
  64996. /**
  64997. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64998. * @param scene defines the current scene where to apply this optimization
  64999. * @param optimizer defines the current optimizer
  65000. * @returns true if everything that can be done was applied
  65001. */
  65002. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65003. }
  65004. /**
  65005. * Defines an optimization used to increase or decrease the rendering resolution
  65006. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65007. */
  65008. export class HardwareScalingOptimization extends SceneOptimization {
  65009. /**
  65010. * Defines the priority of this optimization (0 by default which means first in the list)
  65011. */
  65012. priority: number;
  65013. /**
  65014. * Defines the maximum scale to use (2 by default)
  65015. */
  65016. maximumScale: number;
  65017. /**
  65018. * Defines the step to use between two passes (0.5 by default)
  65019. */
  65020. step: number;
  65021. private _currentScale;
  65022. private _directionOffset;
  65023. /**
  65024. * Gets a string describing the action executed by the current optimization
  65025. * @return description string
  65026. */
  65027. getDescription(): string;
  65028. /**
  65029. * Creates the HardwareScalingOptimization object
  65030. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65031. * @param maximumScale defines the maximum scale to use (2 by default)
  65032. * @param step defines the step to use between two passes (0.5 by default)
  65033. */
  65034. constructor(
  65035. /**
  65036. * Defines the priority of this optimization (0 by default which means first in the list)
  65037. */
  65038. priority?: number,
  65039. /**
  65040. * Defines the maximum scale to use (2 by default)
  65041. */
  65042. maximumScale?: number,
  65043. /**
  65044. * Defines the step to use between two passes (0.5 by default)
  65045. */
  65046. step?: number);
  65047. /**
  65048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65049. * @param scene defines the current scene where to apply this optimization
  65050. * @param optimizer defines the current optimizer
  65051. * @returns true if everything that can be done was applied
  65052. */
  65053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65054. }
  65055. /**
  65056. * Defines an optimization used to remove shadows
  65057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65058. */
  65059. export class ShadowsOptimization extends SceneOptimization {
  65060. /**
  65061. * Gets a string describing the action executed by the current optimization
  65062. * @return description string
  65063. */
  65064. getDescription(): string;
  65065. /**
  65066. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65067. * @param scene defines the current scene where to apply this optimization
  65068. * @param optimizer defines the current optimizer
  65069. * @returns true if everything that can be done was applied
  65070. */
  65071. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65072. }
  65073. /**
  65074. * Defines an optimization used to turn post-processes off
  65075. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65076. */
  65077. export class PostProcessesOptimization extends SceneOptimization {
  65078. /**
  65079. * Gets a string describing the action executed by the current optimization
  65080. * @return description string
  65081. */
  65082. getDescription(): string;
  65083. /**
  65084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65085. * @param scene defines the current scene where to apply this optimization
  65086. * @param optimizer defines the current optimizer
  65087. * @returns true if everything that can be done was applied
  65088. */
  65089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65090. }
  65091. /**
  65092. * Defines an optimization used to turn lens flares off
  65093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65094. */
  65095. export class LensFlaresOptimization extends SceneOptimization {
  65096. /**
  65097. * Gets a string describing the action executed by the current optimization
  65098. * @return description string
  65099. */
  65100. getDescription(): string;
  65101. /**
  65102. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65103. * @param scene defines the current scene where to apply this optimization
  65104. * @param optimizer defines the current optimizer
  65105. * @returns true if everything that can be done was applied
  65106. */
  65107. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65108. }
  65109. /**
  65110. * Defines an optimization based on user defined callback.
  65111. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65112. */
  65113. export class CustomOptimization extends SceneOptimization {
  65114. /**
  65115. * Callback called to apply the custom optimization.
  65116. */
  65117. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65118. /**
  65119. * Callback called to get custom description
  65120. */
  65121. onGetDescription: () => string;
  65122. /**
  65123. * Gets a string describing the action executed by the current optimization
  65124. * @returns description string
  65125. */
  65126. getDescription(): string;
  65127. /**
  65128. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65129. * @param scene defines the current scene where to apply this optimization
  65130. * @param optimizer defines the current optimizer
  65131. * @returns true if everything that can be done was applied
  65132. */
  65133. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65134. }
  65135. /**
  65136. * Defines an optimization used to turn particles off
  65137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65138. */
  65139. export class ParticlesOptimization extends SceneOptimization {
  65140. /**
  65141. * Gets a string describing the action executed by the current optimization
  65142. * @return description string
  65143. */
  65144. getDescription(): string;
  65145. /**
  65146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65147. * @param scene defines the current scene where to apply this optimization
  65148. * @param optimizer defines the current optimizer
  65149. * @returns true if everything that can be done was applied
  65150. */
  65151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65152. }
  65153. /**
  65154. * Defines an optimization used to turn render targets off
  65155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65156. */
  65157. export class RenderTargetsOptimization extends SceneOptimization {
  65158. /**
  65159. * Gets a string describing the action executed by the current optimization
  65160. * @return description string
  65161. */
  65162. getDescription(): string;
  65163. /**
  65164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65165. * @param scene defines the current scene where to apply this optimization
  65166. * @param optimizer defines the current optimizer
  65167. * @returns true if everything that can be done was applied
  65168. */
  65169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65170. }
  65171. /**
  65172. * Defines an optimization used to merge meshes with compatible materials
  65173. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65174. */
  65175. export class MergeMeshesOptimization extends SceneOptimization {
  65176. private static _UpdateSelectionTree;
  65177. /**
  65178. * Gets or sets a boolean which defines if optimization octree has to be updated
  65179. */
  65180. /**
  65181. * Gets or sets a boolean which defines if optimization octree has to be updated
  65182. */
  65183. static UpdateSelectionTree: boolean;
  65184. /**
  65185. * Gets a string describing the action executed by the current optimization
  65186. * @return description string
  65187. */
  65188. getDescription(): string;
  65189. private _canBeMerged;
  65190. /**
  65191. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65192. * @param scene defines the current scene where to apply this optimization
  65193. * @param optimizer defines the current optimizer
  65194. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65195. * @returns true if everything that can be done was applied
  65196. */
  65197. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65198. }
  65199. /**
  65200. * Defines a list of options used by SceneOptimizer
  65201. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65202. */
  65203. export class SceneOptimizerOptions {
  65204. /**
  65205. * Defines the target frame rate to reach (60 by default)
  65206. */
  65207. targetFrameRate: number;
  65208. /**
  65209. * Defines the interval between two checkes (2000ms by default)
  65210. */
  65211. trackerDuration: number;
  65212. /**
  65213. * Gets the list of optimizations to apply
  65214. */
  65215. optimizations: SceneOptimization[];
  65216. /**
  65217. * Creates a new list of options used by SceneOptimizer
  65218. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65219. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65220. */
  65221. constructor(
  65222. /**
  65223. * Defines the target frame rate to reach (60 by default)
  65224. */
  65225. targetFrameRate?: number,
  65226. /**
  65227. * Defines the interval between two checkes (2000ms by default)
  65228. */
  65229. trackerDuration?: number);
  65230. /**
  65231. * Add a new optimization
  65232. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65233. * @returns the current SceneOptimizerOptions
  65234. */
  65235. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65236. /**
  65237. * Add a new custom optimization
  65238. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65239. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65240. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65241. * @returns the current SceneOptimizerOptions
  65242. */
  65243. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65244. /**
  65245. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65246. * @param targetFrameRate defines the target frame rate (60 by default)
  65247. * @returns a SceneOptimizerOptions object
  65248. */
  65249. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65250. /**
  65251. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65252. * @param targetFrameRate defines the target frame rate (60 by default)
  65253. * @returns a SceneOptimizerOptions object
  65254. */
  65255. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65256. /**
  65257. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65258. * @param targetFrameRate defines the target frame rate (60 by default)
  65259. * @returns a SceneOptimizerOptions object
  65260. */
  65261. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65262. }
  65263. /**
  65264. * Class used to run optimizations in order to reach a target frame rate
  65265. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65266. */
  65267. export class SceneOptimizer implements IDisposable {
  65268. private _isRunning;
  65269. private _options;
  65270. private _scene;
  65271. private _currentPriorityLevel;
  65272. private _targetFrameRate;
  65273. private _trackerDuration;
  65274. private _currentFrameRate;
  65275. private _sceneDisposeObserver;
  65276. private _improvementMode;
  65277. /**
  65278. * Defines an observable called when the optimizer reaches the target frame rate
  65279. */
  65280. onSuccessObservable: Observable<SceneOptimizer>;
  65281. /**
  65282. * Defines an observable called when the optimizer enables an optimization
  65283. */
  65284. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65285. /**
  65286. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65287. */
  65288. onFailureObservable: Observable<SceneOptimizer>;
  65289. /**
  65290. * Gets a boolean indicating if the optimizer is in improvement mode
  65291. */
  65292. readonly isInImprovementMode: boolean;
  65293. /**
  65294. * Gets the current priority level (0 at start)
  65295. */
  65296. readonly currentPriorityLevel: number;
  65297. /**
  65298. * Gets the current frame rate checked by the SceneOptimizer
  65299. */
  65300. readonly currentFrameRate: number;
  65301. /**
  65302. * Gets or sets the current target frame rate (60 by default)
  65303. */
  65304. /**
  65305. * Gets or sets the current target frame rate (60 by default)
  65306. */
  65307. targetFrameRate: number;
  65308. /**
  65309. * Gets or sets the current interval between two checks (every 2000ms by default)
  65310. */
  65311. /**
  65312. * Gets or sets the current interval between two checks (every 2000ms by default)
  65313. */
  65314. trackerDuration: number;
  65315. /**
  65316. * Gets the list of active optimizations
  65317. */
  65318. readonly optimizations: SceneOptimization[];
  65319. /**
  65320. * Creates a new SceneOptimizer
  65321. * @param scene defines the scene to work on
  65322. * @param options defines the options to use with the SceneOptimizer
  65323. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65324. * @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)
  65325. */
  65326. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65327. /**
  65328. * Stops the current optimizer
  65329. */
  65330. stop(): void;
  65331. /**
  65332. * Reset the optimizer to initial step (current priority level = 0)
  65333. */
  65334. reset(): void;
  65335. /**
  65336. * Start the optimizer. By default it will try to reach a specific framerate
  65337. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65338. */
  65339. start(): void;
  65340. private _checkCurrentState;
  65341. /**
  65342. * Release all resources
  65343. */
  65344. dispose(): void;
  65345. /**
  65346. * Helper function to create a SceneOptimizer with one single line of code
  65347. * @param scene defines the scene to work on
  65348. * @param options defines the options to use with the SceneOptimizer
  65349. * @param onSuccess defines a callback to call on success
  65350. * @param onFailure defines a callback to call on failure
  65351. * @returns the new SceneOptimizer object
  65352. */
  65353. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65354. }
  65355. }
  65356. declare module BABYLON {
  65357. /**
  65358. * Class used to serialize a scene into a string
  65359. */
  65360. export class SceneSerializer {
  65361. /**
  65362. * Clear cache used by a previous serialization
  65363. */
  65364. static ClearCache(): void;
  65365. /**
  65366. * Serialize a scene into a JSON compatible object
  65367. * @param scene defines the scene to serialize
  65368. * @returns a JSON compatible object
  65369. */
  65370. static Serialize(scene: Scene): any;
  65371. /**
  65372. * Serialize a mesh into a JSON compatible object
  65373. * @param toSerialize defines the mesh to serialize
  65374. * @param withParents defines if parents must be serialized as well
  65375. * @param withChildren defines if children must be serialized as well
  65376. * @returns a JSON compatible object
  65377. */
  65378. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65379. }
  65380. }
  65381. declare module BABYLON {
  65382. /**
  65383. * Class used to host texture specific utilities
  65384. */
  65385. export class TextureTools {
  65386. /**
  65387. * Uses the GPU to create a copy texture rescaled at a given size
  65388. * @param texture Texture to copy from
  65389. * @param width defines the desired width
  65390. * @param height defines the desired height
  65391. * @param useBilinearMode defines if bilinear mode has to be used
  65392. * @return the generated texture
  65393. */
  65394. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65395. }
  65396. }
  65397. declare module BABYLON {
  65398. /**
  65399. * This represents the different options available for the video capture.
  65400. */
  65401. export interface VideoRecorderOptions {
  65402. /** Defines the mime type of the video. */
  65403. mimeType: string;
  65404. /** Defines the FPS the video should be recorded at. */
  65405. fps: number;
  65406. /** Defines the chunk size for the recording data. */
  65407. recordChunckSize: number;
  65408. /** The audio tracks to attach to the recording. */
  65409. audioTracks?: MediaStreamTrack[];
  65410. }
  65411. /**
  65412. * This can help with recording videos from BabylonJS.
  65413. * This is based on the available WebRTC functionalities of the browser.
  65414. *
  65415. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65416. */
  65417. export class VideoRecorder {
  65418. private static readonly _defaultOptions;
  65419. /**
  65420. * Returns whether or not the VideoRecorder is available in your browser.
  65421. * @param engine Defines the Babylon Engine.
  65422. * @returns true if supported otherwise false.
  65423. */
  65424. static IsSupported(engine: Engine): boolean;
  65425. private readonly _options;
  65426. private _canvas;
  65427. private _mediaRecorder;
  65428. private _recordedChunks;
  65429. private _fileName;
  65430. private _resolve;
  65431. private _reject;
  65432. /**
  65433. * True when a recording is already in progress.
  65434. */
  65435. readonly isRecording: boolean;
  65436. /**
  65437. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65438. * @param engine Defines the BabylonJS Engine you wish to record.
  65439. * @param options Defines options that can be used to customize the capture.
  65440. */
  65441. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65442. /**
  65443. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65444. */
  65445. stopRecording(): void;
  65446. /**
  65447. * Starts recording the canvas for a max duration specified in parameters.
  65448. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65449. * If null no automatic download will start and you can rely on the promise to get the data back.
  65450. * @param maxDuration Defines the maximum recording time in seconds.
  65451. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65452. * @return A promise callback at the end of the recording with the video data in Blob.
  65453. */
  65454. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65455. /**
  65456. * Releases internal resources used during the recording.
  65457. */
  65458. dispose(): void;
  65459. private _handleDataAvailable;
  65460. private _handleError;
  65461. private _handleStop;
  65462. }
  65463. }
  65464. declare module BABYLON {
  65465. /**
  65466. * Class containing a set of static utilities functions for screenshots
  65467. */
  65468. export class ScreenshotTools {
  65469. /**
  65470. * Captures a screenshot of the current rendering
  65471. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65472. * @param engine defines the rendering engine
  65473. * @param camera defines the source camera
  65474. * @param size This parameter can be set to a single number or to an object with the
  65475. * following (optional) properties: precision, width, height. If a single number is passed,
  65476. * it will be used for both width and height. If an object is passed, the screenshot size
  65477. * will be derived from the parameters. The precision property is a multiplier allowing
  65478. * rendering at a higher or lower resolution
  65479. * @param successCallback defines the callback receives a single parameter which contains the
  65480. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65481. * src parameter of an <img> to display it
  65482. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65483. * Check your browser for supported MIME types
  65484. */
  65485. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65486. /**
  65487. * Captures a screenshot of the current rendering
  65488. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65489. * @param engine defines the rendering engine
  65490. * @param camera defines the source camera
  65491. * @param size This parameter can be set to a single number or to an object with the
  65492. * following (optional) properties: precision, width, height. If a single number is passed,
  65493. * it will be used for both width and height. If an object is passed, the screenshot size
  65494. * will be derived from the parameters. The precision property is a multiplier allowing
  65495. * rendering at a higher or lower resolution
  65496. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65497. * Check your browser for supported MIME types
  65498. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65499. * to the src parameter of an <img> to display it
  65500. */
  65501. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65502. /**
  65503. * Generates an image screenshot from the specified camera.
  65504. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65505. * @param engine The engine to use for rendering
  65506. * @param camera The camera to use for rendering
  65507. * @param size This parameter can be set to a single number or to an object with the
  65508. * following (optional) properties: precision, width, height. If a single number is passed,
  65509. * it will be used for both width and height. If an object is passed, the screenshot size
  65510. * will be derived from the parameters. The precision property is a multiplier allowing
  65511. * rendering at a higher or lower resolution
  65512. * @param successCallback The callback receives a single parameter which contains the
  65513. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65514. * src parameter of an <img> to display it
  65515. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65516. * Check your browser for supported MIME types
  65517. * @param samples Texture samples (default: 1)
  65518. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65519. * @param fileName A name for for the downloaded file.
  65520. */
  65521. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65522. /**
  65523. * Generates an image screenshot from the specified camera.
  65524. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65525. * @param engine The engine to use for rendering
  65526. * @param camera The camera to use for rendering
  65527. * @param size This parameter can be set to a single number or to an object with the
  65528. * following (optional) properties: precision, width, height. If a single number is passed,
  65529. * it will be used for both width and height. If an object is passed, the screenshot size
  65530. * will be derived from the parameters. The precision property is a multiplier allowing
  65531. * rendering at a higher or lower resolution
  65532. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65533. * Check your browser for supported MIME types
  65534. * @param samples Texture samples (default: 1)
  65535. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65536. * @param fileName A name for for the downloaded file.
  65537. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65538. * to the src parameter of an <img> to display it
  65539. */
  65540. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65541. /**
  65542. * Gets height and width for screenshot size
  65543. * @private
  65544. */
  65545. private static _getScreenshotSize;
  65546. }
  65547. }
  65548. declare module BABYLON {
  65549. /**
  65550. * Interface for a data buffer
  65551. */
  65552. export interface IDataBuffer {
  65553. /**
  65554. * Reads bytes from the data buffer.
  65555. * @param byteOffset The byte offset to read
  65556. * @param byteLength The byte length to read
  65557. * @returns A promise that resolves when the bytes are read
  65558. */
  65559. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  65560. /**
  65561. * The byte length of the buffer.
  65562. */
  65563. readonly byteLength: number;
  65564. }
  65565. /**
  65566. * Utility class for reading from a data buffer
  65567. */
  65568. export class DataReader {
  65569. /**
  65570. * The data buffer associated with this data reader.
  65571. */
  65572. readonly buffer: IDataBuffer;
  65573. /**
  65574. * The current byte offset from the beginning of the data buffer.
  65575. */
  65576. byteOffset: number;
  65577. private _dataView;
  65578. private _dataByteOffset;
  65579. /**
  65580. * Constructor
  65581. * @param buffer The buffer to read
  65582. */
  65583. constructor(buffer: IDataBuffer);
  65584. /**
  65585. * Loads the given byte length.
  65586. * @param byteLength The byte length to load
  65587. * @returns A promise that resolves when the load is complete
  65588. */
  65589. loadAsync(byteLength: number): Promise<void>;
  65590. /**
  65591. * Read a unsigned 32-bit integer from the currently loaded data range.
  65592. * @returns The 32-bit integer read
  65593. */
  65594. readUint32(): number;
  65595. /**
  65596. * Read a byte array from the currently loaded data range.
  65597. * @param byteLength The byte length to read
  65598. * @returns The byte array read
  65599. */
  65600. readUint8Array(byteLength: number): Uint8Array;
  65601. /**
  65602. * Read a string from the currently loaded data range.
  65603. * @param byteLength The byte length to read
  65604. * @returns The string read
  65605. */
  65606. readString(byteLength: number): string;
  65607. /**
  65608. * Skips the given byte length the currently loaded data range.
  65609. * @param byteLength The byte length to skip
  65610. */
  65611. skipBytes(byteLength: number): void;
  65612. }
  65613. }
  65614. declare module BABYLON {
  65615. /**
  65616. * A cursor which tracks a point on a path
  65617. */
  65618. export class PathCursor {
  65619. private path;
  65620. /**
  65621. * Stores path cursor callbacks for when an onchange event is triggered
  65622. */
  65623. private _onchange;
  65624. /**
  65625. * The value of the path cursor
  65626. */
  65627. value: number;
  65628. /**
  65629. * The animation array of the path cursor
  65630. */
  65631. animations: Animation[];
  65632. /**
  65633. * Initializes the path cursor
  65634. * @param path The path to track
  65635. */
  65636. constructor(path: Path2);
  65637. /**
  65638. * Gets the cursor point on the path
  65639. * @returns A point on the path cursor at the cursor location
  65640. */
  65641. getPoint(): Vector3;
  65642. /**
  65643. * Moves the cursor ahead by the step amount
  65644. * @param step The amount to move the cursor forward
  65645. * @returns This path cursor
  65646. */
  65647. moveAhead(step?: number): PathCursor;
  65648. /**
  65649. * Moves the cursor behind by the step amount
  65650. * @param step The amount to move the cursor back
  65651. * @returns This path cursor
  65652. */
  65653. moveBack(step?: number): PathCursor;
  65654. /**
  65655. * Moves the cursor by the step amount
  65656. * If the step amount is greater than one, an exception is thrown
  65657. * @param step The amount to move the cursor
  65658. * @returns This path cursor
  65659. */
  65660. move(step: number): PathCursor;
  65661. /**
  65662. * Ensures that the value is limited between zero and one
  65663. * @returns This path cursor
  65664. */
  65665. private ensureLimits;
  65666. /**
  65667. * Runs onchange callbacks on change (used by the animation engine)
  65668. * @returns This path cursor
  65669. */
  65670. private raiseOnChange;
  65671. /**
  65672. * Executes a function on change
  65673. * @param f A path cursor onchange callback
  65674. * @returns This path cursor
  65675. */
  65676. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65677. }
  65678. }
  65679. declare module BABYLON {
  65680. /** @hidden */
  65681. export var blurPixelShader: {
  65682. name: string;
  65683. shader: string;
  65684. };
  65685. }
  65686. declare module BABYLON {
  65687. /** @hidden */
  65688. export var pointCloudVertexDeclaration: {
  65689. name: string;
  65690. shader: string;
  65691. };
  65692. }
  65693. // Mixins
  65694. interface Window {
  65695. mozIndexedDB: IDBFactory;
  65696. webkitIndexedDB: IDBFactory;
  65697. msIndexedDB: IDBFactory;
  65698. webkitURL: typeof URL;
  65699. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  65700. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  65701. WebGLRenderingContext: WebGLRenderingContext;
  65702. MSGesture: MSGesture;
  65703. CANNON: any;
  65704. AudioContext: AudioContext;
  65705. webkitAudioContext: AudioContext;
  65706. PointerEvent: any;
  65707. Math: Math;
  65708. Uint8Array: Uint8ArrayConstructor;
  65709. Float32Array: Float32ArrayConstructor;
  65710. mozURL: typeof URL;
  65711. msURL: typeof URL;
  65712. VRFrameData: any; // WebVR, from specs 1.1
  65713. DracoDecoderModule: any;
  65714. setImmediate(handler: (...args: any[]) => void): number;
  65715. }
  65716. interface HTMLCanvasElement {
  65717. requestPointerLock(): void;
  65718. msRequestPointerLock?(): void;
  65719. mozRequestPointerLock?(): void;
  65720. webkitRequestPointerLock?(): void;
  65721. /** Track wether a record is in progress */
  65722. isRecording: boolean;
  65723. /** Capture Stream method defined by some browsers */
  65724. captureStream(fps?: number): MediaStream;
  65725. }
  65726. interface CanvasRenderingContext2D {
  65727. msImageSmoothingEnabled: boolean;
  65728. }
  65729. interface MouseEvent {
  65730. mozMovementX: number;
  65731. mozMovementY: number;
  65732. webkitMovementX: number;
  65733. webkitMovementY: number;
  65734. msMovementX: number;
  65735. msMovementY: number;
  65736. }
  65737. interface Navigator {
  65738. mozGetVRDevices: (any: any) => any;
  65739. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65740. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65741. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65742. webkitGetGamepads(): Gamepad[];
  65743. msGetGamepads(): Gamepad[];
  65744. webkitGamepads(): Gamepad[];
  65745. }
  65746. interface HTMLVideoElement {
  65747. mozSrcObject: any;
  65748. }
  65749. interface Math {
  65750. fround(x: number): number;
  65751. imul(a: number, b: number): number;
  65752. }
  65753. interface WebGLRenderingContext {
  65754. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  65755. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  65756. vertexAttribDivisor(index: number, divisor: number): void;
  65757. createVertexArray(): any;
  65758. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  65759. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  65760. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  65761. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  65762. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  65763. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  65764. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  65765. // Queries
  65766. createQuery(): WebGLQuery;
  65767. deleteQuery(query: WebGLQuery): void;
  65768. beginQuery(target: number, query: WebGLQuery): void;
  65769. endQuery(target: number): void;
  65770. getQueryParameter(query: WebGLQuery, pname: number): any;
  65771. getQuery(target: number, pname: number): any;
  65772. MAX_SAMPLES: number;
  65773. RGBA8: number;
  65774. READ_FRAMEBUFFER: number;
  65775. DRAW_FRAMEBUFFER: number;
  65776. UNIFORM_BUFFER: number;
  65777. HALF_FLOAT_OES: number;
  65778. RGBA16F: number;
  65779. RGBA32F: number;
  65780. R32F: number;
  65781. RG32F: number;
  65782. RGB32F: number;
  65783. R16F: number;
  65784. RG16F: number;
  65785. RGB16F: number;
  65786. RED: number;
  65787. RG: number;
  65788. R8: number;
  65789. RG8: number;
  65790. UNSIGNED_INT_24_8: number;
  65791. DEPTH24_STENCIL8: number;
  65792. MIN: number;
  65793. MAX: number;
  65794. /* Multiple Render Targets */
  65795. drawBuffers(buffers: number[]): void;
  65796. readBuffer(src: number): void;
  65797. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  65798. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  65799. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  65800. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  65801. // Occlusion Query
  65802. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  65803. ANY_SAMPLES_PASSED: number;
  65804. QUERY_RESULT_AVAILABLE: number;
  65805. QUERY_RESULT: number;
  65806. }
  65807. interface WebGLProgram {
  65808. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  65809. }
  65810. interface EXT_disjoint_timer_query {
  65811. QUERY_COUNTER_BITS_EXT: number;
  65812. TIME_ELAPSED_EXT: number;
  65813. TIMESTAMP_EXT: number;
  65814. GPU_DISJOINT_EXT: number;
  65815. QUERY_RESULT_EXT: number;
  65816. QUERY_RESULT_AVAILABLE_EXT: number;
  65817. queryCounterEXT(query: WebGLQuery, target: number): void;
  65818. createQueryEXT(): WebGLQuery;
  65819. beginQueryEXT(target: number, query: WebGLQuery): void;
  65820. endQueryEXT(target: number): void;
  65821. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  65822. deleteQueryEXT(query: WebGLQuery): void;
  65823. }
  65824. interface WebGLUniformLocation {
  65825. _currentState: any;
  65826. }
  65827. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  65828. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  65829. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  65830. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  65831. interface WebGLRenderingContext {
  65832. readonly RASTERIZER_DISCARD: number;
  65833. readonly DEPTH_COMPONENT24: number;
  65834. readonly TEXTURE_3D: number;
  65835. readonly TEXTURE_2D_ARRAY: number;
  65836. readonly TEXTURE_COMPARE_FUNC: number;
  65837. readonly TEXTURE_COMPARE_MODE: number;
  65838. readonly COMPARE_REF_TO_TEXTURE: number;
  65839. readonly TEXTURE_WRAP_R: number;
  65840. readonly HALF_FLOAT: number;
  65841. readonly RGB8: number;
  65842. readonly RED_INTEGER: number;
  65843. readonly RG_INTEGER: number;
  65844. readonly RGB_INTEGER: number;
  65845. readonly RGBA_INTEGER: number;
  65846. readonly R8_SNORM: number;
  65847. readonly RG8_SNORM: number;
  65848. readonly RGB8_SNORM: number;
  65849. readonly RGBA8_SNORM: number;
  65850. readonly R8I: number;
  65851. readonly RG8I: number;
  65852. readonly RGB8I: number;
  65853. readonly RGBA8I: number;
  65854. readonly R8UI: number;
  65855. readonly RG8UI: number;
  65856. readonly RGB8UI: number;
  65857. readonly RGBA8UI: number;
  65858. readonly R16I: number;
  65859. readonly RG16I: number;
  65860. readonly RGB16I: number;
  65861. readonly RGBA16I: number;
  65862. readonly R16UI: number;
  65863. readonly RG16UI: number;
  65864. readonly RGB16UI: number;
  65865. readonly RGBA16UI: number;
  65866. readonly R32I: number;
  65867. readonly RG32I: number;
  65868. readonly RGB32I: number;
  65869. readonly RGBA32I: number;
  65870. readonly R32UI: number;
  65871. readonly RG32UI: number;
  65872. readonly RGB32UI: number;
  65873. readonly RGBA32UI: number;
  65874. readonly RGB10_A2UI: number;
  65875. readonly R11F_G11F_B10F: number;
  65876. readonly RGB9_E5: number;
  65877. readonly RGB10_A2: number;
  65878. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  65879. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  65880. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  65881. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  65882. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  65883. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  65884. 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;
  65885. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  65886. readonly TRANSFORM_FEEDBACK: number;
  65887. readonly INTERLEAVED_ATTRIBS: number;
  65888. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  65889. createTransformFeedback(): WebGLTransformFeedback;
  65890. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  65891. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  65892. beginTransformFeedback(primitiveMode: number): void;
  65893. endTransformFeedback(): void;
  65894. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  65895. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65896. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65897. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65898. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  65899. }
  65900. interface ImageBitmap {
  65901. readonly width: number;
  65902. readonly height: number;
  65903. close(): void;
  65904. }
  65905. interface WebGLQuery extends WebGLObject {
  65906. }
  65907. declare var WebGLQuery: {
  65908. prototype: WebGLQuery;
  65909. new(): WebGLQuery;
  65910. };
  65911. interface WebGLSampler extends WebGLObject {
  65912. }
  65913. declare var WebGLSampler: {
  65914. prototype: WebGLSampler;
  65915. new(): WebGLSampler;
  65916. };
  65917. interface WebGLSync extends WebGLObject {
  65918. }
  65919. declare var WebGLSync: {
  65920. prototype: WebGLSync;
  65921. new(): WebGLSync;
  65922. };
  65923. interface WebGLTransformFeedback extends WebGLObject {
  65924. }
  65925. declare var WebGLTransformFeedback: {
  65926. prototype: WebGLTransformFeedback;
  65927. new(): WebGLTransformFeedback;
  65928. };
  65929. interface WebGLVertexArrayObject extends WebGLObject {
  65930. }
  65931. declare var WebGLVertexArrayObject: {
  65932. prototype: WebGLVertexArrayObject;
  65933. new(): WebGLVertexArrayObject;
  65934. };
  65935. // Type definitions for WebVR API
  65936. // Project: https://w3c.github.io/webvr/
  65937. // Definitions by: six a <https://github.com/lostfictions>
  65938. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  65939. interface VRDisplay extends EventTarget {
  65940. /**
  65941. * Dictionary of capabilities describing the VRDisplay.
  65942. */
  65943. readonly capabilities: VRDisplayCapabilities;
  65944. /**
  65945. * z-depth defining the far plane of the eye view frustum
  65946. * enables mapping of values in the render target depth
  65947. * attachment to scene coordinates. Initially set to 10000.0.
  65948. */
  65949. depthFar: number;
  65950. /**
  65951. * z-depth defining the near plane of the eye view frustum
  65952. * enables mapping of values in the render target depth
  65953. * attachment to scene coordinates. Initially set to 0.01.
  65954. */
  65955. depthNear: number;
  65956. /**
  65957. * An identifier for this distinct VRDisplay. Used as an
  65958. * association point in the Gamepad API.
  65959. */
  65960. readonly displayId: number;
  65961. /**
  65962. * A display name, a user-readable name identifying it.
  65963. */
  65964. readonly displayName: string;
  65965. readonly isConnected: boolean;
  65966. readonly isPresenting: boolean;
  65967. /**
  65968. * If this VRDisplay supports room-scale experiences, the optional
  65969. * stage attribute contains details on the room-scale parameters.
  65970. */
  65971. readonly stageParameters: VRStageParameters | null;
  65972. /**
  65973. * Passing the value returned by `requestAnimationFrame` to
  65974. * `cancelAnimationFrame` will unregister the callback.
  65975. * @param handle Define the hanle of the request to cancel
  65976. */
  65977. cancelAnimationFrame(handle: number): void;
  65978. /**
  65979. * Stops presenting to the VRDisplay.
  65980. * @returns a promise to know when it stopped
  65981. */
  65982. exitPresent(): Promise<void>;
  65983. /**
  65984. * Return the current VREyeParameters for the given eye.
  65985. * @param whichEye Define the eye we want the parameter for
  65986. * @returns the eye parameters
  65987. */
  65988. getEyeParameters(whichEye: string): VREyeParameters;
  65989. /**
  65990. * Populates the passed VRFrameData with the information required to render
  65991. * the current frame.
  65992. * @param frameData Define the data structure to populate
  65993. * @returns true if ok otherwise false
  65994. */
  65995. getFrameData(frameData: VRFrameData): boolean;
  65996. /**
  65997. * Get the layers currently being presented.
  65998. * @returns the list of VR layers
  65999. */
  66000. getLayers(): VRLayer[];
  66001. /**
  66002. * Return a VRPose containing the future predicted pose of the VRDisplay
  66003. * when the current frame will be presented. The value returned will not
  66004. * change until JavaScript has returned control to the browser.
  66005. *
  66006. * The VRPose will contain the position, orientation, velocity,
  66007. * and acceleration of each of these properties.
  66008. * @returns the pose object
  66009. */
  66010. getPose(): VRPose;
  66011. /**
  66012. * Return the current instantaneous pose of the VRDisplay, with no
  66013. * prediction applied.
  66014. * @returns the current instantaneous pose
  66015. */
  66016. getImmediatePose(): VRPose;
  66017. /**
  66018. * The callback passed to `requestAnimationFrame` will be called
  66019. * any time a new frame should be rendered. When the VRDisplay is
  66020. * presenting the callback will be called at the native refresh
  66021. * rate of the HMD. When not presenting this function acts
  66022. * identically to how window.requestAnimationFrame acts. Content should
  66023. * make no assumptions of frame rate or vsync behavior as the HMD runs
  66024. * asynchronously from other displays and at differing refresh rates.
  66025. * @param callback Define the eaction to run next frame
  66026. * @returns the request handle it
  66027. */
  66028. requestAnimationFrame(callback: FrameRequestCallback): number;
  66029. /**
  66030. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  66031. * Repeat calls while already presenting will update the VRLayers being displayed.
  66032. * @param layers Define the list of layer to present
  66033. * @returns a promise to know when the request has been fulfilled
  66034. */
  66035. requestPresent(layers: VRLayer[]): Promise<void>;
  66036. /**
  66037. * Reset the pose for this display, treating its current position and
  66038. * orientation as the "origin/zero" values. VRPose.position,
  66039. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  66040. * updated when calling resetPose(). This should be called in only
  66041. * sitting-space experiences.
  66042. */
  66043. resetPose(): void;
  66044. /**
  66045. * The VRLayer provided to the VRDisplay will be captured and presented
  66046. * in the HMD. Calling this function has the same effect on the source
  66047. * canvas as any other operation that uses its source image, and canvases
  66048. * created without preserveDrawingBuffer set to true will be cleared.
  66049. * @param pose Define the pose to submit
  66050. */
  66051. submitFrame(pose?: VRPose): void;
  66052. }
  66053. declare var VRDisplay: {
  66054. prototype: VRDisplay;
  66055. new(): VRDisplay;
  66056. };
  66057. interface VRLayer {
  66058. leftBounds?: number[] | Float32Array | null;
  66059. rightBounds?: number[] | Float32Array | null;
  66060. source?: HTMLCanvasElement | null;
  66061. }
  66062. interface VRDisplayCapabilities {
  66063. readonly canPresent: boolean;
  66064. readonly hasExternalDisplay: boolean;
  66065. readonly hasOrientation: boolean;
  66066. readonly hasPosition: boolean;
  66067. readonly maxLayers: number;
  66068. }
  66069. interface VREyeParameters {
  66070. /** @deprecated */
  66071. readonly fieldOfView: VRFieldOfView;
  66072. readonly offset: Float32Array;
  66073. readonly renderHeight: number;
  66074. readonly renderWidth: number;
  66075. }
  66076. interface VRFieldOfView {
  66077. readonly downDegrees: number;
  66078. readonly leftDegrees: number;
  66079. readonly rightDegrees: number;
  66080. readonly upDegrees: number;
  66081. }
  66082. interface VRFrameData {
  66083. readonly leftProjectionMatrix: Float32Array;
  66084. readonly leftViewMatrix: Float32Array;
  66085. readonly pose: VRPose;
  66086. readonly rightProjectionMatrix: Float32Array;
  66087. readonly rightViewMatrix: Float32Array;
  66088. readonly timestamp: number;
  66089. }
  66090. interface VRPose {
  66091. readonly angularAcceleration: Float32Array | null;
  66092. readonly angularVelocity: Float32Array | null;
  66093. readonly linearAcceleration: Float32Array | null;
  66094. readonly linearVelocity: Float32Array | null;
  66095. readonly orientation: Float32Array | null;
  66096. readonly position: Float32Array | null;
  66097. readonly timestamp: number;
  66098. }
  66099. interface VRStageParameters {
  66100. sittingToStandingTransform?: Float32Array;
  66101. sizeX?: number;
  66102. sizeY?: number;
  66103. }
  66104. interface Navigator {
  66105. getVRDisplays(): Promise<VRDisplay[]>;
  66106. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  66107. }
  66108. interface Window {
  66109. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  66110. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  66111. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  66112. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  66113. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  66114. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  66115. }
  66116. interface Gamepad {
  66117. readonly displayId: number;
  66118. }
  66119. type XRSessionMode =
  66120. | "inline"
  66121. | "immersive-vr"
  66122. | "immersive-ar";
  66123. type XRReferenceSpaceType =
  66124. | "viewer"
  66125. | "local"
  66126. | "local-floor"
  66127. | "bounded-floor"
  66128. | "unbounded";
  66129. type XREnvironmentBlendMode =
  66130. | "opaque"
  66131. | "additive"
  66132. | "alpha-blend";
  66133. type XRVisibilityState =
  66134. | "visible"
  66135. | "visible-blurred"
  66136. | "hidden";
  66137. type XRHandedness =
  66138. | "none"
  66139. | "left"
  66140. | "right";
  66141. type XRTargetRayMode =
  66142. | "gaze"
  66143. | "tracked-pointer"
  66144. | "screen";
  66145. type XREye =
  66146. | "none"
  66147. | "left"
  66148. | "right";
  66149. interface XRSpace extends EventTarget {
  66150. }
  66151. interface XRRenderState {
  66152. depthNear?: number;
  66153. depthFar?: number;
  66154. inlineVerticalFieldOfView?: number;
  66155. baseLayer?: XRWebGLLayer;
  66156. }
  66157. interface XRInputSource {
  66158. handedness: XRHandedness;
  66159. targetRayMode: XRTargetRayMode;
  66160. targetRaySpace: XRSpace;
  66161. gripSpace: XRSpace | undefined;
  66162. gamepad: Gamepad | undefined;
  66163. profiles: Array<string>;
  66164. }
  66165. interface XRSession {
  66166. addEventListener: Function;
  66167. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  66168. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  66169. requestAnimationFrame: Function;
  66170. end(): Promise<void>;
  66171. renderState: XRRenderState;
  66172. inputSources: Array<XRInputSource>;
  66173. }
  66174. interface XRReferenceSpace extends XRSpace {
  66175. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  66176. onreset: any;
  66177. }
  66178. interface XRFrame {
  66179. session: XRSession;
  66180. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  66181. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  66182. }
  66183. interface XRViewerPose extends XRPose {
  66184. views: Array<XRView>;
  66185. }
  66186. interface XRPose {
  66187. transform: XRRigidTransform;
  66188. emulatedPosition: boolean;
  66189. }
  66190. interface XRWebGLLayerOptions {
  66191. antialias ?: boolean;
  66192. depth ?: boolean;
  66193. stencil ?: boolean;
  66194. alpha ?: boolean;
  66195. multiview ?: boolean;
  66196. framebufferScaleFactor ?: number;
  66197. }
  66198. declare var XRWebGLLayer: {
  66199. prototype: XRWebGLLayer;
  66200. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  66201. };
  66202. interface XRWebGLLayer {
  66203. framebuffer: WebGLFramebuffer;
  66204. framebufferWidth: number;
  66205. framebufferHeight: number;
  66206. getViewport: Function;
  66207. }
  66208. interface XRRigidTransform {
  66209. position: DOMPointReadOnly;
  66210. orientation: DOMPointReadOnly;
  66211. matrix: Float32Array;
  66212. inverse: XRRigidTransform;
  66213. }
  66214. interface XRView {
  66215. eye: XREye;
  66216. projectionMatrix: Float32Array;
  66217. transform: XRRigidTransform;
  66218. }
  66219. interface XRInputSourceChangeEvent {
  66220. session: XRSession;
  66221. removed: Array<XRInputSource>;
  66222. added: Array<XRInputSource>;
  66223. }
  66224. interface XRInputSourceEvent extends Event {
  66225. readonly frame: XRFrame;
  66226. readonly inputSource: XRInputSource;
  66227. }
  66228. /**
  66229. * @ignore
  66230. */
  66231. declare module BABYLON.GLTF2.Exporter {
  66232. }
  66233. /**
  66234. * @ignore
  66235. */
  66236. declare module BABYLON.GLTF1 {
  66237. }
  66238. declare module BABYLON.GUI {
  66239. /**
  66240. * Class used to specific a value and its associated unit
  66241. */
  66242. export class ValueAndUnit {
  66243. /** defines the unit to store */
  66244. unit: number;
  66245. /** defines a boolean indicating if the value can be negative */
  66246. negativeValueAllowed: boolean;
  66247. private _value;
  66248. private _originalUnit;
  66249. /**
  66250. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  66251. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66252. */
  66253. ignoreAdaptiveScaling: boolean;
  66254. /**
  66255. * Creates a new ValueAndUnit
  66256. * @param value defines the value to store
  66257. * @param unit defines the unit to store
  66258. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  66259. */
  66260. constructor(value: number,
  66261. /** defines the unit to store */
  66262. unit?: number,
  66263. /** defines a boolean indicating if the value can be negative */
  66264. negativeValueAllowed?: boolean);
  66265. /** Gets a boolean indicating if the value is a percentage */
  66266. readonly isPercentage: boolean;
  66267. /** Gets a boolean indicating if the value is store as pixel */
  66268. readonly isPixel: boolean;
  66269. /** Gets direct internal value */
  66270. readonly internalValue: number;
  66271. /**
  66272. * Gets value as pixel
  66273. * @param host defines the root host
  66274. * @param refValue defines the reference value for percentages
  66275. * @returns the value as pixel
  66276. */
  66277. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  66278. /**
  66279. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  66280. * @param value defines the value to store
  66281. * @param unit defines the unit to store
  66282. * @returns the current ValueAndUnit
  66283. */
  66284. updateInPlace(value: number, unit?: number): ValueAndUnit;
  66285. /**
  66286. * Gets the value accordingly to its unit
  66287. * @param host defines the root host
  66288. * @returns the value
  66289. */
  66290. getValue(host: AdvancedDynamicTexture): number;
  66291. /**
  66292. * Gets a string representation of the value
  66293. * @param host defines the root host
  66294. * @param decimals defines an optional number of decimals to display
  66295. * @returns a string
  66296. */
  66297. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  66298. /**
  66299. * Store a value parsed from a string
  66300. * @param source defines the source string
  66301. * @returns true if the value was successfully parsed
  66302. */
  66303. fromString(source: string | number): boolean;
  66304. private static _Regex;
  66305. private static _UNITMODE_PERCENTAGE;
  66306. private static _UNITMODE_PIXEL;
  66307. /** UNITMODE_PERCENTAGE */
  66308. static readonly UNITMODE_PERCENTAGE: number;
  66309. /** UNITMODE_PIXEL */
  66310. static readonly UNITMODE_PIXEL: number;
  66311. }
  66312. }
  66313. declare module BABYLON.GUI {
  66314. /**
  66315. * Define a style used by control to automatically setup properties based on a template.
  66316. * Only support font related properties so far
  66317. */
  66318. export class Style implements BABYLON.IDisposable {
  66319. private _fontFamily;
  66320. private _fontStyle;
  66321. private _fontWeight;
  66322. /** @hidden */
  66323. _host: AdvancedDynamicTexture;
  66324. /** @hidden */
  66325. _fontSize: ValueAndUnit;
  66326. /**
  66327. * BABYLON.Observable raised when the style values are changed
  66328. */
  66329. onChangedObservable: BABYLON.Observable<Style>;
  66330. /**
  66331. * Creates a new style object
  66332. * @param host defines the AdvancedDynamicTexture which hosts this style
  66333. */
  66334. constructor(host: AdvancedDynamicTexture);
  66335. /**
  66336. * Gets or sets the font size
  66337. */
  66338. fontSize: string | number;
  66339. /**
  66340. * Gets or sets the font family
  66341. */
  66342. fontFamily: string;
  66343. /**
  66344. * Gets or sets the font style
  66345. */
  66346. fontStyle: string;
  66347. /** Gets or sets font weight */
  66348. fontWeight: string;
  66349. /** Dispose all associated resources */
  66350. dispose(): void;
  66351. }
  66352. }
  66353. declare module BABYLON.GUI {
  66354. /**
  66355. * Class used to transport BABYLON.Vector2 information for pointer events
  66356. */
  66357. export class Vector2WithInfo extends BABYLON.Vector2 {
  66358. /** defines the current mouse button index */
  66359. buttonIndex: number;
  66360. /**
  66361. * Creates a new Vector2WithInfo
  66362. * @param source defines the vector2 data to transport
  66363. * @param buttonIndex defines the current mouse button index
  66364. */
  66365. constructor(source: BABYLON.Vector2,
  66366. /** defines the current mouse button index */
  66367. buttonIndex?: number);
  66368. }
  66369. /** Class used to provide 2D matrix features */
  66370. export class Matrix2D {
  66371. /** Gets the internal array of 6 floats used to store matrix data */
  66372. m: Float32Array;
  66373. /**
  66374. * Creates a new matrix
  66375. * @param m00 defines value for (0, 0)
  66376. * @param m01 defines value for (0, 1)
  66377. * @param m10 defines value for (1, 0)
  66378. * @param m11 defines value for (1, 1)
  66379. * @param m20 defines value for (2, 0)
  66380. * @param m21 defines value for (2, 1)
  66381. */
  66382. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  66383. /**
  66384. * Fills the matrix from direct values
  66385. * @param m00 defines value for (0, 0)
  66386. * @param m01 defines value for (0, 1)
  66387. * @param m10 defines value for (1, 0)
  66388. * @param m11 defines value for (1, 1)
  66389. * @param m20 defines value for (2, 0)
  66390. * @param m21 defines value for (2, 1)
  66391. * @returns the current modified matrix
  66392. */
  66393. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  66394. /**
  66395. * Gets matrix determinant
  66396. * @returns the determinant
  66397. */
  66398. determinant(): number;
  66399. /**
  66400. * Inverses the matrix and stores it in a target matrix
  66401. * @param result defines the target matrix
  66402. * @returns the current matrix
  66403. */
  66404. invertToRef(result: Matrix2D): Matrix2D;
  66405. /**
  66406. * Multiplies the current matrix with another one
  66407. * @param other defines the second operand
  66408. * @param result defines the target matrix
  66409. * @returns the current matrix
  66410. */
  66411. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  66412. /**
  66413. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  66414. * @param x defines the x coordinate to transform
  66415. * @param y defines the x coordinate to transform
  66416. * @param result defines the target vector2
  66417. * @returns the current matrix
  66418. */
  66419. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  66420. /**
  66421. * Creates an identity matrix
  66422. * @returns a new matrix
  66423. */
  66424. static Identity(): Matrix2D;
  66425. /**
  66426. * Creates a translation matrix and stores it in a target matrix
  66427. * @param x defines the x coordinate of the translation
  66428. * @param y defines the y coordinate of the translation
  66429. * @param result defines the target matrix
  66430. */
  66431. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  66432. /**
  66433. * Creates a scaling matrix and stores it in a target matrix
  66434. * @param x defines the x coordinate of the scaling
  66435. * @param y defines the y coordinate of the scaling
  66436. * @param result defines the target matrix
  66437. */
  66438. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  66439. /**
  66440. * Creates a rotation matrix and stores it in a target matrix
  66441. * @param angle defines the rotation angle
  66442. * @param result defines the target matrix
  66443. */
  66444. static RotationToRef(angle: number, result: Matrix2D): void;
  66445. private static _TempPreTranslationMatrix;
  66446. private static _TempPostTranslationMatrix;
  66447. private static _TempRotationMatrix;
  66448. private static _TempScalingMatrix;
  66449. private static _TempCompose0;
  66450. private static _TempCompose1;
  66451. private static _TempCompose2;
  66452. /**
  66453. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  66454. * @param tx defines the x coordinate of the translation
  66455. * @param ty defines the y coordinate of the translation
  66456. * @param angle defines the rotation angle
  66457. * @param scaleX defines the x coordinate of the scaling
  66458. * @param scaleY defines the y coordinate of the scaling
  66459. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  66460. * @param result defines the target matrix
  66461. */
  66462. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  66463. }
  66464. }
  66465. declare module BABYLON.GUI {
  66466. /**
  66467. * Class used to store 2D control sizes
  66468. */
  66469. export class Measure {
  66470. /** defines left coordinate */
  66471. left: number;
  66472. /** defines top coordinate */
  66473. top: number;
  66474. /** defines width dimension */
  66475. width: number;
  66476. /** defines height dimension */
  66477. height: number;
  66478. /**
  66479. * Creates a new measure
  66480. * @param left defines left coordinate
  66481. * @param top defines top coordinate
  66482. * @param width defines width dimension
  66483. * @param height defines height dimension
  66484. */
  66485. constructor(
  66486. /** defines left coordinate */
  66487. left: number,
  66488. /** defines top coordinate */
  66489. top: number,
  66490. /** defines width dimension */
  66491. width: number,
  66492. /** defines height dimension */
  66493. height: number);
  66494. /**
  66495. * Copy from another measure
  66496. * @param other defines the other measure to copy from
  66497. */
  66498. copyFrom(other: Measure): void;
  66499. /**
  66500. * Copy from a group of 4 floats
  66501. * @param left defines left coordinate
  66502. * @param top defines top coordinate
  66503. * @param width defines width dimension
  66504. * @param height defines height dimension
  66505. */
  66506. copyFromFloats(left: number, top: number, width: number, height: number): void;
  66507. /**
  66508. * Computes the axis aligned bounding box measure for two given measures
  66509. * @param a Input measure
  66510. * @param b Input measure
  66511. * @param result the resulting bounding measure
  66512. */
  66513. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  66514. /**
  66515. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  66516. * @param transform the matrix to transform the measure before computing the AABB
  66517. * @param result the resulting AABB
  66518. */
  66519. transformToRef(transform: Matrix2D, result: Measure): void;
  66520. /**
  66521. * Check equality between this measure and another one
  66522. * @param other defines the other measures
  66523. * @returns true if both measures are equals
  66524. */
  66525. isEqualsTo(other: Measure): boolean;
  66526. /**
  66527. * Creates an empty measure
  66528. * @returns a new measure
  66529. */
  66530. static Empty(): Measure;
  66531. }
  66532. }
  66533. declare module BABYLON.GUI {
  66534. /**
  66535. * Interface used to define a control that can receive focus
  66536. */
  66537. export interface IFocusableControl {
  66538. /**
  66539. * Function called when the control receives the focus
  66540. */
  66541. onFocus(): void;
  66542. /**
  66543. * Function called when the control loses the focus
  66544. */
  66545. onBlur(): void;
  66546. /**
  66547. * Function called to let the control handle keyboard events
  66548. * @param evt defines the current keyboard event
  66549. */
  66550. processKeyboard(evt: KeyboardEvent): void;
  66551. /**
  66552. * Function called to get the list of controls that should not steal the focus from this control
  66553. * @returns an array of controls
  66554. */
  66555. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66556. }
  66557. /**
  66558. * Class used to create texture to support 2D GUI elements
  66559. * @see http://doc.babylonjs.com/how_to/gui
  66560. */
  66561. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  66562. private _isDirty;
  66563. private _renderObserver;
  66564. private _resizeObserver;
  66565. private _preKeyboardObserver;
  66566. private _pointerMoveObserver;
  66567. private _pointerObserver;
  66568. private _canvasPointerOutObserver;
  66569. private _background;
  66570. /** @hidden */
  66571. _rootContainer: Container;
  66572. /** @hidden */
  66573. _lastPickedControl: Control;
  66574. /** @hidden */
  66575. _lastControlOver: {
  66576. [pointerId: number]: Control;
  66577. };
  66578. /** @hidden */
  66579. _lastControlDown: {
  66580. [pointerId: number]: Control;
  66581. };
  66582. /** @hidden */
  66583. _capturingControl: {
  66584. [pointerId: number]: Control;
  66585. };
  66586. /** @hidden */
  66587. _shouldBlockPointer: boolean;
  66588. /** @hidden */
  66589. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  66590. /** @hidden */
  66591. _linkedControls: Control[];
  66592. private _isFullscreen;
  66593. private _fullscreenViewport;
  66594. private _idealWidth;
  66595. private _idealHeight;
  66596. private _useSmallestIdeal;
  66597. private _renderAtIdealSize;
  66598. private _focusedControl;
  66599. private _blockNextFocusCheck;
  66600. private _renderScale;
  66601. private _rootElement;
  66602. private _cursorChanged;
  66603. /**
  66604. * Define type to string to ensure compatibility across browsers
  66605. * Safari doesn't support DataTransfer constructor
  66606. */
  66607. private _clipboardData;
  66608. /**
  66609. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  66610. */
  66611. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  66612. /**
  66613. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  66614. */
  66615. onControlPickedObservable: BABYLON.Observable<Control>;
  66616. /**
  66617. * BABYLON.Observable event triggered before layout is evaluated
  66618. */
  66619. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66620. /**
  66621. * BABYLON.Observable event triggered after the layout was evaluated
  66622. */
  66623. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66624. /**
  66625. * BABYLON.Observable event triggered before the texture is rendered
  66626. */
  66627. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66628. /**
  66629. * BABYLON.Observable event triggered after the texture was rendered
  66630. */
  66631. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66632. /**
  66633. * Gets or sets a boolean defining if alpha is stored as premultiplied
  66634. */
  66635. premulAlpha: boolean;
  66636. /**
  66637. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  66638. * Useful when you want more antialiasing
  66639. */
  66640. renderScale: number;
  66641. /** Gets or sets the background color */
  66642. background: string;
  66643. /**
  66644. * Gets or sets the ideal width used to design controls.
  66645. * The GUI will then rescale everything accordingly
  66646. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66647. */
  66648. idealWidth: number;
  66649. /**
  66650. * Gets or sets the ideal height used to design controls.
  66651. * The GUI will then rescale everything accordingly
  66652. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66653. */
  66654. idealHeight: number;
  66655. /**
  66656. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  66657. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66658. */
  66659. useSmallestIdeal: boolean;
  66660. /**
  66661. * Gets or sets a boolean indicating if adaptive scaling must be used
  66662. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66663. */
  66664. renderAtIdealSize: boolean;
  66665. /**
  66666. * Gets the underlying layer used to render the texture when in fullscreen mode
  66667. */
  66668. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  66669. /**
  66670. * Gets the root container control
  66671. */
  66672. readonly rootContainer: Container;
  66673. /**
  66674. * Returns an array containing the root container.
  66675. * This is mostly used to let the Inspector introspects the ADT
  66676. * @returns an array containing the rootContainer
  66677. */
  66678. getChildren(): Array<Container>;
  66679. /**
  66680. * Will return all controls that are inside this texture
  66681. * @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
  66682. * @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
  66683. * @return all child controls
  66684. */
  66685. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  66686. /**
  66687. * Gets or sets the current focused control
  66688. */
  66689. focusedControl: BABYLON.Nullable<IFocusableControl>;
  66690. /**
  66691. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  66692. */
  66693. isForeground: boolean;
  66694. /**
  66695. * Gets or set information about clipboardData
  66696. */
  66697. clipboardData: string;
  66698. /**
  66699. * Creates a new AdvancedDynamicTexture
  66700. * @param name defines the name of the texture
  66701. * @param width defines the width of the texture
  66702. * @param height defines the height of the texture
  66703. * @param scene defines the hosting scene
  66704. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  66705. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  66706. */
  66707. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  66708. /**
  66709. * Get the current class name of the texture useful for serialization or dynamic coding.
  66710. * @returns "AdvancedDynamicTexture"
  66711. */
  66712. getClassName(): string;
  66713. /**
  66714. * Function used to execute a function on all controls
  66715. * @param func defines the function to execute
  66716. * @param container defines the container where controls belong. If null the root container will be used
  66717. */
  66718. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  66719. private _useInvalidateRectOptimization;
  66720. /**
  66721. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  66722. */
  66723. useInvalidateRectOptimization: boolean;
  66724. private _invalidatedRectangle;
  66725. /**
  66726. * Invalidates a rectangle area on the gui texture
  66727. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  66728. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  66729. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  66730. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  66731. */
  66732. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  66733. /**
  66734. * Marks the texture as dirty forcing a complete update
  66735. */
  66736. markAsDirty(): void;
  66737. /**
  66738. * Helper function used to create a new style
  66739. * @returns a new style
  66740. * @see http://doc.babylonjs.com/how_to/gui#styles
  66741. */
  66742. createStyle(): Style;
  66743. /**
  66744. * Adds a new control to the root container
  66745. * @param control defines the control to add
  66746. * @returns the current texture
  66747. */
  66748. addControl(control: Control): AdvancedDynamicTexture;
  66749. /**
  66750. * Removes a control from the root container
  66751. * @param control defines the control to remove
  66752. * @returns the current texture
  66753. */
  66754. removeControl(control: Control): AdvancedDynamicTexture;
  66755. /**
  66756. * Release all resources
  66757. */
  66758. dispose(): void;
  66759. private _onResize;
  66760. /** @hidden */
  66761. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  66762. /**
  66763. * Get screen coordinates for a vector3
  66764. * @param position defines the position to project
  66765. * @param worldMatrix defines the world matrix to use
  66766. * @returns the projected position
  66767. */
  66768. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  66769. private _checkUpdate;
  66770. private _clearMeasure;
  66771. private _render;
  66772. /** @hidden */
  66773. _changeCursor(cursor: string): void;
  66774. /** @hidden */
  66775. _registerLastControlDown(control: Control, pointerId: number): void;
  66776. private _doPicking;
  66777. /** @hidden */
  66778. _cleanControlAfterRemovalFromList(list: {
  66779. [pointerId: number]: Control;
  66780. }, control: Control): void;
  66781. /** @hidden */
  66782. _cleanControlAfterRemoval(control: Control): void;
  66783. /** Attach to all scene events required to support pointer events */
  66784. attach(): void;
  66785. /** @hidden */
  66786. private onClipboardCopy;
  66787. /** @hidden */
  66788. private onClipboardCut;
  66789. /** @hidden */
  66790. private onClipboardPaste;
  66791. /**
  66792. * Register the clipboard Events onto the canvas
  66793. */
  66794. registerClipboardEvents(): void;
  66795. /**
  66796. * Unregister the clipboard Events from the canvas
  66797. */
  66798. unRegisterClipboardEvents(): void;
  66799. /**
  66800. * Connect the texture to a hosting mesh to enable interactions
  66801. * @param mesh defines the mesh to attach to
  66802. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  66803. */
  66804. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  66805. /**
  66806. * Move the focus to a specific control
  66807. * @param control defines the control which will receive the focus
  66808. */
  66809. moveFocusToControl(control: IFocusableControl): void;
  66810. private _manageFocus;
  66811. private _attachToOnPointerOut;
  66812. /**
  66813. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  66814. * @param mesh defines the mesh which will receive the texture
  66815. * @param width defines the texture width (1024 by default)
  66816. * @param height defines the texture height (1024 by default)
  66817. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  66818. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  66819. * @returns a new AdvancedDynamicTexture
  66820. */
  66821. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  66822. /**
  66823. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  66824. * In this mode the texture will rely on a layer for its rendering.
  66825. * This allows it to be treated like any other layer.
  66826. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  66827. * LayerMask is set through advancedTexture.layer.layerMask
  66828. * @param name defines name for the texture
  66829. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  66830. * @param scene defines the hsoting scene
  66831. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  66832. * @returns a new AdvancedDynamicTexture
  66833. */
  66834. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  66835. }
  66836. }
  66837. declare module BABYLON.GUI {
  66838. /**
  66839. * Root class used for all 2D controls
  66840. * @see http://doc.babylonjs.com/how_to/gui#controls
  66841. */
  66842. export class Control {
  66843. /** defines the name of the control */
  66844. name?: string | undefined;
  66845. /**
  66846. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  66847. */
  66848. static AllowAlphaInheritance: boolean;
  66849. private _alpha;
  66850. private _alphaSet;
  66851. private _zIndex;
  66852. /** @hidden */
  66853. _host: AdvancedDynamicTexture;
  66854. /** Gets or sets the control parent */
  66855. parent: BABYLON.Nullable<Container>;
  66856. /** @hidden */
  66857. _currentMeasure: Measure;
  66858. private _fontFamily;
  66859. private _fontStyle;
  66860. private _fontWeight;
  66861. private _fontSize;
  66862. private _font;
  66863. /** @hidden */
  66864. _width: ValueAndUnit;
  66865. /** @hidden */
  66866. _height: ValueAndUnit;
  66867. /** @hidden */
  66868. protected _fontOffset: {
  66869. ascent: number;
  66870. height: number;
  66871. descent: number;
  66872. };
  66873. private _color;
  66874. private _style;
  66875. private _styleObserver;
  66876. /** @hidden */
  66877. protected _horizontalAlignment: number;
  66878. /** @hidden */
  66879. protected _verticalAlignment: number;
  66880. /** @hidden */
  66881. protected _isDirty: boolean;
  66882. /** @hidden */
  66883. protected _wasDirty: boolean;
  66884. /** @hidden */
  66885. _tempParentMeasure: Measure;
  66886. /** @hidden */
  66887. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  66888. /** @hidden */
  66889. protected _cachedParentMeasure: Measure;
  66890. private _paddingLeft;
  66891. private _paddingRight;
  66892. private _paddingTop;
  66893. private _paddingBottom;
  66894. /** @hidden */
  66895. _left: ValueAndUnit;
  66896. /** @hidden */
  66897. _top: ValueAndUnit;
  66898. private _scaleX;
  66899. private _scaleY;
  66900. private _rotation;
  66901. private _transformCenterX;
  66902. private _transformCenterY;
  66903. /** @hidden */
  66904. _transformMatrix: Matrix2D;
  66905. /** @hidden */
  66906. protected _invertTransformMatrix: Matrix2D;
  66907. /** @hidden */
  66908. protected _transformedPosition: BABYLON.Vector2;
  66909. private _isMatrixDirty;
  66910. private _cachedOffsetX;
  66911. private _cachedOffsetY;
  66912. private _isVisible;
  66913. private _isHighlighted;
  66914. /** @hidden */
  66915. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66916. private _fontSet;
  66917. private _dummyVector2;
  66918. private _downCount;
  66919. private _enterCount;
  66920. private _doNotRender;
  66921. private _downPointerIds;
  66922. protected _isEnabled: boolean;
  66923. protected _disabledColor: string;
  66924. /** @hidden */
  66925. protected _rebuildLayout: boolean;
  66926. /** @hidden */
  66927. _isClipped: boolean;
  66928. /** @hidden */
  66929. _automaticSize: boolean;
  66930. /** @hidden */
  66931. _tag: any;
  66932. /**
  66933. * 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
  66934. */
  66935. uniqueId: number;
  66936. /**
  66937. * Gets or sets an object used to store user defined information for the node
  66938. */
  66939. metadata: any;
  66940. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  66941. isHitTestVisible: boolean;
  66942. /** Gets or sets a boolean indicating if the control can block pointer events */
  66943. isPointerBlocker: boolean;
  66944. /** Gets or sets a boolean indicating if the control can be focusable */
  66945. isFocusInvisible: boolean;
  66946. /**
  66947. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  66948. * 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
  66949. */
  66950. clipChildren: boolean;
  66951. /**
  66952. * Gets or sets a boolean indicating that control content must be clipped
  66953. * 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
  66954. */
  66955. clipContent: boolean;
  66956. /**
  66957. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  66958. */
  66959. useBitmapCache: boolean;
  66960. private _cacheData;
  66961. private _shadowOffsetX;
  66962. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  66963. shadowOffsetX: number;
  66964. private _shadowOffsetY;
  66965. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  66966. shadowOffsetY: number;
  66967. private _shadowBlur;
  66968. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  66969. shadowBlur: number;
  66970. private _shadowColor;
  66971. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  66972. shadowColor: string;
  66973. /** Gets or sets the cursor to use when the control is hovered */
  66974. hoverCursor: string;
  66975. /** @hidden */
  66976. protected _linkOffsetX: ValueAndUnit;
  66977. /** @hidden */
  66978. protected _linkOffsetY: ValueAndUnit;
  66979. /** Gets the control type name */
  66980. readonly typeName: string;
  66981. /**
  66982. * Get the current class name of the control.
  66983. * @returns current class name
  66984. */
  66985. getClassName(): string;
  66986. /**
  66987. * An event triggered when the pointer move over the control.
  66988. */
  66989. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  66990. /**
  66991. * An event triggered when the pointer move out of the control.
  66992. */
  66993. onPointerOutObservable: BABYLON.Observable<Control>;
  66994. /**
  66995. * An event triggered when the pointer taps the control
  66996. */
  66997. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  66998. /**
  66999. * An event triggered when pointer up
  67000. */
  67001. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  67002. /**
  67003. * An event triggered when a control is clicked on
  67004. */
  67005. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  67006. /**
  67007. * An event triggered when pointer enters the control
  67008. */
  67009. onPointerEnterObservable: BABYLON.Observable<Control>;
  67010. /**
  67011. * An event triggered when the control is marked as dirty
  67012. */
  67013. onDirtyObservable: BABYLON.Observable<Control>;
  67014. /**
  67015. * An event triggered before drawing the control
  67016. */
  67017. onBeforeDrawObservable: BABYLON.Observable<Control>;
  67018. /**
  67019. * An event triggered after the control was drawn
  67020. */
  67021. onAfterDrawObservable: BABYLON.Observable<Control>;
  67022. /**
  67023. * Get the hosting AdvancedDynamicTexture
  67024. */
  67025. readonly host: AdvancedDynamicTexture;
  67026. /** Gets or set information about font offsets (used to render and align text) */
  67027. fontOffset: {
  67028. ascent: number;
  67029. height: number;
  67030. descent: number;
  67031. };
  67032. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  67033. alpha: number;
  67034. /**
  67035. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  67036. */
  67037. isHighlighted: boolean;
  67038. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  67039. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67040. */
  67041. scaleX: number;
  67042. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  67043. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67044. */
  67045. scaleY: number;
  67046. /** Gets or sets the rotation angle (0 by default)
  67047. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67048. */
  67049. rotation: number;
  67050. /** Gets or sets the transformation center on Y axis (0 by default)
  67051. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67052. */
  67053. transformCenterY: number;
  67054. /** Gets or sets the transformation center on X axis (0 by default)
  67055. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67056. */
  67057. transformCenterX: number;
  67058. /**
  67059. * Gets or sets the horizontal alignment
  67060. * @see http://doc.babylonjs.com/how_to/gui#alignments
  67061. */
  67062. horizontalAlignment: number;
  67063. /**
  67064. * Gets or sets the vertical alignment
  67065. * @see http://doc.babylonjs.com/how_to/gui#alignments
  67066. */
  67067. verticalAlignment: number;
  67068. /**
  67069. * Gets or sets control width
  67070. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67071. */
  67072. width: string | number;
  67073. /**
  67074. * Gets or sets the control width in pixel
  67075. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67076. */
  67077. widthInPixels: number;
  67078. /**
  67079. * Gets or sets control height
  67080. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67081. */
  67082. height: string | number;
  67083. /**
  67084. * Gets or sets control height in pixel
  67085. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67086. */
  67087. heightInPixels: number;
  67088. /** Gets or set font family */
  67089. fontFamily: string;
  67090. /** Gets or sets font style */
  67091. fontStyle: string;
  67092. /** Gets or sets font weight */
  67093. fontWeight: string;
  67094. /**
  67095. * Gets or sets style
  67096. * @see http://doc.babylonjs.com/how_to/gui#styles
  67097. */
  67098. style: BABYLON.Nullable<Style>;
  67099. /** @hidden */
  67100. readonly _isFontSizeInPercentage: boolean;
  67101. /** Gets or sets font size in pixels */
  67102. fontSizeInPixels: number;
  67103. /** Gets or sets font size */
  67104. fontSize: string | number;
  67105. /** Gets or sets foreground color */
  67106. color: string;
  67107. /** Gets or sets z index which is used to reorder controls on the z axis */
  67108. zIndex: number;
  67109. /** Gets or sets a boolean indicating if the control can be rendered */
  67110. notRenderable: boolean;
  67111. /** Gets or sets a boolean indicating if the control is visible */
  67112. isVisible: boolean;
  67113. /** Gets a boolean indicating that the control needs to update its rendering */
  67114. readonly isDirty: boolean;
  67115. /**
  67116. * Gets the current linked mesh (or null if none)
  67117. */
  67118. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67119. /**
  67120. * Gets or sets a value indicating the padding to use on the left of the control
  67121. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67122. */
  67123. paddingLeft: string | number;
  67124. /**
  67125. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  67126. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67127. */
  67128. paddingLeftInPixels: number;
  67129. /**
  67130. * Gets or sets a value indicating the padding to use on the right of the control
  67131. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67132. */
  67133. paddingRight: string | number;
  67134. /**
  67135. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  67136. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67137. */
  67138. paddingRightInPixels: number;
  67139. /**
  67140. * Gets or sets a value indicating the padding to use on the top of the control
  67141. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67142. */
  67143. paddingTop: string | number;
  67144. /**
  67145. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  67146. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67147. */
  67148. paddingTopInPixels: number;
  67149. /**
  67150. * Gets or sets a value indicating the padding to use on the bottom of the control
  67151. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67152. */
  67153. paddingBottom: string | number;
  67154. /**
  67155. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  67156. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67157. */
  67158. paddingBottomInPixels: number;
  67159. /**
  67160. * Gets or sets a value indicating the left coordinate of the control
  67161. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67162. */
  67163. left: string | number;
  67164. /**
  67165. * Gets or sets a value indicating the left coordinate in pixels of the control
  67166. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67167. */
  67168. leftInPixels: number;
  67169. /**
  67170. * Gets or sets a value indicating the top coordinate of the control
  67171. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67172. */
  67173. top: string | number;
  67174. /**
  67175. * Gets or sets a value indicating the top coordinate in pixels of the control
  67176. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67177. */
  67178. topInPixels: number;
  67179. /**
  67180. * Gets or sets a value indicating the offset on X axis to the linked mesh
  67181. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67182. */
  67183. linkOffsetX: string | number;
  67184. /**
  67185. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  67186. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67187. */
  67188. linkOffsetXInPixels: number;
  67189. /**
  67190. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  67191. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67192. */
  67193. linkOffsetY: string | number;
  67194. /**
  67195. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  67196. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67197. */
  67198. linkOffsetYInPixels: number;
  67199. /** Gets the center coordinate on X axis */
  67200. readonly centerX: number;
  67201. /** Gets the center coordinate on Y axis */
  67202. readonly centerY: number;
  67203. /** Gets or sets if control is Enabled*/
  67204. isEnabled: boolean;
  67205. /** Gets or sets background color of control if it's disabled*/
  67206. disabledColor: string;
  67207. /**
  67208. * Creates a new control
  67209. * @param name defines the name of the control
  67210. */
  67211. constructor(
  67212. /** defines the name of the control */
  67213. name?: string | undefined);
  67214. /** @hidden */
  67215. protected _getTypeName(): string;
  67216. /**
  67217. * Gets the first ascendant in the hierarchy of the given type
  67218. * @param className defines the required type
  67219. * @returns the ascendant or null if not found
  67220. */
  67221. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  67222. /** @hidden */
  67223. _resetFontCache(): void;
  67224. /**
  67225. * Determines if a container is an ascendant of the current control
  67226. * @param container defines the container to look for
  67227. * @returns true if the container is one of the ascendant of the control
  67228. */
  67229. isAscendant(container: Control): boolean;
  67230. /**
  67231. * Gets coordinates in local control space
  67232. * @param globalCoordinates defines the coordinates to transform
  67233. * @returns the new coordinates in local space
  67234. */
  67235. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  67236. /**
  67237. * Gets coordinates in local control space
  67238. * @param globalCoordinates defines the coordinates to transform
  67239. * @param result defines the target vector2 where to store the result
  67240. * @returns the current control
  67241. */
  67242. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  67243. /**
  67244. * Gets coordinates in parent local control space
  67245. * @param globalCoordinates defines the coordinates to transform
  67246. * @returns the new coordinates in parent local space
  67247. */
  67248. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  67249. /**
  67250. * Move the current control to a vector3 position projected onto the screen.
  67251. * @param position defines the target position
  67252. * @param scene defines the hosting scene
  67253. */
  67254. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  67255. /**
  67256. * Will store all controls that have this control as ascendant in a given array
  67257. * @param results defines the array where to store the descendants
  67258. * @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
  67259. * @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
  67260. */
  67261. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  67262. /**
  67263. * Will return all controls that have this control as ascendant
  67264. * @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
  67265. * @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
  67266. * @return all child controls
  67267. */
  67268. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67269. /**
  67270. * Link current control with a target mesh
  67271. * @param mesh defines the mesh to link with
  67272. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67273. */
  67274. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  67275. /** @hidden */
  67276. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  67277. /** @hidden */
  67278. _offsetLeft(offset: number): void;
  67279. /** @hidden */
  67280. _offsetTop(offset: number): void;
  67281. /** @hidden */
  67282. _markMatrixAsDirty(): void;
  67283. /** @hidden */
  67284. _flagDescendantsAsMatrixDirty(): void;
  67285. /** @hidden */
  67286. _intersectsRect(rect: Measure): boolean;
  67287. /** @hidden */
  67288. protected invalidateRect(): void;
  67289. /** @hidden */
  67290. _markAsDirty(force?: boolean): void;
  67291. /** @hidden */
  67292. _markAllAsDirty(): void;
  67293. /** @hidden */
  67294. _link(host: AdvancedDynamicTexture): void;
  67295. /** @hidden */
  67296. protected _transform(context?: CanvasRenderingContext2D): void;
  67297. /** @hidden */
  67298. _renderHighlight(context: CanvasRenderingContext2D): void;
  67299. /** @hidden */
  67300. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67301. /** @hidden */
  67302. protected _applyStates(context: CanvasRenderingContext2D): void;
  67303. /** @hidden */
  67304. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  67305. /** @hidden */
  67306. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67307. protected _evaluateClippingState(parentMeasure: Measure): void;
  67308. /** @hidden */
  67309. _measure(): void;
  67310. /** @hidden */
  67311. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67312. /** @hidden */
  67313. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67314. /** @hidden */
  67315. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67316. /** @hidden */
  67317. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67318. private static _ClipMeasure;
  67319. private _tmpMeasureA;
  67320. private _clip;
  67321. /** @hidden */
  67322. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  67323. /** @hidden */
  67324. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67325. /**
  67326. * Tests if a given coordinates belong to the current control
  67327. * @param x defines x coordinate to test
  67328. * @param y defines y coordinate to test
  67329. * @returns true if the coordinates are inside the control
  67330. */
  67331. contains(x: number, y: number): boolean;
  67332. /** @hidden */
  67333. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67334. /** @hidden */
  67335. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67336. /** @hidden */
  67337. _onPointerEnter(target: Control): boolean;
  67338. /** @hidden */
  67339. _onPointerOut(target: Control, force?: boolean): void;
  67340. /** @hidden */
  67341. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67342. /** @hidden */
  67343. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67344. /** @hidden */
  67345. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67346. /** @hidden */
  67347. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  67348. private _prepareFont;
  67349. /** Releases associated resources */
  67350. dispose(): void;
  67351. private static _HORIZONTAL_ALIGNMENT_LEFT;
  67352. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  67353. private static _HORIZONTAL_ALIGNMENT_CENTER;
  67354. private static _VERTICAL_ALIGNMENT_TOP;
  67355. private static _VERTICAL_ALIGNMENT_BOTTOM;
  67356. private static _VERTICAL_ALIGNMENT_CENTER;
  67357. /** HORIZONTAL_ALIGNMENT_LEFT */
  67358. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  67359. /** HORIZONTAL_ALIGNMENT_RIGHT */
  67360. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  67361. /** HORIZONTAL_ALIGNMENT_CENTER */
  67362. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  67363. /** VERTICAL_ALIGNMENT_TOP */
  67364. static readonly VERTICAL_ALIGNMENT_TOP: number;
  67365. /** VERTICAL_ALIGNMENT_BOTTOM */
  67366. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  67367. /** VERTICAL_ALIGNMENT_CENTER */
  67368. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  67369. private static _FontHeightSizes;
  67370. /** @hidden */
  67371. static _GetFontOffset(font: string): {
  67372. ascent: number;
  67373. height: number;
  67374. descent: number;
  67375. };
  67376. /**
  67377. * Creates a stack panel that can be used to render headers
  67378. * @param control defines the control to associate with the header
  67379. * @param text defines the text of the header
  67380. * @param size defines the size of the header
  67381. * @param options defines options used to configure the header
  67382. * @returns a new StackPanel
  67383. * @ignore
  67384. * @hidden
  67385. */
  67386. static AddHeader: (control: Control, text: string, size: string | number, options: {
  67387. isHorizontal: boolean;
  67388. controlFirst: boolean;
  67389. }) => any;
  67390. /** @hidden */
  67391. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  67392. }
  67393. }
  67394. declare module BABYLON.GUI {
  67395. /**
  67396. * Root class for 2D containers
  67397. * @see http://doc.babylonjs.com/how_to/gui#containers
  67398. */
  67399. export class Container extends Control {
  67400. name?: string | undefined;
  67401. /** @hidden */
  67402. protected _children: Control[];
  67403. /** @hidden */
  67404. protected _measureForChildren: Measure;
  67405. /** @hidden */
  67406. protected _background: string;
  67407. /** @hidden */
  67408. protected _adaptWidthToChildren: boolean;
  67409. /** @hidden */
  67410. protected _adaptHeightToChildren: boolean;
  67411. /**
  67412. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  67413. */
  67414. logLayoutCycleErrors: boolean;
  67415. /**
  67416. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  67417. */
  67418. maxLayoutCycle: number;
  67419. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  67420. adaptHeightToChildren: boolean;
  67421. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  67422. adaptWidthToChildren: boolean;
  67423. /** Gets or sets background color */
  67424. background: string;
  67425. /** Gets the list of children */
  67426. readonly children: Control[];
  67427. /**
  67428. * Creates a new Container
  67429. * @param name defines the name of the container
  67430. */
  67431. constructor(name?: string | undefined);
  67432. protected _getTypeName(): string;
  67433. _flagDescendantsAsMatrixDirty(): void;
  67434. /**
  67435. * Gets a child using its name
  67436. * @param name defines the child name to look for
  67437. * @returns the child control if found
  67438. */
  67439. getChildByName(name: string): BABYLON.Nullable<Control>;
  67440. /**
  67441. * Gets a child using its type and its name
  67442. * @param name defines the child name to look for
  67443. * @param type defines the child type to look for
  67444. * @returns the child control if found
  67445. */
  67446. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  67447. /**
  67448. * Search for a specific control in children
  67449. * @param control defines the control to look for
  67450. * @returns true if the control is in child list
  67451. */
  67452. containsControl(control: Control): boolean;
  67453. /**
  67454. * Adds a new control to the current container
  67455. * @param control defines the control to add
  67456. * @returns the current container
  67457. */
  67458. addControl(control: BABYLON.Nullable<Control>): Container;
  67459. /**
  67460. * Removes all controls from the current container
  67461. * @returns the current container
  67462. */
  67463. clearControls(): Container;
  67464. /**
  67465. * Removes a control from the current container
  67466. * @param control defines the control to remove
  67467. * @returns the current container
  67468. */
  67469. removeControl(control: Control): Container;
  67470. /** @hidden */
  67471. _reOrderControl(control: Control): void;
  67472. /** @hidden */
  67473. _offsetLeft(offset: number): void;
  67474. /** @hidden */
  67475. _offsetTop(offset: number): void;
  67476. /** @hidden */
  67477. _markAllAsDirty(): void;
  67478. /** @hidden */
  67479. protected _localDraw(context: CanvasRenderingContext2D): void;
  67480. /** @hidden */
  67481. _link(host: AdvancedDynamicTexture): void;
  67482. /** @hidden */
  67483. protected _beforeLayout(): void;
  67484. /** @hidden */
  67485. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67486. /** @hidden */
  67487. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  67488. protected _postMeasure(): void;
  67489. /** @hidden */
  67490. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  67491. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  67492. /** @hidden */
  67493. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67494. /** @hidden */
  67495. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67496. /** Releases associated resources */
  67497. dispose(): void;
  67498. }
  67499. }
  67500. declare module BABYLON.GUI {
  67501. /** Class used to create rectangle container */
  67502. export class Rectangle extends Container {
  67503. name?: string | undefined;
  67504. private _thickness;
  67505. private _cornerRadius;
  67506. /** Gets or sets border thickness */
  67507. thickness: number;
  67508. /** Gets or sets the corner radius angle */
  67509. cornerRadius: number;
  67510. /**
  67511. * Creates a new Rectangle
  67512. * @param name defines the control name
  67513. */
  67514. constructor(name?: string | undefined);
  67515. protected _getTypeName(): string;
  67516. protected _localDraw(context: CanvasRenderingContext2D): void;
  67517. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67518. private _drawRoundedRect;
  67519. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67520. }
  67521. }
  67522. declare module BABYLON.GUI {
  67523. /**
  67524. * Enum that determines the text-wrapping mode to use.
  67525. */
  67526. export enum TextWrapping {
  67527. /**
  67528. * Clip the text when it's larger than Control.width; this is the default mode.
  67529. */
  67530. Clip = 0,
  67531. /**
  67532. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  67533. */
  67534. WordWrap = 1,
  67535. /**
  67536. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  67537. */
  67538. Ellipsis = 2
  67539. }
  67540. /**
  67541. * Class used to create text block control
  67542. */
  67543. export class TextBlock extends Control {
  67544. /**
  67545. * Defines the name of the control
  67546. */
  67547. name?: string | undefined;
  67548. private _text;
  67549. private _textWrapping;
  67550. private _textHorizontalAlignment;
  67551. private _textVerticalAlignment;
  67552. private _lines;
  67553. private _resizeToFit;
  67554. private _lineSpacing;
  67555. private _outlineWidth;
  67556. private _outlineColor;
  67557. /**
  67558. * An event triggered after the text is changed
  67559. */
  67560. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  67561. /**
  67562. * An event triggered after the text was broken up into lines
  67563. */
  67564. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  67565. /**
  67566. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  67567. */
  67568. readonly lines: any[];
  67569. /**
  67570. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  67571. */
  67572. /**
  67573. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  67574. */
  67575. resizeToFit: boolean;
  67576. /**
  67577. * Gets or sets a boolean indicating if text must be wrapped
  67578. */
  67579. /**
  67580. * Gets or sets a boolean indicating if text must be wrapped
  67581. */
  67582. textWrapping: TextWrapping | boolean;
  67583. /**
  67584. * Gets or sets text to display
  67585. */
  67586. /**
  67587. * Gets or sets text to display
  67588. */
  67589. text: string;
  67590. /**
  67591. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  67592. */
  67593. /**
  67594. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  67595. */
  67596. textHorizontalAlignment: number;
  67597. /**
  67598. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  67599. */
  67600. /**
  67601. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  67602. */
  67603. textVerticalAlignment: number;
  67604. /**
  67605. * Gets or sets line spacing value
  67606. */
  67607. /**
  67608. * Gets or sets line spacing value
  67609. */
  67610. lineSpacing: string | number;
  67611. /**
  67612. * Gets or sets outlineWidth of the text to display
  67613. */
  67614. /**
  67615. * Gets or sets outlineWidth of the text to display
  67616. */
  67617. outlineWidth: number;
  67618. /**
  67619. * Gets or sets outlineColor of the text to display
  67620. */
  67621. /**
  67622. * Gets or sets outlineColor of the text to display
  67623. */
  67624. outlineColor: string;
  67625. /**
  67626. * Creates a new TextBlock object
  67627. * @param name defines the name of the control
  67628. * @param text defines the text to display (emptry string by default)
  67629. */
  67630. constructor(
  67631. /**
  67632. * Defines the name of the control
  67633. */
  67634. name?: string | undefined, text?: string);
  67635. protected _getTypeName(): string;
  67636. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67637. private _drawText;
  67638. /** @hidden */
  67639. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67640. protected _applyStates(context: CanvasRenderingContext2D): void;
  67641. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  67642. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  67643. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  67644. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  67645. protected _renderLines(context: CanvasRenderingContext2D): void;
  67646. /**
  67647. * Given a width constraint applied on the text block, find the expected height
  67648. * @returns expected height
  67649. */
  67650. computeExpectedHeight(): number;
  67651. dispose(): void;
  67652. }
  67653. }
  67654. declare module BABYLON.GUI {
  67655. /**
  67656. * Class used to create 2D images
  67657. */
  67658. export class Image extends Control {
  67659. name?: string | undefined;
  67660. private _workingCanvas;
  67661. private _domImage;
  67662. private _imageWidth;
  67663. private _imageHeight;
  67664. private _loaded;
  67665. private _stretch;
  67666. private _source;
  67667. private _autoScale;
  67668. private _sourceLeft;
  67669. private _sourceTop;
  67670. private _sourceWidth;
  67671. private _sourceHeight;
  67672. private _cellWidth;
  67673. private _cellHeight;
  67674. private _cellId;
  67675. private _populateNinePatchSlicesFromImage;
  67676. private _sliceLeft;
  67677. private _sliceRight;
  67678. private _sliceTop;
  67679. private _sliceBottom;
  67680. private _detectPointerOnOpaqueOnly;
  67681. /**
  67682. * BABYLON.Observable notified when the content is loaded
  67683. */
  67684. onImageLoadedObservable: BABYLON.Observable<Image>;
  67685. /**
  67686. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  67687. */
  67688. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  67689. /**
  67690. * Gets a boolean indicating that the content is loaded
  67691. */
  67692. readonly isLoaded: boolean;
  67693. /**
  67694. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  67695. */
  67696. populateNinePatchSlicesFromImage: boolean;
  67697. /**
  67698. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  67699. * Beware using this as this will comsume more memory as the image has to be stored twice
  67700. */
  67701. detectPointerOnOpaqueOnly: boolean;
  67702. /**
  67703. * Gets or sets the left value for slicing (9-patch)
  67704. */
  67705. sliceLeft: number;
  67706. /**
  67707. * Gets or sets the right value for slicing (9-patch)
  67708. */
  67709. sliceRight: number;
  67710. /**
  67711. * Gets or sets the top value for slicing (9-patch)
  67712. */
  67713. sliceTop: number;
  67714. /**
  67715. * Gets or sets the bottom value for slicing (9-patch)
  67716. */
  67717. sliceBottom: number;
  67718. /**
  67719. * Gets or sets the left coordinate in the source image
  67720. */
  67721. sourceLeft: number;
  67722. /**
  67723. * Gets or sets the top coordinate in the source image
  67724. */
  67725. sourceTop: number;
  67726. /**
  67727. * Gets or sets the width to capture in the source image
  67728. */
  67729. sourceWidth: number;
  67730. /**
  67731. * Gets or sets the height to capture in the source image
  67732. */
  67733. sourceHeight: number;
  67734. /**
  67735. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  67736. * @see http://doc.babylonjs.com/how_to/gui#image
  67737. */
  67738. autoScale: boolean;
  67739. /** Gets or sets the streching mode used by the image */
  67740. stretch: number;
  67741. /** @hidden */
  67742. _rotate90(n: number): Image;
  67743. /**
  67744. * Gets or sets the internal DOM image used to render the control
  67745. */
  67746. domImage: HTMLImageElement;
  67747. private _onImageLoaded;
  67748. private _extractNinePatchSliceDataFromImage;
  67749. /**
  67750. * Gets or sets image source url
  67751. */
  67752. source: BABYLON.Nullable<string>;
  67753. /**
  67754. * Checks for svg document with icon id present
  67755. */
  67756. private _svgCheck;
  67757. /**
  67758. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  67759. * given external svg file and icon id
  67760. */
  67761. private _getSVGAttribs;
  67762. /**
  67763. * Gets or sets the cell width to use when animation sheet is enabled
  67764. * @see http://doc.babylonjs.com/how_to/gui#image
  67765. */
  67766. cellWidth: number;
  67767. /**
  67768. * Gets or sets the cell height to use when animation sheet is enabled
  67769. * @see http://doc.babylonjs.com/how_to/gui#image
  67770. */
  67771. cellHeight: number;
  67772. /**
  67773. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  67774. * @see http://doc.babylonjs.com/how_to/gui#image
  67775. */
  67776. cellId: number;
  67777. /**
  67778. * Creates a new Image
  67779. * @param name defines the control name
  67780. * @param url defines the image url
  67781. */
  67782. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  67783. /**
  67784. * Tests if a given coordinates belong to the current control
  67785. * @param x defines x coordinate to test
  67786. * @param y defines y coordinate to test
  67787. * @returns true if the coordinates are inside the control
  67788. */
  67789. contains(x: number, y: number): boolean;
  67790. protected _getTypeName(): string;
  67791. /** Force the control to synchronize with its content */
  67792. synchronizeSizeWithContent(): void;
  67793. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67794. private _prepareWorkingCanvasForOpaqueDetection;
  67795. private _drawImage;
  67796. _draw(context: CanvasRenderingContext2D): void;
  67797. private _renderCornerPatch;
  67798. private _renderNinePatch;
  67799. dispose(): void;
  67800. /** STRETCH_NONE */
  67801. static readonly STRETCH_NONE: number;
  67802. /** STRETCH_FILL */
  67803. static readonly STRETCH_FILL: number;
  67804. /** STRETCH_UNIFORM */
  67805. static readonly STRETCH_UNIFORM: number;
  67806. /** STRETCH_EXTEND */
  67807. static readonly STRETCH_EXTEND: number;
  67808. /** NINE_PATCH */
  67809. static readonly STRETCH_NINE_PATCH: number;
  67810. }
  67811. }
  67812. declare module BABYLON.GUI {
  67813. /**
  67814. * Class used to create 2D buttons
  67815. */
  67816. export class Button extends Rectangle {
  67817. name?: string | undefined;
  67818. /**
  67819. * Function called to generate a pointer enter animation
  67820. */
  67821. pointerEnterAnimation: () => void;
  67822. /**
  67823. * Function called to generate a pointer out animation
  67824. */
  67825. pointerOutAnimation: () => void;
  67826. /**
  67827. * Function called to generate a pointer down animation
  67828. */
  67829. pointerDownAnimation: () => void;
  67830. /**
  67831. * Function called to generate a pointer up animation
  67832. */
  67833. pointerUpAnimation: () => void;
  67834. /**
  67835. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  67836. */
  67837. delegatePickingToChildren: boolean;
  67838. private _image;
  67839. /**
  67840. * Returns the image part of the button (if any)
  67841. */
  67842. readonly image: BABYLON.Nullable<Image>;
  67843. private _textBlock;
  67844. /**
  67845. * Returns the image part of the button (if any)
  67846. */
  67847. readonly textBlock: BABYLON.Nullable<TextBlock>;
  67848. /**
  67849. * Creates a new Button
  67850. * @param name defines the name of the button
  67851. */
  67852. constructor(name?: string | undefined);
  67853. protected _getTypeName(): string;
  67854. /** @hidden */
  67855. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67856. /** @hidden */
  67857. _onPointerEnter(target: Control): boolean;
  67858. /** @hidden */
  67859. _onPointerOut(target: Control, force?: boolean): void;
  67860. /** @hidden */
  67861. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67862. /** @hidden */
  67863. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67864. /**
  67865. * Creates a new button made with an image and a text
  67866. * @param name defines the name of the button
  67867. * @param text defines the text of the button
  67868. * @param imageUrl defines the url of the image
  67869. * @returns a new Button
  67870. */
  67871. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  67872. /**
  67873. * Creates a new button made with an image
  67874. * @param name defines the name of the button
  67875. * @param imageUrl defines the url of the image
  67876. * @returns a new Button
  67877. */
  67878. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  67879. /**
  67880. * Creates a new button made with a text
  67881. * @param name defines the name of the button
  67882. * @param text defines the text of the button
  67883. * @returns a new Button
  67884. */
  67885. static CreateSimpleButton(name: string, text: string): Button;
  67886. /**
  67887. * Creates a new button made with an image and a centered text
  67888. * @param name defines the name of the button
  67889. * @param text defines the text of the button
  67890. * @param imageUrl defines the url of the image
  67891. * @returns a new Button
  67892. */
  67893. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  67894. }
  67895. }
  67896. declare module BABYLON.GUI {
  67897. /**
  67898. * Class used to create a 2D stack panel container
  67899. */
  67900. export class StackPanel extends Container {
  67901. name?: string | undefined;
  67902. private _isVertical;
  67903. private _manualWidth;
  67904. private _manualHeight;
  67905. private _doNotTrackManualChanges;
  67906. /**
  67907. * Gets or sets a boolean indicating that layou warnings should be ignored
  67908. */
  67909. ignoreLayoutWarnings: boolean;
  67910. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  67911. isVertical: boolean;
  67912. /**
  67913. * Gets or sets panel width.
  67914. * This value should not be set when in horizontal mode as it will be computed automatically
  67915. */
  67916. width: string | number;
  67917. /**
  67918. * Gets or sets panel height.
  67919. * This value should not be set when in vertical mode as it will be computed automatically
  67920. */
  67921. height: string | number;
  67922. /**
  67923. * Creates a new StackPanel
  67924. * @param name defines control name
  67925. */
  67926. constructor(name?: string | undefined);
  67927. protected _getTypeName(): string;
  67928. /** @hidden */
  67929. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67930. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67931. protected _postMeasure(): void;
  67932. }
  67933. }
  67934. declare module BABYLON.GUI {
  67935. /**
  67936. * Class used to represent a 2D checkbox
  67937. */
  67938. export class Checkbox extends Control {
  67939. name?: string | undefined;
  67940. private _isChecked;
  67941. private _background;
  67942. private _checkSizeRatio;
  67943. private _thickness;
  67944. /** Gets or sets border thickness */
  67945. thickness: number;
  67946. /**
  67947. * BABYLON.Observable raised when isChecked property changes
  67948. */
  67949. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  67950. /** Gets or sets a value indicating the ratio between overall size and check size */
  67951. checkSizeRatio: number;
  67952. /** Gets or sets background color */
  67953. background: string;
  67954. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  67955. isChecked: boolean;
  67956. /**
  67957. * Creates a new CheckBox
  67958. * @param name defines the control name
  67959. */
  67960. constructor(name?: string | undefined);
  67961. protected _getTypeName(): string;
  67962. /** @hidden */
  67963. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67964. /** @hidden */
  67965. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67966. /**
  67967. * Utility function to easily create a checkbox with a header
  67968. * @param title defines the label to use for the header
  67969. * @param onValueChanged defines the callback to call when value changes
  67970. * @returns a StackPanel containing the checkbox and a textBlock
  67971. */
  67972. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  67973. }
  67974. }
  67975. declare module BABYLON.GUI {
  67976. /**
  67977. * Class used to store key control properties
  67978. */
  67979. export class KeyPropertySet {
  67980. /** Width */
  67981. width?: string;
  67982. /** Height */
  67983. height?: string;
  67984. /** Left padding */
  67985. paddingLeft?: string;
  67986. /** Right padding */
  67987. paddingRight?: string;
  67988. /** Top padding */
  67989. paddingTop?: string;
  67990. /** Bottom padding */
  67991. paddingBottom?: string;
  67992. /** Foreground color */
  67993. color?: string;
  67994. /** Background color */
  67995. background?: string;
  67996. }
  67997. /**
  67998. * Class used to create virtual keyboard
  67999. */
  68000. export class VirtualKeyboard extends StackPanel {
  68001. /** BABYLON.Observable raised when a key is pressed */
  68002. onKeyPressObservable: BABYLON.Observable<string>;
  68003. /** Gets or sets default key button width */
  68004. defaultButtonWidth: string;
  68005. /** Gets or sets default key button height */
  68006. defaultButtonHeight: string;
  68007. /** Gets or sets default key button left padding */
  68008. defaultButtonPaddingLeft: string;
  68009. /** Gets or sets default key button right padding */
  68010. defaultButtonPaddingRight: string;
  68011. /** Gets or sets default key button top padding */
  68012. defaultButtonPaddingTop: string;
  68013. /** Gets or sets default key button bottom padding */
  68014. defaultButtonPaddingBottom: string;
  68015. /** Gets or sets default key button foreground color */
  68016. defaultButtonColor: string;
  68017. /** Gets or sets default key button background color */
  68018. defaultButtonBackground: string;
  68019. /** Gets or sets shift button foreground color */
  68020. shiftButtonColor: string;
  68021. /** Gets or sets shift button thickness*/
  68022. selectedShiftThickness: number;
  68023. /** Gets shift key state */
  68024. shiftState: number;
  68025. protected _getTypeName(): string;
  68026. private _createKey;
  68027. /**
  68028. * Adds a new row of keys
  68029. * @param keys defines the list of keys to add
  68030. * @param propertySets defines the associated property sets
  68031. */
  68032. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  68033. /**
  68034. * Set the shift key to a specific state
  68035. * @param shiftState defines the new shift state
  68036. */
  68037. applyShiftState(shiftState: number): void;
  68038. private _currentlyConnectedInputText;
  68039. private _connectedInputTexts;
  68040. private _onKeyPressObserver;
  68041. /** Gets the input text control currently attached to the keyboard */
  68042. readonly connectedInputText: BABYLON.Nullable<InputText>;
  68043. /**
  68044. * Connects the keyboard with an input text control
  68045. *
  68046. * @param input defines the target control
  68047. */
  68048. connect(input: InputText): void;
  68049. /**
  68050. * Disconnects the keyboard from connected InputText controls
  68051. *
  68052. * @param input optionally defines a target control, otherwise all are disconnected
  68053. */
  68054. disconnect(input?: InputText): void;
  68055. private _removeConnectedInputObservables;
  68056. /**
  68057. * Release all resources
  68058. */
  68059. dispose(): void;
  68060. /**
  68061. * Creates a new keyboard using a default layout
  68062. *
  68063. * @param name defines control name
  68064. * @returns a new VirtualKeyboard
  68065. */
  68066. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  68067. }
  68068. }
  68069. declare module BABYLON.GUI {
  68070. /**
  68071. * Class used to create input text control
  68072. */
  68073. export class InputText extends Control implements IFocusableControl {
  68074. name?: string | undefined;
  68075. private _text;
  68076. private _placeholderText;
  68077. private _background;
  68078. private _focusedBackground;
  68079. private _focusedColor;
  68080. private _placeholderColor;
  68081. private _thickness;
  68082. private _margin;
  68083. private _autoStretchWidth;
  68084. private _maxWidth;
  68085. private _isFocused;
  68086. private _blinkTimeout;
  68087. private _blinkIsEven;
  68088. private _cursorOffset;
  68089. private _scrollLeft;
  68090. private _textWidth;
  68091. private _clickedCoordinate;
  68092. private _deadKey;
  68093. private _addKey;
  68094. private _currentKey;
  68095. private _isTextHighlightOn;
  68096. private _textHighlightColor;
  68097. private _highligherOpacity;
  68098. private _highlightedText;
  68099. private _startHighlightIndex;
  68100. private _endHighlightIndex;
  68101. private _cursorIndex;
  68102. private _onFocusSelectAll;
  68103. private _isPointerDown;
  68104. private _onClipboardObserver;
  68105. private _onPointerDblTapObserver;
  68106. /** @hidden */
  68107. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  68108. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  68109. promptMessage: string;
  68110. /** Force disable prompt on mobile device */
  68111. disableMobilePrompt: boolean;
  68112. /** BABYLON.Observable raised when the text changes */
  68113. onTextChangedObservable: BABYLON.Observable<InputText>;
  68114. /** BABYLON.Observable raised just before an entered character is to be added */
  68115. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  68116. /** BABYLON.Observable raised when the control gets the focus */
  68117. onFocusObservable: BABYLON.Observable<InputText>;
  68118. /** BABYLON.Observable raised when the control loses the focus */
  68119. onBlurObservable: BABYLON.Observable<InputText>;
  68120. /**Observable raised when the text is highlighted */
  68121. onTextHighlightObservable: BABYLON.Observable<InputText>;
  68122. /**Observable raised when copy event is triggered */
  68123. onTextCopyObservable: BABYLON.Observable<InputText>;
  68124. /** BABYLON.Observable raised when cut event is triggered */
  68125. onTextCutObservable: BABYLON.Observable<InputText>;
  68126. /** BABYLON.Observable raised when paste event is triggered */
  68127. onTextPasteObservable: BABYLON.Observable<InputText>;
  68128. /** BABYLON.Observable raised when a key event was processed */
  68129. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  68130. /** Gets or sets the maximum width allowed by the control */
  68131. maxWidth: string | number;
  68132. /** Gets the maximum width allowed by the control in pixels */
  68133. readonly maxWidthInPixels: number;
  68134. /** Gets or sets the text highlighter transparency; default: 0.4 */
  68135. highligherOpacity: number;
  68136. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  68137. onFocusSelectAll: boolean;
  68138. /** Gets or sets the text hightlight color */
  68139. textHighlightColor: string;
  68140. /** Gets or sets control margin */
  68141. margin: string;
  68142. /** Gets control margin in pixels */
  68143. readonly marginInPixels: number;
  68144. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  68145. autoStretchWidth: boolean;
  68146. /** Gets or sets border thickness */
  68147. thickness: number;
  68148. /** Gets or sets the background color when focused */
  68149. focusedBackground: string;
  68150. /** Gets or sets the background color when focused */
  68151. focusedColor: string;
  68152. /** Gets or sets the background color */
  68153. background: string;
  68154. /** Gets or sets the placeholder color */
  68155. placeholderColor: string;
  68156. /** Gets or sets the text displayed when the control is empty */
  68157. placeholderText: string;
  68158. /** Gets or sets the dead key flag */
  68159. deadKey: boolean;
  68160. /** Gets or sets the highlight text */
  68161. highlightedText: string;
  68162. /** Gets or sets if the current key should be added */
  68163. addKey: boolean;
  68164. /** Gets or sets the value of the current key being entered */
  68165. currentKey: string;
  68166. /** Gets or sets the text displayed in the control */
  68167. text: string;
  68168. /** Gets or sets control width */
  68169. width: string | number;
  68170. /**
  68171. * Creates a new InputText
  68172. * @param name defines the control name
  68173. * @param text defines the text of the control
  68174. */
  68175. constructor(name?: string | undefined, text?: string);
  68176. /** @hidden */
  68177. onBlur(): void;
  68178. /** @hidden */
  68179. onFocus(): void;
  68180. protected _getTypeName(): string;
  68181. /**
  68182. * Function called to get the list of controls that should not steal the focus from this control
  68183. * @returns an array of controls
  68184. */
  68185. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  68186. /** @hidden */
  68187. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  68188. /** @hidden */
  68189. private _updateValueFromCursorIndex;
  68190. /** @hidden */
  68191. private _processDblClick;
  68192. /** @hidden */
  68193. private _selectAllText;
  68194. /**
  68195. * Handles the keyboard event
  68196. * @param evt Defines the KeyboardEvent
  68197. */
  68198. processKeyboard(evt: KeyboardEvent): void;
  68199. /** @hidden */
  68200. private _onCopyText;
  68201. /** @hidden */
  68202. private _onCutText;
  68203. /** @hidden */
  68204. private _onPasteText;
  68205. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68206. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68207. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68208. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68209. protected _beforeRenderText(text: string): string;
  68210. dispose(): void;
  68211. }
  68212. }
  68213. declare module BABYLON.GUI {
  68214. /**
  68215. * Class used to create a 2D grid container
  68216. */
  68217. export class Grid extends Container {
  68218. name?: string | undefined;
  68219. private _rowDefinitions;
  68220. private _columnDefinitions;
  68221. private _cells;
  68222. private _childControls;
  68223. /**
  68224. * Gets the number of columns
  68225. */
  68226. readonly columnCount: number;
  68227. /**
  68228. * Gets the number of rows
  68229. */
  68230. readonly rowCount: number;
  68231. /** Gets the list of children */
  68232. readonly children: Control[];
  68233. /** Gets the list of cells (e.g. the containers) */
  68234. readonly cells: {
  68235. [key: string]: Container;
  68236. };
  68237. /**
  68238. * Gets the definition of a specific row
  68239. * @param index defines the index of the row
  68240. * @returns the row definition
  68241. */
  68242. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  68243. /**
  68244. * Gets the definition of a specific column
  68245. * @param index defines the index of the column
  68246. * @returns the column definition
  68247. */
  68248. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  68249. /**
  68250. * Adds a new row to the grid
  68251. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  68252. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  68253. * @returns the current grid
  68254. */
  68255. addRowDefinition(height: number, isPixel?: boolean): Grid;
  68256. /**
  68257. * Adds a new column to the grid
  68258. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  68259. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  68260. * @returns the current grid
  68261. */
  68262. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  68263. /**
  68264. * Update a row definition
  68265. * @param index defines the index of the row to update
  68266. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  68267. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  68268. * @returns the current grid
  68269. */
  68270. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  68271. /**
  68272. * Update a column definition
  68273. * @param index defines the index of the column to update
  68274. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  68275. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  68276. * @returns the current grid
  68277. */
  68278. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  68279. /**
  68280. * Gets the list of children stored in a specific cell
  68281. * @param row defines the row to check
  68282. * @param column defines the column to check
  68283. * @returns the list of controls
  68284. */
  68285. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  68286. /**
  68287. * Gets a string representing the child cell info (row x column)
  68288. * @param child defines the control to get info from
  68289. * @returns a string containing the child cell info (row x column)
  68290. */
  68291. getChildCellInfo(child: Control): string;
  68292. private _removeCell;
  68293. private _offsetCell;
  68294. /**
  68295. * Remove a column definition at specified index
  68296. * @param index defines the index of the column to remove
  68297. * @returns the current grid
  68298. */
  68299. removeColumnDefinition(index: number): Grid;
  68300. /**
  68301. * Remove a row definition at specified index
  68302. * @param index defines the index of the row to remove
  68303. * @returns the current grid
  68304. */
  68305. removeRowDefinition(index: number): Grid;
  68306. /**
  68307. * Adds a new control to the current grid
  68308. * @param control defines the control to add
  68309. * @param row defines the row where to add the control (0 by default)
  68310. * @param column defines the column where to add the control (0 by default)
  68311. * @returns the current grid
  68312. */
  68313. addControl(control: Control, row?: number, column?: number): Grid;
  68314. /**
  68315. * Removes a control from the current container
  68316. * @param control defines the control to remove
  68317. * @returns the current container
  68318. */
  68319. removeControl(control: Control): Container;
  68320. /**
  68321. * Creates a new Grid
  68322. * @param name defines control name
  68323. */
  68324. constructor(name?: string | undefined);
  68325. protected _getTypeName(): string;
  68326. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  68327. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68328. _flagDescendantsAsMatrixDirty(): void;
  68329. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68330. /** Releases associated resources */
  68331. dispose(): void;
  68332. }
  68333. }
  68334. declare module BABYLON.GUI {
  68335. /** Class used to create color pickers */
  68336. export class ColorPicker extends Control {
  68337. name?: string | undefined;
  68338. private static _Epsilon;
  68339. private _colorWheelCanvas;
  68340. private _value;
  68341. private _tmpColor;
  68342. private _pointerStartedOnSquare;
  68343. private _pointerStartedOnWheel;
  68344. private _squareLeft;
  68345. private _squareTop;
  68346. private _squareSize;
  68347. private _h;
  68348. private _s;
  68349. private _v;
  68350. private _lastPointerDownID;
  68351. /**
  68352. * BABYLON.Observable raised when the value changes
  68353. */
  68354. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  68355. /** Gets or sets the color of the color picker */
  68356. value: BABYLON.Color3;
  68357. /**
  68358. * Gets or sets control width
  68359. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68360. */
  68361. width: string | number;
  68362. /**
  68363. * Gets or sets control height
  68364. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68365. */
  68366. /** Gets or sets control height */
  68367. height: string | number;
  68368. /** Gets or sets control size */
  68369. size: string | number;
  68370. /**
  68371. * Creates a new ColorPicker
  68372. * @param name defines the control name
  68373. */
  68374. constructor(name?: string | undefined);
  68375. protected _getTypeName(): string;
  68376. /** @hidden */
  68377. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68378. private _updateSquareProps;
  68379. private _drawGradientSquare;
  68380. private _drawCircle;
  68381. private _createColorWheelCanvas;
  68382. /** @hidden */
  68383. _draw(context: CanvasRenderingContext2D): void;
  68384. private _pointerIsDown;
  68385. private _updateValueFromPointer;
  68386. private _isPointOnSquare;
  68387. private _isPointOnWheel;
  68388. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68389. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68390. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68391. /**
  68392. * This function expands the color picker by creating a color picker dialog with manual
  68393. * color value input and the ability to save colors into an array to be used later in
  68394. * subsequent launches of the dialogue.
  68395. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  68396. * @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.
  68397. * @returns picked color as a hex string and the saved colors array as hex strings.
  68398. */
  68399. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  68400. pickerWidth?: string;
  68401. pickerHeight?: string;
  68402. headerHeight?: string;
  68403. lastColor?: string;
  68404. swatchLimit?: number;
  68405. numSwatchesPerLine?: number;
  68406. savedColors?: Array<string>;
  68407. }): Promise<{
  68408. savedColors?: string[];
  68409. pickedColor: string;
  68410. }>;
  68411. }
  68412. }
  68413. declare module BABYLON.GUI {
  68414. /** Class used to create 2D ellipse containers */
  68415. export class Ellipse extends Container {
  68416. name?: string | undefined;
  68417. private _thickness;
  68418. /** Gets or sets border thickness */
  68419. thickness: number;
  68420. /**
  68421. * Creates a new Ellipse
  68422. * @param name defines the control name
  68423. */
  68424. constructor(name?: string | undefined);
  68425. protected _getTypeName(): string;
  68426. protected _localDraw(context: CanvasRenderingContext2D): void;
  68427. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68428. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68429. }
  68430. }
  68431. declare module BABYLON.GUI {
  68432. /**
  68433. * Class used to create a password control
  68434. */
  68435. export class InputPassword extends InputText {
  68436. protected _beforeRenderText(text: string): string;
  68437. }
  68438. }
  68439. declare module BABYLON.GUI {
  68440. /** Class used to render 2D lines */
  68441. export class Line extends Control {
  68442. name?: string | undefined;
  68443. private _lineWidth;
  68444. private _x1;
  68445. private _y1;
  68446. private _x2;
  68447. private _y2;
  68448. private _dash;
  68449. private _connectedControl;
  68450. private _connectedControlDirtyObserver;
  68451. /** Gets or sets the dash pattern */
  68452. dash: Array<number>;
  68453. /** Gets or sets the control connected with the line end */
  68454. connectedControl: Control;
  68455. /** Gets or sets start coordinates on X axis */
  68456. x1: string | number;
  68457. /** Gets or sets start coordinates on Y axis */
  68458. y1: string | number;
  68459. /** Gets or sets end coordinates on X axis */
  68460. x2: string | number;
  68461. /** Gets or sets end coordinates on Y axis */
  68462. y2: string | number;
  68463. /** Gets or sets line width */
  68464. lineWidth: number;
  68465. /** Gets or sets horizontal alignment */
  68466. horizontalAlignment: number;
  68467. /** Gets or sets vertical alignment */
  68468. verticalAlignment: number;
  68469. private readonly _effectiveX2;
  68470. private readonly _effectiveY2;
  68471. /**
  68472. * Creates a new Line
  68473. * @param name defines the control name
  68474. */
  68475. constructor(name?: string | undefined);
  68476. protected _getTypeName(): string;
  68477. _draw(context: CanvasRenderingContext2D): void;
  68478. _measure(): void;
  68479. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68480. /**
  68481. * Move one end of the line given 3D cartesian coordinates.
  68482. * @param position Targeted world position
  68483. * @param scene BABYLON.Scene
  68484. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  68485. */
  68486. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  68487. /**
  68488. * Move one end of the line to a position in screen absolute space.
  68489. * @param projectedPosition Position in screen absolute space (X, Y)
  68490. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  68491. */
  68492. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  68493. }
  68494. }
  68495. declare module BABYLON.GUI {
  68496. /**
  68497. * Class used to store a point for a MultiLine object.
  68498. * The point can be pure 2D coordinates, a mesh or a control
  68499. */
  68500. export class MultiLinePoint {
  68501. private _multiLine;
  68502. private _x;
  68503. private _y;
  68504. private _control;
  68505. private _mesh;
  68506. private _controlObserver;
  68507. private _meshObserver;
  68508. /** @hidden */
  68509. _point: BABYLON.Vector2;
  68510. /**
  68511. * Creates a new MultiLinePoint
  68512. * @param multiLine defines the source MultiLine object
  68513. */
  68514. constructor(multiLine: MultiLine);
  68515. /** Gets or sets x coordinate */
  68516. x: string | number;
  68517. /** Gets or sets y coordinate */
  68518. y: string | number;
  68519. /** Gets or sets the control associated with this point */
  68520. control: BABYLON.Nullable<Control>;
  68521. /** Gets or sets the mesh associated with this point */
  68522. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68523. /** Resets links */
  68524. resetLinks(): void;
  68525. /**
  68526. * Gets a translation vector
  68527. * @returns the translation vector
  68528. */
  68529. translate(): BABYLON.Vector2;
  68530. private _translatePoint;
  68531. /** Release associated resources */
  68532. dispose(): void;
  68533. }
  68534. }
  68535. declare module BABYLON.GUI {
  68536. /**
  68537. * Class used to create multi line control
  68538. */
  68539. export class MultiLine extends Control {
  68540. name?: string | undefined;
  68541. private _lineWidth;
  68542. private _dash;
  68543. private _points;
  68544. private _minX;
  68545. private _minY;
  68546. private _maxX;
  68547. private _maxY;
  68548. /**
  68549. * Creates a new MultiLine
  68550. * @param name defines the control name
  68551. */
  68552. constructor(name?: string | undefined);
  68553. /** Gets or sets dash pattern */
  68554. dash: Array<number>;
  68555. /**
  68556. * Gets point stored at specified index
  68557. * @param index defines the index to look for
  68558. * @returns the requested point if found
  68559. */
  68560. getAt(index: number): MultiLinePoint;
  68561. /** Function called when a point is updated */
  68562. onPointUpdate: () => void;
  68563. /**
  68564. * Adds new points to the point collection
  68565. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  68566. * @returns the list of created MultiLinePoint
  68567. */
  68568. add(...items: (AbstractMesh | Control | {
  68569. x: string | number;
  68570. y: string | number;
  68571. })[]): MultiLinePoint[];
  68572. /**
  68573. * Adds a new point to the point collection
  68574. * @param item defines the item (mesh, control or 2d coordiantes) to add
  68575. * @returns the created MultiLinePoint
  68576. */
  68577. push(item?: (AbstractMesh | Control | {
  68578. x: string | number;
  68579. y: string | number;
  68580. })): MultiLinePoint;
  68581. /**
  68582. * Remove a specific value or point from the active point collection
  68583. * @param value defines the value or point to remove
  68584. */
  68585. remove(value: number | MultiLinePoint): void;
  68586. /**
  68587. * Resets this object to initial state (no point)
  68588. */
  68589. reset(): void;
  68590. /**
  68591. * Resets all links
  68592. */
  68593. resetLinks(): void;
  68594. /** Gets or sets line width */
  68595. lineWidth: number;
  68596. horizontalAlignment: number;
  68597. verticalAlignment: number;
  68598. protected _getTypeName(): string;
  68599. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68600. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68601. _measure(): void;
  68602. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68603. dispose(): void;
  68604. }
  68605. }
  68606. declare module BABYLON.GUI {
  68607. /**
  68608. * Class used to create radio button controls
  68609. */
  68610. export class RadioButton extends Control {
  68611. name?: string | undefined;
  68612. private _isChecked;
  68613. private _background;
  68614. private _checkSizeRatio;
  68615. private _thickness;
  68616. /** Gets or sets border thickness */
  68617. thickness: number;
  68618. /** Gets or sets group name */
  68619. group: string;
  68620. /** BABYLON.Observable raised when isChecked is changed */
  68621. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  68622. /** Gets or sets a value indicating the ratio between overall size and check size */
  68623. checkSizeRatio: number;
  68624. /** Gets or sets background color */
  68625. background: string;
  68626. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  68627. isChecked: boolean;
  68628. /**
  68629. * Creates a new RadioButton
  68630. * @param name defines the control name
  68631. */
  68632. constructor(name?: string | undefined);
  68633. protected _getTypeName(): string;
  68634. _draw(context: CanvasRenderingContext2D): void;
  68635. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68636. /**
  68637. * Utility function to easily create a radio button with a header
  68638. * @param title defines the label to use for the header
  68639. * @param group defines the group to use for the radio button
  68640. * @param isChecked defines the initial state of the radio button
  68641. * @param onValueChanged defines the callback to call when value changes
  68642. * @returns a StackPanel containing the radio button and a textBlock
  68643. */
  68644. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  68645. }
  68646. }
  68647. declare module BABYLON.GUI {
  68648. /**
  68649. * Class used to create slider controls
  68650. */
  68651. export class BaseSlider extends Control {
  68652. name?: string | undefined;
  68653. protected _thumbWidth: ValueAndUnit;
  68654. private _minimum;
  68655. private _maximum;
  68656. private _value;
  68657. private _isVertical;
  68658. protected _barOffset: ValueAndUnit;
  68659. private _isThumbClamped;
  68660. protected _displayThumb: boolean;
  68661. private _step;
  68662. private _lastPointerDownID;
  68663. protected _effectiveBarOffset: number;
  68664. protected _renderLeft: number;
  68665. protected _renderTop: number;
  68666. protected _renderWidth: number;
  68667. protected _renderHeight: number;
  68668. protected _backgroundBoxLength: number;
  68669. protected _backgroundBoxThickness: number;
  68670. protected _effectiveThumbThickness: number;
  68671. /** BABYLON.Observable raised when the sldier value changes */
  68672. onValueChangedObservable: BABYLON.Observable<number>;
  68673. /** Gets or sets a boolean indicating if the thumb must be rendered */
  68674. displayThumb: boolean;
  68675. /** Gets or sets a step to apply to values (0 by default) */
  68676. step: number;
  68677. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  68678. barOffset: string | number;
  68679. /** Gets main bar offset in pixels*/
  68680. readonly barOffsetInPixels: number;
  68681. /** Gets or sets thumb width */
  68682. thumbWidth: string | number;
  68683. /** Gets thumb width in pixels */
  68684. readonly thumbWidthInPixels: number;
  68685. /** Gets or sets minimum value */
  68686. minimum: number;
  68687. /** Gets or sets maximum value */
  68688. maximum: number;
  68689. /** Gets or sets current value */
  68690. value: number;
  68691. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  68692. isVertical: boolean;
  68693. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  68694. isThumbClamped: boolean;
  68695. /**
  68696. * Creates a new BaseSlider
  68697. * @param name defines the control name
  68698. */
  68699. constructor(name?: string | undefined);
  68700. protected _getTypeName(): string;
  68701. protected _getThumbPosition(): number;
  68702. protected _getThumbThickness(type: string): number;
  68703. protected _prepareRenderingData(type: string): void;
  68704. private _pointerIsDown;
  68705. /** @hidden */
  68706. protected _updateValueFromPointer(x: number, y: number): void;
  68707. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68708. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68709. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68710. }
  68711. }
  68712. declare module BABYLON.GUI {
  68713. /**
  68714. * Class used to create slider controls
  68715. */
  68716. export class Slider extends BaseSlider {
  68717. name?: string | undefined;
  68718. private _background;
  68719. private _borderColor;
  68720. private _isThumbCircle;
  68721. protected _displayValueBar: boolean;
  68722. /** Gets or sets a boolean indicating if the value bar must be rendered */
  68723. displayValueBar: boolean;
  68724. /** Gets or sets border color */
  68725. borderColor: string;
  68726. /** Gets or sets background color */
  68727. background: string;
  68728. /** Gets or sets a boolean indicating if the thumb should be round or square */
  68729. isThumbCircle: boolean;
  68730. /**
  68731. * Creates a new Slider
  68732. * @param name defines the control name
  68733. */
  68734. constructor(name?: string | undefined);
  68735. protected _getTypeName(): string;
  68736. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68737. }
  68738. }
  68739. declare module BABYLON.GUI {
  68740. /** Class used to create a RadioGroup
  68741. * which contains groups of radio buttons
  68742. */
  68743. export class SelectorGroup {
  68744. /** name of SelectorGroup */
  68745. name: string;
  68746. private _groupPanel;
  68747. private _selectors;
  68748. private _groupHeader;
  68749. /**
  68750. * Creates a new SelectorGroup
  68751. * @param name of group, used as a group heading
  68752. */
  68753. constructor(
  68754. /** name of SelectorGroup */
  68755. name: string);
  68756. /** Gets the groupPanel of the SelectorGroup */
  68757. readonly groupPanel: StackPanel;
  68758. /** Gets the selectors array */
  68759. readonly selectors: StackPanel[];
  68760. /** Gets and sets the group header */
  68761. header: string;
  68762. /** @hidden */
  68763. private _addGroupHeader;
  68764. /** @hidden*/
  68765. _getSelector(selectorNb: number): StackPanel | undefined;
  68766. /** Removes the selector at the given position
  68767. * @param selectorNb the position of the selector within the group
  68768. */
  68769. removeSelector(selectorNb: number): void;
  68770. }
  68771. /** Class used to create a CheckboxGroup
  68772. * which contains groups of checkbox buttons
  68773. */
  68774. export class CheckboxGroup extends SelectorGroup {
  68775. /** Adds a checkbox as a control
  68776. * @param text is the label for the selector
  68777. * @param func is the function called when the Selector is checked
  68778. * @param checked is true when Selector is checked
  68779. */
  68780. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  68781. /** @hidden */
  68782. _setSelectorLabel(selectorNb: number, label: string): void;
  68783. /** @hidden */
  68784. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68785. /** @hidden */
  68786. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68787. /** @hidden */
  68788. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68789. }
  68790. /** Class used to create a RadioGroup
  68791. * which contains groups of radio buttons
  68792. */
  68793. export class RadioGroup extends SelectorGroup {
  68794. private _selectNb;
  68795. /** Adds a radio button as a control
  68796. * @param label is the label for the selector
  68797. * @param func is the function called when the Selector is checked
  68798. * @param checked is true when Selector is checked
  68799. */
  68800. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  68801. /** @hidden */
  68802. _setSelectorLabel(selectorNb: number, label: string): void;
  68803. /** @hidden */
  68804. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68805. /** @hidden */
  68806. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68807. /** @hidden */
  68808. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68809. }
  68810. /** Class used to create a SliderGroup
  68811. * which contains groups of slider buttons
  68812. */
  68813. export class SliderGroup extends SelectorGroup {
  68814. /**
  68815. * Adds a slider to the SelectorGroup
  68816. * @param label is the label for the SliderBar
  68817. * @param func is the function called when the Slider moves
  68818. * @param unit is a string describing the units used, eg degrees or metres
  68819. * @param min is the minimum value for the Slider
  68820. * @param max is the maximum value for the Slider
  68821. * @param value is the start value for the Slider between min and max
  68822. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  68823. */
  68824. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  68825. /** @hidden */
  68826. _setSelectorLabel(selectorNb: number, label: string): void;
  68827. /** @hidden */
  68828. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68829. /** @hidden */
  68830. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68831. /** @hidden */
  68832. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68833. }
  68834. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  68835. * @see http://doc.babylonjs.com/how_to/selector
  68836. */
  68837. export class SelectionPanel extends Rectangle {
  68838. /** name of SelectionPanel */
  68839. name: string;
  68840. /** an array of SelectionGroups */
  68841. groups: SelectorGroup[];
  68842. private _panel;
  68843. private _buttonColor;
  68844. private _buttonBackground;
  68845. private _headerColor;
  68846. private _barColor;
  68847. private _barHeight;
  68848. private _spacerHeight;
  68849. private _labelColor;
  68850. private _groups;
  68851. private _bars;
  68852. /**
  68853. * Creates a new SelectionPanel
  68854. * @param name of SelectionPanel
  68855. * @param groups is an array of SelectionGroups
  68856. */
  68857. constructor(
  68858. /** name of SelectionPanel */
  68859. name: string,
  68860. /** an array of SelectionGroups */
  68861. groups?: SelectorGroup[]);
  68862. protected _getTypeName(): string;
  68863. /** Gets or sets the headerColor */
  68864. headerColor: string;
  68865. private _setHeaderColor;
  68866. /** Gets or sets the button color */
  68867. buttonColor: string;
  68868. private _setbuttonColor;
  68869. /** Gets or sets the label color */
  68870. labelColor: string;
  68871. private _setLabelColor;
  68872. /** Gets or sets the button background */
  68873. buttonBackground: string;
  68874. private _setButtonBackground;
  68875. /** Gets or sets the color of separator bar */
  68876. barColor: string;
  68877. private _setBarColor;
  68878. /** Gets or sets the height of separator bar */
  68879. barHeight: string;
  68880. private _setBarHeight;
  68881. /** Gets or sets the height of spacers*/
  68882. spacerHeight: string;
  68883. private _setSpacerHeight;
  68884. /** Adds a bar between groups */
  68885. private _addSpacer;
  68886. /** Add a group to the selection panel
  68887. * @param group is the selector group to add
  68888. */
  68889. addGroup(group: SelectorGroup): void;
  68890. /** Remove the group from the given position
  68891. * @param groupNb is the position of the group in the list
  68892. */
  68893. removeGroup(groupNb: number): void;
  68894. /** Change a group header label
  68895. * @param label is the new group header label
  68896. * @param groupNb is the number of the group to relabel
  68897. * */
  68898. setHeaderName(label: string, groupNb: number): void;
  68899. /** Change selector label to the one given
  68900. * @param label is the new selector label
  68901. * @param groupNb is the number of the groupcontaining the selector
  68902. * @param selectorNb is the number of the selector within a group to relabel
  68903. * */
  68904. relabel(label: string, groupNb: number, selectorNb: number): void;
  68905. /** For a given group position remove the selector at the given position
  68906. * @param groupNb is the number of the group to remove the selector from
  68907. * @param selectorNb is the number of the selector within the group
  68908. */
  68909. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  68910. /** For a given group position of correct type add a checkbox button
  68911. * @param groupNb is the number of the group to remove the selector from
  68912. * @param label is the label for the selector
  68913. * @param func is the function called when the Selector is checked
  68914. * @param checked is true when Selector is checked
  68915. */
  68916. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  68917. /** For a given group position of correct type add a radio button
  68918. * @param groupNb is the number of the group to remove the selector from
  68919. * @param label is the label for the selector
  68920. * @param func is the function called when the Selector is checked
  68921. * @param checked is true when Selector is checked
  68922. */
  68923. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  68924. /**
  68925. * For a given slider group add a slider
  68926. * @param groupNb is the number of the group to add the slider to
  68927. * @param label is the label for the Slider
  68928. * @param func is the function called when the Slider moves
  68929. * @param unit is a string describing the units used, eg degrees or metres
  68930. * @param min is the minimum value for the Slider
  68931. * @param max is the maximum value for the Slider
  68932. * @param value is the start value for the Slider between min and max
  68933. * @param onVal is the function used to format the value displayed, eg radians to degrees
  68934. */
  68935. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  68936. }
  68937. }
  68938. declare module BABYLON.GUI {
  68939. /**
  68940. * Class used to hold a the container for ScrollViewer
  68941. * @hidden
  68942. */
  68943. export class _ScrollViewerWindow extends Container {
  68944. parentClientWidth: number;
  68945. parentClientHeight: number;
  68946. /**
  68947. * Creates a new ScrollViewerWindow
  68948. * @param name of ScrollViewerWindow
  68949. */
  68950. constructor(name?: string);
  68951. protected _getTypeName(): string;
  68952. /** @hidden */
  68953. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68954. protected _postMeasure(): void;
  68955. }
  68956. }
  68957. declare module BABYLON.GUI {
  68958. /**
  68959. * Class used to create slider controls
  68960. */
  68961. export class ScrollBar extends BaseSlider {
  68962. name?: string | undefined;
  68963. private _background;
  68964. private _borderColor;
  68965. private _tempMeasure;
  68966. /** Gets or sets border color */
  68967. borderColor: string;
  68968. /** Gets or sets background color */
  68969. background: string;
  68970. /**
  68971. * Creates a new Slider
  68972. * @param name defines the control name
  68973. */
  68974. constructor(name?: string | undefined);
  68975. protected _getTypeName(): string;
  68976. protected _getThumbThickness(): number;
  68977. _draw(context: CanvasRenderingContext2D): void;
  68978. private _first;
  68979. private _originX;
  68980. private _originY;
  68981. /** @hidden */
  68982. protected _updateValueFromPointer(x: number, y: number): void;
  68983. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68984. }
  68985. }
  68986. declare module BABYLON.GUI {
  68987. /**
  68988. * Class used to create slider controls
  68989. */
  68990. export class ImageScrollBar extends BaseSlider {
  68991. name?: string | undefined;
  68992. private _backgroundBaseImage;
  68993. private _backgroundImage;
  68994. private _thumbImage;
  68995. private _thumbBaseImage;
  68996. private _thumbLength;
  68997. private _thumbHeight;
  68998. private _barImageHeight;
  68999. private _tempMeasure;
  69000. /**
  69001. * Gets or sets the image used to render the background for horizontal bar
  69002. */
  69003. backgroundImage: Image;
  69004. /**
  69005. * Gets or sets the image used to render the thumb
  69006. */
  69007. thumbImage: Image;
  69008. /**
  69009. * Gets or sets the length of the thumb
  69010. */
  69011. thumbLength: number;
  69012. /**
  69013. * Gets or sets the height of the thumb
  69014. */
  69015. thumbHeight: number;
  69016. /**
  69017. * Gets or sets the height of the bar image
  69018. */
  69019. barImageHeight: number;
  69020. /**
  69021. * Creates a new ImageScrollBar
  69022. * @param name defines the control name
  69023. */
  69024. constructor(name?: string | undefined);
  69025. protected _getTypeName(): string;
  69026. protected _getThumbThickness(): number;
  69027. _draw(context: CanvasRenderingContext2D): void;
  69028. private _first;
  69029. private _originX;
  69030. private _originY;
  69031. /** @hidden */
  69032. protected _updateValueFromPointer(x: number, y: number): void;
  69033. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69034. }
  69035. }
  69036. declare module BABYLON.GUI {
  69037. /**
  69038. * Class used to hold a viewer window and sliders in a grid
  69039. */
  69040. export class ScrollViewer extends Rectangle {
  69041. private _grid;
  69042. private _horizontalBarSpace;
  69043. private _verticalBarSpace;
  69044. private _dragSpace;
  69045. private _horizontalBar;
  69046. private _verticalBar;
  69047. private _barColor;
  69048. private _barBackground;
  69049. private _barImage;
  69050. private _barBackgroundImage;
  69051. private _barSize;
  69052. private _endLeft;
  69053. private _endTop;
  69054. private _window;
  69055. private _pointerIsOver;
  69056. private _wheelPrecision;
  69057. private _onPointerObserver;
  69058. private _clientWidth;
  69059. private _clientHeight;
  69060. private _useImageBar;
  69061. private _thumbLength;
  69062. private _thumbHeight;
  69063. private _barImageHeight;
  69064. /**
  69065. * Gets the horizontal scrollbar
  69066. */
  69067. readonly horizontalBar: ScrollBar | ImageScrollBar;
  69068. /**
  69069. * Gets the vertical scrollbar
  69070. */
  69071. readonly verticalBar: ScrollBar | ImageScrollBar;
  69072. /**
  69073. * Adds a new control to the current container
  69074. * @param control defines the control to add
  69075. * @returns the current container
  69076. */
  69077. addControl(control: BABYLON.Nullable<Control>): Container;
  69078. /**
  69079. * Removes a control from the current container
  69080. * @param control defines the control to remove
  69081. * @returns the current container
  69082. */
  69083. removeControl(control: Control): Container;
  69084. /** Gets the list of children */
  69085. readonly children: Control[];
  69086. _flagDescendantsAsMatrixDirty(): void;
  69087. /**
  69088. * Creates a new ScrollViewer
  69089. * @param name of ScrollViewer
  69090. */
  69091. constructor(name?: string, isImageBased?: boolean);
  69092. /** Reset the scroll viewer window to initial size */
  69093. resetWindow(): void;
  69094. protected _getTypeName(): string;
  69095. private _buildClientSizes;
  69096. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69097. protected _postMeasure(): void;
  69098. /**
  69099. * Gets or sets the mouse wheel precision
  69100. * from 0 to 1 with a default value of 0.05
  69101. * */
  69102. wheelPrecision: number;
  69103. /** Gets or sets the scroll bar container background color */
  69104. scrollBackground: string;
  69105. /** Gets or sets the bar color */
  69106. barColor: string;
  69107. /** Gets or sets the bar image */
  69108. thumbImage: Image;
  69109. /** Gets or sets the size of the bar */
  69110. barSize: number;
  69111. /** Gets or sets the length of the thumb */
  69112. thumbLength: number;
  69113. /** Gets or sets the height of the thumb */
  69114. thumbHeight: number;
  69115. /** Gets or sets the height of the bar image */
  69116. barImageHeight: number;
  69117. /** Gets or sets the bar background */
  69118. barBackground: string;
  69119. /** Gets or sets the bar background image */
  69120. barImage: Image;
  69121. /** @hidden */
  69122. private _updateScroller;
  69123. _link(host: AdvancedDynamicTexture): void;
  69124. /** @hidden */
  69125. private _addBar;
  69126. /** @hidden */
  69127. private _attachWheel;
  69128. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69129. /** Releases associated resources */
  69130. dispose(): void;
  69131. }
  69132. }
  69133. declare module BABYLON.GUI {
  69134. /** Class used to render a grid */
  69135. export class DisplayGrid extends Control {
  69136. name?: string | undefined;
  69137. private _cellWidth;
  69138. private _cellHeight;
  69139. private _minorLineTickness;
  69140. private _minorLineColor;
  69141. private _majorLineTickness;
  69142. private _majorLineColor;
  69143. private _majorLineFrequency;
  69144. private _background;
  69145. private _displayMajorLines;
  69146. private _displayMinorLines;
  69147. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  69148. displayMinorLines: boolean;
  69149. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  69150. displayMajorLines: boolean;
  69151. /** Gets or sets background color (Black by default) */
  69152. background: string;
  69153. /** Gets or sets the width of each cell (20 by default) */
  69154. cellWidth: number;
  69155. /** Gets or sets the height of each cell (20 by default) */
  69156. cellHeight: number;
  69157. /** Gets or sets the tickness of minor lines (1 by default) */
  69158. minorLineTickness: number;
  69159. /** Gets or sets the color of minor lines (DarkGray by default) */
  69160. minorLineColor: string;
  69161. /** Gets or sets the tickness of major lines (2 by default) */
  69162. majorLineTickness: number;
  69163. /** Gets or sets the color of major lines (White by default) */
  69164. majorLineColor: string;
  69165. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  69166. majorLineFrequency: number;
  69167. /**
  69168. * Creates a new GridDisplayRectangle
  69169. * @param name defines the control name
  69170. */
  69171. constructor(name?: string | undefined);
  69172. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69173. protected _getTypeName(): string;
  69174. }
  69175. }
  69176. declare module BABYLON.GUI {
  69177. /**
  69178. * Class used to create slider controls based on images
  69179. */
  69180. export class ImageBasedSlider extends BaseSlider {
  69181. name?: string | undefined;
  69182. private _backgroundImage;
  69183. private _thumbImage;
  69184. private _valueBarImage;
  69185. private _tempMeasure;
  69186. displayThumb: boolean;
  69187. /**
  69188. * Gets or sets the image used to render the background
  69189. */
  69190. backgroundImage: Image;
  69191. /**
  69192. * Gets or sets the image used to render the value bar
  69193. */
  69194. valueBarImage: Image;
  69195. /**
  69196. * Gets or sets the image used to render the thumb
  69197. */
  69198. thumbImage: Image;
  69199. /**
  69200. * Creates a new ImageBasedSlider
  69201. * @param name defines the control name
  69202. */
  69203. constructor(name?: string | undefined);
  69204. protected _getTypeName(): string;
  69205. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69206. }
  69207. }
  69208. declare module BABYLON.GUI {
  69209. /**
  69210. * Forcing an export so that this code will execute
  69211. * @hidden
  69212. */
  69213. const name = "Statics";
  69214. }
  69215. declare module BABYLON.GUI {
  69216. /**
  69217. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  69218. */
  69219. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  69220. /**
  69221. * Define the instrumented AdvancedDynamicTexture.
  69222. */
  69223. texture: AdvancedDynamicTexture;
  69224. private _captureRenderTime;
  69225. private _renderTime;
  69226. private _captureLayoutTime;
  69227. private _layoutTime;
  69228. private _onBeginRenderObserver;
  69229. private _onEndRenderObserver;
  69230. private _onBeginLayoutObserver;
  69231. private _onEndLayoutObserver;
  69232. /**
  69233. * Gets the perf counter used to capture render time
  69234. */
  69235. readonly renderTimeCounter: BABYLON.PerfCounter;
  69236. /**
  69237. * Gets the perf counter used to capture layout time
  69238. */
  69239. readonly layoutTimeCounter: BABYLON.PerfCounter;
  69240. /**
  69241. * Enable or disable the render time capture
  69242. */
  69243. captureRenderTime: boolean;
  69244. /**
  69245. * Enable or disable the layout time capture
  69246. */
  69247. captureLayoutTime: boolean;
  69248. /**
  69249. * Instantiates a new advanced dynamic texture instrumentation.
  69250. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  69251. * @param texture Defines the AdvancedDynamicTexture to instrument
  69252. */
  69253. constructor(
  69254. /**
  69255. * Define the instrumented AdvancedDynamicTexture.
  69256. */
  69257. texture: AdvancedDynamicTexture);
  69258. /**
  69259. * Dispose and release associated resources.
  69260. */
  69261. dispose(): void;
  69262. }
  69263. }
  69264. declare module BABYLON.GUI {
  69265. /**
  69266. * Class used to load GUI via XML.
  69267. */
  69268. export class XmlLoader {
  69269. private _nodes;
  69270. private _nodeTypes;
  69271. private _isLoaded;
  69272. private _objectAttributes;
  69273. private _parentClass;
  69274. /**
  69275. * Create a new xml loader
  69276. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  69277. */
  69278. constructor(parentClass?: null);
  69279. private _getChainElement;
  69280. private _getClassAttribute;
  69281. private _createGuiElement;
  69282. private _parseGrid;
  69283. private _parseElement;
  69284. private _prepareSourceElement;
  69285. private _parseElementsFromSource;
  69286. private _parseXml;
  69287. /**
  69288. * Gets if the loading has finished.
  69289. * @returns whether the loading has finished or not
  69290. */
  69291. isLoaded(): boolean;
  69292. /**
  69293. * Gets a loaded node / control by id.
  69294. * @param id the Controls id set in the xml
  69295. * @returns element of type Control
  69296. */
  69297. getNodeById(id: string): any;
  69298. /**
  69299. * Gets all loaded nodes / controls
  69300. * @returns Array of controls
  69301. */
  69302. getNodes(): any;
  69303. /**
  69304. * Initiates the xml layout loading
  69305. * @param xmlFile defines the xml layout to load
  69306. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  69307. * @param callback defines the callback called on layout load.
  69308. */
  69309. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  69310. }
  69311. }
  69312. declare module BABYLON.GUI {
  69313. /**
  69314. * Class used to create containers for controls
  69315. */
  69316. export class Container3D extends Control3D {
  69317. private _blockLayout;
  69318. /**
  69319. * Gets the list of child controls
  69320. */
  69321. protected _children: Control3D[];
  69322. /**
  69323. * Gets the list of child controls
  69324. */
  69325. readonly children: Array<Control3D>;
  69326. /**
  69327. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  69328. * This is helpful to optimize layout operation when adding multiple children in a row
  69329. */
  69330. blockLayout: boolean;
  69331. /**
  69332. * Creates a new container
  69333. * @param name defines the container name
  69334. */
  69335. constructor(name?: string);
  69336. /**
  69337. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  69338. * @returns the current container
  69339. */
  69340. updateLayout(): Container3D;
  69341. /**
  69342. * Gets a boolean indicating if the given control is in the children of this control
  69343. * @param control defines the control to check
  69344. * @returns true if the control is in the child list
  69345. */
  69346. containsControl(control: Control3D): boolean;
  69347. /**
  69348. * Adds a control to the children of this control
  69349. * @param control defines the control to add
  69350. * @returns the current container
  69351. */
  69352. addControl(control: Control3D): Container3D;
  69353. /**
  69354. * This function will be called everytime a new control is added
  69355. */
  69356. protected _arrangeChildren(): void;
  69357. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  69358. /**
  69359. * Removes a control from the children of this control
  69360. * @param control defines the control to remove
  69361. * @returns the current container
  69362. */
  69363. removeControl(control: Control3D): Container3D;
  69364. protected _getTypeName(): string;
  69365. /**
  69366. * Releases all associated resources
  69367. */
  69368. dispose(): void;
  69369. /** Control rotation will remain unchanged */
  69370. static readonly UNSET_ORIENTATION: number;
  69371. /** Control will rotate to make it look at sphere central axis */
  69372. static readonly FACEORIGIN_ORIENTATION: number;
  69373. /** Control will rotate to make it look back at sphere central axis */
  69374. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  69375. /** Control will rotate to look at z axis (0, 0, 1) */
  69376. static readonly FACEFORWARD_ORIENTATION: number;
  69377. /** Control will rotate to look at negative z axis (0, 0, -1) */
  69378. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  69379. }
  69380. }
  69381. declare module BABYLON.GUI {
  69382. /**
  69383. * Class used to manage 3D user interface
  69384. * @see http://doc.babylonjs.com/how_to/gui3d
  69385. */
  69386. export class GUI3DManager implements BABYLON.IDisposable {
  69387. private _scene;
  69388. private _sceneDisposeObserver;
  69389. private _utilityLayer;
  69390. private _rootContainer;
  69391. private _pointerObserver;
  69392. private _pointerOutObserver;
  69393. /** @hidden */
  69394. _lastPickedControl: Control3D;
  69395. /** @hidden */
  69396. _lastControlOver: {
  69397. [pointerId: number]: Control3D;
  69398. };
  69399. /** @hidden */
  69400. _lastControlDown: {
  69401. [pointerId: number]: Control3D;
  69402. };
  69403. /**
  69404. * BABYLON.Observable raised when the point picked by the pointer events changed
  69405. */
  69406. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  69407. /** @hidden */
  69408. _sharedMaterials: {
  69409. [key: string]: BABYLON.Material;
  69410. };
  69411. /** Gets the hosting scene */
  69412. readonly scene: BABYLON.Scene;
  69413. /** Gets associated utility layer */
  69414. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  69415. /**
  69416. * Creates a new GUI3DManager
  69417. * @param scene
  69418. */
  69419. constructor(scene?: BABYLON.Scene);
  69420. private _handlePointerOut;
  69421. private _doPicking;
  69422. /**
  69423. * Gets the root container
  69424. */
  69425. readonly rootContainer: Container3D;
  69426. /**
  69427. * Gets a boolean indicating if the given control is in the root child list
  69428. * @param control defines the control to check
  69429. * @returns true if the control is in the root child list
  69430. */
  69431. containsControl(control: Control3D): boolean;
  69432. /**
  69433. * Adds a control to the root child list
  69434. * @param control defines the control to add
  69435. * @returns the current manager
  69436. */
  69437. addControl(control: Control3D): GUI3DManager;
  69438. /**
  69439. * Removes a control from the root child list
  69440. * @param control defines the control to remove
  69441. * @returns the current container
  69442. */
  69443. removeControl(control: Control3D): GUI3DManager;
  69444. /**
  69445. * Releases all associated resources
  69446. */
  69447. dispose(): void;
  69448. }
  69449. }
  69450. declare module BABYLON.GUI {
  69451. /**
  69452. * Class used to transport BABYLON.Vector3 information for pointer events
  69453. */
  69454. export class Vector3WithInfo extends BABYLON.Vector3 {
  69455. /** defines the current mouse button index */
  69456. buttonIndex: number;
  69457. /**
  69458. * Creates a new Vector3WithInfo
  69459. * @param source defines the vector3 data to transport
  69460. * @param buttonIndex defines the current mouse button index
  69461. */
  69462. constructor(source: BABYLON.Vector3,
  69463. /** defines the current mouse button index */
  69464. buttonIndex?: number);
  69465. }
  69466. }
  69467. declare module BABYLON.GUI {
  69468. /**
  69469. * Class used as base class for controls
  69470. */
  69471. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  69472. /** Defines the control name */
  69473. name?: string | undefined;
  69474. /** @hidden */
  69475. _host: GUI3DManager;
  69476. private _node;
  69477. private _downCount;
  69478. private _enterCount;
  69479. private _downPointerIds;
  69480. private _isVisible;
  69481. /** Gets or sets the control position in world space */
  69482. position: BABYLON.Vector3;
  69483. /** Gets or sets the control scaling in world space */
  69484. scaling: BABYLON.Vector3;
  69485. /** Callback used to start pointer enter animation */
  69486. pointerEnterAnimation: () => void;
  69487. /** Callback used to start pointer out animation */
  69488. pointerOutAnimation: () => void;
  69489. /** Callback used to start pointer down animation */
  69490. pointerDownAnimation: () => void;
  69491. /** Callback used to start pointer up animation */
  69492. pointerUpAnimation: () => void;
  69493. /**
  69494. * An event triggered when the pointer move over the control
  69495. */
  69496. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  69497. /**
  69498. * An event triggered when the pointer move out of the control
  69499. */
  69500. onPointerOutObservable: BABYLON.Observable<Control3D>;
  69501. /**
  69502. * An event triggered when the pointer taps the control
  69503. */
  69504. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  69505. /**
  69506. * An event triggered when pointer is up
  69507. */
  69508. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  69509. /**
  69510. * An event triggered when a control is clicked on (with a mouse)
  69511. */
  69512. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  69513. /**
  69514. * An event triggered when pointer enters the control
  69515. */
  69516. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  69517. /**
  69518. * Gets or sets the parent container
  69519. */
  69520. parent: BABYLON.Nullable<Container3D>;
  69521. private _behaviors;
  69522. /**
  69523. * Gets the list of attached behaviors
  69524. * @see http://doc.babylonjs.com/features/behaviour
  69525. */
  69526. readonly behaviors: BABYLON.Behavior<Control3D>[];
  69527. /**
  69528. * Attach a behavior to the control
  69529. * @see http://doc.babylonjs.com/features/behaviour
  69530. * @param behavior defines the behavior to attach
  69531. * @returns the current control
  69532. */
  69533. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  69534. /**
  69535. * Remove an attached behavior
  69536. * @see http://doc.babylonjs.com/features/behaviour
  69537. * @param behavior defines the behavior to attach
  69538. * @returns the current control
  69539. */
  69540. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  69541. /**
  69542. * Gets an attached behavior by name
  69543. * @param name defines the name of the behavior to look for
  69544. * @see http://doc.babylonjs.com/features/behaviour
  69545. * @returns null if behavior was not found else the requested behavior
  69546. */
  69547. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  69548. /** Gets or sets a boolean indicating if the control is visible */
  69549. isVisible: boolean;
  69550. /**
  69551. * Creates a new control
  69552. * @param name defines the control name
  69553. */
  69554. constructor(
  69555. /** Defines the control name */
  69556. name?: string | undefined);
  69557. /**
  69558. * Gets a string representing the class name
  69559. */
  69560. readonly typeName: string;
  69561. /**
  69562. * Get the current class name of the control.
  69563. * @returns current class name
  69564. */
  69565. getClassName(): string;
  69566. protected _getTypeName(): string;
  69567. /**
  69568. * Gets the transform node used by this control
  69569. */
  69570. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  69571. /**
  69572. * Gets the mesh used to render this control
  69573. */
  69574. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  69575. /**
  69576. * Link the control as child of the given node
  69577. * @param node defines the node to link to. Use null to unlink the control
  69578. * @returns the current control
  69579. */
  69580. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  69581. /** @hidden **/
  69582. _prepareNode(scene: BABYLON.Scene): void;
  69583. /**
  69584. * Node creation.
  69585. * Can be overriden by children
  69586. * @param scene defines the scene where the node must be attached
  69587. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  69588. */
  69589. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  69590. /**
  69591. * Affect a material to the given mesh
  69592. * @param mesh defines the mesh which will represent the control
  69593. */
  69594. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69595. /** @hidden */
  69596. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  69597. /** @hidden */
  69598. _onPointerEnter(target: Control3D): boolean;
  69599. /** @hidden */
  69600. _onPointerOut(target: Control3D): void;
  69601. /** @hidden */
  69602. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  69603. /** @hidden */
  69604. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69605. /** @hidden */
  69606. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  69607. /** @hidden */
  69608. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  69609. /** @hidden */
  69610. _disposeNode(): void;
  69611. /**
  69612. * Releases all associated resources
  69613. */
  69614. dispose(): void;
  69615. }
  69616. }
  69617. declare module BABYLON.GUI {
  69618. /**
  69619. * Class used as a root to all buttons
  69620. */
  69621. export class AbstractButton3D extends Control3D {
  69622. /**
  69623. * Creates a new button
  69624. * @param name defines the control name
  69625. */
  69626. constructor(name?: string);
  69627. protected _getTypeName(): string;
  69628. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69629. }
  69630. }
  69631. declare module BABYLON.GUI {
  69632. /**
  69633. * Class used to create a button in 3D
  69634. */
  69635. export class Button3D extends AbstractButton3D {
  69636. /** @hidden */
  69637. protected _currentMaterial: BABYLON.Material;
  69638. private _facadeTexture;
  69639. private _content;
  69640. private _contentResolution;
  69641. private _contentScaleRatio;
  69642. /**
  69643. * Gets or sets the texture resolution used to render content (512 by default)
  69644. */
  69645. contentResolution: BABYLON.int;
  69646. /**
  69647. * Gets or sets the texture scale ratio used to render content (2 by default)
  69648. */
  69649. contentScaleRatio: number;
  69650. protected _disposeFacadeTexture(): void;
  69651. protected _resetContent(): void;
  69652. /**
  69653. * Creates a new button
  69654. * @param name defines the control name
  69655. */
  69656. constructor(name?: string);
  69657. /**
  69658. * Gets or sets the GUI 2D content used to display the button's facade
  69659. */
  69660. content: Control;
  69661. /**
  69662. * Apply the facade texture (created from the content property).
  69663. * This function can be overloaded by child classes
  69664. * @param facadeTexture defines the AdvancedDynamicTexture to use
  69665. */
  69666. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  69667. protected _getTypeName(): string;
  69668. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69669. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69670. /**
  69671. * Releases all associated resources
  69672. */
  69673. dispose(): void;
  69674. }
  69675. }
  69676. declare module BABYLON.GUI {
  69677. /**
  69678. * Abstract class used to create a container panel deployed on the surface of a volume
  69679. */
  69680. export abstract class VolumeBasedPanel extends Container3D {
  69681. private _columns;
  69682. private _rows;
  69683. private _rowThenColum;
  69684. private _orientation;
  69685. protected _cellWidth: number;
  69686. protected _cellHeight: number;
  69687. /**
  69688. * Gets or sets the distance between elements
  69689. */
  69690. margin: number;
  69691. /**
  69692. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  69693. * | Value | Type | Description |
  69694. * | ----- | ----------------------------------- | ----------- |
  69695. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  69696. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  69697. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  69698. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  69699. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  69700. */
  69701. orientation: number;
  69702. /**
  69703. * Gets or sets the number of columns requested (10 by default).
  69704. * The panel will automatically compute the number of rows based on number of child controls.
  69705. */
  69706. columns: BABYLON.int;
  69707. /**
  69708. * Gets or sets a the number of rows requested.
  69709. * The panel will automatically compute the number of columns based on number of child controls.
  69710. */
  69711. rows: BABYLON.int;
  69712. /**
  69713. * Creates new VolumeBasedPanel
  69714. */
  69715. constructor();
  69716. protected _arrangeChildren(): void;
  69717. /** Child classes must implement this function to provide correct control positioning */
  69718. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69719. /** Child classes can implement this function to provide additional processing */
  69720. protected _finalProcessing(): void;
  69721. }
  69722. }
  69723. declare module BABYLON.GUI {
  69724. /**
  69725. * Class used to create a container panel deployed on the surface of a cylinder
  69726. */
  69727. export class CylinderPanel extends VolumeBasedPanel {
  69728. private _radius;
  69729. /**
  69730. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  69731. */
  69732. radius: BABYLON.float;
  69733. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69734. private _cylindricalMapping;
  69735. }
  69736. }
  69737. declare module BABYLON.GUI {
  69738. /** @hidden */
  69739. export var fluentVertexShader: {
  69740. name: string;
  69741. shader: string;
  69742. };
  69743. }
  69744. declare module BABYLON.GUI {
  69745. /** @hidden */
  69746. export var fluentPixelShader: {
  69747. name: string;
  69748. shader: string;
  69749. };
  69750. }
  69751. declare module BABYLON.GUI {
  69752. /** @hidden */
  69753. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  69754. INNERGLOW: boolean;
  69755. BORDER: boolean;
  69756. HOVERLIGHT: boolean;
  69757. TEXTURE: boolean;
  69758. constructor();
  69759. }
  69760. /**
  69761. * Class used to render controls with fluent desgin
  69762. */
  69763. export class FluentMaterial extends BABYLON.PushMaterial {
  69764. /**
  69765. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  69766. */
  69767. innerGlowColorIntensity: number;
  69768. /**
  69769. * Gets or sets the inner glow color (white by default)
  69770. */
  69771. innerGlowColor: BABYLON.Color3;
  69772. /**
  69773. * Gets or sets alpha value (default is 1.0)
  69774. */
  69775. alpha: number;
  69776. /**
  69777. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  69778. */
  69779. albedoColor: BABYLON.Color3;
  69780. /**
  69781. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  69782. */
  69783. renderBorders: boolean;
  69784. /**
  69785. * Gets or sets border width (default is 0.5)
  69786. */
  69787. borderWidth: number;
  69788. /**
  69789. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  69790. */
  69791. edgeSmoothingValue: number;
  69792. /**
  69793. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  69794. */
  69795. borderMinValue: number;
  69796. /**
  69797. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  69798. */
  69799. renderHoverLight: boolean;
  69800. /**
  69801. * Gets or sets the radius used to render the hover light (default is 1.0)
  69802. */
  69803. hoverRadius: number;
  69804. /**
  69805. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  69806. */
  69807. hoverColor: BABYLON.Color4;
  69808. /**
  69809. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  69810. */
  69811. hoverPosition: BABYLON.Vector3;
  69812. private _albedoTexture;
  69813. /** Gets or sets the texture to use for albedo color */
  69814. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69815. /**
  69816. * Creates a new Fluent material
  69817. * @param name defines the name of the material
  69818. * @param scene defines the hosting scene
  69819. */
  69820. constructor(name: string, scene: BABYLON.Scene);
  69821. needAlphaBlending(): boolean;
  69822. needAlphaTesting(): boolean;
  69823. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69824. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69825. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69826. getActiveTextures(): BABYLON.BaseTexture[];
  69827. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69828. dispose(forceDisposeEffect?: boolean): void;
  69829. clone(name: string): FluentMaterial;
  69830. serialize(): any;
  69831. getClassName(): string;
  69832. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  69833. }
  69834. }
  69835. declare module BABYLON.GUI {
  69836. /**
  69837. * Class used to create a holographic button in 3D
  69838. */
  69839. export class HolographicButton extends Button3D {
  69840. private _backPlate;
  69841. private _textPlate;
  69842. private _frontPlate;
  69843. private _text;
  69844. private _imageUrl;
  69845. private _shareMaterials;
  69846. private _frontMaterial;
  69847. private _backMaterial;
  69848. private _plateMaterial;
  69849. private _pickedPointObserver;
  69850. private _tooltipFade;
  69851. private _tooltipTextBlock;
  69852. private _tooltipTexture;
  69853. private _tooltipMesh;
  69854. private _tooltipHoverObserver;
  69855. private _tooltipOutObserver;
  69856. private _disposeTooltip;
  69857. /**
  69858. * Rendering ground id of all the mesh in the button
  69859. */
  69860. renderingGroupId: number;
  69861. /**
  69862. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  69863. */
  69864. tooltipText: BABYLON.Nullable<string>;
  69865. /**
  69866. * Gets or sets text for the button
  69867. */
  69868. text: string;
  69869. /**
  69870. * Gets or sets the image url for the button
  69871. */
  69872. imageUrl: string;
  69873. /**
  69874. * Gets the back material used by this button
  69875. */
  69876. readonly backMaterial: FluentMaterial;
  69877. /**
  69878. * Gets the front material used by this button
  69879. */
  69880. readonly frontMaterial: FluentMaterial;
  69881. /**
  69882. * Gets the plate material used by this button
  69883. */
  69884. readonly plateMaterial: BABYLON.StandardMaterial;
  69885. /**
  69886. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  69887. */
  69888. readonly shareMaterials: boolean;
  69889. /**
  69890. * Creates a new button
  69891. * @param name defines the control name
  69892. */
  69893. constructor(name?: string, shareMaterials?: boolean);
  69894. protected _getTypeName(): string;
  69895. private _rebuildContent;
  69896. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69897. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  69898. private _createBackMaterial;
  69899. private _createFrontMaterial;
  69900. private _createPlateMaterial;
  69901. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  69902. /**
  69903. * Releases all associated resources
  69904. */
  69905. dispose(): void;
  69906. }
  69907. }
  69908. declare module BABYLON.GUI {
  69909. /**
  69910. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  69911. */
  69912. export class MeshButton3D extends Button3D {
  69913. /** @hidden */
  69914. protected _currentMesh: BABYLON.Mesh;
  69915. /**
  69916. * Creates a new 3D button based on a mesh
  69917. * @param mesh mesh to become a 3D button
  69918. * @param name defines the control name
  69919. */
  69920. constructor(mesh: BABYLON.Mesh, name?: string);
  69921. protected _getTypeName(): string;
  69922. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69923. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69924. }
  69925. }
  69926. declare module BABYLON.GUI {
  69927. /**
  69928. * Class used to create a container panel deployed on the surface of a plane
  69929. */
  69930. export class PlanePanel extends VolumeBasedPanel {
  69931. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69932. }
  69933. }
  69934. declare module BABYLON.GUI {
  69935. /**
  69936. * Class used to create a container panel where items get randomized planar mapping
  69937. */
  69938. export class ScatterPanel extends VolumeBasedPanel {
  69939. private _iteration;
  69940. /**
  69941. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  69942. */
  69943. iteration: BABYLON.float;
  69944. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69945. private _scatterMapping;
  69946. protected _finalProcessing(): void;
  69947. }
  69948. }
  69949. declare module BABYLON.GUI {
  69950. /**
  69951. * Class used to create a container panel deployed on the surface of a sphere
  69952. */
  69953. export class SpherePanel extends VolumeBasedPanel {
  69954. private _radius;
  69955. /**
  69956. * Gets or sets the radius of the sphere where to project controls (5 by default)
  69957. */
  69958. radius: BABYLON.float;
  69959. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69960. private _sphericalMapping;
  69961. }
  69962. }
  69963. declare module BABYLON.GUI {
  69964. /**
  69965. * Class used to create a stack panel in 3D on XY plane
  69966. */
  69967. export class StackPanel3D extends Container3D {
  69968. private _isVertical;
  69969. /**
  69970. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  69971. */
  69972. isVertical: boolean;
  69973. /**
  69974. * Gets or sets the distance between elements
  69975. */
  69976. margin: number;
  69977. /**
  69978. * Creates new StackPanel
  69979. * @param isVertical
  69980. */
  69981. constructor(isVertical?: boolean);
  69982. protected _arrangeChildren(): void;
  69983. }
  69984. }
  69985. declare module BABYLON {
  69986. /**
  69987. * Mode that determines the coordinate system to use.
  69988. */
  69989. export enum GLTFLoaderCoordinateSystemMode {
  69990. /**
  69991. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  69992. */
  69993. AUTO = 0,
  69994. /**
  69995. * Sets the useRightHandedSystem flag on the scene.
  69996. */
  69997. FORCE_RIGHT_HANDED = 1
  69998. }
  69999. /**
  70000. * Mode that determines what animations will start.
  70001. */
  70002. export enum GLTFLoaderAnimationStartMode {
  70003. /**
  70004. * No animation will start.
  70005. */
  70006. NONE = 0,
  70007. /**
  70008. * The first animation will start.
  70009. */
  70010. FIRST = 1,
  70011. /**
  70012. * All animations will start.
  70013. */
  70014. ALL = 2
  70015. }
  70016. /**
  70017. * Interface that contains the data for the glTF asset.
  70018. */
  70019. export interface IGLTFLoaderData {
  70020. /**
  70021. * The object that represents the glTF JSON.
  70022. */
  70023. json: Object;
  70024. /**
  70025. * The BIN chunk of a binary glTF.
  70026. */
  70027. bin: Nullable<IDataBuffer>;
  70028. }
  70029. /**
  70030. * Interface for extending the loader.
  70031. */
  70032. export interface IGLTFLoaderExtension {
  70033. /**
  70034. * The name of this extension.
  70035. */
  70036. readonly name: string;
  70037. /**
  70038. * Defines whether this extension is enabled.
  70039. */
  70040. enabled: boolean;
  70041. /**
  70042. * Defines the order of this extension.
  70043. * The loader sorts the extensions using these values when loading.
  70044. */
  70045. order?: number;
  70046. }
  70047. /**
  70048. * Loader state.
  70049. */
  70050. export enum GLTFLoaderState {
  70051. /**
  70052. * The asset is loading.
  70053. */
  70054. LOADING = 0,
  70055. /**
  70056. * The asset is ready for rendering.
  70057. */
  70058. READY = 1,
  70059. /**
  70060. * The asset is completely loaded.
  70061. */
  70062. COMPLETE = 2
  70063. }
  70064. /** @hidden */
  70065. export interface IGLTFLoader extends IDisposable {
  70066. readonly state: Nullable<GLTFLoaderState>;
  70067. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  70068. meshes: AbstractMesh[];
  70069. particleSystems: IParticleSystem[];
  70070. skeletons: Skeleton[];
  70071. animationGroups: AnimationGroup[];
  70072. }>;
  70073. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  70074. }
  70075. /**
  70076. * File loader for loading glTF files into a scene.
  70077. */
  70078. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70079. /** @hidden */
  70080. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  70081. /** @hidden */
  70082. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  70083. /**
  70084. * Raised when the asset has been parsed
  70085. */
  70086. onParsedObservable: Observable<IGLTFLoaderData>;
  70087. private _onParsedObserver;
  70088. /**
  70089. * Raised when the asset has been parsed
  70090. */
  70091. onParsed: (loaderData: IGLTFLoaderData) => void;
  70092. /**
  70093. * 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.
  70094. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  70095. * Defaults to true.
  70096. * @hidden
  70097. */
  70098. static IncrementalLoading: boolean;
  70099. /**
  70100. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  70101. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  70102. * @hidden
  70103. */
  70104. static HomogeneousCoordinates: boolean;
  70105. /**
  70106. * The coordinate system mode. Defaults to AUTO.
  70107. */
  70108. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  70109. /**
  70110. * The animation start mode. Defaults to FIRST.
  70111. */
  70112. animationStartMode: GLTFLoaderAnimationStartMode;
  70113. /**
  70114. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  70115. */
  70116. compileMaterials: boolean;
  70117. /**
  70118. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  70119. */
  70120. useClipPlane: boolean;
  70121. /**
  70122. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  70123. */
  70124. compileShadowGenerators: boolean;
  70125. /**
  70126. * Defines if the Alpha blended materials are only applied as coverage.
  70127. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  70128. * If true, no extra effects are applied to transparent pixels.
  70129. */
  70130. transparencyAsCoverage: boolean;
  70131. /**
  70132. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  70133. * Enabling will disable offline support and glTF validator.
  70134. * Defaults to false.
  70135. */
  70136. useRangeRequests: boolean;
  70137. /**
  70138. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  70139. */
  70140. createInstances: boolean;
  70141. /**
  70142. * Function called before loading a url referenced by the asset.
  70143. */
  70144. preprocessUrlAsync: (url: string) => Promise<string>;
  70145. /**
  70146. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  70147. */
  70148. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  70149. private _onMeshLoadedObserver;
  70150. /**
  70151. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  70152. */
  70153. onMeshLoaded: (mesh: AbstractMesh) => void;
  70154. /**
  70155. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  70156. */
  70157. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  70158. private _onTextureLoadedObserver;
  70159. /**
  70160. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  70161. */
  70162. onTextureLoaded: (texture: BaseTexture) => void;
  70163. /**
  70164. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  70165. */
  70166. readonly onMaterialLoadedObservable: Observable<Material>;
  70167. private _onMaterialLoadedObserver;
  70168. /**
  70169. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  70170. */
  70171. onMaterialLoaded: (material: Material) => void;
  70172. /**
  70173. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  70174. */
  70175. readonly onCameraLoadedObservable: Observable<Camera>;
  70176. private _onCameraLoadedObserver;
  70177. /**
  70178. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  70179. */
  70180. onCameraLoaded: (camera: Camera) => void;
  70181. /**
  70182. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  70183. * For assets with LODs, raised when all of the LODs are complete.
  70184. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  70185. */
  70186. readonly onCompleteObservable: Observable<void>;
  70187. private _onCompleteObserver;
  70188. /**
  70189. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  70190. * For assets with LODs, raised when all of the LODs are complete.
  70191. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  70192. */
  70193. onComplete: () => void;
  70194. /**
  70195. * Observable raised when an error occurs.
  70196. */
  70197. readonly onErrorObservable: Observable<any>;
  70198. private _onErrorObserver;
  70199. /**
  70200. * Callback raised when an error occurs.
  70201. */
  70202. onError: (reason: any) => void;
  70203. /**
  70204. * Observable raised after the loader is disposed.
  70205. */
  70206. readonly onDisposeObservable: Observable<void>;
  70207. private _onDisposeObserver;
  70208. /**
  70209. * Callback raised after the loader is disposed.
  70210. */
  70211. onDispose: () => void;
  70212. /**
  70213. * Observable raised after a loader extension is created.
  70214. * Set additional options for a loader extension in this event.
  70215. */
  70216. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  70217. private _onExtensionLoadedObserver;
  70218. /**
  70219. * Callback raised after a loader extension is created.
  70220. */
  70221. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  70222. /**
  70223. * Defines if the loader logging is enabled.
  70224. */
  70225. loggingEnabled: boolean;
  70226. /**
  70227. * Defines if the loader should capture performance counters.
  70228. */
  70229. capturePerformanceCounters: boolean;
  70230. /**
  70231. * Defines if the loader should validate the asset.
  70232. */
  70233. validate: boolean;
  70234. /**
  70235. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  70236. */
  70237. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  70238. private _onValidatedObserver;
  70239. /**
  70240. * Callback raised after a loader extension is created.
  70241. */
  70242. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  70243. private _loader;
  70244. /**
  70245. * Name of the loader ("gltf")
  70246. */
  70247. name: string;
  70248. /** @hidden */
  70249. extensions: ISceneLoaderPluginExtensions;
  70250. /**
  70251. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  70252. */
  70253. dispose(): void;
  70254. /** @hidden */
  70255. _clear(): void;
  70256. /** @hidden */
  70257. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  70258. /** @hidden */
  70259. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  70260. /** @hidden */
  70261. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70262. meshes: AbstractMesh[];
  70263. particleSystems: IParticleSystem[];
  70264. skeletons: Skeleton[];
  70265. animationGroups: AnimationGroup[];
  70266. }>;
  70267. /** @hidden */
  70268. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70269. /** @hidden */
  70270. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70271. /** @hidden */
  70272. canDirectLoad(data: string): boolean;
  70273. /** @hidden */
  70274. directLoad(scene: Scene, data: string): any;
  70275. /**
  70276. * The callback that allows custom handling of the root url based on the response url.
  70277. * @param rootUrl the original root url
  70278. * @param responseURL the response url if available
  70279. * @returns the new root url
  70280. */
  70281. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  70282. /** @hidden */
  70283. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  70284. /**
  70285. * The loader state or null if the loader is not active.
  70286. */
  70287. readonly loaderState: Nullable<GLTFLoaderState>;
  70288. /**
  70289. * Returns a promise that resolves when the asset is completely loaded.
  70290. * @returns a promise that resolves when the asset is completely loaded.
  70291. */
  70292. whenCompleteAsync(): Promise<void>;
  70293. private _validateAsync;
  70294. private _getLoader;
  70295. private _parseJson;
  70296. private _unpackBinaryAsync;
  70297. private _unpackBinaryV1Async;
  70298. private _unpackBinaryV2Async;
  70299. private static _parseVersion;
  70300. private static _compareVersion;
  70301. private static readonly _logSpaces;
  70302. private _logIndentLevel;
  70303. private _loggingEnabled;
  70304. /** @hidden */
  70305. _log: (message: string) => void;
  70306. /** @hidden */
  70307. _logOpen(message: string): void;
  70308. /** @hidden */
  70309. _logClose(): void;
  70310. private _logEnabled;
  70311. private _logDisabled;
  70312. private _capturePerformanceCounters;
  70313. /** @hidden */
  70314. _startPerformanceCounter: (counterName: string) => void;
  70315. /** @hidden */
  70316. _endPerformanceCounter: (counterName: string) => void;
  70317. private _startPerformanceCounterEnabled;
  70318. private _startPerformanceCounterDisabled;
  70319. private _endPerformanceCounterEnabled;
  70320. private _endPerformanceCounterDisabled;
  70321. }
  70322. }
  70323. declare module BABYLON.GLTF1 {
  70324. /**
  70325. * Enums
  70326. * @hidden
  70327. */
  70328. export enum EComponentType {
  70329. BYTE = 5120,
  70330. UNSIGNED_BYTE = 5121,
  70331. SHORT = 5122,
  70332. UNSIGNED_SHORT = 5123,
  70333. FLOAT = 5126
  70334. }
  70335. /** @hidden */
  70336. export enum EShaderType {
  70337. FRAGMENT = 35632,
  70338. VERTEX = 35633
  70339. }
  70340. /** @hidden */
  70341. export enum EParameterType {
  70342. BYTE = 5120,
  70343. UNSIGNED_BYTE = 5121,
  70344. SHORT = 5122,
  70345. UNSIGNED_SHORT = 5123,
  70346. INT = 5124,
  70347. UNSIGNED_INT = 5125,
  70348. FLOAT = 5126,
  70349. FLOAT_VEC2 = 35664,
  70350. FLOAT_VEC3 = 35665,
  70351. FLOAT_VEC4 = 35666,
  70352. INT_VEC2 = 35667,
  70353. INT_VEC3 = 35668,
  70354. INT_VEC4 = 35669,
  70355. BOOL = 35670,
  70356. BOOL_VEC2 = 35671,
  70357. BOOL_VEC3 = 35672,
  70358. BOOL_VEC4 = 35673,
  70359. FLOAT_MAT2 = 35674,
  70360. FLOAT_MAT3 = 35675,
  70361. FLOAT_MAT4 = 35676,
  70362. SAMPLER_2D = 35678
  70363. }
  70364. /** @hidden */
  70365. export enum ETextureWrapMode {
  70366. CLAMP_TO_EDGE = 33071,
  70367. MIRRORED_REPEAT = 33648,
  70368. REPEAT = 10497
  70369. }
  70370. /** @hidden */
  70371. export enum ETextureFilterType {
  70372. NEAREST = 9728,
  70373. LINEAR = 9728,
  70374. NEAREST_MIPMAP_NEAREST = 9984,
  70375. LINEAR_MIPMAP_NEAREST = 9985,
  70376. NEAREST_MIPMAP_LINEAR = 9986,
  70377. LINEAR_MIPMAP_LINEAR = 9987
  70378. }
  70379. /** @hidden */
  70380. export enum ETextureFormat {
  70381. ALPHA = 6406,
  70382. RGB = 6407,
  70383. RGBA = 6408,
  70384. LUMINANCE = 6409,
  70385. LUMINANCE_ALPHA = 6410
  70386. }
  70387. /** @hidden */
  70388. export enum ECullingType {
  70389. FRONT = 1028,
  70390. BACK = 1029,
  70391. FRONT_AND_BACK = 1032
  70392. }
  70393. /** @hidden */
  70394. export enum EBlendingFunction {
  70395. ZERO = 0,
  70396. ONE = 1,
  70397. SRC_COLOR = 768,
  70398. ONE_MINUS_SRC_COLOR = 769,
  70399. DST_COLOR = 774,
  70400. ONE_MINUS_DST_COLOR = 775,
  70401. SRC_ALPHA = 770,
  70402. ONE_MINUS_SRC_ALPHA = 771,
  70403. DST_ALPHA = 772,
  70404. ONE_MINUS_DST_ALPHA = 773,
  70405. CONSTANT_COLOR = 32769,
  70406. ONE_MINUS_CONSTANT_COLOR = 32770,
  70407. CONSTANT_ALPHA = 32771,
  70408. ONE_MINUS_CONSTANT_ALPHA = 32772,
  70409. SRC_ALPHA_SATURATE = 776
  70410. }
  70411. /** @hidden */
  70412. export interface IGLTFProperty {
  70413. extensions?: {
  70414. [key: string]: any;
  70415. };
  70416. extras?: Object;
  70417. }
  70418. /** @hidden */
  70419. export interface IGLTFChildRootProperty extends IGLTFProperty {
  70420. name?: string;
  70421. }
  70422. /** @hidden */
  70423. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  70424. bufferView: string;
  70425. byteOffset: number;
  70426. byteStride: number;
  70427. count: number;
  70428. type: string;
  70429. componentType: EComponentType;
  70430. max?: number[];
  70431. min?: number[];
  70432. name?: string;
  70433. }
  70434. /** @hidden */
  70435. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  70436. buffer: string;
  70437. byteOffset: number;
  70438. byteLength: number;
  70439. byteStride: number;
  70440. target?: number;
  70441. }
  70442. /** @hidden */
  70443. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  70444. uri: string;
  70445. byteLength?: number;
  70446. type?: string;
  70447. }
  70448. /** @hidden */
  70449. export interface IGLTFShader extends IGLTFChildRootProperty {
  70450. uri: string;
  70451. type: EShaderType;
  70452. }
  70453. /** @hidden */
  70454. export interface IGLTFProgram extends IGLTFChildRootProperty {
  70455. attributes: string[];
  70456. fragmentShader: string;
  70457. vertexShader: string;
  70458. }
  70459. /** @hidden */
  70460. export interface IGLTFTechniqueParameter {
  70461. type: number;
  70462. count?: number;
  70463. semantic?: string;
  70464. node?: string;
  70465. value?: number | boolean | string | Array<any>;
  70466. source?: string;
  70467. babylonValue?: any;
  70468. }
  70469. /** @hidden */
  70470. export interface IGLTFTechniqueCommonProfile {
  70471. lightingModel: string;
  70472. texcoordBindings: Object;
  70473. parameters?: Array<any>;
  70474. }
  70475. /** @hidden */
  70476. export interface IGLTFTechniqueStatesFunctions {
  70477. blendColor?: number[];
  70478. blendEquationSeparate?: number[];
  70479. blendFuncSeparate?: number[];
  70480. colorMask: boolean[];
  70481. cullFace: number[];
  70482. }
  70483. /** @hidden */
  70484. export interface IGLTFTechniqueStates {
  70485. enable: number[];
  70486. functions: IGLTFTechniqueStatesFunctions;
  70487. }
  70488. /** @hidden */
  70489. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  70490. parameters: {
  70491. [key: string]: IGLTFTechniqueParameter;
  70492. };
  70493. program: string;
  70494. attributes: {
  70495. [key: string]: string;
  70496. };
  70497. uniforms: {
  70498. [key: string]: string;
  70499. };
  70500. states: IGLTFTechniqueStates;
  70501. }
  70502. /** @hidden */
  70503. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  70504. technique?: string;
  70505. values: string[];
  70506. }
  70507. /** @hidden */
  70508. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  70509. attributes: {
  70510. [key: string]: string;
  70511. };
  70512. indices: string;
  70513. material: string;
  70514. mode?: number;
  70515. }
  70516. /** @hidden */
  70517. export interface IGLTFMesh extends IGLTFChildRootProperty {
  70518. primitives: IGLTFMeshPrimitive[];
  70519. }
  70520. /** @hidden */
  70521. export interface IGLTFImage extends IGLTFChildRootProperty {
  70522. uri: string;
  70523. }
  70524. /** @hidden */
  70525. export interface IGLTFSampler extends IGLTFChildRootProperty {
  70526. magFilter?: number;
  70527. minFilter?: number;
  70528. wrapS?: number;
  70529. wrapT?: number;
  70530. }
  70531. /** @hidden */
  70532. export interface IGLTFTexture extends IGLTFChildRootProperty {
  70533. sampler: string;
  70534. source: string;
  70535. format?: ETextureFormat;
  70536. internalFormat?: ETextureFormat;
  70537. target?: number;
  70538. type?: number;
  70539. babylonTexture?: Texture;
  70540. }
  70541. /** @hidden */
  70542. export interface IGLTFAmbienLight {
  70543. color?: number[];
  70544. }
  70545. /** @hidden */
  70546. export interface IGLTFDirectionalLight {
  70547. color?: number[];
  70548. }
  70549. /** @hidden */
  70550. export interface IGLTFPointLight {
  70551. color?: number[];
  70552. constantAttenuation?: number;
  70553. linearAttenuation?: number;
  70554. quadraticAttenuation?: number;
  70555. }
  70556. /** @hidden */
  70557. export interface IGLTFSpotLight {
  70558. color?: number[];
  70559. constantAttenuation?: number;
  70560. fallOfAngle?: number;
  70561. fallOffExponent?: number;
  70562. linearAttenuation?: number;
  70563. quadraticAttenuation?: number;
  70564. }
  70565. /** @hidden */
  70566. export interface IGLTFLight extends IGLTFChildRootProperty {
  70567. type: string;
  70568. }
  70569. /** @hidden */
  70570. export interface IGLTFCameraOrthographic {
  70571. xmag: number;
  70572. ymag: number;
  70573. zfar: number;
  70574. znear: number;
  70575. }
  70576. /** @hidden */
  70577. export interface IGLTFCameraPerspective {
  70578. aspectRatio: number;
  70579. yfov: number;
  70580. zfar: number;
  70581. znear: number;
  70582. }
  70583. /** @hidden */
  70584. export interface IGLTFCamera extends IGLTFChildRootProperty {
  70585. type: string;
  70586. }
  70587. /** @hidden */
  70588. export interface IGLTFAnimationChannelTarget {
  70589. id: string;
  70590. path: string;
  70591. }
  70592. /** @hidden */
  70593. export interface IGLTFAnimationChannel {
  70594. sampler: string;
  70595. target: IGLTFAnimationChannelTarget;
  70596. }
  70597. /** @hidden */
  70598. export interface IGLTFAnimationSampler {
  70599. input: string;
  70600. output: string;
  70601. interpolation?: string;
  70602. }
  70603. /** @hidden */
  70604. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  70605. channels?: IGLTFAnimationChannel[];
  70606. parameters?: {
  70607. [key: string]: string;
  70608. };
  70609. samplers?: {
  70610. [key: string]: IGLTFAnimationSampler;
  70611. };
  70612. }
  70613. /** @hidden */
  70614. export interface IGLTFNodeInstanceSkin {
  70615. skeletons: string[];
  70616. skin: string;
  70617. meshes: string[];
  70618. }
  70619. /** @hidden */
  70620. export interface IGLTFSkins extends IGLTFChildRootProperty {
  70621. bindShapeMatrix: number[];
  70622. inverseBindMatrices: string;
  70623. jointNames: string[];
  70624. babylonSkeleton?: Skeleton;
  70625. }
  70626. /** @hidden */
  70627. export interface IGLTFNode extends IGLTFChildRootProperty {
  70628. camera?: string;
  70629. children: string[];
  70630. skin?: string;
  70631. jointName?: string;
  70632. light?: string;
  70633. matrix: number[];
  70634. mesh?: string;
  70635. meshes?: string[];
  70636. rotation?: number[];
  70637. scale?: number[];
  70638. translation?: number[];
  70639. babylonNode?: Node;
  70640. }
  70641. /** @hidden */
  70642. export interface IGLTFScene extends IGLTFChildRootProperty {
  70643. nodes: string[];
  70644. }
  70645. /** @hidden */
  70646. export interface IGLTFRuntime {
  70647. extensions: {
  70648. [key: string]: any;
  70649. };
  70650. accessors: {
  70651. [key: string]: IGLTFAccessor;
  70652. };
  70653. buffers: {
  70654. [key: string]: IGLTFBuffer;
  70655. };
  70656. bufferViews: {
  70657. [key: string]: IGLTFBufferView;
  70658. };
  70659. meshes: {
  70660. [key: string]: IGLTFMesh;
  70661. };
  70662. lights: {
  70663. [key: string]: IGLTFLight;
  70664. };
  70665. cameras: {
  70666. [key: string]: IGLTFCamera;
  70667. };
  70668. nodes: {
  70669. [key: string]: IGLTFNode;
  70670. };
  70671. images: {
  70672. [key: string]: IGLTFImage;
  70673. };
  70674. textures: {
  70675. [key: string]: IGLTFTexture;
  70676. };
  70677. shaders: {
  70678. [key: string]: IGLTFShader;
  70679. };
  70680. programs: {
  70681. [key: string]: IGLTFProgram;
  70682. };
  70683. samplers: {
  70684. [key: string]: IGLTFSampler;
  70685. };
  70686. techniques: {
  70687. [key: string]: IGLTFTechnique;
  70688. };
  70689. materials: {
  70690. [key: string]: IGLTFMaterial;
  70691. };
  70692. animations: {
  70693. [key: string]: IGLTFAnimation;
  70694. };
  70695. skins: {
  70696. [key: string]: IGLTFSkins;
  70697. };
  70698. currentScene?: Object;
  70699. scenes: {
  70700. [key: string]: IGLTFScene;
  70701. };
  70702. extensionsUsed: string[];
  70703. extensionsRequired?: string[];
  70704. buffersCount: number;
  70705. shaderscount: number;
  70706. scene: Scene;
  70707. rootUrl: string;
  70708. loadedBufferCount: number;
  70709. loadedBufferViews: {
  70710. [name: string]: ArrayBufferView;
  70711. };
  70712. loadedShaderCount: number;
  70713. importOnlyMeshes: boolean;
  70714. importMeshesNames?: string[];
  70715. dummyNodes: Node[];
  70716. }
  70717. /** @hidden */
  70718. export interface INodeToRoot {
  70719. bone: Bone;
  70720. node: IGLTFNode;
  70721. id: string;
  70722. }
  70723. /** @hidden */
  70724. export interface IJointNode {
  70725. node: IGLTFNode;
  70726. id: string;
  70727. }
  70728. }
  70729. declare module BABYLON.GLTF1 {
  70730. /**
  70731. * Utils functions for GLTF
  70732. * @hidden
  70733. */
  70734. export class GLTFUtils {
  70735. /**
  70736. * Sets the given "parameter" matrix
  70737. * @param scene: the Scene object
  70738. * @param source: the source node where to pick the matrix
  70739. * @param parameter: the GLTF technique parameter
  70740. * @param uniformName: the name of the shader's uniform
  70741. * @param shaderMaterial: the shader material
  70742. */
  70743. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  70744. /**
  70745. * Sets the given "parameter" matrix
  70746. * @param shaderMaterial: the shader material
  70747. * @param uniform: the name of the shader's uniform
  70748. * @param value: the value of the uniform
  70749. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  70750. */
  70751. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  70752. /**
  70753. * Returns the wrap mode of the texture
  70754. * @param mode: the mode value
  70755. */
  70756. static GetWrapMode(mode: number): number;
  70757. /**
  70758. * Returns the byte stride giving an accessor
  70759. * @param accessor: the GLTF accessor objet
  70760. */
  70761. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  70762. /**
  70763. * Returns the texture filter mode giving a mode value
  70764. * @param mode: the filter mode value
  70765. */
  70766. static GetTextureFilterMode(mode: number): ETextureFilterType;
  70767. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  70768. /**
  70769. * Returns a buffer from its accessor
  70770. * @param gltfRuntime: the GLTF runtime
  70771. * @param accessor: the GLTF accessor
  70772. */
  70773. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  70774. /**
  70775. * Decodes a buffer view into a string
  70776. * @param view: the buffer view
  70777. */
  70778. static DecodeBufferToText(view: ArrayBufferView): string;
  70779. /**
  70780. * Returns the default material of gltf. Related to
  70781. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  70782. * @param scene: the Babylon.js scene
  70783. */
  70784. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  70785. private static _DefaultMaterial;
  70786. }
  70787. }
  70788. declare module BABYLON.GLTF1 {
  70789. /**
  70790. * Implementation of the base glTF spec
  70791. * @hidden
  70792. */
  70793. export class GLTFLoaderBase {
  70794. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  70795. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  70796. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  70797. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  70798. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  70799. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  70800. }
  70801. /**
  70802. * glTF V1 Loader
  70803. * @hidden
  70804. */
  70805. export class GLTFLoader implements IGLTFLoader {
  70806. static Extensions: {
  70807. [name: string]: GLTFLoaderExtension;
  70808. };
  70809. static RegisterExtension(extension: GLTFLoaderExtension): void;
  70810. state: Nullable<GLTFLoaderState>;
  70811. dispose(): void;
  70812. private _importMeshAsync;
  70813. /**
  70814. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  70815. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70816. * @param scene the scene the meshes should be added to
  70817. * @param data gltf data containing information of the meshes in a loaded file
  70818. * @param rootUrl root url to load from
  70819. * @param onProgress event that fires when loading progress has occured
  70820. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70821. */
  70822. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  70823. meshes: AbstractMesh[];
  70824. particleSystems: IParticleSystem[];
  70825. skeletons: Skeleton[];
  70826. animationGroups: AnimationGroup[];
  70827. }>;
  70828. private _loadAsync;
  70829. /**
  70830. * Imports all objects from a loaded gltf file and adds them to the scene
  70831. * @param scene the scene the objects should be added to
  70832. * @param data gltf data containing information of the meshes in a loaded file
  70833. * @param rootUrl root url to load from
  70834. * @param onProgress event that fires when loading progress has occured
  70835. * @returns a promise which completes when objects have been loaded to the scene
  70836. */
  70837. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  70838. private _loadShadersAsync;
  70839. private _loadBuffersAsync;
  70840. private _createNodes;
  70841. }
  70842. /** @hidden */
  70843. export abstract class GLTFLoaderExtension {
  70844. private _name;
  70845. constructor(name: string);
  70846. readonly name: string;
  70847. /**
  70848. * Defines an override for loading the runtime
  70849. * Return true to stop further extensions from loading the runtime
  70850. */
  70851. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  70852. /**
  70853. * Defines an onverride for creating gltf runtime
  70854. * Return true to stop further extensions from creating the runtime
  70855. */
  70856. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  70857. /**
  70858. * Defines an override for loading buffers
  70859. * Return true to stop further extensions from loading this buffer
  70860. */
  70861. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  70862. /**
  70863. * Defines an override for loading texture buffers
  70864. * Return true to stop further extensions from loading this texture data
  70865. */
  70866. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70867. /**
  70868. * Defines an override for creating textures
  70869. * Return true to stop further extensions from loading this texture
  70870. */
  70871. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  70872. /**
  70873. * Defines an override for loading shader strings
  70874. * Return true to stop further extensions from loading this shader data
  70875. */
  70876. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  70877. /**
  70878. * Defines an override for loading materials
  70879. * Return true to stop further extensions from loading this material
  70880. */
  70881. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  70882. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  70883. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  70884. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  70885. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  70886. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  70887. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  70888. private static LoadTextureBufferAsync;
  70889. private static CreateTextureAsync;
  70890. private static ApplyExtensions;
  70891. }
  70892. }
  70893. declare module BABYLON.GLTF1 {
  70894. /** @hidden */
  70895. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  70896. private _bin;
  70897. constructor();
  70898. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  70899. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70900. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70901. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  70902. }
  70903. }
  70904. declare module BABYLON.GLTF1 {
  70905. /** @hidden */
  70906. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  70907. constructor();
  70908. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  70909. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  70910. private _loadTexture;
  70911. }
  70912. }
  70913. declare module BABYLON.GLTF2.Loader {
  70914. /**
  70915. * Loader interface with an index field.
  70916. */
  70917. export interface IArrayItem {
  70918. /**
  70919. * The index of this item in the array.
  70920. */
  70921. index: number;
  70922. }
  70923. /**
  70924. * Loader interface with additional members.
  70925. */
  70926. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  70927. /** @hidden */
  70928. _data?: Promise<ArrayBufferView>;
  70929. /** @hidden */
  70930. _babylonVertexBuffer?: Promise<VertexBuffer>;
  70931. }
  70932. /**
  70933. * Loader interface with additional members.
  70934. */
  70935. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  70936. }
  70937. /** @hidden */
  70938. export interface _IAnimationSamplerData {
  70939. input: Float32Array;
  70940. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  70941. output: Float32Array;
  70942. }
  70943. /**
  70944. * Loader interface with additional members.
  70945. */
  70946. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  70947. /** @hidden */
  70948. _data?: Promise<_IAnimationSamplerData>;
  70949. }
  70950. /**
  70951. * Loader interface with additional members.
  70952. */
  70953. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  70954. channels: IAnimationChannel[];
  70955. samplers: IAnimationSampler[];
  70956. /** @hidden */
  70957. _babylonAnimationGroup?: AnimationGroup;
  70958. }
  70959. /**
  70960. * Loader interface with additional members.
  70961. */
  70962. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  70963. /** @hidden */
  70964. _data?: Promise<ArrayBufferView>;
  70965. }
  70966. /**
  70967. * Loader interface with additional members.
  70968. */
  70969. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  70970. /** @hidden */
  70971. _data?: Promise<ArrayBufferView>;
  70972. /** @hidden */
  70973. _babylonBuffer?: Promise<Buffer>;
  70974. }
  70975. /**
  70976. * Loader interface with additional members.
  70977. */
  70978. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  70979. }
  70980. /**
  70981. * Loader interface with additional members.
  70982. */
  70983. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  70984. /** @hidden */
  70985. _data?: Promise<ArrayBufferView>;
  70986. }
  70987. /**
  70988. * Loader interface with additional members.
  70989. */
  70990. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  70991. }
  70992. /**
  70993. * Loader interface with additional members.
  70994. */
  70995. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  70996. }
  70997. /**
  70998. * Loader interface with additional members.
  70999. */
  71000. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  71001. baseColorTexture?: ITextureInfo;
  71002. metallicRoughnessTexture?: ITextureInfo;
  71003. }
  71004. /**
  71005. * Loader interface with additional members.
  71006. */
  71007. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  71008. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71009. normalTexture?: IMaterialNormalTextureInfo;
  71010. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71011. emissiveTexture?: ITextureInfo;
  71012. /** @hidden */
  71013. _data?: {
  71014. [babylonDrawMode: number]: {
  71015. babylonMaterial: Material;
  71016. babylonMeshes: AbstractMesh[];
  71017. promise: Promise<void>;
  71018. };
  71019. };
  71020. }
  71021. /**
  71022. * Loader interface with additional members.
  71023. */
  71024. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  71025. primitives: IMeshPrimitive[];
  71026. }
  71027. /**
  71028. * Loader interface with additional members.
  71029. */
  71030. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  71031. /** @hidden */
  71032. _instanceData?: {
  71033. babylonSourceMesh: Mesh;
  71034. promise: Promise<any>;
  71035. };
  71036. }
  71037. /**
  71038. * Loader interface with additional members.
  71039. */
  71040. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  71041. /**
  71042. * The parent glTF node.
  71043. */
  71044. parent?: INode;
  71045. /** @hidden */
  71046. _babylonTransformNode?: TransformNode;
  71047. /** @hidden */
  71048. _primitiveBabylonMeshes?: AbstractMesh[];
  71049. /** @hidden */
  71050. _babylonBones?: Bone[];
  71051. /** @hidden */
  71052. _numMorphTargets?: number;
  71053. }
  71054. /** @hidden */
  71055. export interface _ISamplerData {
  71056. noMipMaps: boolean;
  71057. samplingMode: number;
  71058. wrapU: number;
  71059. wrapV: number;
  71060. }
  71061. /**
  71062. * Loader interface with additional members.
  71063. */
  71064. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  71065. /** @hidden */
  71066. _data?: _ISamplerData;
  71067. }
  71068. /**
  71069. * Loader interface with additional members.
  71070. */
  71071. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  71072. }
  71073. /**
  71074. * Loader interface with additional members.
  71075. */
  71076. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  71077. /** @hidden */
  71078. _data?: {
  71079. babylonSkeleton: Skeleton;
  71080. promise: Promise<void>;
  71081. };
  71082. }
  71083. /**
  71084. * Loader interface with additional members.
  71085. */
  71086. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  71087. }
  71088. /**
  71089. * Loader interface with additional members.
  71090. */
  71091. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  71092. }
  71093. /**
  71094. * Loader interface with additional members.
  71095. */
  71096. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  71097. accessors?: IAccessor[];
  71098. animations?: IAnimation[];
  71099. buffers?: IBuffer[];
  71100. bufferViews?: IBufferView[];
  71101. cameras?: ICamera[];
  71102. images?: IImage[];
  71103. materials?: IMaterial[];
  71104. meshes?: IMesh[];
  71105. nodes?: INode[];
  71106. samplers?: ISampler[];
  71107. scenes?: IScene[];
  71108. skins?: ISkin[];
  71109. textures?: ITexture[];
  71110. }
  71111. }
  71112. declare module BABYLON.GLTF2 {
  71113. /**
  71114. * Interface for a glTF loader extension.
  71115. */
  71116. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  71117. /**
  71118. * Called after the loader state changes to LOADING.
  71119. */
  71120. onLoading?(): void;
  71121. /**
  71122. * Called after the loader state changes to READY.
  71123. */
  71124. onReady?(): void;
  71125. /**
  71126. * Define this method to modify the default behavior when loading scenes.
  71127. * @param context The context when loading the asset
  71128. * @param scene The glTF scene property
  71129. * @returns A promise that resolves when the load is complete or null if not handled
  71130. */
  71131. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  71132. /**
  71133. * Define this method to modify the default behavior when loading nodes.
  71134. * @param context The context when loading the asset
  71135. * @param node The glTF node property
  71136. * @param assign A function called synchronously after parsing the glTF properties
  71137. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  71138. */
  71139. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71140. /**
  71141. * Define this method to modify the default behavior when loading cameras.
  71142. * @param context The context when loading the asset
  71143. * @param camera The glTF camera property
  71144. * @param assign A function called synchronously after parsing the glTF properties
  71145. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  71146. */
  71147. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  71148. /**
  71149. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  71150. * @param context The context when loading the asset
  71151. * @param primitive The glTF mesh primitive property
  71152. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  71153. */
  71154. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  71155. /**
  71156. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  71157. * @param context The context when loading the asset
  71158. * @param name The mesh name when loading the asset
  71159. * @param node The glTF node when loading the asset
  71160. * @param mesh The glTF mesh when loading the asset
  71161. * @param primitive The glTF mesh primitive property
  71162. * @param assign A function called synchronously after parsing the glTF properties
  71163. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  71164. */
  71165. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  71166. /**
  71167. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  71168. * @param context The context when loading the asset
  71169. * @param material The glTF material property
  71170. * @param assign A function called synchronously after parsing the glTF properties
  71171. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  71172. */
  71173. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  71174. /**
  71175. * Define this method to modify the default behavior when creating materials.
  71176. * @param context The context when loading the asset
  71177. * @param material The glTF material property
  71178. * @param babylonDrawMode The draw mode for the Babylon material
  71179. * @returns The Babylon material or null if not handled
  71180. */
  71181. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  71182. /**
  71183. * Define this method to modify the default behavior when loading material properties.
  71184. * @param context The context when loading the asset
  71185. * @param material The glTF material property
  71186. * @param babylonMaterial The Babylon material
  71187. * @returns A promise that resolves when the load is complete or null if not handled
  71188. */
  71189. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71190. /**
  71191. * Define this method to modify the default behavior when loading texture infos.
  71192. * @param context The context when loading the asset
  71193. * @param textureInfo The glTF texture info property
  71194. * @param assign A function called synchronously after parsing the glTF properties
  71195. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  71196. */
  71197. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  71198. /**
  71199. * Define this method to modify the default behavior when loading animations.
  71200. * @param context The context when loading the asset
  71201. * @param animation The glTF animation property
  71202. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  71203. */
  71204. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  71205. /**
  71206. * @hidden Define this method to modify the default behavior when loading skins.
  71207. * @param context The context when loading the asset
  71208. * @param node The glTF node property
  71209. * @param skin The glTF skin property
  71210. * @returns A promise that resolves when the load is complete or null if not handled
  71211. */
  71212. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  71213. /**
  71214. * @hidden Define this method to modify the default behavior when loading uris.
  71215. * @param context The context when loading the asset
  71216. * @param property The glTF property associated with the uri
  71217. * @param uri The uri to load
  71218. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71219. */
  71220. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  71221. /**
  71222. * Define this method to modify the default behavior when loading buffer views.
  71223. * @param context The context when loading the asset
  71224. * @param bufferView The glTF buffer view property
  71225. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71226. */
  71227. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  71228. /**
  71229. * Define this method to modify the default behavior when loading buffers.
  71230. * @param context The context when loading the asset
  71231. * @param buffer The glTF buffer property
  71232. * @param byteOffset The byte offset to load
  71233. * @param byteLength The byte length to load
  71234. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71235. */
  71236. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  71237. }
  71238. }
  71239. declare module BABYLON.GLTF2 {
  71240. /**
  71241. * Helper class for working with arrays when loading the glTF asset
  71242. */
  71243. export class ArrayItem {
  71244. /**
  71245. * Gets an item from the given array.
  71246. * @param context The context when loading the asset
  71247. * @param array The array to get the item from
  71248. * @param index The index to the array
  71249. * @returns The array item
  71250. */
  71251. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  71252. /**
  71253. * Assign an `index` field to each item of the given array.
  71254. * @param array The array of items
  71255. */
  71256. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  71257. }
  71258. /**
  71259. * The glTF 2.0 loader
  71260. */
  71261. export class GLTFLoader implements IGLTFLoader {
  71262. /** @hidden */
  71263. _completePromises: Promise<any>[];
  71264. private _disposed;
  71265. private _parent;
  71266. private _state;
  71267. private _extensions;
  71268. private _rootUrl;
  71269. private _fileName;
  71270. private _uniqueRootUrl;
  71271. private _gltf;
  71272. private _bin;
  71273. private _babylonScene;
  71274. private _rootBabylonMesh;
  71275. private _defaultBabylonMaterialData;
  71276. private _progressCallback?;
  71277. private _requests;
  71278. private static readonly _DefaultSampler;
  71279. private static _RegisteredExtensions;
  71280. /**
  71281. * Registers a loader extension.
  71282. * @param name The name of the loader extension.
  71283. * @param factory The factory function that creates the loader extension.
  71284. */
  71285. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  71286. /**
  71287. * Unregisters a loader extension.
  71288. * @param name The name of the loader extension.
  71289. * @returns A boolean indicating whether the extension has been unregistered
  71290. */
  71291. static UnregisterExtension(name: string): boolean;
  71292. /**
  71293. * Gets the loader state.
  71294. */
  71295. readonly state: Nullable<GLTFLoaderState>;
  71296. /**
  71297. * The object that represents the glTF JSON.
  71298. */
  71299. readonly gltf: IGLTF;
  71300. /**
  71301. * The BIN chunk of a binary glTF.
  71302. */
  71303. readonly bin: Nullable<IDataBuffer>;
  71304. /**
  71305. * The parent file loader.
  71306. */
  71307. readonly parent: GLTFFileLoader;
  71308. /**
  71309. * The Babylon scene when loading the asset.
  71310. */
  71311. readonly babylonScene: Scene;
  71312. /**
  71313. * The root Babylon mesh when loading the asset.
  71314. */
  71315. readonly rootBabylonMesh: Mesh;
  71316. /** @hidden */
  71317. constructor(parent: GLTFFileLoader);
  71318. /** @hidden */
  71319. dispose(): void;
  71320. /** @hidden */
  71321. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71322. meshes: AbstractMesh[];
  71323. particleSystems: IParticleSystem[];
  71324. skeletons: Skeleton[];
  71325. animationGroups: AnimationGroup[];
  71326. }>;
  71327. /** @hidden */
  71328. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71329. private _loadAsync;
  71330. private _loadData;
  71331. private _setupData;
  71332. private _loadExtensions;
  71333. private _checkExtensions;
  71334. private _setState;
  71335. private _createRootNode;
  71336. /**
  71337. * Loads a glTF scene.
  71338. * @param context The context when loading the asset
  71339. * @param scene The glTF scene property
  71340. * @returns A promise that resolves when the load is complete
  71341. */
  71342. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  71343. private _forEachPrimitive;
  71344. private _getMeshes;
  71345. private _getSkeletons;
  71346. private _getAnimationGroups;
  71347. private _startAnimations;
  71348. /**
  71349. * Loads a glTF node.
  71350. * @param context The context when loading the asset
  71351. * @param node The glTF node property
  71352. * @param assign A function called synchronously after parsing the glTF properties
  71353. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  71354. */
  71355. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  71356. private _loadMeshAsync;
  71357. /**
  71358. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  71359. * @param context The context when loading the asset
  71360. * @param name The mesh name when loading the asset
  71361. * @param node The glTF node when loading the asset
  71362. * @param mesh The glTF mesh when loading the asset
  71363. * @param primitive The glTF mesh primitive property
  71364. * @param assign A function called synchronously after parsing the glTF properties
  71365. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  71366. */
  71367. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  71368. private _loadVertexDataAsync;
  71369. private _createMorphTargets;
  71370. private _loadMorphTargetsAsync;
  71371. private _loadMorphTargetVertexDataAsync;
  71372. private static _LoadTransform;
  71373. private _loadSkinAsync;
  71374. private _loadBones;
  71375. private _loadBone;
  71376. private _loadSkinInverseBindMatricesDataAsync;
  71377. private _updateBoneMatrices;
  71378. private _getNodeMatrix;
  71379. /**
  71380. * Loads a glTF camera.
  71381. * @param context The context when loading the asset
  71382. * @param camera The glTF camera property
  71383. * @param assign A function called synchronously after parsing the glTF properties
  71384. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  71385. */
  71386. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  71387. private _loadAnimationsAsync;
  71388. /**
  71389. * Loads a glTF animation.
  71390. * @param context The context when loading the asset
  71391. * @param animation The glTF animation property
  71392. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  71393. */
  71394. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  71395. /**
  71396. * @hidden Loads a glTF animation channel.
  71397. * @param context The context when loading the asset
  71398. * @param animationContext The context of the animation when loading the asset
  71399. * @param animation The glTF animation property
  71400. * @param channel The glTF animation channel property
  71401. * @param babylonAnimationGroup The babylon animation group property
  71402. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  71403. * @returns A void promise when the channel load is complete
  71404. */
  71405. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  71406. private _loadAnimationSamplerAsync;
  71407. private _loadBufferAsync;
  71408. /**
  71409. * Loads a glTF buffer view.
  71410. * @param context The context when loading the asset
  71411. * @param bufferView The glTF buffer view property
  71412. * @returns A promise that resolves with the loaded data when the load is complete
  71413. */
  71414. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  71415. private _loadAccessorAsync;
  71416. private _loadFloatAccessorAsync;
  71417. private _loadIndicesAccessorAsync;
  71418. private _loadVertexBufferViewAsync;
  71419. private _loadVertexAccessorAsync;
  71420. private _loadMaterialMetallicRoughnessPropertiesAsync;
  71421. /** @hidden */
  71422. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  71423. private _createDefaultMaterial;
  71424. /**
  71425. * Creates a Babylon material from a glTF material.
  71426. * @param context The context when loading the asset
  71427. * @param material The glTF material property
  71428. * @param babylonDrawMode The draw mode for the Babylon material
  71429. * @returns The Babylon material
  71430. */
  71431. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  71432. /**
  71433. * Loads properties from a glTF material into a Babylon material.
  71434. * @param context The context when loading the asset
  71435. * @param material The glTF material property
  71436. * @param babylonMaterial The Babylon material
  71437. * @returns A promise that resolves when the load is complete
  71438. */
  71439. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  71440. /**
  71441. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  71442. * @param context The context when loading the asset
  71443. * @param material The glTF material property
  71444. * @param babylonMaterial The Babylon material
  71445. * @returns A promise that resolves when the load is complete
  71446. */
  71447. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  71448. /**
  71449. * Loads the alpha properties from a glTF material into a Babylon material.
  71450. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  71451. * @param context The context when loading the asset
  71452. * @param material The glTF material property
  71453. * @param babylonMaterial The Babylon material
  71454. */
  71455. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  71456. /**
  71457. * Loads a glTF texture info.
  71458. * @param context The context when loading the asset
  71459. * @param textureInfo The glTF texture info property
  71460. * @param assign A function called synchronously after parsing the glTF properties
  71461. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  71462. */
  71463. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  71464. private _loadTextureAsync;
  71465. private _loadSampler;
  71466. /**
  71467. * Loads a glTF image.
  71468. * @param context The context when loading the asset
  71469. * @param image The glTF image property
  71470. * @returns A promise that resolves with the loaded data when the load is complete
  71471. */
  71472. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  71473. /**
  71474. * Loads a glTF uri.
  71475. * @param context The context when loading the asset
  71476. * @param property The glTF property associated with the uri
  71477. * @param uri The base64 or relative uri
  71478. * @returns A promise that resolves with the loaded data when the load is complete
  71479. */
  71480. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  71481. private _onProgress;
  71482. /**
  71483. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  71484. * @param babylonObject the Babylon object with metadata
  71485. * @param pointer the JSON pointer
  71486. */
  71487. static AddPointerMetadata(babylonObject: {
  71488. metadata: any;
  71489. }, pointer: string): void;
  71490. private static _GetTextureWrapMode;
  71491. private static _GetTextureSamplingMode;
  71492. private static _GetTypedArrayConstructor;
  71493. private static _GetTypedArray;
  71494. private static _GetNumComponents;
  71495. private static _ValidateUri;
  71496. private static _GetDrawMode;
  71497. private _compileMaterialsAsync;
  71498. private _compileShadowGeneratorsAsync;
  71499. private _forEachExtensions;
  71500. private _applyExtensions;
  71501. private _extensionsOnLoading;
  71502. private _extensionsOnReady;
  71503. private _extensionsLoadSceneAsync;
  71504. private _extensionsLoadNodeAsync;
  71505. private _extensionsLoadCameraAsync;
  71506. private _extensionsLoadVertexDataAsync;
  71507. private _extensionsLoadMeshPrimitiveAsync;
  71508. private _extensionsLoadMaterialAsync;
  71509. private _extensionsCreateMaterial;
  71510. private _extensionsLoadMaterialPropertiesAsync;
  71511. private _extensionsLoadTextureInfoAsync;
  71512. private _extensionsLoadAnimationAsync;
  71513. private _extensionsLoadSkinAsync;
  71514. private _extensionsLoadUriAsync;
  71515. private _extensionsLoadBufferViewAsync;
  71516. private _extensionsLoadBufferAsync;
  71517. /**
  71518. * Helper method called by a loader extension to load an glTF extension.
  71519. * @param context The context when loading the asset
  71520. * @param property The glTF property to load the extension from
  71521. * @param extensionName The name of the extension to load
  71522. * @param actionAsync The action to run
  71523. * @returns The promise returned by actionAsync or null if the extension does not exist
  71524. */
  71525. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  71526. /**
  71527. * Helper method called by a loader extension to load a glTF extra.
  71528. * @param context The context when loading the asset
  71529. * @param property The glTF property to load the extra from
  71530. * @param extensionName The name of the extension to load
  71531. * @param actionAsync The action to run
  71532. * @returns The promise returned by actionAsync or null if the extra does not exist
  71533. */
  71534. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  71535. /**
  71536. * Checks for presence of an extension.
  71537. * @param name The name of the extension to check
  71538. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  71539. */
  71540. isExtensionUsed(name: string): boolean;
  71541. /**
  71542. * Increments the indentation level and logs a message.
  71543. * @param message The message to log
  71544. */
  71545. logOpen(message: string): void;
  71546. /**
  71547. * Decrements the indentation level.
  71548. */
  71549. logClose(): void;
  71550. /**
  71551. * Logs a message
  71552. * @param message The message to log
  71553. */
  71554. log(message: string): void;
  71555. /**
  71556. * Starts a performance counter.
  71557. * @param counterName The name of the performance counter
  71558. */
  71559. startPerformanceCounter(counterName: string): void;
  71560. /**
  71561. * Ends a performance counter.
  71562. * @param counterName The name of the performance counter
  71563. */
  71564. endPerformanceCounter(counterName: string): void;
  71565. }
  71566. }
  71567. declare module BABYLON.GLTF2.Loader.Extensions {
  71568. /**
  71569. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  71570. */
  71571. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  71572. /**
  71573. * The name of this extension.
  71574. */
  71575. readonly name: string;
  71576. /**
  71577. * Defines whether this extension is enabled.
  71578. */
  71579. enabled: boolean;
  71580. private _loader;
  71581. private _lights?;
  71582. /** @hidden */
  71583. constructor(loader: GLTFLoader);
  71584. /** @hidden */
  71585. dispose(): void;
  71586. /** @hidden */
  71587. onLoading(): void;
  71588. /** @hidden */
  71589. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  71590. private _loadLightAsync;
  71591. }
  71592. }
  71593. declare module BABYLON.GLTF2.Loader.Extensions {
  71594. /**
  71595. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  71596. */
  71597. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  71598. /**
  71599. * The name of this extension.
  71600. */
  71601. readonly name: string;
  71602. /**
  71603. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  71604. */
  71605. dracoCompression?: DracoCompression;
  71606. /**
  71607. * Defines whether this extension is enabled.
  71608. */
  71609. enabled: boolean;
  71610. private _loader;
  71611. /** @hidden */
  71612. constructor(loader: GLTFLoader);
  71613. /** @hidden */
  71614. dispose(): void;
  71615. /** @hidden */
  71616. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  71617. }
  71618. }
  71619. declare module BABYLON.GLTF2.Loader.Extensions {
  71620. /**
  71621. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71622. */
  71623. export class KHR_lights implements IGLTFLoaderExtension {
  71624. /**
  71625. * The name of this extension.
  71626. */
  71627. readonly name: string;
  71628. /**
  71629. * Defines whether this extension is enabled.
  71630. */
  71631. enabled: boolean;
  71632. private _loader;
  71633. private _lights?;
  71634. /** @hidden */
  71635. constructor(loader: GLTFLoader);
  71636. /** @hidden */
  71637. dispose(): void;
  71638. /** @hidden */
  71639. onLoading(): void;
  71640. /** @hidden */
  71641. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71642. }
  71643. }
  71644. declare module BABYLON.GLTF2.Loader.Extensions {
  71645. /**
  71646. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  71647. */
  71648. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  71649. /**
  71650. * The name of this extension.
  71651. */
  71652. readonly name: string;
  71653. /**
  71654. * Defines whether this extension is enabled.
  71655. */
  71656. enabled: boolean;
  71657. /**
  71658. * Defines a number that determines the order the extensions are applied.
  71659. */
  71660. order: number;
  71661. private _loader;
  71662. /** @hidden */
  71663. constructor(loader: GLTFLoader);
  71664. /** @hidden */
  71665. dispose(): void;
  71666. /** @hidden */
  71667. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71668. private _loadSpecularGlossinessPropertiesAsync;
  71669. }
  71670. }
  71671. declare module BABYLON.GLTF2.Loader.Extensions {
  71672. /**
  71673. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  71674. */
  71675. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  71676. /**
  71677. * The name of this extension.
  71678. */
  71679. readonly name: string;
  71680. /**
  71681. * Defines whether this extension is enabled.
  71682. */
  71683. enabled: boolean;
  71684. /**
  71685. * Defines a number that determines the order the extensions are applied.
  71686. */
  71687. order: number;
  71688. private _loader;
  71689. /** @hidden */
  71690. constructor(loader: GLTFLoader);
  71691. /** @hidden */
  71692. dispose(): void;
  71693. /** @hidden */
  71694. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71695. private _loadUnlitPropertiesAsync;
  71696. }
  71697. }
  71698. declare module BABYLON.GLTF2.Loader.Extensions {
  71699. /**
  71700. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  71701. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  71702. * !!! Experimental Extension Subject to Changes !!!
  71703. */
  71704. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  71705. /**
  71706. * The name of this extension.
  71707. */
  71708. readonly name: string;
  71709. /**
  71710. * Defines whether this extension is enabled.
  71711. */
  71712. enabled: boolean;
  71713. /**
  71714. * Defines a number that determines the order the extensions are applied.
  71715. */
  71716. order: number;
  71717. private _loader;
  71718. /** @hidden */
  71719. constructor(loader: GLTFLoader);
  71720. /** @hidden */
  71721. dispose(): void;
  71722. /** @hidden */
  71723. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71724. private _loadClearCoatPropertiesAsync;
  71725. }
  71726. }
  71727. declare module BABYLON.GLTF2.Loader.Extensions {
  71728. /**
  71729. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  71730. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  71731. * !!! Experimental Extension Subject to Changes !!!
  71732. */
  71733. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  71734. /**
  71735. * The name of this extension.
  71736. */
  71737. readonly name: string;
  71738. /**
  71739. * Defines whether this extension is enabled.
  71740. */
  71741. enabled: boolean;
  71742. /**
  71743. * Defines a number that determines the order the extensions are applied.
  71744. */
  71745. order: number;
  71746. private _loader;
  71747. /** @hidden */
  71748. constructor(loader: GLTFLoader);
  71749. /** @hidden */
  71750. dispose(): void;
  71751. /** @hidden */
  71752. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71753. private _loadSheenPropertiesAsync;
  71754. }
  71755. }
  71756. declare module BABYLON.GLTF2.Loader.Extensions {
  71757. /**
  71758. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  71759. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  71760. * !!! Experimental Extension Subject to Changes !!!
  71761. */
  71762. export class KHR_materials_specular implements IGLTFLoaderExtension {
  71763. /**
  71764. * The name of this extension.
  71765. */
  71766. readonly name: string;
  71767. /**
  71768. * Defines whether this extension is enabled.
  71769. */
  71770. enabled: boolean;
  71771. /**
  71772. * Defines a number that determines the order the extensions are applied.
  71773. */
  71774. order: number;
  71775. private _loader;
  71776. /** @hidden */
  71777. constructor(loader: GLTFLoader);
  71778. /** @hidden */
  71779. dispose(): void;
  71780. /** @hidden */
  71781. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71782. private _loadSpecularPropertiesAsync;
  71783. }
  71784. }
  71785. declare module BABYLON.GLTF2.Loader.Extensions {
  71786. /**
  71787. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  71788. */
  71789. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  71790. /**
  71791. * The name of this extension.
  71792. */
  71793. readonly name: string;
  71794. /**
  71795. * Defines whether this extension is enabled.
  71796. */
  71797. enabled: boolean;
  71798. /** @hidden */
  71799. constructor(loader: GLTFLoader);
  71800. /** @hidden */
  71801. dispose(): void;
  71802. }
  71803. }
  71804. declare module BABYLON.GLTF2.Loader.Extensions {
  71805. /**
  71806. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  71807. */
  71808. export class KHR_texture_transform implements IGLTFLoaderExtension {
  71809. /**
  71810. * The name of this extension.
  71811. */
  71812. readonly name: string;
  71813. /**
  71814. * Defines whether this extension is enabled.
  71815. */
  71816. enabled: boolean;
  71817. private _loader;
  71818. /** @hidden */
  71819. constructor(loader: GLTFLoader);
  71820. /** @hidden */
  71821. dispose(): void;
  71822. /** @hidden */
  71823. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  71824. }
  71825. }
  71826. declare module BABYLON.GLTF2.Loader.Extensions {
  71827. /**
  71828. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  71829. */
  71830. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  71831. /**
  71832. * The name of this extension.
  71833. */
  71834. readonly name: string;
  71835. /**
  71836. * Defines whether this extension is enabled.
  71837. */
  71838. enabled: boolean;
  71839. private _loader;
  71840. private _clips;
  71841. private _emitters;
  71842. /** @hidden */
  71843. constructor(loader: GLTFLoader);
  71844. /** @hidden */
  71845. dispose(): void;
  71846. /** @hidden */
  71847. onLoading(): void;
  71848. /** @hidden */
  71849. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  71850. /** @hidden */
  71851. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71852. /** @hidden */
  71853. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  71854. private _loadClipAsync;
  71855. private _loadEmitterAsync;
  71856. private _getEventAction;
  71857. private _loadAnimationEventAsync;
  71858. }
  71859. }
  71860. declare module BABYLON.GLTF2.Loader.Extensions {
  71861. /**
  71862. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  71863. */
  71864. export class MSFT_lod implements IGLTFLoaderExtension {
  71865. /**
  71866. * The name of this extension.
  71867. */
  71868. readonly name: string;
  71869. /**
  71870. * Defines whether this extension is enabled.
  71871. */
  71872. enabled: boolean;
  71873. /**
  71874. * Defines a number that determines the order the extensions are applied.
  71875. */
  71876. order: number;
  71877. /**
  71878. * Maximum number of LODs to load, starting from the lowest LOD.
  71879. */
  71880. maxLODsToLoad: number;
  71881. /**
  71882. * Observable raised when all node LODs of one level are loaded.
  71883. * The event data is the index of the loaded LOD starting from zero.
  71884. * Dispose the loader to cancel the loading of the next level of LODs.
  71885. */
  71886. onNodeLODsLoadedObservable: Observable<number>;
  71887. /**
  71888. * Observable raised when all material LODs of one level are loaded.
  71889. * The event data is the index of the loaded LOD starting from zero.
  71890. * Dispose the loader to cancel the loading of the next level of LODs.
  71891. */
  71892. onMaterialLODsLoadedObservable: Observable<number>;
  71893. private _loader;
  71894. private _nodeIndexLOD;
  71895. private _nodeSignalLODs;
  71896. private _nodePromiseLODs;
  71897. private _materialIndexLOD;
  71898. private _materialSignalLODs;
  71899. private _materialPromiseLODs;
  71900. private _indexLOD;
  71901. private _bufferLODs;
  71902. /** @hidden */
  71903. constructor(loader: GLTFLoader);
  71904. /** @hidden */
  71905. dispose(): void;
  71906. /** @hidden */
  71907. onReady(): void;
  71908. /** @hidden */
  71909. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71910. /** @hidden */
  71911. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  71912. /** @hidden */
  71913. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  71914. /** @hidden */
  71915. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  71916. private _loadBufferLOD;
  71917. /**
  71918. * Gets an array of LOD properties from lowest to highest.
  71919. */
  71920. private _getLODs;
  71921. private _disposeUnusedMaterials;
  71922. }
  71923. }
  71924. declare module BABYLON.GLTF2.Loader.Extensions {
  71925. /** @hidden */
  71926. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  71927. readonly name: string;
  71928. enabled: boolean;
  71929. private _loader;
  71930. constructor(loader: GLTFLoader);
  71931. dispose(): void;
  71932. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71933. }
  71934. }
  71935. declare module BABYLON.GLTF2.Loader.Extensions {
  71936. /** @hidden */
  71937. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  71938. readonly name: string;
  71939. enabled: boolean;
  71940. private _loader;
  71941. constructor(loader: GLTFLoader);
  71942. dispose(): void;
  71943. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71944. }
  71945. }
  71946. declare module BABYLON.GLTF2.Loader.Extensions {
  71947. /**
  71948. * Store glTF extras (if present) in BJS objects' metadata
  71949. */
  71950. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  71951. /**
  71952. * The name of this extension.
  71953. */
  71954. readonly name: string;
  71955. /**
  71956. * Defines whether this extension is enabled.
  71957. */
  71958. enabled: boolean;
  71959. private _loader;
  71960. private _assignExtras;
  71961. /** @hidden */
  71962. constructor(loader: GLTFLoader);
  71963. /** @hidden */
  71964. dispose(): void;
  71965. /** @hidden */
  71966. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71967. /** @hidden */
  71968. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  71969. /** @hidden */
  71970. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  71971. }
  71972. }
  71973. declare module BABYLON {
  71974. /**
  71975. * Class reading and parsing the MTL file bundled with the obj file.
  71976. */
  71977. export class MTLFileLoader {
  71978. /**
  71979. * All material loaded from the mtl will be set here
  71980. */
  71981. materials: StandardMaterial[];
  71982. /**
  71983. * This function will read the mtl file and create each material described inside
  71984. * This function could be improve by adding :
  71985. * -some component missing (Ni, Tf...)
  71986. * -including the specific options available
  71987. *
  71988. * @param scene defines the scene the material will be created in
  71989. * @param data defines the mtl data to parse
  71990. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  71991. */
  71992. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  71993. /**
  71994. * Gets the texture for the material.
  71995. *
  71996. * If the material is imported from input file,
  71997. * We sanitize the url to ensure it takes the textre from aside the material.
  71998. *
  71999. * @param rootUrl The root url to load from
  72000. * @param value The value stored in the mtl
  72001. * @return The Texture
  72002. */
  72003. private static _getTexture;
  72004. }
  72005. /**
  72006. * Options for loading OBJ/MTL files
  72007. */
  72008. type MeshLoadOptions = {
  72009. /**
  72010. * Defines if UVs are optimized by default during load.
  72011. */
  72012. OptimizeWithUV: boolean;
  72013. /**
  72014. * Defines custom scaling of UV coordinates of loaded meshes.
  72015. */
  72016. UVScaling: Vector2;
  72017. /**
  72018. * Invert model on y-axis (does a model scaling inversion)
  72019. */
  72020. InvertY: boolean;
  72021. /**
  72022. * Invert Y-Axis of referenced textures on load
  72023. */
  72024. InvertTextureY: boolean;
  72025. /**
  72026. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  72027. */
  72028. ImportVertexColors: boolean;
  72029. /**
  72030. * Compute the normals for the model, even if normals are present in the file.
  72031. */
  72032. ComputeNormals: boolean;
  72033. /**
  72034. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  72035. */
  72036. SkipMaterials: boolean;
  72037. /**
  72038. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  72039. */
  72040. MaterialLoadingFailsSilently: boolean;
  72041. };
  72042. /**
  72043. * OBJ file type loader.
  72044. * This is a babylon scene loader plugin.
  72045. */
  72046. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  72047. /**
  72048. * Defines if UVs are optimized by default during load.
  72049. */
  72050. static OPTIMIZE_WITH_UV: boolean;
  72051. /**
  72052. * Invert model on y-axis (does a model scaling inversion)
  72053. */
  72054. static INVERT_Y: boolean;
  72055. /**
  72056. * Invert Y-Axis of referenced textures on load
  72057. */
  72058. static INVERT_TEXTURE_Y: boolean;
  72059. /**
  72060. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  72061. */
  72062. static IMPORT_VERTEX_COLORS: boolean;
  72063. /**
  72064. * Compute the normals for the model, even if normals are present in the file.
  72065. */
  72066. static COMPUTE_NORMALS: boolean;
  72067. /**
  72068. * Defines custom scaling of UV coordinates of loaded meshes.
  72069. */
  72070. static UV_SCALING: Vector2;
  72071. /**
  72072. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  72073. */
  72074. static SKIP_MATERIALS: boolean;
  72075. /**
  72076. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  72077. *
  72078. * Defaults to true for backwards compatibility.
  72079. */
  72080. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  72081. /**
  72082. * Defines the name of the plugin.
  72083. */
  72084. name: string;
  72085. /**
  72086. * Defines the extension the plugin is able to load.
  72087. */
  72088. extensions: string;
  72089. /** @hidden */
  72090. obj: RegExp;
  72091. /** @hidden */
  72092. group: RegExp;
  72093. /** @hidden */
  72094. mtllib: RegExp;
  72095. /** @hidden */
  72096. usemtl: RegExp;
  72097. /** @hidden */
  72098. smooth: RegExp;
  72099. /** @hidden */
  72100. vertexPattern: RegExp;
  72101. /** @hidden */
  72102. normalPattern: RegExp;
  72103. /** @hidden */
  72104. uvPattern: RegExp;
  72105. /** @hidden */
  72106. facePattern1: RegExp;
  72107. /** @hidden */
  72108. facePattern2: RegExp;
  72109. /** @hidden */
  72110. facePattern3: RegExp;
  72111. /** @hidden */
  72112. facePattern4: RegExp;
  72113. /** @hidden */
  72114. facePattern5: RegExp;
  72115. private _meshLoadOptions;
  72116. /**
  72117. * Creates loader for .OBJ files
  72118. *
  72119. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  72120. */
  72121. constructor(meshLoadOptions?: MeshLoadOptions);
  72122. private static readonly currentMeshLoadOptions;
  72123. /**
  72124. * Calls synchronously the MTL file attached to this obj.
  72125. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  72126. * Without this function materials are not displayed in the first frame (but displayed after).
  72127. * In consequence it is impossible to get material information in your HTML file
  72128. *
  72129. * @param url The URL of the MTL file
  72130. * @param rootUrl
  72131. * @param onSuccess Callback function to be called when the MTL file is loaded
  72132. * @private
  72133. */
  72134. private _loadMTL;
  72135. /**
  72136. * Instantiates a OBJ file loader plugin.
  72137. * @returns the created plugin
  72138. */
  72139. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  72140. /**
  72141. * If the data string can be loaded directly.
  72142. *
  72143. * @param data string containing the file data
  72144. * @returns if the data can be loaded directly
  72145. */
  72146. canDirectLoad(data: string): boolean;
  72147. /**
  72148. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  72149. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  72150. * @param scene the scene the meshes should be added to
  72151. * @param data the OBJ data to load
  72152. * @param rootUrl root url to load from
  72153. * @param onProgress event that fires when loading progress has occured
  72154. * @param fileName Defines the name of the file to load
  72155. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  72156. */
  72157. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72158. meshes: AbstractMesh[];
  72159. particleSystems: IParticleSystem[];
  72160. skeletons: Skeleton[];
  72161. animationGroups: AnimationGroup[];
  72162. }>;
  72163. /**
  72164. * Imports all objects from the loaded OBJ data and adds them to the scene
  72165. * @param scene the scene the objects should be added to
  72166. * @param data the OBJ data to load
  72167. * @param rootUrl root url to load from
  72168. * @param onProgress event that fires when loading progress has occured
  72169. * @param fileName Defines the name of the file to load
  72170. * @returns a promise which completes when objects have been loaded to the scene
  72171. */
  72172. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72173. /**
  72174. * Load into an asset container.
  72175. * @param scene The scene to load into
  72176. * @param data The data to import
  72177. * @param rootUrl The root url for scene and resources
  72178. * @param onProgress The callback when the load progresses
  72179. * @param fileName Defines the name of the file to load
  72180. * @returns The loaded asset container
  72181. */
  72182. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  72183. /**
  72184. * Read the OBJ file and create an Array of meshes.
  72185. * Each mesh contains all information given by the OBJ and the MTL file.
  72186. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  72187. *
  72188. * @param meshesNames
  72189. * @param scene Scene The scene where are displayed the data
  72190. * @param data String The content of the obj file
  72191. * @param rootUrl String The path to the folder
  72192. * @returns Array<AbstractMesh>
  72193. * @private
  72194. */
  72195. private _parseSolid;
  72196. }
  72197. }
  72198. declare module BABYLON {
  72199. /**
  72200. * STL file type loader.
  72201. * This is a babylon scene loader plugin.
  72202. */
  72203. export class STLFileLoader implements ISceneLoaderPlugin {
  72204. /** @hidden */
  72205. solidPattern: RegExp;
  72206. /** @hidden */
  72207. facetsPattern: RegExp;
  72208. /** @hidden */
  72209. normalPattern: RegExp;
  72210. /** @hidden */
  72211. vertexPattern: RegExp;
  72212. /**
  72213. * Defines the name of the plugin.
  72214. */
  72215. name: string;
  72216. /**
  72217. * Defines the extensions the stl loader is able to load.
  72218. * force data to come in as an ArrayBuffer
  72219. * we'll convert to string if it looks like it's an ASCII .stl
  72220. */
  72221. extensions: ISceneLoaderPluginExtensions;
  72222. /**
  72223. * Import meshes into a scene.
  72224. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  72225. * @param scene The scene to import into
  72226. * @param data The data to import
  72227. * @param rootUrl The root url for scene and resources
  72228. * @param meshes The meshes array to import into
  72229. * @param particleSystems The particle systems array to import into
  72230. * @param skeletons The skeletons array to import into
  72231. * @param onError The callback when import fails
  72232. * @returns True if successful or false otherwise
  72233. */
  72234. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  72235. /**
  72236. * Load into a scene.
  72237. * @param scene The scene to load into
  72238. * @param data The data to import
  72239. * @param rootUrl The root url for scene and resources
  72240. * @param onError The callback when import fails
  72241. * @returns true if successful or false otherwise
  72242. */
  72243. load(scene: Scene, data: any, rootUrl: string): boolean;
  72244. /**
  72245. * Load into an asset container.
  72246. * @param scene The scene to load into
  72247. * @param data The data to import
  72248. * @param rootUrl The root url for scene and resources
  72249. * @param onError The callback when import fails
  72250. * @returns The loaded asset container
  72251. */
  72252. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  72253. private _isBinary;
  72254. private _parseBinary;
  72255. private _parseASCII;
  72256. }
  72257. }
  72258. declare module BABYLON {
  72259. /**
  72260. * Class for generating OBJ data from a Babylon scene.
  72261. */
  72262. export class OBJExport {
  72263. /**
  72264. * Exports the geometry of a Mesh array in .OBJ file format (text)
  72265. * @param mesh defines the list of meshes to serialize
  72266. * @param materials defines if materials should be exported
  72267. * @param matlibname defines the name of the associated mtl file
  72268. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  72269. * @returns the OBJ content
  72270. */
  72271. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  72272. /**
  72273. * Exports the material(s) of a mesh in .MTL file format (text)
  72274. * @param mesh defines the mesh to extract the material from
  72275. * @returns the mtl content
  72276. */
  72277. static MTL(mesh: Mesh): string;
  72278. }
  72279. }
  72280. declare module BABYLON {
  72281. /** @hidden */
  72282. export var __IGLTFExporterExtension: number;
  72283. /**
  72284. * Interface for extending the exporter
  72285. * @hidden
  72286. */
  72287. export interface IGLTFExporterExtension {
  72288. /**
  72289. * The name of this extension
  72290. */
  72291. readonly name: string;
  72292. /**
  72293. * Defines whether this extension is enabled
  72294. */
  72295. enabled: boolean;
  72296. /**
  72297. * Defines whether this extension is required
  72298. */
  72299. required: boolean;
  72300. }
  72301. }
  72302. declare module BABYLON.GLTF2.Exporter {
  72303. /** @hidden */
  72304. export var __IGLTFExporterExtensionV2: number;
  72305. /**
  72306. * Interface for a glTF exporter extension
  72307. * @hidden
  72308. */
  72309. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  72310. /**
  72311. * Define this method to modify the default behavior before exporting a texture
  72312. * @param context The context when loading the asset
  72313. * @param babylonTexture The Babylon.js texture
  72314. * @param mimeType The mime-type of the generated image
  72315. * @returns A promise that resolves with the exported texture
  72316. */
  72317. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  72318. /**
  72319. * Define this method to get notified when a texture info is created
  72320. * @param context The context when loading the asset
  72321. * @param textureInfo The glTF texture info
  72322. * @param babylonTexture The Babylon.js texture
  72323. */
  72324. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  72325. /**
  72326. * Define this method to modify the default behavior when exporting texture info
  72327. * @param context The context when loading the asset
  72328. * @param meshPrimitive glTF mesh primitive
  72329. * @param babylonSubMesh Babylon submesh
  72330. * @param binaryWriter glTF serializer binary writer instance
  72331. * @returns nullable IMeshPrimitive promise
  72332. */
  72333. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  72334. /**
  72335. * Define this method to modify the default behavior when exporting a node
  72336. * @param context The context when exporting the node
  72337. * @param node glTF node
  72338. * @param babylonNode BabylonJS node
  72339. * @returns nullable INode promise
  72340. */
  72341. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  72342. /**
  72343. * Define this method to modify the default behavior when exporting a material
  72344. * @param material glTF material
  72345. * @param babylonMaterial BabylonJS material
  72346. * @returns nullable IMaterial promise
  72347. */
  72348. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  72349. /**
  72350. * Define this method to return additional textures to export from a material
  72351. * @param material glTF material
  72352. * @param babylonMaterial BabylonJS material
  72353. * @returns List of textures
  72354. */
  72355. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  72356. /** Gets a boolean indicating that this extension was used */
  72357. wasUsed: boolean;
  72358. /** Gets a boolean indicating that this extension is required for the file to work */
  72359. required: boolean;
  72360. /**
  72361. * Called after the exporter state changes to EXPORTING
  72362. */
  72363. onExporting?(): void;
  72364. }
  72365. }
  72366. declare module BABYLON.GLTF2.Exporter {
  72367. /**
  72368. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  72369. * @hidden
  72370. */
  72371. export class _GLTFMaterialExporter {
  72372. /**
  72373. * Represents the dielectric specular values for R, G and B
  72374. */
  72375. private static readonly _DielectricSpecular;
  72376. /**
  72377. * Allows the maximum specular power to be defined for material calculations
  72378. */
  72379. private static readonly _MaxSpecularPower;
  72380. /**
  72381. * Mapping to store textures
  72382. */
  72383. private _textureMap;
  72384. /**
  72385. * Numeric tolerance value
  72386. */
  72387. private static readonly _Epsilon;
  72388. /**
  72389. * Reference to the glTF Exporter
  72390. */
  72391. private _exporter;
  72392. constructor(exporter: _Exporter);
  72393. /**
  72394. * Specifies if two colors are approximately equal in value
  72395. * @param color1 first color to compare to
  72396. * @param color2 second color to compare to
  72397. * @param epsilon threshold value
  72398. */
  72399. private static FuzzyEquals;
  72400. /**
  72401. * Gets the materials from a Babylon scene and converts them to glTF materials
  72402. * @param scene babylonjs scene
  72403. * @param mimeType texture mime type
  72404. * @param images array of images
  72405. * @param textures array of textures
  72406. * @param materials array of materials
  72407. * @param imageData mapping of texture names to base64 textures
  72408. * @param hasTextureCoords specifies if texture coordinates are present on the material
  72409. */
  72410. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  72411. /**
  72412. * Makes a copy of the glTF material without the texture parameters
  72413. * @param originalMaterial original glTF material
  72414. * @returns glTF material without texture parameters
  72415. */
  72416. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  72417. /**
  72418. * Specifies if the material has any texture parameters present
  72419. * @param material glTF Material
  72420. * @returns boolean specifying if texture parameters are present
  72421. */
  72422. _hasTexturesPresent(material: IMaterial): boolean;
  72423. /**
  72424. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  72425. * @param babylonStandardMaterial
  72426. * @returns glTF Metallic Roughness Material representation
  72427. */
  72428. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  72429. /**
  72430. * Computes the metallic factor
  72431. * @param diffuse diffused value
  72432. * @param specular specular value
  72433. * @param oneMinusSpecularStrength one minus the specular strength
  72434. * @returns metallic value
  72435. */
  72436. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  72437. /**
  72438. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  72439. * @param glTFMaterial glTF material
  72440. * @param babylonMaterial Babylon material
  72441. */
  72442. private static _SetAlphaMode;
  72443. /**
  72444. * Converts a Babylon Standard Material to a glTF Material
  72445. * @param babylonStandardMaterial BJS Standard Material
  72446. * @param mimeType mime type to use for the textures
  72447. * @param images array of glTF image interfaces
  72448. * @param textures array of glTF texture interfaces
  72449. * @param materials array of glTF material interfaces
  72450. * @param imageData map of image file name to data
  72451. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72452. */
  72453. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  72454. private _finishMaterial;
  72455. /**
  72456. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  72457. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  72458. * @param mimeType mime type to use for the textures
  72459. * @param images array of glTF image interfaces
  72460. * @param textures array of glTF texture interfaces
  72461. * @param materials array of glTF material interfaces
  72462. * @param imageData map of image file name to data
  72463. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72464. */
  72465. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  72466. /**
  72467. * Converts an image typed array buffer to a base64 image
  72468. * @param buffer typed array buffer
  72469. * @param width width of the image
  72470. * @param height height of the image
  72471. * @param mimeType mimetype of the image
  72472. * @returns base64 image string
  72473. */
  72474. private _createBase64FromCanvasAsync;
  72475. /**
  72476. * Generates a white texture based on the specified width and height
  72477. * @param width width of the texture in pixels
  72478. * @param height height of the texture in pixels
  72479. * @param scene babylonjs scene
  72480. * @returns white texture
  72481. */
  72482. private _createWhiteTexture;
  72483. /**
  72484. * 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
  72485. * @param texture1 first texture to resize
  72486. * @param texture2 second texture to resize
  72487. * @param scene babylonjs scene
  72488. * @returns resized textures or null
  72489. */
  72490. private _resizeTexturesToSameDimensions;
  72491. /**
  72492. * Converts an array of pixels to a Float32Array
  72493. * Throws an error if the pixel format is not supported
  72494. * @param pixels - array buffer containing pixel values
  72495. * @returns Float32 of pixels
  72496. */
  72497. private _convertPixelArrayToFloat32;
  72498. /**
  72499. * Convert Specular Glossiness Textures to Metallic Roughness
  72500. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  72501. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  72502. * @param diffuseTexture texture used to store diffuse information
  72503. * @param specularGlossinessTexture texture used to store specular and glossiness information
  72504. * @param factors specular glossiness material factors
  72505. * @param mimeType the mime type to use for the texture
  72506. * @returns pbr metallic roughness interface or null
  72507. */
  72508. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  72509. /**
  72510. * Converts specular glossiness material properties to metallic roughness
  72511. * @param specularGlossiness interface with specular glossiness material properties
  72512. * @returns interface with metallic roughness material properties
  72513. */
  72514. private _convertSpecularGlossinessToMetallicRoughness;
  72515. /**
  72516. * Calculates the surface reflectance, independent of lighting conditions
  72517. * @param color Color source to calculate brightness from
  72518. * @returns number representing the perceived brightness, or zero if color is undefined
  72519. */
  72520. private _getPerceivedBrightness;
  72521. /**
  72522. * Returns the maximum color component value
  72523. * @param color
  72524. * @returns maximum color component value, or zero if color is null or undefined
  72525. */
  72526. private _getMaxComponent;
  72527. /**
  72528. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  72529. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72530. * @param mimeType mime type to use for the textures
  72531. * @param images array of glTF image interfaces
  72532. * @param textures array of glTF texture interfaces
  72533. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  72534. * @param imageData map of image file name to data
  72535. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72536. * @returns glTF PBR Metallic Roughness factors
  72537. */
  72538. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  72539. private _getGLTFTextureSampler;
  72540. private _getGLTFTextureWrapMode;
  72541. private _getGLTFTextureWrapModesSampler;
  72542. /**
  72543. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  72544. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72545. * @param mimeType mime type to use for the textures
  72546. * @param images array of glTF image interfaces
  72547. * @param textures array of glTF texture interfaces
  72548. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  72549. * @param imageData map of image file name to data
  72550. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72551. * @returns glTF PBR Metallic Roughness factors
  72552. */
  72553. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  72554. /**
  72555. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  72556. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72557. * @param mimeType mime type to use for the textures
  72558. * @param images array of glTF image interfaces
  72559. * @param textures array of glTF texture interfaces
  72560. * @param materials array of glTF material interfaces
  72561. * @param imageData map of image file name to data
  72562. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72563. */
  72564. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  72565. private setMetallicRoughnessPbrMaterial;
  72566. private getPixelsFromTexture;
  72567. /**
  72568. * Extracts a texture from a Babylon texture into file data and glTF data
  72569. * @param babylonTexture Babylon texture to extract
  72570. * @param mimeType Mime Type of the babylonTexture
  72571. * @return glTF texture info, or null if the texture format is not supported
  72572. */
  72573. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  72574. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  72575. /**
  72576. * Builds a texture from base64 string
  72577. * @param base64Texture base64 texture string
  72578. * @param baseTextureName Name to use for the texture
  72579. * @param mimeType image mime type for the texture
  72580. * @param images array of images
  72581. * @param textures array of textures
  72582. * @param imageData map of image data
  72583. * @returns glTF texture info, or null if the texture format is not supported
  72584. */
  72585. private _getTextureInfoFromBase64;
  72586. }
  72587. }
  72588. declare module BABYLON {
  72589. /**
  72590. * Class for holding and downloading glTF file data
  72591. */
  72592. export class GLTFData {
  72593. /**
  72594. * Object which contains the file name as the key and its data as the value
  72595. */
  72596. glTFFiles: {
  72597. [fileName: string]: string | Blob;
  72598. };
  72599. /**
  72600. * Initializes the glTF file object
  72601. */
  72602. constructor();
  72603. /**
  72604. * Downloads the glTF data as files based on their names and data
  72605. */
  72606. downloadFiles(): void;
  72607. }
  72608. }
  72609. declare module BABYLON {
  72610. /**
  72611. * Holds a collection of exporter options and parameters
  72612. */
  72613. export interface IExportOptions {
  72614. /**
  72615. * Function which indicates whether a babylon node should be exported or not
  72616. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  72617. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  72618. */
  72619. shouldExportNode?(node: Node): boolean;
  72620. /**
  72621. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  72622. * @param metadata source metadata to read from
  72623. * @returns the data to store to glTF node extras
  72624. */
  72625. metadataSelector?(metadata: any): any;
  72626. /**
  72627. * The sample rate to bake animation curves
  72628. */
  72629. animationSampleRate?: number;
  72630. /**
  72631. * Begin serialization without waiting for the scene to be ready
  72632. */
  72633. exportWithoutWaitingForScene?: boolean;
  72634. }
  72635. /**
  72636. * Class for generating glTF data from a Babylon scene.
  72637. */
  72638. export class GLTF2Export {
  72639. /**
  72640. * Exports the geometry of the scene to .gltf file format asynchronously
  72641. * @param scene Babylon scene with scene hierarchy information
  72642. * @param filePrefix File prefix to use when generating the glTF file
  72643. * @param options Exporter options
  72644. * @returns Returns an object with a .gltf file and associates texture names
  72645. * as keys and their data and paths as values
  72646. */
  72647. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  72648. private static _PreExportAsync;
  72649. private static _PostExportAsync;
  72650. /**
  72651. * Exports the geometry of the scene to .glb file format asychronously
  72652. * @param scene Babylon scene with scene hierarchy information
  72653. * @param filePrefix File prefix to use when generating glb file
  72654. * @param options Exporter options
  72655. * @returns Returns an object with a .glb filename as key and data as value
  72656. */
  72657. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  72658. }
  72659. }
  72660. declare module BABYLON.GLTF2.Exporter {
  72661. /**
  72662. * @hidden
  72663. */
  72664. export class _GLTFUtilities {
  72665. /**
  72666. * Creates a buffer view based on the supplied arguments
  72667. * @param bufferIndex index value of the specified buffer
  72668. * @param byteOffset byte offset value
  72669. * @param byteLength byte length of the bufferView
  72670. * @param byteStride byte distance between conequential elements
  72671. * @param name name of the buffer view
  72672. * @returns bufferView for glTF
  72673. */
  72674. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  72675. /**
  72676. * Creates an accessor based on the supplied arguments
  72677. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  72678. * @param name The name of the accessor
  72679. * @param type The type of the accessor
  72680. * @param componentType The datatype of components in the attribute
  72681. * @param count The number of attributes referenced by this accessor
  72682. * @param byteOffset The offset relative to the start of the bufferView in bytes
  72683. * @param min Minimum value of each component in this attribute
  72684. * @param max Maximum value of each component in this attribute
  72685. * @returns accessor for glTF
  72686. */
  72687. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  72688. /**
  72689. * Calculates the minimum and maximum values of an array of position floats
  72690. * @param positions Positions array of a mesh
  72691. * @param vertexStart Starting vertex offset to calculate min and max values
  72692. * @param vertexCount Number of vertices to check for min and max values
  72693. * @returns min number array and max number array
  72694. */
  72695. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  72696. min: number[];
  72697. max: number[];
  72698. };
  72699. /**
  72700. * Converts a new right-handed Vector3
  72701. * @param vector vector3 array
  72702. * @returns right-handed Vector3
  72703. */
  72704. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  72705. /**
  72706. * Converts a Vector3 to right-handed
  72707. * @param vector Vector3 to convert to right-handed
  72708. */
  72709. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  72710. /**
  72711. * Converts a three element number array to right-handed
  72712. * @param vector number array to convert to right-handed
  72713. */
  72714. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  72715. /**
  72716. * Converts a new right-handed Vector3
  72717. * @param vector vector3 array
  72718. * @returns right-handed Vector3
  72719. */
  72720. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  72721. /**
  72722. * Converts a Vector3 to right-handed
  72723. * @param vector Vector3 to convert to right-handed
  72724. */
  72725. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  72726. /**
  72727. * Converts a three element number array to right-handed
  72728. * @param vector number array to convert to right-handed
  72729. */
  72730. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  72731. /**
  72732. * Converts a Vector4 to right-handed
  72733. * @param vector Vector4 to convert to right-handed
  72734. */
  72735. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  72736. /**
  72737. * Converts a Vector4 to right-handed
  72738. * @param vector Vector4 to convert to right-handed
  72739. */
  72740. static _GetRightHandedArray4FromRef(vector: number[]): void;
  72741. /**
  72742. * Converts a Quaternion to right-handed
  72743. * @param quaternion Source quaternion to convert to right-handed
  72744. */
  72745. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  72746. /**
  72747. * Converts a Quaternion to right-handed
  72748. * @param quaternion Source quaternion to convert to right-handed
  72749. */
  72750. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  72751. static _NormalizeTangentFromRef(tangent: Vector4): void;
  72752. }
  72753. }
  72754. declare module BABYLON.GLTF2.Exporter {
  72755. /**
  72756. * Converts Babylon Scene into glTF 2.0.
  72757. * @hidden
  72758. */
  72759. export class _Exporter {
  72760. /**
  72761. * Stores the glTF to export
  72762. */
  72763. _glTF: IGLTF;
  72764. /**
  72765. * Stores all generated buffer views, which represents views into the main glTF buffer data
  72766. */
  72767. _bufferViews: IBufferView[];
  72768. /**
  72769. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  72770. */
  72771. _accessors: IAccessor[];
  72772. /**
  72773. * Stores all the generated nodes, which contains transform and/or mesh information per node
  72774. */
  72775. private _nodes;
  72776. /**
  72777. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  72778. */
  72779. private _scenes;
  72780. /**
  72781. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  72782. */
  72783. private _meshes;
  72784. /**
  72785. * Stores all the generated material information, which represents the appearance of each primitive
  72786. */
  72787. _materials: IMaterial[];
  72788. _materialMap: {
  72789. [materialID: number]: number;
  72790. };
  72791. /**
  72792. * Stores all the generated texture information, which is referenced by glTF materials
  72793. */
  72794. _textures: ITexture[];
  72795. /**
  72796. * Stores all the generated image information, which is referenced by glTF textures
  72797. */
  72798. _images: IImage[];
  72799. /**
  72800. * Stores all the texture samplers
  72801. */
  72802. _samplers: ISampler[];
  72803. /**
  72804. * Stores all the generated animation samplers, which is referenced by glTF animations
  72805. */
  72806. /**
  72807. * Stores the animations for glTF models
  72808. */
  72809. private _animations;
  72810. /**
  72811. * Stores the total amount of bytes stored in the glTF buffer
  72812. */
  72813. private _totalByteLength;
  72814. /**
  72815. * Stores a reference to the Babylon scene containing the source geometry and material information
  72816. */
  72817. _babylonScene: Scene;
  72818. /**
  72819. * Stores a map of the image data, where the key is the file name and the value
  72820. * is the image data
  72821. */
  72822. _imageData: {
  72823. [fileName: string]: {
  72824. data: Uint8Array;
  72825. mimeType: ImageMimeType;
  72826. };
  72827. };
  72828. /**
  72829. * Stores a map of the unique id of a node to its index in the node array
  72830. */
  72831. private _nodeMap;
  72832. /**
  72833. * Specifies if the Babylon scene should be converted to right-handed on export
  72834. */
  72835. _convertToRightHandedSystem: boolean;
  72836. /**
  72837. * Baked animation sample rate
  72838. */
  72839. private _animationSampleRate;
  72840. private _options;
  72841. private _localEngine;
  72842. _glTFMaterialExporter: _GLTFMaterialExporter;
  72843. private _extensions;
  72844. private static _ExtensionNames;
  72845. private static _ExtensionFactories;
  72846. private _applyExtension;
  72847. private _applyExtensions;
  72848. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  72849. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  72850. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  72851. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  72852. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  72853. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  72854. private _forEachExtensions;
  72855. private _extensionsOnExporting;
  72856. /**
  72857. * Load glTF serializer extensions
  72858. */
  72859. private _loadExtensions;
  72860. /**
  72861. * Creates a glTF Exporter instance, which can accept optional exporter options
  72862. * @param babylonScene Babylon scene object
  72863. * @param options Options to modify the behavior of the exporter
  72864. */
  72865. constructor(babylonScene: Scene, options?: IExportOptions);
  72866. dispose(): void;
  72867. /**
  72868. * Registers a glTF exporter extension
  72869. * @param name Name of the extension to export
  72870. * @param factory The factory function that creates the exporter extension
  72871. */
  72872. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  72873. /**
  72874. * Un-registers an exporter extension
  72875. * @param name The name fo the exporter extension
  72876. * @returns A boolean indicating whether the extension has been un-registered
  72877. */
  72878. static UnregisterExtension(name: string): boolean;
  72879. /**
  72880. * Lazy load a local engine with premultiplied alpha set to false
  72881. */
  72882. _getLocalEngine(): Engine;
  72883. private reorderIndicesBasedOnPrimitiveMode;
  72884. /**
  72885. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  72886. * clock-wise during export to glTF
  72887. * @param submesh BabylonJS submesh
  72888. * @param primitiveMode Primitive mode of the mesh
  72889. * @param sideOrientation the winding order of the submesh
  72890. * @param vertexBufferKind The type of vertex attribute
  72891. * @param meshAttributeArray The vertex attribute data
  72892. * @param byteOffset The offset to the binary data
  72893. * @param binaryWriter The binary data for the glTF file
  72894. */
  72895. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  72896. /**
  72897. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  72898. * clock-wise during export to glTF
  72899. * @param submesh BabylonJS submesh
  72900. * @param primitiveMode Primitive mode of the mesh
  72901. * @param sideOrientation the winding order of the submesh
  72902. * @param vertexBufferKind The type of vertex attribute
  72903. * @param meshAttributeArray The vertex attribute data
  72904. * @param byteOffset The offset to the binary data
  72905. * @param binaryWriter The binary data for the glTF file
  72906. */
  72907. private reorderTriangleFillMode;
  72908. /**
  72909. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  72910. * clock-wise during export to glTF
  72911. * @param submesh BabylonJS submesh
  72912. * @param primitiveMode Primitive mode of the mesh
  72913. * @param sideOrientation the winding order of the submesh
  72914. * @param vertexBufferKind The type of vertex attribute
  72915. * @param meshAttributeArray The vertex attribute data
  72916. * @param byteOffset The offset to the binary data
  72917. * @param binaryWriter The binary data for the glTF file
  72918. */
  72919. private reorderTriangleStripDrawMode;
  72920. /**
  72921. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  72922. * clock-wise during export to glTF
  72923. * @param submesh BabylonJS submesh
  72924. * @param primitiveMode Primitive mode of the mesh
  72925. * @param sideOrientation the winding order of the submesh
  72926. * @param vertexBufferKind The type of vertex attribute
  72927. * @param meshAttributeArray The vertex attribute data
  72928. * @param byteOffset The offset to the binary data
  72929. * @param binaryWriter The binary data for the glTF file
  72930. */
  72931. private reorderTriangleFanMode;
  72932. /**
  72933. * Writes the vertex attribute data to binary
  72934. * @param vertices The vertices to write to the binary writer
  72935. * @param byteOffset The offset into the binary writer to overwrite binary data
  72936. * @param vertexAttributeKind The vertex attribute type
  72937. * @param meshAttributeArray The vertex attribute data
  72938. * @param binaryWriter The writer containing the binary data
  72939. */
  72940. private writeVertexAttributeData;
  72941. /**
  72942. * Writes mesh attribute data to a data buffer
  72943. * Returns the bytelength of the data
  72944. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  72945. * @param meshAttributeArray Array containing the attribute data
  72946. * @param binaryWriter The buffer to write the binary data to
  72947. * @param indices Used to specify the order of the vertex data
  72948. */
  72949. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  72950. /**
  72951. * Generates glTF json data
  72952. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  72953. * @param glTFPrefix Text to use when prefixing a glTF file
  72954. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  72955. * @returns json data as string
  72956. */
  72957. private generateJSON;
  72958. /**
  72959. * Generates data for .gltf and .bin files based on the glTF prefix string
  72960. * @param glTFPrefix Text to use when prefixing a glTF file
  72961. * @param dispose Dispose the exporter
  72962. * @returns GLTFData with glTF file data
  72963. */
  72964. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  72965. /**
  72966. * Creates a binary buffer for glTF
  72967. * @returns array buffer for binary data
  72968. */
  72969. private _generateBinaryAsync;
  72970. /**
  72971. * Pads the number to a multiple of 4
  72972. * @param num number to pad
  72973. * @returns padded number
  72974. */
  72975. private _getPadding;
  72976. /**
  72977. * @hidden
  72978. */
  72979. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  72980. /**
  72981. * Sets the TRS for each node
  72982. * @param node glTF Node for storing the transformation data
  72983. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  72984. */
  72985. private setNodeTransformation;
  72986. private getVertexBufferFromMesh;
  72987. /**
  72988. * Creates a bufferview based on the vertices type for the Babylon mesh
  72989. * @param kind Indicates the type of vertices data
  72990. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  72991. * @param binaryWriter The buffer to write the bufferview data to
  72992. */
  72993. private createBufferViewKind;
  72994. /**
  72995. * The primitive mode of the Babylon mesh
  72996. * @param babylonMesh The BabylonJS mesh
  72997. */
  72998. private getMeshPrimitiveMode;
  72999. /**
  73000. * Sets the primitive mode of the glTF mesh primitive
  73001. * @param meshPrimitive glTF mesh primitive
  73002. * @param primitiveMode The primitive mode
  73003. */
  73004. private setPrimitiveMode;
  73005. /**
  73006. * Sets the vertex attribute accessor based of the glTF mesh primitive
  73007. * @param meshPrimitive glTF mesh primitive
  73008. * @param attributeKind vertex attribute
  73009. * @returns boolean specifying if uv coordinates are present
  73010. */
  73011. private setAttributeKind;
  73012. /**
  73013. * Sets data for the primitive attributes of each submesh
  73014. * @param mesh glTF Mesh object to store the primitive attribute information
  73015. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  73016. * @param binaryWriter Buffer to write the attribute data to
  73017. */
  73018. private setPrimitiveAttributesAsync;
  73019. /**
  73020. * Creates a glTF scene based on the array of meshes
  73021. * Returns the the total byte offset
  73022. * @param babylonScene Babylon scene to get the mesh data from
  73023. * @param binaryWriter Buffer to write binary data to
  73024. */
  73025. private createSceneAsync;
  73026. /**
  73027. * Creates a mapping of Node unique id to node index and handles animations
  73028. * @param babylonScene Babylon Scene
  73029. * @param nodes Babylon transform nodes
  73030. * @param binaryWriter Buffer to write binary data to
  73031. * @returns Node mapping of unique id to index
  73032. */
  73033. private createNodeMapAndAnimationsAsync;
  73034. /**
  73035. * Creates a glTF node from a Babylon mesh
  73036. * @param babylonMesh Source Babylon mesh
  73037. * @param binaryWriter Buffer for storing geometry data
  73038. * @returns glTF node
  73039. */
  73040. private createNodeAsync;
  73041. }
  73042. /**
  73043. * @hidden
  73044. *
  73045. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  73046. */
  73047. export class _BinaryWriter {
  73048. /**
  73049. * Array buffer which stores all binary data
  73050. */
  73051. private _arrayBuffer;
  73052. /**
  73053. * View of the array buffer
  73054. */
  73055. private _dataView;
  73056. /**
  73057. * byte offset of data in array buffer
  73058. */
  73059. private _byteOffset;
  73060. /**
  73061. * Initialize binary writer with an initial byte length
  73062. * @param byteLength Initial byte length of the array buffer
  73063. */
  73064. constructor(byteLength: number);
  73065. /**
  73066. * Resize the array buffer to the specified byte length
  73067. * @param byteLength
  73068. */
  73069. private resizeBuffer;
  73070. /**
  73071. * Get an array buffer with the length of the byte offset
  73072. * @returns ArrayBuffer resized to the byte offset
  73073. */
  73074. getArrayBuffer(): ArrayBuffer;
  73075. /**
  73076. * Get the byte offset of the array buffer
  73077. * @returns byte offset
  73078. */
  73079. getByteOffset(): number;
  73080. /**
  73081. * Stores an UInt8 in the array buffer
  73082. * @param entry
  73083. * @param byteOffset If defined, specifies where to set the value as an offset.
  73084. */
  73085. setUInt8(entry: number, byteOffset?: number): void;
  73086. /**
  73087. * Gets an UInt32 in the array buffer
  73088. * @param entry
  73089. * @param byteOffset If defined, specifies where to set the value as an offset.
  73090. */
  73091. getUInt32(byteOffset: number): number;
  73092. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  73093. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  73094. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  73095. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  73096. /**
  73097. * Stores a Float32 in the array buffer
  73098. * @param entry
  73099. */
  73100. setFloat32(entry: number, byteOffset?: number): void;
  73101. /**
  73102. * Stores an UInt32 in the array buffer
  73103. * @param entry
  73104. * @param byteOffset If defined, specifies where to set the value as an offset.
  73105. */
  73106. setUInt32(entry: number, byteOffset?: number): void;
  73107. }
  73108. }
  73109. declare module BABYLON.GLTF2.Exporter {
  73110. /**
  73111. * @hidden
  73112. * Interface to store animation data.
  73113. */
  73114. export interface _IAnimationData {
  73115. /**
  73116. * Keyframe data.
  73117. */
  73118. inputs: number[];
  73119. /**
  73120. * Value data.
  73121. */
  73122. outputs: number[][];
  73123. /**
  73124. * Animation interpolation data.
  73125. */
  73126. samplerInterpolation: AnimationSamplerInterpolation;
  73127. /**
  73128. * Minimum keyframe value.
  73129. */
  73130. inputsMin: number;
  73131. /**
  73132. * Maximum keyframe value.
  73133. */
  73134. inputsMax: number;
  73135. }
  73136. /**
  73137. * @hidden
  73138. */
  73139. export interface _IAnimationInfo {
  73140. /**
  73141. * The target channel for the animation
  73142. */
  73143. animationChannelTargetPath: AnimationChannelTargetPath;
  73144. /**
  73145. * The glTF accessor type for the data.
  73146. */
  73147. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  73148. /**
  73149. * Specifies if quaternions should be used.
  73150. */
  73151. useQuaternion: boolean;
  73152. }
  73153. /**
  73154. * @hidden
  73155. * Utility class for generating glTF animation data from BabylonJS.
  73156. */
  73157. export class _GLTFAnimation {
  73158. /**
  73159. * @ignore
  73160. *
  73161. * Creates glTF channel animation from BabylonJS animation.
  73162. * @param babylonTransformNode - BabylonJS mesh.
  73163. * @param animation - animation.
  73164. * @param animationChannelTargetPath - The target animation channel.
  73165. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  73166. * @param useQuaternion - Specifies if quaternions are used.
  73167. * @returns nullable IAnimationData
  73168. */
  73169. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  73170. private static _DeduceAnimationInfo;
  73171. /**
  73172. * @ignore
  73173. * Create node animations from the transform node animations
  73174. * @param babylonNode
  73175. * @param runtimeGLTFAnimation
  73176. * @param idleGLTFAnimations
  73177. * @param nodeMap
  73178. * @param nodes
  73179. * @param binaryWriter
  73180. * @param bufferViews
  73181. * @param accessors
  73182. * @param convertToRightHandedSystem
  73183. */
  73184. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  73185. [key: number]: number;
  73186. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  73187. /**
  73188. * @ignore
  73189. * Create node animations from the animation groups
  73190. * @param babylonScene
  73191. * @param glTFAnimations
  73192. * @param nodeMap
  73193. * @param nodes
  73194. * @param binaryWriter
  73195. * @param bufferViews
  73196. * @param accessors
  73197. * @param convertToRightHandedSystem
  73198. */
  73199. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  73200. [key: number]: number;
  73201. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  73202. private static AddAnimation;
  73203. /**
  73204. * Create a baked animation
  73205. * @param babylonTransformNode BabylonJS mesh
  73206. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  73207. * @param animationChannelTargetPath animation target channel
  73208. * @param minFrame minimum animation frame
  73209. * @param maxFrame maximum animation frame
  73210. * @param fps frames per second of the animation
  73211. * @param inputs input key frames of the animation
  73212. * @param outputs output key frame data of the animation
  73213. * @param convertToRightHandedSystem converts the values to right-handed
  73214. * @param useQuaternion specifies if quaternions should be used
  73215. */
  73216. private static _CreateBakedAnimation;
  73217. private static _ConvertFactorToVector3OrQuaternion;
  73218. private static _SetInterpolatedValue;
  73219. /**
  73220. * Creates linear animation from the animation key frames
  73221. * @param babylonTransformNode BabylonJS mesh
  73222. * @param animation BabylonJS animation
  73223. * @param animationChannelTargetPath The target animation channel
  73224. * @param frameDelta The difference between the last and first frame of the animation
  73225. * @param inputs Array to store the key frame times
  73226. * @param outputs Array to store the key frame data
  73227. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  73228. * @param useQuaternion Specifies if quaternions are used in the animation
  73229. */
  73230. private static _CreateLinearOrStepAnimation;
  73231. /**
  73232. * Creates cubic spline animation from the animation key frames
  73233. * @param babylonTransformNode BabylonJS mesh
  73234. * @param animation BabylonJS animation
  73235. * @param animationChannelTargetPath The target animation channel
  73236. * @param frameDelta The difference between the last and first frame of the animation
  73237. * @param inputs Array to store the key frame times
  73238. * @param outputs Array to store the key frame data
  73239. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  73240. * @param useQuaternion Specifies if quaternions are used in the animation
  73241. */
  73242. private static _CreateCubicSplineAnimation;
  73243. private static _GetBasePositionRotationOrScale;
  73244. /**
  73245. * Adds a key frame value
  73246. * @param keyFrame
  73247. * @param animation
  73248. * @param outputs
  73249. * @param animationChannelTargetPath
  73250. * @param basePositionRotationOrScale
  73251. * @param convertToRightHandedSystem
  73252. * @param useQuaternion
  73253. */
  73254. private static _AddKeyframeValue;
  73255. /**
  73256. * Determine the interpolation based on the key frames
  73257. * @param keyFrames
  73258. * @param animationChannelTargetPath
  73259. * @param useQuaternion
  73260. */
  73261. private static _DeduceInterpolation;
  73262. /**
  73263. * Adds an input tangent or output tangent to the output data
  73264. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  73265. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  73266. * @param outputs The animation data by keyframe
  73267. * @param animationChannelTargetPath The target animation channel
  73268. * @param interpolation The interpolation type
  73269. * @param keyFrame The key frame with the animation data
  73270. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  73271. * @param useQuaternion Specifies if quaternions are used
  73272. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  73273. */
  73274. private static AddSplineTangent;
  73275. /**
  73276. * Get the minimum and maximum key frames' frame values
  73277. * @param keyFrames animation key frames
  73278. * @returns the minimum and maximum key frame value
  73279. */
  73280. private static calculateMinMaxKeyFrames;
  73281. }
  73282. }
  73283. declare module BABYLON.GLTF2.Exporter {
  73284. /** @hidden */
  73285. export var textureTransformPixelShader: {
  73286. name: string;
  73287. shader: string;
  73288. };
  73289. }
  73290. declare module BABYLON.GLTF2.Exporter.Extensions {
  73291. /**
  73292. * @hidden
  73293. */
  73294. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  73295. private _recordedTextures;
  73296. /** Name of this extension */
  73297. readonly name: string;
  73298. /** Defines whether this extension is enabled */
  73299. enabled: boolean;
  73300. /** Defines whether this extension is required */
  73301. required: boolean;
  73302. /** Reference to the glTF exporter */
  73303. private _wasUsed;
  73304. constructor(exporter: _Exporter);
  73305. dispose(): void;
  73306. /** @hidden */
  73307. readonly wasUsed: boolean;
  73308. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  73309. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  73310. /**
  73311. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  73312. * @param babylonTexture
  73313. * @param offset
  73314. * @param rotation
  73315. * @param scale
  73316. * @param scene
  73317. */
  73318. private _textureTransformTextureAsync;
  73319. }
  73320. }
  73321. declare module BABYLON.GLTF2.Exporter.Extensions {
  73322. /**
  73323. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73324. */
  73325. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  73326. /** The name of this extension. */
  73327. readonly name: string;
  73328. /** Defines whether this extension is enabled. */
  73329. enabled: boolean;
  73330. /** Defines whether this extension is required */
  73331. required: boolean;
  73332. /** Reference to the glTF exporter */
  73333. private _exporter;
  73334. private _lights;
  73335. /** @hidden */
  73336. constructor(exporter: _Exporter);
  73337. /** @hidden */
  73338. dispose(): void;
  73339. /** @hidden */
  73340. readonly wasUsed: boolean;
  73341. /** @hidden */
  73342. onExporting(): void;
  73343. /**
  73344. * Define this method to modify the default behavior when exporting a node
  73345. * @param context The context when exporting the node
  73346. * @param node glTF node
  73347. * @param babylonNode BabylonJS node
  73348. * @returns nullable INode promise
  73349. */
  73350. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  73351. }
  73352. }
  73353. declare module BABYLON.GLTF2.Exporter.Extensions {
  73354. /**
  73355. * @hidden
  73356. */
  73357. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  73358. /** Name of this extension */
  73359. readonly name: string;
  73360. /** Defines whether this extension is enabled */
  73361. enabled: boolean;
  73362. /** Defines whether this extension is required */
  73363. required: boolean;
  73364. /** Reference to the glTF exporter */
  73365. private _textureInfos;
  73366. private _exportedTextures;
  73367. private _wasUsed;
  73368. constructor(exporter: _Exporter);
  73369. dispose(): void;
  73370. /** @hidden */
  73371. readonly wasUsed: boolean;
  73372. private _getTextureIndex;
  73373. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  73374. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  73375. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  73376. }
  73377. }
  73378. declare module BABYLON {
  73379. /**
  73380. * Class for generating STL data from a Babylon scene.
  73381. */
  73382. export class STLExport {
  73383. /**
  73384. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  73385. * @param meshes list defines the mesh to serialize
  73386. * @param download triggers the automatic download of the file.
  73387. * @param fileName changes the downloads fileName.
  73388. * @param binary changes the STL to a binary type.
  73389. * @param isLittleEndian toggle for binary type exporter.
  73390. * @returns the STL as UTF8 string
  73391. */
  73392. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  73393. }
  73394. }
  73395. declare module "babylonjs-gltf2interface" {
  73396. export = BABYLON.GLTF2;
  73397. }
  73398. /**
  73399. * Module for glTF 2.0 Interface
  73400. */
  73401. declare module BABYLON.GLTF2 {
  73402. /**
  73403. * The datatype of the components in the attribute
  73404. */
  73405. const enum AccessorComponentType {
  73406. /**
  73407. * Byte
  73408. */
  73409. BYTE = 5120,
  73410. /**
  73411. * Unsigned Byte
  73412. */
  73413. UNSIGNED_BYTE = 5121,
  73414. /**
  73415. * Short
  73416. */
  73417. SHORT = 5122,
  73418. /**
  73419. * Unsigned Short
  73420. */
  73421. UNSIGNED_SHORT = 5123,
  73422. /**
  73423. * Unsigned Int
  73424. */
  73425. UNSIGNED_INT = 5125,
  73426. /**
  73427. * Float
  73428. */
  73429. FLOAT = 5126,
  73430. }
  73431. /**
  73432. * Specifies if the attirbute is a scalar, vector, or matrix
  73433. */
  73434. const enum AccessorType {
  73435. /**
  73436. * Scalar
  73437. */
  73438. SCALAR = "SCALAR",
  73439. /**
  73440. * Vector2
  73441. */
  73442. VEC2 = "VEC2",
  73443. /**
  73444. * Vector3
  73445. */
  73446. VEC3 = "VEC3",
  73447. /**
  73448. * Vector4
  73449. */
  73450. VEC4 = "VEC4",
  73451. /**
  73452. * Matrix2x2
  73453. */
  73454. MAT2 = "MAT2",
  73455. /**
  73456. * Matrix3x3
  73457. */
  73458. MAT3 = "MAT3",
  73459. /**
  73460. * Matrix4x4
  73461. */
  73462. MAT4 = "MAT4",
  73463. }
  73464. /**
  73465. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  73466. */
  73467. const enum AnimationChannelTargetPath {
  73468. /**
  73469. * Translation
  73470. */
  73471. TRANSLATION = "translation",
  73472. /**
  73473. * Rotation
  73474. */
  73475. ROTATION = "rotation",
  73476. /**
  73477. * Scale
  73478. */
  73479. SCALE = "scale",
  73480. /**
  73481. * Weights
  73482. */
  73483. WEIGHTS = "weights",
  73484. }
  73485. /**
  73486. * Interpolation algorithm
  73487. */
  73488. const enum AnimationSamplerInterpolation {
  73489. /**
  73490. * The animated values are linearly interpolated between keyframes
  73491. */
  73492. LINEAR = "LINEAR",
  73493. /**
  73494. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  73495. */
  73496. STEP = "STEP",
  73497. /**
  73498. * The animation's interpolation is computed using a cubic spline with specified tangents
  73499. */
  73500. CUBICSPLINE = "CUBICSPLINE",
  73501. }
  73502. /**
  73503. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  73504. */
  73505. const enum CameraType {
  73506. /**
  73507. * A perspective camera containing properties to create a perspective projection matrix
  73508. */
  73509. PERSPECTIVE = "perspective",
  73510. /**
  73511. * An orthographic camera containing properties to create an orthographic projection matrix
  73512. */
  73513. ORTHOGRAPHIC = "orthographic",
  73514. }
  73515. /**
  73516. * The mime-type of the image
  73517. */
  73518. const enum ImageMimeType {
  73519. /**
  73520. * JPEG Mime-type
  73521. */
  73522. JPEG = "image/jpeg",
  73523. /**
  73524. * PNG Mime-type
  73525. */
  73526. PNG = "image/png",
  73527. }
  73528. /**
  73529. * The alpha rendering mode of the material
  73530. */
  73531. const enum MaterialAlphaMode {
  73532. /**
  73533. * The alpha value is ignored and the rendered output is fully opaque
  73534. */
  73535. OPAQUE = "OPAQUE",
  73536. /**
  73537. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  73538. */
  73539. MASK = "MASK",
  73540. /**
  73541. * 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)
  73542. */
  73543. BLEND = "BLEND",
  73544. }
  73545. /**
  73546. * The type of the primitives to render
  73547. */
  73548. const enum MeshPrimitiveMode {
  73549. /**
  73550. * Points
  73551. */
  73552. POINTS = 0,
  73553. /**
  73554. * Lines
  73555. */
  73556. LINES = 1,
  73557. /**
  73558. * Line Loop
  73559. */
  73560. LINE_LOOP = 2,
  73561. /**
  73562. * Line Strip
  73563. */
  73564. LINE_STRIP = 3,
  73565. /**
  73566. * Triangles
  73567. */
  73568. TRIANGLES = 4,
  73569. /**
  73570. * Triangle Strip
  73571. */
  73572. TRIANGLE_STRIP = 5,
  73573. /**
  73574. * Triangle Fan
  73575. */
  73576. TRIANGLE_FAN = 6,
  73577. }
  73578. /**
  73579. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  73580. */
  73581. const enum TextureMagFilter {
  73582. /**
  73583. * Nearest
  73584. */
  73585. NEAREST = 9728,
  73586. /**
  73587. * Linear
  73588. */
  73589. LINEAR = 9729,
  73590. }
  73591. /**
  73592. * Minification filter. All valid values correspond to WebGL enums
  73593. */
  73594. const enum TextureMinFilter {
  73595. /**
  73596. * Nearest
  73597. */
  73598. NEAREST = 9728,
  73599. /**
  73600. * Linear
  73601. */
  73602. LINEAR = 9729,
  73603. /**
  73604. * Nearest Mip-Map Nearest
  73605. */
  73606. NEAREST_MIPMAP_NEAREST = 9984,
  73607. /**
  73608. * Linear Mipmap Nearest
  73609. */
  73610. LINEAR_MIPMAP_NEAREST = 9985,
  73611. /**
  73612. * Nearest Mipmap Linear
  73613. */
  73614. NEAREST_MIPMAP_LINEAR = 9986,
  73615. /**
  73616. * Linear Mipmap Linear
  73617. */
  73618. LINEAR_MIPMAP_LINEAR = 9987,
  73619. }
  73620. /**
  73621. * S (U) wrapping mode. All valid values correspond to WebGL enums
  73622. */
  73623. const enum TextureWrapMode {
  73624. /**
  73625. * Clamp to Edge
  73626. */
  73627. CLAMP_TO_EDGE = 33071,
  73628. /**
  73629. * Mirrored Repeat
  73630. */
  73631. MIRRORED_REPEAT = 33648,
  73632. /**
  73633. * Repeat
  73634. */
  73635. REPEAT = 10497,
  73636. }
  73637. /**
  73638. * glTF Property
  73639. */
  73640. interface IProperty {
  73641. /**
  73642. * Dictionary object with extension-specific objects
  73643. */
  73644. extensions?: {
  73645. [key: string]: any;
  73646. };
  73647. /**
  73648. * Application-Specific data
  73649. */
  73650. extras?: any;
  73651. }
  73652. /**
  73653. * glTF Child of Root Property
  73654. */
  73655. interface IChildRootProperty extends IProperty {
  73656. /**
  73657. * The user-defined name of this object
  73658. */
  73659. name?: string;
  73660. }
  73661. /**
  73662. * Indices of those attributes that deviate from their initialization value
  73663. */
  73664. interface IAccessorSparseIndices extends IProperty {
  73665. /**
  73666. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  73667. */
  73668. bufferView: number;
  73669. /**
  73670. * The offset relative to the start of the bufferView in bytes. Must be aligned
  73671. */
  73672. byteOffset?: number;
  73673. /**
  73674. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  73675. */
  73676. componentType: AccessorComponentType;
  73677. }
  73678. /**
  73679. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  73680. */
  73681. interface IAccessorSparseValues extends IProperty {
  73682. /**
  73683. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  73684. */
  73685. bufferView: number;
  73686. /**
  73687. * The offset relative to the start of the bufferView in bytes. Must be aligned
  73688. */
  73689. byteOffset?: number;
  73690. }
  73691. /**
  73692. * Sparse storage of attributes that deviate from their initialization value
  73693. */
  73694. interface IAccessorSparse extends IProperty {
  73695. /**
  73696. * The number of attributes encoded in this sparse accessor
  73697. */
  73698. count: number;
  73699. /**
  73700. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  73701. */
  73702. indices: IAccessorSparseIndices;
  73703. /**
  73704. * 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
  73705. */
  73706. values: IAccessorSparseValues;
  73707. }
  73708. /**
  73709. * 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
  73710. */
  73711. interface IAccessor extends IChildRootProperty {
  73712. /**
  73713. * The index of the bufferview
  73714. */
  73715. bufferView?: number;
  73716. /**
  73717. * The offset relative to the start of the bufferView in bytes
  73718. */
  73719. byteOffset?: number;
  73720. /**
  73721. * The datatype of components in the attribute
  73722. */
  73723. componentType: AccessorComponentType;
  73724. /**
  73725. * Specifies whether integer data values should be normalized
  73726. */
  73727. normalized?: boolean;
  73728. /**
  73729. * The number of attributes referenced by this accessor
  73730. */
  73731. count: number;
  73732. /**
  73733. * Specifies if the attribute is a scalar, vector, or matrix
  73734. */
  73735. type: AccessorType;
  73736. /**
  73737. * Maximum value of each component in this attribute
  73738. */
  73739. max?: number[];
  73740. /**
  73741. * Minimum value of each component in this attribute
  73742. */
  73743. min?: number[];
  73744. /**
  73745. * Sparse storage of attributes that deviate from their initialization value
  73746. */
  73747. sparse?: IAccessorSparse;
  73748. }
  73749. /**
  73750. * Targets an animation's sampler at a node's property
  73751. */
  73752. interface IAnimationChannel extends IProperty {
  73753. /**
  73754. * The index of a sampler in this animation used to compute the value for the target
  73755. */
  73756. sampler: number;
  73757. /**
  73758. * The index of the node and TRS property to target
  73759. */
  73760. target: IAnimationChannelTarget;
  73761. }
  73762. /**
  73763. * The index of the node and TRS property that an animation channel targets
  73764. */
  73765. interface IAnimationChannelTarget extends IProperty {
  73766. /**
  73767. * The index of the node to target
  73768. */
  73769. node: number;
  73770. /**
  73771. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  73772. */
  73773. path: AnimationChannelTargetPath;
  73774. }
  73775. /**
  73776. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  73777. */
  73778. interface IAnimationSampler extends IProperty {
  73779. /**
  73780. * The index of an accessor containing keyframe input values, e.g., time
  73781. */
  73782. input: number;
  73783. /**
  73784. * Interpolation algorithm
  73785. */
  73786. interpolation?: AnimationSamplerInterpolation;
  73787. /**
  73788. * The index of an accessor, containing keyframe output values
  73789. */
  73790. output: number;
  73791. }
  73792. /**
  73793. * A keyframe animation
  73794. */
  73795. interface IAnimation extends IChildRootProperty {
  73796. /**
  73797. * An array of channels, each of which targets an animation's sampler at a node's property
  73798. */
  73799. channels: IAnimationChannel[];
  73800. /**
  73801. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  73802. */
  73803. samplers: IAnimationSampler[];
  73804. }
  73805. /**
  73806. * Metadata about the glTF asset
  73807. */
  73808. interface IAsset extends IChildRootProperty {
  73809. /**
  73810. * A copyright message suitable for display to credit the content creator
  73811. */
  73812. copyright?: string;
  73813. /**
  73814. * Tool that generated this glTF model. Useful for debugging
  73815. */
  73816. generator?: string;
  73817. /**
  73818. * The glTF version that this asset targets
  73819. */
  73820. version: string;
  73821. /**
  73822. * The minimum glTF version that this asset targets
  73823. */
  73824. minVersion?: string;
  73825. }
  73826. /**
  73827. * A buffer points to binary geometry, animation, or skins
  73828. */
  73829. interface IBuffer extends IChildRootProperty {
  73830. /**
  73831. * 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
  73832. */
  73833. uri?: string;
  73834. /**
  73835. * The length of the buffer in bytes
  73836. */
  73837. byteLength: number;
  73838. }
  73839. /**
  73840. * A view into a buffer generally representing a subset of the buffer
  73841. */
  73842. interface IBufferView extends IChildRootProperty {
  73843. /**
  73844. * The index of the buffer
  73845. */
  73846. buffer: number;
  73847. /**
  73848. * The offset into the buffer in bytes
  73849. */
  73850. byteOffset?: number;
  73851. /**
  73852. * The lenth of the bufferView in bytes
  73853. */
  73854. byteLength: number;
  73855. /**
  73856. * The stride, in bytes
  73857. */
  73858. byteStride?: number;
  73859. }
  73860. /**
  73861. * An orthographic camera containing properties to create an orthographic projection matrix
  73862. */
  73863. interface ICameraOrthographic extends IProperty {
  73864. /**
  73865. * The floating-point horizontal magnification of the view. Must not be zero
  73866. */
  73867. xmag: number;
  73868. /**
  73869. * The floating-point vertical magnification of the view. Must not be zero
  73870. */
  73871. ymag: number;
  73872. /**
  73873. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  73874. */
  73875. zfar: number;
  73876. /**
  73877. * The floating-point distance to the near clipping plane
  73878. */
  73879. znear: number;
  73880. }
  73881. /**
  73882. * A perspective camera containing properties to create a perspective projection matrix
  73883. */
  73884. interface ICameraPerspective extends IProperty {
  73885. /**
  73886. * The floating-point aspect ratio of the field of view
  73887. */
  73888. aspectRatio?: number;
  73889. /**
  73890. * The floating-point vertical field of view in radians
  73891. */
  73892. yfov: number;
  73893. /**
  73894. * The floating-point distance to the far clipping plane
  73895. */
  73896. zfar?: number;
  73897. /**
  73898. * The floating-point distance to the near clipping plane
  73899. */
  73900. znear: number;
  73901. }
  73902. /**
  73903. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  73904. */
  73905. interface ICamera extends IChildRootProperty {
  73906. /**
  73907. * An orthographic camera containing properties to create an orthographic projection matrix
  73908. */
  73909. orthographic?: ICameraOrthographic;
  73910. /**
  73911. * A perspective camera containing properties to create a perspective projection matrix
  73912. */
  73913. perspective?: ICameraPerspective;
  73914. /**
  73915. * Specifies if the camera uses a perspective or orthographic projection
  73916. */
  73917. type: CameraType;
  73918. }
  73919. /**
  73920. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  73921. */
  73922. interface IImage extends IChildRootProperty {
  73923. /**
  73924. * 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
  73925. */
  73926. uri?: string;
  73927. /**
  73928. * The image's MIME type
  73929. */
  73930. mimeType?: ImageMimeType;
  73931. /**
  73932. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  73933. */
  73934. bufferView?: number;
  73935. }
  73936. /**
  73937. * Material Normal Texture Info
  73938. */
  73939. interface IMaterialNormalTextureInfo extends ITextureInfo {
  73940. /**
  73941. * The scalar multiplier applied to each normal vector of the normal texture
  73942. */
  73943. scale?: number;
  73944. }
  73945. /**
  73946. * Material Occlusion Texture Info
  73947. */
  73948. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  73949. /**
  73950. * A scalar multiplier controlling the amount of occlusion applied
  73951. */
  73952. strength?: number;
  73953. }
  73954. /**
  73955. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  73956. */
  73957. interface IMaterialPbrMetallicRoughness {
  73958. /**
  73959. * The material's base color factor
  73960. */
  73961. baseColorFactor?: number[];
  73962. /**
  73963. * The base color texture
  73964. */
  73965. baseColorTexture?: ITextureInfo;
  73966. /**
  73967. * The metalness of the material
  73968. */
  73969. metallicFactor?: number;
  73970. /**
  73971. * The roughness of the material
  73972. */
  73973. roughnessFactor?: number;
  73974. /**
  73975. * The metallic-roughness texture
  73976. */
  73977. metallicRoughnessTexture?: ITextureInfo;
  73978. }
  73979. /**
  73980. * The material appearance of a primitive
  73981. */
  73982. interface IMaterial extends IChildRootProperty {
  73983. /**
  73984. * 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
  73985. */
  73986. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  73987. /**
  73988. * The normal map texture
  73989. */
  73990. normalTexture?: IMaterialNormalTextureInfo;
  73991. /**
  73992. * The occlusion map texture
  73993. */
  73994. occlusionTexture?: IMaterialOcclusionTextureInfo;
  73995. /**
  73996. * The emissive map texture
  73997. */
  73998. emissiveTexture?: ITextureInfo;
  73999. /**
  74000. * 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
  74001. */
  74002. emissiveFactor?: number[];
  74003. /**
  74004. * The alpha rendering mode of the material
  74005. */
  74006. alphaMode?: MaterialAlphaMode;
  74007. /**
  74008. * The alpha cutoff value of the material
  74009. */
  74010. alphaCutoff?: number;
  74011. /**
  74012. * Specifies whether the material is double sided
  74013. */
  74014. doubleSided?: boolean;
  74015. }
  74016. /**
  74017. * Geometry to be rendered with the given material
  74018. */
  74019. interface IMeshPrimitive extends IProperty {
  74020. /**
  74021. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  74022. */
  74023. attributes: {
  74024. [name: string]: number;
  74025. };
  74026. /**
  74027. * The index of the accessor that contains the indices
  74028. */
  74029. indices?: number;
  74030. /**
  74031. * The index of the material to apply to this primitive when rendering
  74032. */
  74033. material?: number;
  74034. /**
  74035. * The type of primitives to render. All valid values correspond to WebGL enums
  74036. */
  74037. mode?: MeshPrimitiveMode;
  74038. /**
  74039. * 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
  74040. */
  74041. targets?: {
  74042. [name: string]: number;
  74043. }[];
  74044. }
  74045. /**
  74046. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  74047. */
  74048. interface IMesh extends IChildRootProperty {
  74049. /**
  74050. * An array of primitives, each defining geometry to be rendered with a material
  74051. */
  74052. primitives: IMeshPrimitive[];
  74053. /**
  74054. * Array of weights to be applied to the Morph Targets
  74055. */
  74056. weights?: number[];
  74057. }
  74058. /**
  74059. * A node in the node hierarchy
  74060. */
  74061. interface INode extends IChildRootProperty {
  74062. /**
  74063. * The index of the camera referenced by this node
  74064. */
  74065. camera?: number;
  74066. /**
  74067. * The indices of this node's children
  74068. */
  74069. children?: number[];
  74070. /**
  74071. * The index of the skin referenced by this node
  74072. */
  74073. skin?: number;
  74074. /**
  74075. * A floating-point 4x4 transformation matrix stored in column-major order
  74076. */
  74077. matrix?: number[];
  74078. /**
  74079. * The index of the mesh in this node
  74080. */
  74081. mesh?: number;
  74082. /**
  74083. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  74084. */
  74085. rotation?: number[];
  74086. /**
  74087. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  74088. */
  74089. scale?: number[];
  74090. /**
  74091. * The node's translation along the x, y, and z axes
  74092. */
  74093. translation?: number[];
  74094. /**
  74095. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  74096. */
  74097. weights?: number[];
  74098. }
  74099. /**
  74100. * Texture sampler properties for filtering and wrapping modes
  74101. */
  74102. interface ISampler extends IChildRootProperty {
  74103. /**
  74104. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  74105. */
  74106. magFilter?: TextureMagFilter;
  74107. /**
  74108. * Minification filter. All valid values correspond to WebGL enums
  74109. */
  74110. minFilter?: TextureMinFilter;
  74111. /**
  74112. * S (U) wrapping mode. All valid values correspond to WebGL enums
  74113. */
  74114. wrapS?: TextureWrapMode;
  74115. /**
  74116. * T (V) wrapping mode. All valid values correspond to WebGL enums
  74117. */
  74118. wrapT?: TextureWrapMode;
  74119. }
  74120. /**
  74121. * The root nodes of a scene
  74122. */
  74123. interface IScene extends IChildRootProperty {
  74124. /**
  74125. * The indices of each root node
  74126. */
  74127. nodes: number[];
  74128. }
  74129. /**
  74130. * Joints and matrices defining a skin
  74131. */
  74132. interface ISkin extends IChildRootProperty {
  74133. /**
  74134. * 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
  74135. */
  74136. inverseBindMatrices?: number;
  74137. /**
  74138. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  74139. */
  74140. skeleton?: number;
  74141. /**
  74142. * 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)
  74143. */
  74144. joints: number[];
  74145. }
  74146. /**
  74147. * A texture and its sampler
  74148. */
  74149. interface ITexture extends IChildRootProperty {
  74150. /**
  74151. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  74152. */
  74153. sampler?: number;
  74154. /**
  74155. * The index of the image used by this texture
  74156. */
  74157. source: number;
  74158. }
  74159. /**
  74160. * Reference to a texture
  74161. */
  74162. interface ITextureInfo extends IProperty {
  74163. /**
  74164. * The index of the texture
  74165. */
  74166. index: number;
  74167. /**
  74168. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  74169. */
  74170. texCoord?: number;
  74171. }
  74172. /**
  74173. * The root object for a glTF asset
  74174. */
  74175. interface IGLTF extends IProperty {
  74176. /**
  74177. * An array of accessors. An accessor is a typed view into a bufferView
  74178. */
  74179. accessors?: IAccessor[];
  74180. /**
  74181. * An array of keyframe animations
  74182. */
  74183. animations?: IAnimation[];
  74184. /**
  74185. * Metadata about the glTF asset
  74186. */
  74187. asset: IAsset;
  74188. /**
  74189. * An array of buffers. A buffer points to binary geometry, animation, or skins
  74190. */
  74191. buffers?: IBuffer[];
  74192. /**
  74193. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  74194. */
  74195. bufferViews?: IBufferView[];
  74196. /**
  74197. * An array of cameras
  74198. */
  74199. cameras?: ICamera[];
  74200. /**
  74201. * Names of glTF extensions used somewhere in this asset
  74202. */
  74203. extensionsUsed?: string[];
  74204. /**
  74205. * Names of glTF extensions required to properly load this asset
  74206. */
  74207. extensionsRequired?: string[];
  74208. /**
  74209. * An array of images. An image defines data used to create a texture
  74210. */
  74211. images?: IImage[];
  74212. /**
  74213. * An array of materials. A material defines the appearance of a primitive
  74214. */
  74215. materials?: IMaterial[];
  74216. /**
  74217. * An array of meshes. A mesh is a set of primitives to be rendered
  74218. */
  74219. meshes?: IMesh[];
  74220. /**
  74221. * An array of nodes
  74222. */
  74223. nodes?: INode[];
  74224. /**
  74225. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  74226. */
  74227. samplers?: ISampler[];
  74228. /**
  74229. * The index of the default scene
  74230. */
  74231. scene?: number;
  74232. /**
  74233. * An array of scenes
  74234. */
  74235. scenes?: IScene[];
  74236. /**
  74237. * An array of skins. A skin is defined by joints and matrices
  74238. */
  74239. skins?: ISkin[];
  74240. /**
  74241. * An array of textures
  74242. */
  74243. textures?: ITexture[];
  74244. }
  74245. /**
  74246. * The glTF validation results
  74247. * @ignore
  74248. */
  74249. interface IGLTFValidationResults {
  74250. info: {
  74251. generator: string;
  74252. hasAnimations: boolean;
  74253. hasDefaultScene: boolean;
  74254. hasMaterials: boolean;
  74255. hasMorphTargets: boolean;
  74256. hasSkins: boolean;
  74257. hasTextures: boolean;
  74258. maxAttributesUsed: number;
  74259. primitivesCount: number
  74260. };
  74261. issues: {
  74262. messages: Array<string>;
  74263. numErrors: number;
  74264. numHints: number;
  74265. numInfos: number;
  74266. numWarnings: number;
  74267. truncated: boolean
  74268. };
  74269. mimeType: string;
  74270. uri: string;
  74271. validatedAt: string;
  74272. validatorVersion: string;
  74273. }
  74274. /**
  74275. * The glTF validation options
  74276. */
  74277. interface IGLTFValidationOptions {
  74278. /** Uri to use */
  74279. uri?: string;
  74280. /** Function used to load external resources */
  74281. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  74282. /** Boolean indicating that we need to validate accessor data */
  74283. validateAccessorData?: boolean;
  74284. /** max number of issues allowed */
  74285. maxIssues?: number;
  74286. /** Ignored issues */
  74287. ignoredIssues?: Array<string>;
  74288. /** Value to override severy settings */
  74289. severityOverrides?: Object;
  74290. }
  74291. /**
  74292. * The glTF validator object
  74293. * @ignore
  74294. */
  74295. interface IGLTFValidator {
  74296. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  74297. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  74298. }
  74299. }
  74300. declare module BABYLON {
  74301. /** @hidden */
  74302. export var cellPixelShader: {
  74303. name: string;
  74304. shader: string;
  74305. };
  74306. }
  74307. declare module BABYLON {
  74308. /** @hidden */
  74309. export var cellVertexShader: {
  74310. name: string;
  74311. shader: string;
  74312. };
  74313. }
  74314. declare module BABYLON {
  74315. export class CellMaterial extends BABYLON.PushMaterial {
  74316. private _diffuseTexture;
  74317. diffuseTexture: BABYLON.BaseTexture;
  74318. diffuseColor: BABYLON.Color3;
  74319. _computeHighLevel: boolean;
  74320. computeHighLevel: boolean;
  74321. private _disableLighting;
  74322. disableLighting: boolean;
  74323. private _maxSimultaneousLights;
  74324. maxSimultaneousLights: number;
  74325. private _renderId;
  74326. constructor(name: string, scene: BABYLON.Scene);
  74327. needAlphaBlending(): boolean;
  74328. needAlphaTesting(): boolean;
  74329. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74330. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74331. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74332. getAnimatables(): BABYLON.IAnimatable[];
  74333. getActiveTextures(): BABYLON.BaseTexture[];
  74334. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74335. dispose(forceDisposeEffect?: boolean): void;
  74336. getClassName(): string;
  74337. clone(name: string): CellMaterial;
  74338. serialize(): any;
  74339. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  74340. }
  74341. }
  74342. declare module BABYLON {
  74343. export class CustomShaderStructure {
  74344. FragmentStore: string;
  74345. VertexStore: string;
  74346. constructor();
  74347. }
  74348. export class ShaderSpecialParts {
  74349. constructor();
  74350. Fragment_Begin: string;
  74351. Fragment_Definitions: string;
  74352. Fragment_MainBegin: string;
  74353. Fragment_Custom_Diffuse: string;
  74354. Fragment_Before_Lights: string;
  74355. Fragment_Before_Fog: string;
  74356. Fragment_Custom_Alpha: string;
  74357. Fragment_Before_FragColor: string;
  74358. Vertex_Begin: string;
  74359. Vertex_Definitions: string;
  74360. Vertex_MainBegin: string;
  74361. Vertex_Before_PositionUpdated: string;
  74362. Vertex_Before_NormalUpdated: string;
  74363. Vertex_MainEnd: string;
  74364. }
  74365. export class CustomMaterial extends BABYLON.StandardMaterial {
  74366. static ShaderIndexer: number;
  74367. CustomParts: ShaderSpecialParts;
  74368. _isCreatedShader: boolean;
  74369. _createdShaderName: string;
  74370. _customUniform: string[];
  74371. _newUniforms: string[];
  74372. _newUniformInstances: any[];
  74373. _newSamplerInstances: BABYLON.Texture[];
  74374. FragmentShader: string;
  74375. VertexShader: string;
  74376. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  74377. ReviewUniform(name: string, arr: string[]): string[];
  74378. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  74379. constructor(name: string, scene: BABYLON.Scene);
  74380. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  74381. Fragment_Begin(shaderPart: string): CustomMaterial;
  74382. Fragment_Definitions(shaderPart: string): CustomMaterial;
  74383. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  74384. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  74385. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  74386. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  74387. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  74388. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  74389. Vertex_Begin(shaderPart: string): CustomMaterial;
  74390. Vertex_Definitions(shaderPart: string): CustomMaterial;
  74391. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  74392. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  74393. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  74394. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  74395. }
  74396. }
  74397. declare module BABYLON {
  74398. export class ShaderAlebdoParts {
  74399. constructor();
  74400. Fragment_Begin: string;
  74401. Fragment_Definitions: string;
  74402. Fragment_MainBegin: string;
  74403. Fragment_Custom_Albedo: string;
  74404. Fragment_Before_Lights: string;
  74405. Fragment_Custom_MetallicRoughness: string;
  74406. Fragment_Custom_MicroSurface: string;
  74407. Fragment_Before_Fog: string;
  74408. Fragment_Custom_Alpha: string;
  74409. Fragment_Before_FragColor: string;
  74410. Vertex_Begin: string;
  74411. Vertex_Definitions: string;
  74412. Vertex_MainBegin: string;
  74413. Vertex_Before_PositionUpdated: string;
  74414. Vertex_Before_NormalUpdated: string;
  74415. Vertex_MainEnd: string;
  74416. }
  74417. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  74418. static ShaderIndexer: number;
  74419. CustomParts: ShaderAlebdoParts;
  74420. _isCreatedShader: boolean;
  74421. _createdShaderName: string;
  74422. _customUniform: string[];
  74423. _newUniforms: string[];
  74424. _newUniformInstances: any[];
  74425. _newSamplerInstances: BABYLON.Texture[];
  74426. FragmentShader: string;
  74427. VertexShader: string;
  74428. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  74429. ReviewUniform(name: string, arr: string[]): string[];
  74430. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  74431. constructor(name: string, scene: BABYLON.Scene);
  74432. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  74433. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  74434. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  74435. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  74436. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  74437. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  74438. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  74439. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  74440. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  74441. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  74442. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  74443. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  74444. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  74445. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  74446. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  74447. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  74448. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  74449. }
  74450. }
  74451. declare module BABYLON {
  74452. /** @hidden */
  74453. export var firePixelShader: {
  74454. name: string;
  74455. shader: string;
  74456. };
  74457. }
  74458. declare module BABYLON {
  74459. /** @hidden */
  74460. export var fireVertexShader: {
  74461. name: string;
  74462. shader: string;
  74463. };
  74464. }
  74465. declare module BABYLON {
  74466. export class FireMaterial extends BABYLON.PushMaterial {
  74467. private _diffuseTexture;
  74468. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74469. private _distortionTexture;
  74470. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74471. private _opacityTexture;
  74472. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74473. diffuseColor: BABYLON.Color3;
  74474. speed: number;
  74475. private _scaledDiffuse;
  74476. private _renderId;
  74477. private _lastTime;
  74478. constructor(name: string, scene: BABYLON.Scene);
  74479. needAlphaBlending(): boolean;
  74480. needAlphaTesting(): boolean;
  74481. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74482. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74483. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74484. getAnimatables(): BABYLON.IAnimatable[];
  74485. getActiveTextures(): BABYLON.BaseTexture[];
  74486. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74487. getClassName(): string;
  74488. dispose(forceDisposeEffect?: boolean): void;
  74489. clone(name: string): FireMaterial;
  74490. serialize(): any;
  74491. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  74492. }
  74493. }
  74494. declare module BABYLON {
  74495. /** @hidden */
  74496. export var furPixelShader: {
  74497. name: string;
  74498. shader: string;
  74499. };
  74500. }
  74501. declare module BABYLON {
  74502. /** @hidden */
  74503. export var furVertexShader: {
  74504. name: string;
  74505. shader: string;
  74506. };
  74507. }
  74508. declare module BABYLON {
  74509. export class FurMaterial extends BABYLON.PushMaterial {
  74510. private _diffuseTexture;
  74511. diffuseTexture: BABYLON.BaseTexture;
  74512. private _heightTexture;
  74513. heightTexture: BABYLON.BaseTexture;
  74514. diffuseColor: BABYLON.Color3;
  74515. furLength: number;
  74516. furAngle: number;
  74517. furColor: BABYLON.Color3;
  74518. furOffset: number;
  74519. furSpacing: number;
  74520. furGravity: BABYLON.Vector3;
  74521. furSpeed: number;
  74522. furDensity: number;
  74523. furOcclusion: number;
  74524. furTexture: BABYLON.DynamicTexture;
  74525. private _disableLighting;
  74526. disableLighting: boolean;
  74527. private _maxSimultaneousLights;
  74528. maxSimultaneousLights: number;
  74529. highLevelFur: boolean;
  74530. _meshes: BABYLON.AbstractMesh[];
  74531. private _renderId;
  74532. private _furTime;
  74533. constructor(name: string, scene: BABYLON.Scene);
  74534. furTime: number;
  74535. needAlphaBlending(): boolean;
  74536. needAlphaTesting(): boolean;
  74537. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74538. updateFur(): void;
  74539. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74540. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74541. getAnimatables(): BABYLON.IAnimatable[];
  74542. getActiveTextures(): BABYLON.BaseTexture[];
  74543. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74544. dispose(forceDisposeEffect?: boolean): void;
  74545. clone(name: string): FurMaterial;
  74546. serialize(): any;
  74547. getClassName(): string;
  74548. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  74549. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  74550. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  74551. }
  74552. }
  74553. declare module BABYLON {
  74554. /** @hidden */
  74555. export var gradientPixelShader: {
  74556. name: string;
  74557. shader: string;
  74558. };
  74559. }
  74560. declare module BABYLON {
  74561. /** @hidden */
  74562. export var gradientVertexShader: {
  74563. name: string;
  74564. shader: string;
  74565. };
  74566. }
  74567. declare module BABYLON {
  74568. export class GradientMaterial extends BABYLON.PushMaterial {
  74569. private _maxSimultaneousLights;
  74570. maxSimultaneousLights: number;
  74571. topColor: BABYLON.Color3;
  74572. topColorAlpha: number;
  74573. bottomColor: BABYLON.Color3;
  74574. bottomColorAlpha: number;
  74575. offset: number;
  74576. scale: number;
  74577. smoothness: number;
  74578. private _disableLighting;
  74579. disableLighting: boolean;
  74580. private _renderId;
  74581. constructor(name: string, scene: BABYLON.Scene);
  74582. needAlphaBlending(): boolean;
  74583. needAlphaTesting(): boolean;
  74584. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74585. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74586. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74587. getAnimatables(): BABYLON.IAnimatable[];
  74588. dispose(forceDisposeEffect?: boolean): void;
  74589. clone(name: string): GradientMaterial;
  74590. serialize(): any;
  74591. getClassName(): string;
  74592. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  74593. }
  74594. }
  74595. declare module BABYLON {
  74596. /** @hidden */
  74597. export var gridPixelShader: {
  74598. name: string;
  74599. shader: string;
  74600. };
  74601. }
  74602. declare module BABYLON {
  74603. /** @hidden */
  74604. export var gridVertexShader: {
  74605. name: string;
  74606. shader: string;
  74607. };
  74608. }
  74609. declare module BABYLON {
  74610. /**
  74611. * The grid materials allows you to wrap any shape with a grid.
  74612. * Colors are customizable.
  74613. */
  74614. export class GridMaterial extends BABYLON.PushMaterial {
  74615. /**
  74616. * Main color of the grid (e.g. between lines)
  74617. */
  74618. mainColor: BABYLON.Color3;
  74619. /**
  74620. * Color of the grid lines.
  74621. */
  74622. lineColor: BABYLON.Color3;
  74623. /**
  74624. * The scale of the grid compared to unit.
  74625. */
  74626. gridRatio: number;
  74627. /**
  74628. * Allows setting an offset for the grid lines.
  74629. */
  74630. gridOffset: BABYLON.Vector3;
  74631. /**
  74632. * The frequency of thicker lines.
  74633. */
  74634. majorUnitFrequency: number;
  74635. /**
  74636. * The visibility of minor units in the grid.
  74637. */
  74638. minorUnitVisibility: number;
  74639. /**
  74640. * The grid opacity outside of the lines.
  74641. */
  74642. opacity: number;
  74643. /**
  74644. * Determine RBG output is premultiplied by alpha value.
  74645. */
  74646. preMultiplyAlpha: boolean;
  74647. private _opacityTexture;
  74648. opacityTexture: BABYLON.BaseTexture;
  74649. private _gridControl;
  74650. private _renderId;
  74651. /**
  74652. * constructor
  74653. * @param name The name given to the material in order to identify it afterwards.
  74654. * @param scene The scene the material is used in.
  74655. */
  74656. constructor(name: string, scene: BABYLON.Scene);
  74657. /**
  74658. * Returns wehter or not the grid requires alpha blending.
  74659. */
  74660. needAlphaBlending(): boolean;
  74661. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  74662. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74663. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74664. /**
  74665. * Dispose the material and its associated resources.
  74666. * @param forceDisposeEffect will also dispose the used effect when true
  74667. */
  74668. dispose(forceDisposeEffect?: boolean): void;
  74669. clone(name: string): GridMaterial;
  74670. serialize(): any;
  74671. getClassName(): string;
  74672. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  74673. }
  74674. }
  74675. declare module BABYLON {
  74676. /** @hidden */
  74677. export var lavaPixelShader: {
  74678. name: string;
  74679. shader: string;
  74680. };
  74681. }
  74682. declare module BABYLON {
  74683. /** @hidden */
  74684. export var lavaVertexShader: {
  74685. name: string;
  74686. shader: string;
  74687. };
  74688. }
  74689. declare module BABYLON {
  74690. export class LavaMaterial extends BABYLON.PushMaterial {
  74691. private _diffuseTexture;
  74692. diffuseTexture: BABYLON.BaseTexture;
  74693. noiseTexture: BABYLON.BaseTexture;
  74694. fogColor: BABYLON.Color3;
  74695. speed: number;
  74696. movingSpeed: number;
  74697. lowFrequencySpeed: number;
  74698. fogDensity: number;
  74699. private _lastTime;
  74700. diffuseColor: BABYLON.Color3;
  74701. private _disableLighting;
  74702. disableLighting: boolean;
  74703. private _unlit;
  74704. unlit: boolean;
  74705. private _maxSimultaneousLights;
  74706. maxSimultaneousLights: number;
  74707. private _scaledDiffuse;
  74708. private _renderId;
  74709. constructor(name: string, scene: BABYLON.Scene);
  74710. needAlphaBlending(): boolean;
  74711. needAlphaTesting(): boolean;
  74712. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74713. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74714. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74715. getAnimatables(): BABYLON.IAnimatable[];
  74716. getActiveTextures(): BABYLON.BaseTexture[];
  74717. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74718. dispose(forceDisposeEffect?: boolean): void;
  74719. clone(name: string): LavaMaterial;
  74720. serialize(): any;
  74721. getClassName(): string;
  74722. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  74723. }
  74724. }
  74725. declare module BABYLON {
  74726. /** @hidden */
  74727. export var mixPixelShader: {
  74728. name: string;
  74729. shader: string;
  74730. };
  74731. }
  74732. declare module BABYLON {
  74733. /** @hidden */
  74734. export var mixVertexShader: {
  74735. name: string;
  74736. shader: string;
  74737. };
  74738. }
  74739. declare module BABYLON {
  74740. export class MixMaterial extends BABYLON.PushMaterial {
  74741. /**
  74742. * Mix textures
  74743. */
  74744. private _mixTexture1;
  74745. mixTexture1: BABYLON.BaseTexture;
  74746. private _mixTexture2;
  74747. mixTexture2: BABYLON.BaseTexture;
  74748. /**
  74749. * Diffuse textures
  74750. */
  74751. private _diffuseTexture1;
  74752. diffuseTexture1: BABYLON.Texture;
  74753. private _diffuseTexture2;
  74754. diffuseTexture2: BABYLON.Texture;
  74755. private _diffuseTexture3;
  74756. diffuseTexture3: BABYLON.Texture;
  74757. private _diffuseTexture4;
  74758. diffuseTexture4: BABYLON.Texture;
  74759. private _diffuseTexture5;
  74760. diffuseTexture5: BABYLON.Texture;
  74761. private _diffuseTexture6;
  74762. diffuseTexture6: BABYLON.Texture;
  74763. private _diffuseTexture7;
  74764. diffuseTexture7: BABYLON.Texture;
  74765. private _diffuseTexture8;
  74766. diffuseTexture8: BABYLON.Texture;
  74767. /**
  74768. * Uniforms
  74769. */
  74770. diffuseColor: BABYLON.Color3;
  74771. specularColor: BABYLON.Color3;
  74772. specularPower: number;
  74773. private _disableLighting;
  74774. disableLighting: boolean;
  74775. private _maxSimultaneousLights;
  74776. maxSimultaneousLights: number;
  74777. private _renderId;
  74778. constructor(name: string, scene: BABYLON.Scene);
  74779. needAlphaBlending(): boolean;
  74780. needAlphaTesting(): boolean;
  74781. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74782. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74783. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74784. getAnimatables(): BABYLON.IAnimatable[];
  74785. getActiveTextures(): BABYLON.BaseTexture[];
  74786. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74787. dispose(forceDisposeEffect?: boolean): void;
  74788. clone(name: string): MixMaterial;
  74789. serialize(): any;
  74790. getClassName(): string;
  74791. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  74792. }
  74793. }
  74794. declare module BABYLON {
  74795. /** @hidden */
  74796. export var normalPixelShader: {
  74797. name: string;
  74798. shader: string;
  74799. };
  74800. }
  74801. declare module BABYLON {
  74802. /** @hidden */
  74803. export var normalVertexShader: {
  74804. name: string;
  74805. shader: string;
  74806. };
  74807. }
  74808. declare module BABYLON {
  74809. export class NormalMaterial extends BABYLON.PushMaterial {
  74810. private _diffuseTexture;
  74811. diffuseTexture: BABYLON.BaseTexture;
  74812. diffuseColor: BABYLON.Color3;
  74813. private _disableLighting;
  74814. disableLighting: boolean;
  74815. private _maxSimultaneousLights;
  74816. maxSimultaneousLights: number;
  74817. private _renderId;
  74818. constructor(name: string, scene: BABYLON.Scene);
  74819. needAlphaBlending(): boolean;
  74820. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  74821. needAlphaTesting(): boolean;
  74822. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74823. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74824. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74825. getAnimatables(): BABYLON.IAnimatable[];
  74826. getActiveTextures(): BABYLON.BaseTexture[];
  74827. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74828. dispose(forceDisposeEffect?: boolean): void;
  74829. clone(name: string): NormalMaterial;
  74830. serialize(): any;
  74831. getClassName(): string;
  74832. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  74833. }
  74834. }
  74835. declare module BABYLON {
  74836. /** @hidden */
  74837. export var shadowOnlyPixelShader: {
  74838. name: string;
  74839. shader: string;
  74840. };
  74841. }
  74842. declare module BABYLON {
  74843. /** @hidden */
  74844. export var shadowOnlyVertexShader: {
  74845. name: string;
  74846. shader: string;
  74847. };
  74848. }
  74849. declare module BABYLON {
  74850. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  74851. private _renderId;
  74852. private _activeLight;
  74853. constructor(name: string, scene: BABYLON.Scene);
  74854. shadowColor: BABYLON.Color3;
  74855. needAlphaBlending(): boolean;
  74856. needAlphaTesting(): boolean;
  74857. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74858. activeLight: BABYLON.IShadowLight;
  74859. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74860. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74861. clone(name: string): ShadowOnlyMaterial;
  74862. serialize(): any;
  74863. getClassName(): string;
  74864. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  74865. }
  74866. }
  74867. declare module BABYLON {
  74868. /** @hidden */
  74869. export var simplePixelShader: {
  74870. name: string;
  74871. shader: string;
  74872. };
  74873. }
  74874. declare module BABYLON {
  74875. /** @hidden */
  74876. export var simpleVertexShader: {
  74877. name: string;
  74878. shader: string;
  74879. };
  74880. }
  74881. declare module BABYLON {
  74882. export class SimpleMaterial extends BABYLON.PushMaterial {
  74883. private _diffuseTexture;
  74884. diffuseTexture: BABYLON.BaseTexture;
  74885. diffuseColor: BABYLON.Color3;
  74886. private _disableLighting;
  74887. disableLighting: boolean;
  74888. private _maxSimultaneousLights;
  74889. maxSimultaneousLights: number;
  74890. private _renderId;
  74891. constructor(name: string, scene: BABYLON.Scene);
  74892. needAlphaBlending(): boolean;
  74893. needAlphaTesting(): boolean;
  74894. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74895. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74896. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74897. getAnimatables(): BABYLON.IAnimatable[];
  74898. getActiveTextures(): BABYLON.BaseTexture[];
  74899. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74900. dispose(forceDisposeEffect?: boolean): void;
  74901. clone(name: string): SimpleMaterial;
  74902. serialize(): any;
  74903. getClassName(): string;
  74904. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  74905. }
  74906. }
  74907. declare module BABYLON {
  74908. /** @hidden */
  74909. export var skyPixelShader: {
  74910. name: string;
  74911. shader: string;
  74912. };
  74913. }
  74914. declare module BABYLON {
  74915. /** @hidden */
  74916. export var skyVertexShader: {
  74917. name: string;
  74918. shader: string;
  74919. };
  74920. }
  74921. declare module BABYLON {
  74922. /**
  74923. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  74924. * @see https://doc.babylonjs.com/extensions/sky
  74925. */
  74926. export class SkyMaterial extends BABYLON.PushMaterial {
  74927. /**
  74928. * Defines the overall luminance of sky in interval ]0, 1[.
  74929. */
  74930. luminance: number;
  74931. /**
  74932. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  74933. */
  74934. turbidity: number;
  74935. /**
  74936. * Defines the sky appearance (light intensity).
  74937. */
  74938. rayleigh: number;
  74939. /**
  74940. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  74941. */
  74942. mieCoefficient: number;
  74943. /**
  74944. * Defines the amount of haze particles following the Mie scattering theory.
  74945. */
  74946. mieDirectionalG: number;
  74947. /**
  74948. * Defines the distance of the sun according to the active scene camera.
  74949. */
  74950. distance: number;
  74951. /**
  74952. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  74953. * "inclined".
  74954. */
  74955. inclination: number;
  74956. /**
  74957. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  74958. * an object direction and a reference direction.
  74959. */
  74960. azimuth: number;
  74961. /**
  74962. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  74963. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  74964. */
  74965. sunPosition: BABYLON.Vector3;
  74966. /**
  74967. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  74968. * .sunPosition property.
  74969. */
  74970. useSunPosition: boolean;
  74971. /**
  74972. * Defines an offset vector used to get a horizon offset.
  74973. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  74974. */
  74975. cameraOffset: BABYLON.Vector3;
  74976. private _cameraPosition;
  74977. private _renderId;
  74978. /**
  74979. * Instantiates a new sky material.
  74980. * This material allows to create dynamic and texture free
  74981. * effects for skyboxes by taking care of the atmosphere state.
  74982. * @see https://doc.babylonjs.com/extensions/sky
  74983. * @param name Define the name of the material in the scene
  74984. * @param scene Define the scene the material belong to
  74985. */
  74986. constructor(name: string, scene: BABYLON.Scene);
  74987. /**
  74988. * Specifies if the material will require alpha blending
  74989. * @returns a boolean specifying if alpha blending is needed
  74990. */
  74991. needAlphaBlending(): boolean;
  74992. /**
  74993. * Specifies if this material should be rendered in alpha test mode
  74994. * @returns false as the sky material doesn't need alpha testing.
  74995. */
  74996. needAlphaTesting(): boolean;
  74997. /**
  74998. * Get the texture used for alpha test purpose.
  74999. * @returns null as the sky material has no texture.
  75000. */
  75001. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75002. /**
  75003. * Get if the submesh is ready to be used and all its information available.
  75004. * Child classes can use it to update shaders
  75005. * @param mesh defines the mesh to check
  75006. * @param subMesh defines which submesh to check
  75007. * @param useInstances specifies that instances should be used
  75008. * @returns a boolean indicating that the submesh is ready or not
  75009. */
  75010. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75011. /**
  75012. * Binds the submesh to this material by preparing the effect and shader to draw
  75013. * @param world defines the world transformation matrix
  75014. * @param mesh defines the mesh containing the submesh
  75015. * @param subMesh defines the submesh to bind the material to
  75016. */
  75017. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75018. /**
  75019. * Get the list of animatables in the material.
  75020. * @returns the list of animatables object used in the material
  75021. */
  75022. getAnimatables(): BABYLON.IAnimatable[];
  75023. /**
  75024. * Disposes the material
  75025. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75026. */
  75027. dispose(forceDisposeEffect?: boolean): void;
  75028. /**
  75029. * Makes a duplicate of the material, and gives it a new name
  75030. * @param name defines the new name for the duplicated material
  75031. * @returns the cloned material
  75032. */
  75033. clone(name: string): SkyMaterial;
  75034. /**
  75035. * Serializes this material in a JSON representation
  75036. * @returns the serialized material object
  75037. */
  75038. serialize(): any;
  75039. /**
  75040. * Gets the current class name of the material e.g. "SkyMaterial"
  75041. * Mainly use in serialization.
  75042. * @returns the class name
  75043. */
  75044. getClassName(): string;
  75045. /**
  75046. * Creates a sky material from parsed material data
  75047. * @param source defines the JSON representation of the material
  75048. * @param scene defines the hosting scene
  75049. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75050. * @returns a new sky material
  75051. */
  75052. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  75053. }
  75054. }
  75055. declare module BABYLON {
  75056. /** @hidden */
  75057. export var terrainPixelShader: {
  75058. name: string;
  75059. shader: string;
  75060. };
  75061. }
  75062. declare module BABYLON {
  75063. /** @hidden */
  75064. export var terrainVertexShader: {
  75065. name: string;
  75066. shader: string;
  75067. };
  75068. }
  75069. declare module BABYLON {
  75070. export class TerrainMaterial extends BABYLON.PushMaterial {
  75071. private _mixTexture;
  75072. mixTexture: BABYLON.BaseTexture;
  75073. private _diffuseTexture1;
  75074. diffuseTexture1: BABYLON.Texture;
  75075. private _diffuseTexture2;
  75076. diffuseTexture2: BABYLON.Texture;
  75077. private _diffuseTexture3;
  75078. diffuseTexture3: BABYLON.Texture;
  75079. private _bumpTexture1;
  75080. bumpTexture1: BABYLON.Texture;
  75081. private _bumpTexture2;
  75082. bumpTexture2: BABYLON.Texture;
  75083. private _bumpTexture3;
  75084. bumpTexture3: BABYLON.Texture;
  75085. diffuseColor: BABYLON.Color3;
  75086. specularColor: BABYLON.Color3;
  75087. specularPower: number;
  75088. private _disableLighting;
  75089. disableLighting: boolean;
  75090. private _maxSimultaneousLights;
  75091. maxSimultaneousLights: number;
  75092. private _renderId;
  75093. constructor(name: string, scene: BABYLON.Scene);
  75094. needAlphaBlending(): boolean;
  75095. needAlphaTesting(): boolean;
  75096. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75097. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75098. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75099. getAnimatables(): BABYLON.IAnimatable[];
  75100. getActiveTextures(): BABYLON.BaseTexture[];
  75101. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75102. dispose(forceDisposeEffect?: boolean): void;
  75103. clone(name: string): TerrainMaterial;
  75104. serialize(): any;
  75105. getClassName(): string;
  75106. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  75107. }
  75108. }
  75109. declare module BABYLON {
  75110. /** @hidden */
  75111. export var triplanarPixelShader: {
  75112. name: string;
  75113. shader: string;
  75114. };
  75115. }
  75116. declare module BABYLON {
  75117. /** @hidden */
  75118. export var triplanarVertexShader: {
  75119. name: string;
  75120. shader: string;
  75121. };
  75122. }
  75123. declare module BABYLON {
  75124. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  75125. mixTexture: BABYLON.BaseTexture;
  75126. private _diffuseTextureX;
  75127. diffuseTextureX: BABYLON.BaseTexture;
  75128. private _diffuseTextureY;
  75129. diffuseTextureY: BABYLON.BaseTexture;
  75130. private _diffuseTextureZ;
  75131. diffuseTextureZ: BABYLON.BaseTexture;
  75132. private _normalTextureX;
  75133. normalTextureX: BABYLON.BaseTexture;
  75134. private _normalTextureY;
  75135. normalTextureY: BABYLON.BaseTexture;
  75136. private _normalTextureZ;
  75137. normalTextureZ: BABYLON.BaseTexture;
  75138. tileSize: number;
  75139. diffuseColor: BABYLON.Color3;
  75140. specularColor: BABYLON.Color3;
  75141. specularPower: number;
  75142. private _disableLighting;
  75143. disableLighting: boolean;
  75144. private _maxSimultaneousLights;
  75145. maxSimultaneousLights: number;
  75146. private _renderId;
  75147. constructor(name: string, scene: BABYLON.Scene);
  75148. needAlphaBlending(): boolean;
  75149. needAlphaTesting(): boolean;
  75150. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75151. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75152. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75153. getAnimatables(): BABYLON.IAnimatable[];
  75154. getActiveTextures(): BABYLON.BaseTexture[];
  75155. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75156. dispose(forceDisposeEffect?: boolean): void;
  75157. clone(name: string): TriPlanarMaterial;
  75158. serialize(): any;
  75159. getClassName(): string;
  75160. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  75161. }
  75162. }
  75163. declare module BABYLON {
  75164. /** @hidden */
  75165. export var waterPixelShader: {
  75166. name: string;
  75167. shader: string;
  75168. };
  75169. }
  75170. declare module BABYLON {
  75171. /** @hidden */
  75172. export var waterVertexShader: {
  75173. name: string;
  75174. shader: string;
  75175. };
  75176. }
  75177. declare module BABYLON {
  75178. export class WaterMaterial extends BABYLON.PushMaterial {
  75179. renderTargetSize: BABYLON.Vector2;
  75180. private _bumpTexture;
  75181. bumpTexture: BABYLON.BaseTexture;
  75182. diffuseColor: BABYLON.Color3;
  75183. specularColor: BABYLON.Color3;
  75184. specularPower: number;
  75185. private _disableLighting;
  75186. disableLighting: boolean;
  75187. private _maxSimultaneousLights;
  75188. maxSimultaneousLights: number;
  75189. /**
  75190. * @param {number}: Represents the wind force
  75191. */
  75192. windForce: number;
  75193. /**
  75194. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  75195. */
  75196. windDirection: BABYLON.Vector2;
  75197. /**
  75198. * @param {number}: Wave height, represents the height of the waves
  75199. */
  75200. waveHeight: number;
  75201. /**
  75202. * @param {number}: Bump height, represents the bump height related to the bump map
  75203. */
  75204. bumpHeight: number;
  75205. /**
  75206. * @param {boolean}: Add a smaller moving bump to less steady waves.
  75207. */
  75208. private _bumpSuperimpose;
  75209. bumpSuperimpose: boolean;
  75210. /**
  75211. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  75212. */
  75213. private _fresnelSeparate;
  75214. fresnelSeparate: boolean;
  75215. /**
  75216. * @param {boolean}: bump Waves modify the reflection.
  75217. */
  75218. private _bumpAffectsReflection;
  75219. bumpAffectsReflection: boolean;
  75220. /**
  75221. * @param {number}: The water color blended with the refraction (near)
  75222. */
  75223. waterColor: BABYLON.Color3;
  75224. /**
  75225. * @param {number}: The blend factor related to the water color
  75226. */
  75227. colorBlendFactor: number;
  75228. /**
  75229. * @param {number}: The water color blended with the reflection (far)
  75230. */
  75231. waterColor2: BABYLON.Color3;
  75232. /**
  75233. * @param {number}: The blend factor related to the water color (reflection, far)
  75234. */
  75235. colorBlendFactor2: number;
  75236. /**
  75237. * @param {number}: Represents the maximum length of a wave
  75238. */
  75239. waveLength: number;
  75240. /**
  75241. * @param {number}: Defines the waves speed
  75242. */
  75243. waveSpeed: number;
  75244. /**
  75245. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  75246. * will avoid calculating useless pixels in the pixel shader of the water material.
  75247. */
  75248. disableClipPlane: boolean;
  75249. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  75250. private _mesh;
  75251. private _refractionRTT;
  75252. private _reflectionRTT;
  75253. private _reflectionTransform;
  75254. private _lastTime;
  75255. private _lastDeltaTime;
  75256. private _renderId;
  75257. private _useLogarithmicDepth;
  75258. private _waitingRenderList;
  75259. private _imageProcessingConfiguration;
  75260. private _imageProcessingObserver;
  75261. /**
  75262. * Gets a boolean indicating that current material needs to register RTT
  75263. */
  75264. readonly hasRenderTargetTextures: boolean;
  75265. /**
  75266. * Constructor
  75267. */
  75268. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  75269. useLogarithmicDepth: boolean;
  75270. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  75271. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  75272. addToRenderList(node: any): void;
  75273. enableRenderTargets(enable: boolean): void;
  75274. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  75275. readonly renderTargetsEnabled: boolean;
  75276. needAlphaBlending(): boolean;
  75277. needAlphaTesting(): boolean;
  75278. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75279. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75280. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75281. private _createRenderTargets;
  75282. getAnimatables(): BABYLON.IAnimatable[];
  75283. getActiveTextures(): BABYLON.BaseTexture[];
  75284. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75285. dispose(forceDisposeEffect?: boolean): void;
  75286. clone(name: string): WaterMaterial;
  75287. serialize(): any;
  75288. getClassName(): string;
  75289. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  75290. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  75291. }
  75292. }
  75293. declare module BABYLON {
  75294. /** @hidden */
  75295. export var asciiartPixelShader: {
  75296. name: string;
  75297. shader: string;
  75298. };
  75299. }
  75300. declare module BABYLON {
  75301. /**
  75302. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  75303. *
  75304. * It basically takes care rendering the font front the given font size to a texture.
  75305. * This is used later on in the postprocess.
  75306. */
  75307. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  75308. private _font;
  75309. private _text;
  75310. private _charSize;
  75311. /**
  75312. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  75313. */
  75314. readonly charSize: number;
  75315. /**
  75316. * Create a new instance of the Ascii Art FontTexture class
  75317. * @param name the name of the texture
  75318. * @param font the font to use, use the W3C CSS notation
  75319. * @param text the caracter set to use in the rendering.
  75320. * @param scene the scene that owns the texture
  75321. */
  75322. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  75323. /**
  75324. * Gets the max char width of a font.
  75325. * @param font the font to use, use the W3C CSS notation
  75326. * @return the max char width
  75327. */
  75328. private getFontWidth;
  75329. /**
  75330. * Gets the max char height of a font.
  75331. * @param font the font to use, use the W3C CSS notation
  75332. * @return the max char height
  75333. */
  75334. private getFontHeight;
  75335. /**
  75336. * Clones the current AsciiArtTexture.
  75337. * @return the clone of the texture.
  75338. */
  75339. clone(): AsciiArtFontTexture;
  75340. /**
  75341. * Parses a json object representing the texture and returns an instance of it.
  75342. * @param source the source JSON representation
  75343. * @param scene the scene to create the texture for
  75344. * @return the parsed texture
  75345. */
  75346. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  75347. }
  75348. /**
  75349. * Option available in the Ascii Art Post Process.
  75350. */
  75351. export interface IAsciiArtPostProcessOptions {
  75352. /**
  75353. * The font to use following the w3c font definition.
  75354. */
  75355. font?: string;
  75356. /**
  75357. * The character set to use in the postprocess.
  75358. */
  75359. characterSet?: string;
  75360. /**
  75361. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  75362. * This number is defined between 0 and 1;
  75363. */
  75364. mixToTile?: number;
  75365. /**
  75366. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75367. * This number is defined between 0 and 1;
  75368. */
  75369. mixToNormal?: number;
  75370. }
  75371. /**
  75372. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  75373. *
  75374. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75375. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  75376. */
  75377. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  75378. /**
  75379. * The font texture used to render the char in the post process.
  75380. */
  75381. private _asciiArtFontTexture;
  75382. /**
  75383. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  75384. * This number is defined between 0 and 1;
  75385. */
  75386. mixToTile: number;
  75387. /**
  75388. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75389. * This number is defined between 0 and 1;
  75390. */
  75391. mixToNormal: number;
  75392. /**
  75393. * Instantiates a new Ascii Art Post Process.
  75394. * @param name the name to give to the postprocess
  75395. * @camera the camera to apply the post process to.
  75396. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  75397. */
  75398. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  75399. }
  75400. }
  75401. declare module BABYLON {
  75402. /** @hidden */
  75403. export var digitalrainPixelShader: {
  75404. name: string;
  75405. shader: string;
  75406. };
  75407. }
  75408. declare module BABYLON {
  75409. /**
  75410. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  75411. *
  75412. * It basically takes care rendering the font front the given font size to a texture.
  75413. * This is used later on in the postprocess.
  75414. */
  75415. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  75416. private _font;
  75417. private _text;
  75418. private _charSize;
  75419. /**
  75420. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  75421. */
  75422. readonly charSize: number;
  75423. /**
  75424. * Create a new instance of the Digital Rain FontTexture class
  75425. * @param name the name of the texture
  75426. * @param font the font to use, use the W3C CSS notation
  75427. * @param text the caracter set to use in the rendering.
  75428. * @param scene the scene that owns the texture
  75429. */
  75430. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  75431. /**
  75432. * Gets the max char width of a font.
  75433. * @param font the font to use, use the W3C CSS notation
  75434. * @return the max char width
  75435. */
  75436. private getFontWidth;
  75437. /**
  75438. * Gets the max char height of a font.
  75439. * @param font the font to use, use the W3C CSS notation
  75440. * @return the max char height
  75441. */
  75442. private getFontHeight;
  75443. /**
  75444. * Clones the current DigitalRainFontTexture.
  75445. * @return the clone of the texture.
  75446. */
  75447. clone(): DigitalRainFontTexture;
  75448. /**
  75449. * Parses a json object representing the texture and returns an instance of it.
  75450. * @param source the source JSON representation
  75451. * @param scene the scene to create the texture for
  75452. * @return the parsed texture
  75453. */
  75454. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  75455. }
  75456. /**
  75457. * Option available in the Digital Rain Post Process.
  75458. */
  75459. export interface IDigitalRainPostProcessOptions {
  75460. /**
  75461. * The font to use following the w3c font definition.
  75462. */
  75463. font?: string;
  75464. /**
  75465. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  75466. * This number is defined between 0 and 1;
  75467. */
  75468. mixToTile?: number;
  75469. /**
  75470. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  75471. * This number is defined between 0 and 1;
  75472. */
  75473. mixToNormal?: number;
  75474. }
  75475. /**
  75476. * DigitalRainPostProcess helps rendering everithing in digital rain.
  75477. *
  75478. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75479. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  75480. */
  75481. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  75482. /**
  75483. * The font texture used to render the char in the post process.
  75484. */
  75485. private _digitalRainFontTexture;
  75486. /**
  75487. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  75488. * This number is defined between 0 and 1;
  75489. */
  75490. mixToTile: number;
  75491. /**
  75492. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  75493. * This number is defined between 0 and 1;
  75494. */
  75495. mixToNormal: number;
  75496. /**
  75497. * Instantiates a new Digital Rain Post Process.
  75498. * @param name the name to give to the postprocess
  75499. * @camera the camera to apply the post process to.
  75500. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  75501. */
  75502. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  75503. }
  75504. }
  75505. declare module BABYLON {
  75506. /** @hidden */
  75507. export var oceanPostProcessPixelShader: {
  75508. name: string;
  75509. shader: string;
  75510. };
  75511. }
  75512. declare module BABYLON {
  75513. /**
  75514. * Option available in the Ocean Post Process.
  75515. */
  75516. export interface IOceanPostProcessOptions {
  75517. /**
  75518. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  75519. */
  75520. reflectionSize?: number | {
  75521. width: number;
  75522. height: number;
  75523. } | {
  75524. ratio: number;
  75525. };
  75526. /**
  75527. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  75528. */
  75529. refractionSize?: number | {
  75530. width: number;
  75531. height: number;
  75532. } | {
  75533. ratio: number;
  75534. };
  75535. }
  75536. /**
  75537. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  75538. *
  75539. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75540. * Example usage:
  75541. * var pp = new OceanPostProcess("myOcean", camera);
  75542. * pp.reflectionEnabled = true;
  75543. * pp.refractionEnabled = true;
  75544. */
  75545. export class OceanPostProcess extends BABYLON.PostProcess {
  75546. /**
  75547. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  75548. */
  75549. /**
  75550. * Sets weither or not the real-time reflection is enabled on the ocean.
  75551. * Is set to true, the reflection mirror texture will be used as reflection texture.
  75552. */
  75553. reflectionEnabled: boolean;
  75554. /**
  75555. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  75556. */
  75557. /**
  75558. * Sets weither or not the real-time refraction is enabled on the ocean.
  75559. * Is set to true, the refraction render target texture will be used as refraction texture.
  75560. */
  75561. refractionEnabled: boolean;
  75562. /**
  75563. * Gets wether or not the post-processes is supported by the running hardware.
  75564. * This requires draw buffer supports.
  75565. */
  75566. readonly isSupported: boolean;
  75567. /**
  75568. * This is the reflection mirror texture used to display reflections on the ocean.
  75569. * By default, render list is empty.
  75570. */
  75571. reflectionTexture: BABYLON.MirrorTexture;
  75572. /**
  75573. * This is the refraction render target texture used to display refraction on the ocean.
  75574. * By default, render list is empty.
  75575. */
  75576. refractionTexture: BABYLON.RenderTargetTexture;
  75577. private _time;
  75578. private _cameraRotation;
  75579. private _cameraViewMatrix;
  75580. private _reflectionEnabled;
  75581. private _refractionEnabled;
  75582. private _geometryRenderer;
  75583. /**
  75584. * Instantiates a new Ocean Post Process.
  75585. * @param name the name to give to the postprocess.
  75586. * @camera the camera to apply the post process to.
  75587. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  75588. */
  75589. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  75590. /**
  75591. * Returns the appropriate defines according to the current configuration.
  75592. */
  75593. private _getDefines;
  75594. /**
  75595. * Computes the current camera rotation as the shader requires a camera rotation.
  75596. */
  75597. private _computeCameraRotation;
  75598. }
  75599. }
  75600. declare module BABYLON {
  75601. /** @hidden */
  75602. export var brickProceduralTexturePixelShader: {
  75603. name: string;
  75604. shader: string;
  75605. };
  75606. }
  75607. declare module BABYLON {
  75608. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  75609. private _numberOfBricksHeight;
  75610. private _numberOfBricksWidth;
  75611. private _jointColor;
  75612. private _brickColor;
  75613. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75614. updateShaderUniforms(): void;
  75615. numberOfBricksHeight: number;
  75616. numberOfBricksWidth: number;
  75617. jointColor: BABYLON.Color3;
  75618. brickColor: BABYLON.Color3;
  75619. /**
  75620. * Serializes this brick procedural texture
  75621. * @returns a serialized brick procedural texture object
  75622. */
  75623. serialize(): any;
  75624. /**
  75625. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  75626. * @param parsedTexture defines parsed texture data
  75627. * @param scene defines the current scene
  75628. * @param rootUrl defines the root URL containing brick procedural texture information
  75629. * @returns a parsed Brick Procedural BABYLON.Texture
  75630. */
  75631. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  75632. }
  75633. }
  75634. declare module BABYLON {
  75635. /** @hidden */
  75636. export var cloudProceduralTexturePixelShader: {
  75637. name: string;
  75638. shader: string;
  75639. };
  75640. }
  75641. declare module BABYLON {
  75642. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  75643. private _skyColor;
  75644. private _cloudColor;
  75645. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75646. updateShaderUniforms(): void;
  75647. skyColor: BABYLON.Color4;
  75648. cloudColor: BABYLON.Color4;
  75649. /**
  75650. * Serializes this cloud procedural texture
  75651. * @returns a serialized cloud procedural texture object
  75652. */
  75653. serialize(): any;
  75654. /**
  75655. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  75656. * @param parsedTexture defines parsed texture data
  75657. * @param scene defines the current scene
  75658. * @param rootUrl defines the root URL containing cloud procedural texture information
  75659. * @returns a parsed Cloud Procedural BABYLON.Texture
  75660. */
  75661. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  75662. }
  75663. }
  75664. declare module BABYLON {
  75665. /** @hidden */
  75666. export var fireProceduralTexturePixelShader: {
  75667. name: string;
  75668. shader: string;
  75669. };
  75670. }
  75671. declare module BABYLON {
  75672. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  75673. private _time;
  75674. private _speed;
  75675. private _autoGenerateTime;
  75676. private _fireColors;
  75677. private _alphaThreshold;
  75678. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75679. updateShaderUniforms(): void;
  75680. render(useCameraPostProcess?: boolean): void;
  75681. static readonly PurpleFireColors: BABYLON.Color3[];
  75682. static readonly GreenFireColors: BABYLON.Color3[];
  75683. static readonly RedFireColors: BABYLON.Color3[];
  75684. static readonly BlueFireColors: BABYLON.Color3[];
  75685. autoGenerateTime: boolean;
  75686. fireColors: BABYLON.Color3[];
  75687. time: number;
  75688. speed: BABYLON.Vector2;
  75689. alphaThreshold: number;
  75690. /**
  75691. * Serializes this fire procedural texture
  75692. * @returns a serialized fire procedural texture object
  75693. */
  75694. serialize(): any;
  75695. /**
  75696. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  75697. * @param parsedTexture defines parsed texture data
  75698. * @param scene defines the current scene
  75699. * @param rootUrl defines the root URL containing fire procedural texture information
  75700. * @returns a parsed Fire Procedural BABYLON.Texture
  75701. */
  75702. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  75703. }
  75704. }
  75705. declare module BABYLON {
  75706. /** @hidden */
  75707. export var grassProceduralTexturePixelShader: {
  75708. name: string;
  75709. shader: string;
  75710. };
  75711. }
  75712. declare module BABYLON {
  75713. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  75714. private _grassColors;
  75715. private _groundColor;
  75716. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75717. updateShaderUniforms(): void;
  75718. grassColors: BABYLON.Color3[];
  75719. groundColor: BABYLON.Color3;
  75720. /**
  75721. * Serializes this grass procedural texture
  75722. * @returns a serialized grass procedural texture object
  75723. */
  75724. serialize(): any;
  75725. /**
  75726. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  75727. * @param parsedTexture defines parsed texture data
  75728. * @param scene defines the current scene
  75729. * @param rootUrl defines the root URL containing grass procedural texture information
  75730. * @returns a parsed Grass Procedural BABYLON.Texture
  75731. */
  75732. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  75733. }
  75734. }
  75735. declare module BABYLON {
  75736. /** @hidden */
  75737. export var marbleProceduralTexturePixelShader: {
  75738. name: string;
  75739. shader: string;
  75740. };
  75741. }
  75742. declare module BABYLON {
  75743. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  75744. private _numberOfTilesHeight;
  75745. private _numberOfTilesWidth;
  75746. private _amplitude;
  75747. private _jointColor;
  75748. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75749. updateShaderUniforms(): void;
  75750. numberOfTilesHeight: number;
  75751. amplitude: number;
  75752. numberOfTilesWidth: number;
  75753. jointColor: BABYLON.Color3;
  75754. /**
  75755. * Serializes this marble procedural texture
  75756. * @returns a serialized marble procedural texture object
  75757. */
  75758. serialize(): any;
  75759. /**
  75760. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  75761. * @param parsedTexture defines parsed texture data
  75762. * @param scene defines the current scene
  75763. * @param rootUrl defines the root URL containing marble procedural texture information
  75764. * @returns a parsed Marble Procedural BABYLON.Texture
  75765. */
  75766. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  75767. }
  75768. }
  75769. declare module BABYLON {
  75770. /** @hidden */
  75771. export var normalMapProceduralTexturePixelShader: {
  75772. name: string;
  75773. shader: string;
  75774. };
  75775. }
  75776. declare module BABYLON {
  75777. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  75778. private _baseTexture;
  75779. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75780. updateShaderUniforms(): void;
  75781. render(useCameraPostProcess?: boolean): void;
  75782. resize(size: any, generateMipMaps: any): void;
  75783. baseTexture: BABYLON.Texture;
  75784. /**
  75785. * Serializes this normal map procedural texture
  75786. * @returns a serialized normal map procedural texture object
  75787. */
  75788. serialize(): any;
  75789. /**
  75790. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  75791. * @param parsedTexture defines parsed texture data
  75792. * @param scene defines the current scene
  75793. * @param rootUrl defines the root URL containing normal map procedural texture information
  75794. * @returns a parsed Normal Map Procedural BABYLON.Texture
  75795. */
  75796. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  75797. }
  75798. }
  75799. declare module BABYLON {
  75800. /** @hidden */
  75801. export var perlinNoiseProceduralTexturePixelShader: {
  75802. name: string;
  75803. shader: string;
  75804. };
  75805. }
  75806. declare module BABYLON {
  75807. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  75808. time: number;
  75809. timeScale: number;
  75810. translationSpeed: number;
  75811. private _currentTranslation;
  75812. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75813. updateShaderUniforms(): void;
  75814. render(useCameraPostProcess?: boolean): void;
  75815. resize(size: any, generateMipMaps: any): void;
  75816. /**
  75817. * Serializes this perlin noise procedural texture
  75818. * @returns a serialized perlin noise procedural texture object
  75819. */
  75820. serialize(): any;
  75821. /**
  75822. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  75823. * @param parsedTexture defines parsed texture data
  75824. * @param scene defines the current scene
  75825. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  75826. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  75827. */
  75828. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  75829. }
  75830. }
  75831. declare module BABYLON {
  75832. /** @hidden */
  75833. export var roadProceduralTexturePixelShader: {
  75834. name: string;
  75835. shader: string;
  75836. };
  75837. }
  75838. declare module BABYLON {
  75839. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  75840. private _roadColor;
  75841. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75842. updateShaderUniforms(): void;
  75843. roadColor: BABYLON.Color3;
  75844. /**
  75845. * Serializes this road procedural texture
  75846. * @returns a serialized road procedural texture object
  75847. */
  75848. serialize(): any;
  75849. /**
  75850. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  75851. * @param parsedTexture defines parsed texture data
  75852. * @param scene defines the current scene
  75853. * @param rootUrl defines the root URL containing road procedural texture information
  75854. * @returns a parsed Road Procedural BABYLON.Texture
  75855. */
  75856. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  75857. }
  75858. }
  75859. declare module BABYLON {
  75860. /** @hidden */
  75861. export var starfieldProceduralTexturePixelShader: {
  75862. name: string;
  75863. shader: string;
  75864. };
  75865. }
  75866. declare module BABYLON {
  75867. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  75868. private _time;
  75869. private _alpha;
  75870. private _beta;
  75871. private _zoom;
  75872. private _formuparam;
  75873. private _stepsize;
  75874. private _tile;
  75875. private _brightness;
  75876. private _darkmatter;
  75877. private _distfading;
  75878. private _saturation;
  75879. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75880. updateShaderUniforms(): void;
  75881. time: number;
  75882. alpha: number;
  75883. beta: number;
  75884. formuparam: number;
  75885. stepsize: number;
  75886. zoom: number;
  75887. tile: number;
  75888. brightness: number;
  75889. darkmatter: number;
  75890. distfading: number;
  75891. saturation: number;
  75892. /**
  75893. * Serializes this starfield procedural texture
  75894. * @returns a serialized starfield procedural texture object
  75895. */
  75896. serialize(): any;
  75897. /**
  75898. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  75899. * @param parsedTexture defines parsed texture data
  75900. * @param scene defines the current scene
  75901. * @param rootUrl defines the root URL containing startfield procedural texture information
  75902. * @returns a parsed Starfield Procedural BABYLON.Texture
  75903. */
  75904. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  75905. }
  75906. }
  75907. declare module BABYLON {
  75908. /** @hidden */
  75909. export var woodProceduralTexturePixelShader: {
  75910. name: string;
  75911. shader: string;
  75912. };
  75913. }
  75914. declare module BABYLON {
  75915. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  75916. private _ampScale;
  75917. private _woodColor;
  75918. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75919. updateShaderUniforms(): void;
  75920. ampScale: number;
  75921. woodColor: BABYLON.Color3;
  75922. /**
  75923. * Serializes this wood procedural texture
  75924. * @returns a serialized wood procedural texture object
  75925. */
  75926. serialize(): any;
  75927. /**
  75928. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  75929. * @param parsedTexture defines parsed texture data
  75930. * @param scene defines the current scene
  75931. * @param rootUrl defines the root URL containing wood procedural texture information
  75932. * @returns a parsed Wood Procedural BABYLON.Texture
  75933. */
  75934. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  75935. }
  75936. }