documentation.d.ts 3.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684
  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. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module BABYLON {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module BABYLON {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module BABYLON {
  409. /**
  410. * Interface used to define the mechanism to get data from the network
  411. */
  412. export interface IWebRequest {
  413. /**
  414. * Returns client's response url
  415. */
  416. responseURL: string;
  417. /**
  418. * Returns client's status
  419. */
  420. status: number;
  421. /**
  422. * Returns client's status as a text
  423. */
  424. statusText: string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  430. */
  431. export class WebRequest implements IWebRequest {
  432. private _xhr;
  433. /**
  434. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  435. * i.e. when loading files, where the server/service expects an Authorization header
  436. */
  437. static CustomRequestHeaders: {
  438. [key: string]: string;
  439. };
  440. /**
  441. * Add callback functions in this array to update all the requests before they get sent to the network
  442. */
  443. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  444. private _injectCustomRequestHeaders;
  445. /**
  446. * Gets or sets a function to be called when loading progress changes
  447. */
  448. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  449. /**
  450. * Returns client's state
  451. */
  452. readonly readyState: number;
  453. /**
  454. * Returns client's status
  455. */
  456. readonly status: number;
  457. /**
  458. * Returns client's status as a text
  459. */
  460. readonly statusText: string;
  461. /**
  462. * Returns client's response
  463. */
  464. readonly response: any;
  465. /**
  466. * Returns client's response url
  467. */
  468. readonly responseURL: string;
  469. /**
  470. * Returns client's response as text
  471. */
  472. readonly responseText: string;
  473. /**
  474. * Gets or sets the expected response type
  475. */
  476. responseType: XMLHttpRequestResponseType;
  477. /** @hidden */
  478. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  479. /** @hidden */
  480. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  481. /**
  482. * Cancels any network activity
  483. */
  484. abort(): void;
  485. /**
  486. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  487. * @param body defines an optional request body
  488. */
  489. send(body?: Document | BodyInit | null): void;
  490. /**
  491. * Sets the request method, request URL
  492. * @param method defines the method to use (GET, POST, etc..)
  493. * @param url defines the url to connect with
  494. */
  495. open(method: string, url: string): void;
  496. }
  497. }
  498. declare module BABYLON {
  499. /**
  500. * File request interface
  501. */
  502. export interface IFileRequest {
  503. /**
  504. * Raised when the request is complete (success or error).
  505. */
  506. onCompleteObservable: Observable<IFileRequest>;
  507. /**
  508. * Aborts the request for a file.
  509. */
  510. abort: () => void;
  511. }
  512. }
  513. declare module BABYLON {
  514. /**
  515. * Define options used to create a render target texture
  516. */
  517. export class RenderTargetCreationOptions {
  518. /**
  519. * Specifies is mipmaps must be generated
  520. */
  521. generateMipMaps?: boolean;
  522. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  523. generateDepthBuffer?: boolean;
  524. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  525. generateStencilBuffer?: boolean;
  526. /** Defines texture type (int by default) */
  527. type?: number;
  528. /** Defines sampling mode (trilinear by default) */
  529. samplingMode?: number;
  530. /** Defines format (RGBA by default) */
  531. format?: number;
  532. }
  533. }
  534. declare module BABYLON {
  535. /**
  536. * @hidden
  537. **/
  538. export class _TimeToken {
  539. _startTimeQuery: Nullable<WebGLQuery>;
  540. _endTimeQuery: Nullable<WebGLQuery>;
  541. _timeElapsedQuery: Nullable<WebGLQuery>;
  542. _timeElapsedQueryEnded: boolean;
  543. }
  544. }
  545. declare module BABYLON {
  546. /** Defines the cross module used constants to avoid circular dependncies */
  547. export class Constants {
  548. /** Defines that alpha blending is disabled */
  549. static readonly ALPHA_DISABLE: number;
  550. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  551. static readonly ALPHA_ADD: number;
  552. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  553. static readonly ALPHA_COMBINE: number;
  554. /** Defines that alpha blending to DEST - SRC * DEST */
  555. static readonly ALPHA_SUBTRACT: number;
  556. /** Defines that alpha blending to SRC * DEST */
  557. static readonly ALPHA_MULTIPLY: number;
  558. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  559. static readonly ALPHA_MAXIMIZED: number;
  560. /** Defines that alpha blending to SRC + DEST */
  561. static readonly ALPHA_ONEONE: number;
  562. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  563. static readonly ALPHA_PREMULTIPLIED: number;
  564. /**
  565. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  566. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  567. */
  568. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  569. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  570. static readonly ALPHA_INTERPOLATE: number;
  571. /**
  572. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  573. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  574. */
  575. static readonly ALPHA_SCREENMODE: number;
  576. /**
  577. * Defines that alpha blending to SRC + DST
  578. * Alpha will be set to SRC ALPHA + DST ALPHA
  579. */
  580. static readonly ALPHA_ONEONE_ONEONE: number;
  581. /**
  582. * Defines that alpha blending to SRC * DST ALPHA + DST
  583. * Alpha will be set to 0
  584. */
  585. static readonly ALPHA_ALPHATOCOLOR: number;
  586. /**
  587. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  588. */
  589. static readonly ALPHA_REVERSEONEMINUS: number;
  590. /**
  591. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  592. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  593. */
  594. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  595. /**
  596. * Defines that alpha blending to SRC + DST
  597. * Alpha will be set to SRC ALPHA
  598. */
  599. static readonly ALPHA_ONEONE_ONEZERO: number;
  600. /** Defines that alpha blending equation a SUM */
  601. static readonly ALPHA_EQUATION_ADD: number;
  602. /** Defines that alpha blending equation a SUBSTRACTION */
  603. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  604. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  605. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  606. /** Defines that alpha blending equation a MAX operation */
  607. static readonly ALPHA_EQUATION_MAX: number;
  608. /** Defines that alpha blending equation a MIN operation */
  609. static readonly ALPHA_EQUATION_MIN: number;
  610. /**
  611. * Defines that alpha blending equation a DARKEN operation:
  612. * It takes the min of the src and sums the alpha channels.
  613. */
  614. static readonly ALPHA_EQUATION_DARKEN: number;
  615. /** Defines that the ressource is not delayed*/
  616. static readonly DELAYLOADSTATE_NONE: number;
  617. /** Defines that the ressource was successfully delay loaded */
  618. static readonly DELAYLOADSTATE_LOADED: number;
  619. /** Defines that the ressource is currently delay loading */
  620. static readonly DELAYLOADSTATE_LOADING: number;
  621. /** Defines that the ressource is delayed and has not started loading */
  622. static readonly DELAYLOADSTATE_NOTLOADED: number;
  623. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  624. static readonly NEVER: number;
  625. /** 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 */
  626. static readonly ALWAYS: number;
  627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  628. static readonly LESS: number;
  629. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  630. static readonly EQUAL: number;
  631. /** 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 */
  632. static readonly LEQUAL: number;
  633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  634. static readonly GREATER: number;
  635. /** 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 */
  636. static readonly GEQUAL: number;
  637. /** 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 */
  638. static readonly NOTEQUAL: number;
  639. /** Passed to stencilOperation to specify that stencil value must be kept */
  640. static readonly KEEP: number;
  641. /** Passed to stencilOperation to specify that stencil value must be replaced */
  642. static readonly REPLACE: number;
  643. /** Passed to stencilOperation to specify that stencil value must be incremented */
  644. static readonly INCR: number;
  645. /** Passed to stencilOperation to specify that stencil value must be decremented */
  646. static readonly DECR: number;
  647. /** Passed to stencilOperation to specify that stencil value must be inverted */
  648. static readonly INVERT: number;
  649. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  650. static readonly INCR_WRAP: number;
  651. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  652. static readonly DECR_WRAP: number;
  653. /** Texture is not repeating outside of 0..1 UVs */
  654. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  655. /** Texture is repeating outside of 0..1 UVs */
  656. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  657. /** Texture is repeating and mirrored */
  658. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  659. /** ALPHA */
  660. static readonly TEXTUREFORMAT_ALPHA: number;
  661. /** LUMINANCE */
  662. static readonly TEXTUREFORMAT_LUMINANCE: number;
  663. /** LUMINANCE_ALPHA */
  664. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  665. /** RGB */
  666. static readonly TEXTUREFORMAT_RGB: number;
  667. /** RGBA */
  668. static readonly TEXTUREFORMAT_RGBA: number;
  669. /** RED */
  670. static readonly TEXTUREFORMAT_RED: number;
  671. /** RED (2nd reference) */
  672. static readonly TEXTUREFORMAT_R: number;
  673. /** RG */
  674. static readonly TEXTUREFORMAT_RG: number;
  675. /** RED_INTEGER */
  676. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  677. /** RED_INTEGER (2nd reference) */
  678. static readonly TEXTUREFORMAT_R_INTEGER: number;
  679. /** RG_INTEGER */
  680. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  681. /** RGB_INTEGER */
  682. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  683. /** RGBA_INTEGER */
  684. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  685. /** UNSIGNED_BYTE */
  686. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  687. /** UNSIGNED_BYTE (2nd reference) */
  688. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  689. /** FLOAT */
  690. static readonly TEXTURETYPE_FLOAT: number;
  691. /** HALF_FLOAT */
  692. static readonly TEXTURETYPE_HALF_FLOAT: number;
  693. /** BYTE */
  694. static readonly TEXTURETYPE_BYTE: number;
  695. /** SHORT */
  696. static readonly TEXTURETYPE_SHORT: number;
  697. /** UNSIGNED_SHORT */
  698. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  699. /** INT */
  700. static readonly TEXTURETYPE_INT: number;
  701. /** UNSIGNED_INT */
  702. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  703. /** UNSIGNED_SHORT_4_4_4_4 */
  704. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  705. /** UNSIGNED_SHORT_5_5_5_1 */
  706. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  707. /** UNSIGNED_SHORT_5_6_5 */
  708. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  709. /** UNSIGNED_INT_2_10_10_10_REV */
  710. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  711. /** UNSIGNED_INT_24_8 */
  712. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  713. /** UNSIGNED_INT_10F_11F_11F_REV */
  714. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  715. /** UNSIGNED_INT_5_9_9_9_REV */
  716. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  717. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  718. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  719. /** nearest is mag = nearest and min = nearest and mip = linear */
  720. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  721. /** Bilinear is mag = linear and min = linear and mip = nearest */
  722. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  723. /** Trilinear is mag = linear and min = linear and mip = linear */
  724. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  725. /** nearest is mag = nearest and min = nearest and mip = linear */
  726. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  727. /** Bilinear is mag = linear and min = linear and mip = nearest */
  728. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  729. /** Trilinear is mag = linear and min = linear and mip = linear */
  730. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  731. /** mag = nearest and min = nearest and mip = nearest */
  732. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  733. /** mag = nearest and min = linear and mip = nearest */
  734. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  735. /** mag = nearest and min = linear and mip = linear */
  736. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  737. /** mag = nearest and min = linear and mip = none */
  738. static readonly TEXTURE_NEAREST_LINEAR: number;
  739. /** mag = nearest and min = nearest and mip = none */
  740. static readonly TEXTURE_NEAREST_NEAREST: number;
  741. /** mag = linear and min = nearest and mip = nearest */
  742. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  743. /** mag = linear and min = nearest and mip = linear */
  744. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  745. /** mag = linear and min = linear and mip = none */
  746. static readonly TEXTURE_LINEAR_LINEAR: number;
  747. /** mag = linear and min = nearest and mip = none */
  748. static readonly TEXTURE_LINEAR_NEAREST: number;
  749. /** Explicit coordinates mode */
  750. static readonly TEXTURE_EXPLICIT_MODE: number;
  751. /** Spherical coordinates mode */
  752. static readonly TEXTURE_SPHERICAL_MODE: number;
  753. /** Planar coordinates mode */
  754. static readonly TEXTURE_PLANAR_MODE: number;
  755. /** Cubic coordinates mode */
  756. static readonly TEXTURE_CUBIC_MODE: number;
  757. /** Projection coordinates mode */
  758. static readonly TEXTURE_PROJECTION_MODE: number;
  759. /** Skybox coordinates mode */
  760. static readonly TEXTURE_SKYBOX_MODE: number;
  761. /** Inverse Cubic coordinates mode */
  762. static readonly TEXTURE_INVCUBIC_MODE: number;
  763. /** Equirectangular coordinates mode */
  764. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  765. /** Equirectangular Fixed coordinates mode */
  766. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  767. /** Equirectangular Fixed Mirrored coordinates mode */
  768. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  769. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  770. static readonly SCALEMODE_FLOOR: number;
  771. /** Defines that texture rescaling will look for the nearest power of 2 size */
  772. static readonly SCALEMODE_NEAREST: number;
  773. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  774. static readonly SCALEMODE_CEILING: number;
  775. /**
  776. * The dirty texture flag value
  777. */
  778. static readonly MATERIAL_TextureDirtyFlag: number;
  779. /**
  780. * The dirty light flag value
  781. */
  782. static readonly MATERIAL_LightDirtyFlag: number;
  783. /**
  784. * The dirty fresnel flag value
  785. */
  786. static readonly MATERIAL_FresnelDirtyFlag: number;
  787. /**
  788. * The dirty attribute flag value
  789. */
  790. static readonly MATERIAL_AttributesDirtyFlag: number;
  791. /**
  792. * The dirty misc flag value
  793. */
  794. static readonly MATERIAL_MiscDirtyFlag: number;
  795. /**
  796. * The all dirty flag value
  797. */
  798. static readonly MATERIAL_AllDirtyFlag: number;
  799. /**
  800. * Returns the triangle fill mode
  801. */
  802. static readonly MATERIAL_TriangleFillMode: number;
  803. /**
  804. * Returns the wireframe mode
  805. */
  806. static readonly MATERIAL_WireFrameFillMode: number;
  807. /**
  808. * Returns the point fill mode
  809. */
  810. static readonly MATERIAL_PointFillMode: number;
  811. /**
  812. * Returns the point list draw mode
  813. */
  814. static readonly MATERIAL_PointListDrawMode: number;
  815. /**
  816. * Returns the line list draw mode
  817. */
  818. static readonly MATERIAL_LineListDrawMode: number;
  819. /**
  820. * Returns the line loop draw mode
  821. */
  822. static readonly MATERIAL_LineLoopDrawMode: number;
  823. /**
  824. * Returns the line strip draw mode
  825. */
  826. static readonly MATERIAL_LineStripDrawMode: number;
  827. /**
  828. * Returns the triangle strip draw mode
  829. */
  830. static readonly MATERIAL_TriangleStripDrawMode: number;
  831. /**
  832. * Returns the triangle fan draw mode
  833. */
  834. static readonly MATERIAL_TriangleFanDrawMode: number;
  835. /**
  836. * Stores the clock-wise side orientation
  837. */
  838. static readonly MATERIAL_ClockWiseSideOrientation: number;
  839. /**
  840. * Stores the counter clock-wise side orientation
  841. */
  842. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  843. /**
  844. * Nothing
  845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  846. */
  847. static readonly ACTION_NothingTrigger: number;
  848. /**
  849. * On pick
  850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  851. */
  852. static readonly ACTION_OnPickTrigger: number;
  853. /**
  854. * On left pick
  855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  856. */
  857. static readonly ACTION_OnLeftPickTrigger: number;
  858. /**
  859. * On right pick
  860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  861. */
  862. static readonly ACTION_OnRightPickTrigger: number;
  863. /**
  864. * On center pick
  865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  866. */
  867. static readonly ACTION_OnCenterPickTrigger: number;
  868. /**
  869. * On pick down
  870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  871. */
  872. static readonly ACTION_OnPickDownTrigger: number;
  873. /**
  874. * On double pick
  875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  876. */
  877. static readonly ACTION_OnDoublePickTrigger: number;
  878. /**
  879. * On pick up
  880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  881. */
  882. static readonly ACTION_OnPickUpTrigger: number;
  883. /**
  884. * On pick out.
  885. * This trigger will only be raised if you also declared a OnPickDown
  886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  887. */
  888. static readonly ACTION_OnPickOutTrigger: number;
  889. /**
  890. * On long press
  891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  892. */
  893. static readonly ACTION_OnLongPressTrigger: number;
  894. /**
  895. * On pointer over
  896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  897. */
  898. static readonly ACTION_OnPointerOverTrigger: number;
  899. /**
  900. * On pointer out
  901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  902. */
  903. static readonly ACTION_OnPointerOutTrigger: number;
  904. /**
  905. * On every frame
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_OnEveryFrameTrigger: number;
  909. /**
  910. * On intersection enter
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnIntersectionEnterTrigger: number;
  914. /**
  915. * On intersection exit
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnIntersectionExitTrigger: number;
  919. /**
  920. * On key down
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnKeyDownTrigger: number;
  924. /**
  925. * On key up
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnKeyUpTrigger: number;
  929. /**
  930. * Billboard mode will only apply to Y axis
  931. */
  932. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  933. /**
  934. * Billboard mode will apply to all axes
  935. */
  936. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  937. /**
  938. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  939. */
  940. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  941. /**
  942. * Gets or sets base Assets URL
  943. */
  944. static PARTICLES_BaseAssetsUrl: string;
  945. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  946. * Test order :
  947. * Is the bounding sphere outside the frustum ?
  948. * If not, are the bounding box vertices outside the frustum ?
  949. * It not, then the cullable object is in the frustum.
  950. */
  951. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  952. /** Culling strategy : Bounding Sphere Only.
  953. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  954. * It's also less accurate than the standard because some not visible objects can still be selected.
  955. * Test : is the bounding sphere outside the frustum ?
  956. * If not, then the cullable object is in the frustum.
  957. */
  958. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  959. /** Culling strategy : Optimistic Inclusion.
  960. * This in an inclusion test first, then the standard exclusion test.
  961. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  962. * 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.
  963. * Anyway, it's as accurate as the standard strategy.
  964. * Test :
  965. * Is the cullable object bounding sphere center in the frustum ?
  966. * If not, apply the default culling strategy.
  967. */
  968. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  969. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  970. * This in an inclusion test first, then the bounding sphere only exclusion test.
  971. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  972. * 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.
  973. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  974. * Test :
  975. * Is the cullable object bounding sphere center in the frustum ?
  976. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  977. */
  978. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  979. /**
  980. * No logging while loading
  981. */
  982. static readonly SCENELOADER_NO_LOGGING: number;
  983. /**
  984. * Minimal logging while loading
  985. */
  986. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  987. /**
  988. * Summary logging while loading
  989. */
  990. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  991. /**
  992. * Detailled logging while loading
  993. */
  994. static readonly SCENELOADER_DETAILED_LOGGING: number;
  995. }
  996. }
  997. declare module BABYLON {
  998. /**
  999. * This represents the required contract to create a new type of texture loader.
  1000. */
  1001. export interface IInternalTextureLoader {
  1002. /**
  1003. * Defines wether the loader supports cascade loading the different faces.
  1004. */
  1005. supportCascades: boolean;
  1006. /**
  1007. * This returns if the loader support the current file information.
  1008. * @param extension defines the file extension of the file being loaded
  1009. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1010. * @param fallback defines the fallback internal texture if any
  1011. * @param isBase64 defines whether the texture is encoded as a base64
  1012. * @param isBuffer defines whether the texture data are stored as a buffer
  1013. * @returns true if the loader can load the specified file
  1014. */
  1015. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1016. /**
  1017. * Transform the url before loading if required.
  1018. * @param rootUrl the url of the texture
  1019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1020. * @returns the transformed texture
  1021. */
  1022. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1023. /**
  1024. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1025. * @param rootUrl the url of the texture
  1026. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1027. * @returns the fallback texture
  1028. */
  1029. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1030. /**
  1031. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1032. * @param data contains the texture data
  1033. * @param texture defines the BabylonJS internal texture
  1034. * @param createPolynomials will be true if polynomials have been requested
  1035. * @param onLoad defines the callback to trigger once the texture is ready
  1036. * @param onError defines the callback to trigger in case of error
  1037. */
  1038. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1039. /**
  1040. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1041. * @param data contains the texture data
  1042. * @param texture defines the BabylonJS internal texture
  1043. * @param callback defines the method to call once ready to upload
  1044. */
  1045. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1046. }
  1047. }
  1048. declare module BABYLON {
  1049. /**
  1050. * Class used to store and describe the pipeline context associated with an effect
  1051. */
  1052. export interface IPipelineContext {
  1053. /**
  1054. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1055. */
  1056. isAsync: boolean;
  1057. /**
  1058. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1059. */
  1060. isReady: boolean;
  1061. /** @hidden */
  1062. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1063. }
  1064. }
  1065. declare module BABYLON {
  1066. /**
  1067. * Class used to store gfx data (like WebGLBuffer)
  1068. */
  1069. export class DataBuffer {
  1070. /**
  1071. * Gets or sets the number of objects referencing this buffer
  1072. */
  1073. references: number;
  1074. /** Gets or sets the size of the underlying buffer */
  1075. capacity: number;
  1076. /**
  1077. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1078. */
  1079. is32Bits: boolean;
  1080. /**
  1081. * Gets the underlying buffer
  1082. */
  1083. readonly underlyingResource: any;
  1084. }
  1085. }
  1086. declare module BABYLON {
  1087. /** @hidden */
  1088. export interface IShaderProcessor {
  1089. attributeProcessor?: (attribute: string) => string;
  1090. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1091. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1092. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1093. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1094. lineProcessor?: (line: string, isFragment: boolean) => string;
  1095. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1096. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /** @hidden */
  1101. export interface ProcessingOptions {
  1102. defines: string[];
  1103. indexParameters: any;
  1104. isFragment: boolean;
  1105. shouldUseHighPrecisionShader: boolean;
  1106. supportsUniformBuffers: boolean;
  1107. shadersRepository: string;
  1108. includesShadersStore: {
  1109. [key: string]: string;
  1110. };
  1111. processor?: IShaderProcessor;
  1112. version: string;
  1113. platformName: string;
  1114. lookForClosingBracketForUniformBuffer?: boolean;
  1115. }
  1116. }
  1117. declare module BABYLON {
  1118. /**
  1119. * Helper to manipulate strings
  1120. */
  1121. export class StringTools {
  1122. /**
  1123. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1124. * @param str Source string
  1125. * @param suffix Suffix to search for in the source string
  1126. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1127. */
  1128. static EndsWith(str: string, suffix: string): boolean;
  1129. /**
  1130. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1131. * @param str Source string
  1132. * @param suffix Suffix to search for in the source string
  1133. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1134. */
  1135. static StartsWith(str: string, suffix: string): boolean;
  1136. }
  1137. }
  1138. declare module BABYLON {
  1139. /** @hidden */
  1140. export class ShaderCodeNode {
  1141. line: string;
  1142. children: ShaderCodeNode[];
  1143. additionalDefineKey?: string;
  1144. additionalDefineValue?: string;
  1145. isValid(preprocessors: {
  1146. [key: string]: string;
  1147. }): boolean;
  1148. process(preprocessors: {
  1149. [key: string]: string;
  1150. }, options: ProcessingOptions): string;
  1151. }
  1152. }
  1153. declare module BABYLON {
  1154. /** @hidden */
  1155. export class ShaderCodeCursor {
  1156. private _lines;
  1157. lineIndex: number;
  1158. readonly currentLine: string;
  1159. readonly canRead: boolean;
  1160. lines: string[];
  1161. }
  1162. }
  1163. declare module BABYLON {
  1164. /** @hidden */
  1165. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1166. process(preprocessors: {
  1167. [key: string]: string;
  1168. }, options: ProcessingOptions): string;
  1169. }
  1170. }
  1171. declare module BABYLON {
  1172. /** @hidden */
  1173. export class ShaderDefineExpression {
  1174. isTrue(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. }
  1178. }
  1179. declare module BABYLON {
  1180. /** @hidden */
  1181. export class ShaderCodeTestNode extends ShaderCodeNode {
  1182. testExpression: ShaderDefineExpression;
  1183. isValid(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1191. define: string;
  1192. not: boolean;
  1193. constructor(define: string, not?: boolean);
  1194. isTrue(preprocessors: {
  1195. [key: string]: string;
  1196. }): boolean;
  1197. }
  1198. }
  1199. declare module BABYLON {
  1200. /** @hidden */
  1201. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1202. leftOperand: ShaderDefineExpression;
  1203. rightOperand: ShaderDefineExpression;
  1204. isTrue(preprocessors: {
  1205. [key: string]: string;
  1206. }): boolean;
  1207. }
  1208. }
  1209. declare module BABYLON {
  1210. /** @hidden */
  1211. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1212. leftOperand: ShaderDefineExpression;
  1213. rightOperand: ShaderDefineExpression;
  1214. isTrue(preprocessors: {
  1215. [key: string]: string;
  1216. }): boolean;
  1217. }
  1218. }
  1219. declare module BABYLON {
  1220. /** @hidden */
  1221. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1222. define: string;
  1223. operand: string;
  1224. testValue: string;
  1225. constructor(define: string, operand: string, testValue: string);
  1226. isTrue(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /**
  1233. * @ignore
  1234. * Application error to support additional information when loading a file
  1235. */
  1236. export class LoadFileError extends Error {
  1237. /** defines the optional web request */
  1238. request?: WebRequest | undefined;
  1239. private static _setPrototypeOf;
  1240. /**
  1241. * Creates a new LoadFileError
  1242. * @param message defines the message of the error
  1243. * @param request defines the optional web request
  1244. */
  1245. constructor(message: string,
  1246. /** defines the optional web request */
  1247. request?: WebRequest | undefined);
  1248. }
  1249. }
  1250. declare module BABYLON {
  1251. /**
  1252. * Class used to enable access to offline support
  1253. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1254. */
  1255. export interface IOfflineProvider {
  1256. /**
  1257. * Gets a boolean indicating if scene must be saved in the database
  1258. */
  1259. enableSceneOffline: boolean;
  1260. /**
  1261. * Gets a boolean indicating if textures must be saved in the database
  1262. */
  1263. enableTexturesOffline: boolean;
  1264. /**
  1265. * Open the offline support and make it available
  1266. * @param successCallback defines the callback to call on success
  1267. * @param errorCallback defines the callback to call on error
  1268. */
  1269. open(successCallback: () => void, errorCallback: () => void): void;
  1270. /**
  1271. * Loads an image from the offline support
  1272. * @param url defines the url to load from
  1273. * @param image defines the target DOM image
  1274. */
  1275. loadImage(url: string, image: HTMLImageElement): void;
  1276. /**
  1277. * Loads a file from offline support
  1278. * @param url defines the URL to load from
  1279. * @param sceneLoaded defines a callback to call on success
  1280. * @param progressCallBack defines a callback to call when progress changed
  1281. * @param errorCallback defines a callback to call on error
  1282. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1283. */
  1284. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1285. }
  1286. }
  1287. declare module BABYLON {
  1288. /**
  1289. * Class used to help managing file picking and drag'n'drop
  1290. * File Storage
  1291. */
  1292. export class FilesInputStore {
  1293. /**
  1294. * List of files ready to be loaded
  1295. */
  1296. static FilesToLoad: {
  1297. [key: string]: File;
  1298. };
  1299. }
  1300. }
  1301. declare module BABYLON {
  1302. /**
  1303. * Class used to define a retry strategy when error happens while loading assets
  1304. */
  1305. export class RetryStrategy {
  1306. /**
  1307. * Function used to defines an exponential back off strategy
  1308. * @param maxRetries defines the maximum number of retries (3 by default)
  1309. * @param baseInterval defines the interval between retries
  1310. * @returns the strategy function to use
  1311. */
  1312. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1313. }
  1314. }
  1315. declare module BABYLON {
  1316. /**
  1317. * @hidden
  1318. */
  1319. export class FileTools {
  1320. /**
  1321. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1322. */
  1323. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1324. /**
  1325. * Gets or sets the base URL to use to load assets
  1326. */
  1327. static BaseUrl: string;
  1328. /**
  1329. * Default behaviour for cors in the application.
  1330. * It can be a string if the expected behavior is identical in the entire app.
  1331. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1332. */
  1333. static CorsBehavior: string | ((url: string | string[]) => string);
  1334. /**
  1335. * Gets or sets a function used to pre-process url before using them to load assets
  1336. */
  1337. static PreprocessUrl: (url: string) => string;
  1338. /**
  1339. * Removes unwanted characters from an url
  1340. * @param url defines the url to clean
  1341. * @returns the cleaned url
  1342. */
  1343. private static _CleanUrl;
  1344. /**
  1345. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1346. * @param url define the url we are trying
  1347. * @param element define the dom element where to configure the cors policy
  1348. */
  1349. static SetCorsBehavior(url: string | string[], element: {
  1350. crossOrigin: string | null;
  1351. }): void;
  1352. private static _ArrayBufferToBase64;
  1353. /**
  1354. * Loads an image as an HTMLImageElement.
  1355. * @param input url string, ArrayBuffer, or Blob to load
  1356. * @param onLoad callback called when the image successfully loads
  1357. * @param onError callback called when the image fails to load
  1358. * @param offlineProvider offline provider for caching
  1359. * @param mimeType optional mime type
  1360. * @returns the HTMLImageElement of the loaded image
  1361. */
  1362. 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>;
  1363. /**
  1364. * Loads a file
  1365. * @param fileToLoad defines the file to load
  1366. * @param callback defines the callback to call when data is loaded
  1367. * @param progressCallBack defines the callback to call during loading process
  1368. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1369. * @returns a file request object
  1370. */
  1371. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1372. /**
  1373. * Loads a file
  1374. * @param url url string, ArrayBuffer, or Blob to load
  1375. * @param onSuccess callback called when the file successfully loads
  1376. * @param onProgress callback called while file is loading (if the server supports this mode)
  1377. * @param offlineProvider defines the offline provider for caching
  1378. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1379. * @param onError callback called when the file fails to load
  1380. * @returns a file request object
  1381. */
  1382. 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;
  1383. /**
  1384. * Checks if the loaded document was accessed via `file:`-Protocol.
  1385. * @returns boolean
  1386. */
  1387. static IsFileURL(): boolean;
  1388. }
  1389. }
  1390. declare module BABYLON {
  1391. /** @hidden */
  1392. export class ShaderProcessor {
  1393. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1394. private static _ProcessPrecision;
  1395. private static _ExtractOperation;
  1396. private static _BuildSubExpression;
  1397. private static _BuildExpression;
  1398. private static _MoveCursorWithinIf;
  1399. private static _MoveCursor;
  1400. private static _EvaluatePreProcessors;
  1401. private static _PreparePreProcessors;
  1402. private static _ProcessShaderConversion;
  1403. private static _ProcessIncludes;
  1404. }
  1405. }
  1406. declare module BABYLON {
  1407. /**
  1408. * @hidden
  1409. */
  1410. export interface IColor4Like {
  1411. r: float;
  1412. g: float;
  1413. b: float;
  1414. a: float;
  1415. }
  1416. /**
  1417. * @hidden
  1418. */
  1419. export interface IColor3Like {
  1420. r: float;
  1421. g: float;
  1422. b: float;
  1423. }
  1424. /**
  1425. * @hidden
  1426. */
  1427. export interface IVector4Like {
  1428. x: float;
  1429. y: float;
  1430. z: float;
  1431. w: float;
  1432. }
  1433. /**
  1434. * @hidden
  1435. */
  1436. export interface IVector3Like {
  1437. x: float;
  1438. y: float;
  1439. z: float;
  1440. }
  1441. /**
  1442. * @hidden
  1443. */
  1444. export interface IVector2Like {
  1445. x: float;
  1446. y: float;
  1447. }
  1448. /**
  1449. * @hidden
  1450. */
  1451. export interface IMatrixLike {
  1452. toArray(): DeepImmutable<Float32Array>;
  1453. updateFlag: int;
  1454. }
  1455. /**
  1456. * @hidden
  1457. */
  1458. export interface IViewportLike {
  1459. x: float;
  1460. y: float;
  1461. width: float;
  1462. height: float;
  1463. }
  1464. /**
  1465. * @hidden
  1466. */
  1467. export interface IPlaneLike {
  1468. normal: IVector3Like;
  1469. d: float;
  1470. normalize(): void;
  1471. }
  1472. }
  1473. declare module BABYLON {
  1474. /**
  1475. * Interface used to define common properties for effect fallbacks
  1476. */
  1477. export interface IEffectFallbacks {
  1478. /**
  1479. * Removes the defines that should be removed when falling back.
  1480. * @param currentDefines defines the current define statements for the shader.
  1481. * @param effect defines the current effect we try to compile
  1482. * @returns The resulting defines with defines of the current rank removed.
  1483. */
  1484. reduce(currentDefines: string, effect: Effect): string;
  1485. /**
  1486. * Removes the fallback from the bound mesh.
  1487. */
  1488. unBindMesh(): void;
  1489. /**
  1490. * Checks to see if more fallbacks are still availible.
  1491. */
  1492. hasMoreFallbacks: boolean;
  1493. }
  1494. }
  1495. declare module BABYLON {
  1496. /**
  1497. * Class used to evalaute queries containing `and` and `or` operators
  1498. */
  1499. export class AndOrNotEvaluator {
  1500. /**
  1501. * Evaluate a query
  1502. * @param query defines the query to evaluate
  1503. * @param evaluateCallback defines the callback used to filter result
  1504. * @returns true if the query matches
  1505. */
  1506. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1507. private static _HandleParenthesisContent;
  1508. private static _SimplifyNegation;
  1509. }
  1510. }
  1511. declare module BABYLON {
  1512. /**
  1513. * Class used to store custom tags
  1514. */
  1515. export class Tags {
  1516. /**
  1517. * Adds support for tags on the given object
  1518. * @param obj defines the object to use
  1519. */
  1520. static EnableFor(obj: any): void;
  1521. /**
  1522. * Removes tags support
  1523. * @param obj defines the object to use
  1524. */
  1525. static DisableFor(obj: any): void;
  1526. /**
  1527. * Gets a boolean indicating if the given object has tags
  1528. * @param obj defines the object to use
  1529. * @returns a boolean
  1530. */
  1531. static HasTags(obj: any): boolean;
  1532. /**
  1533. * Gets the tags available on a given object
  1534. * @param obj defines the object to use
  1535. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1536. * @returns the tags
  1537. */
  1538. static GetTags(obj: any, asString?: boolean): any;
  1539. /**
  1540. * Adds tags to an object
  1541. * @param obj defines the object to use
  1542. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1543. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1544. */
  1545. static AddTagsTo(obj: any, tagsString: string): void;
  1546. /**
  1547. * @hidden
  1548. */
  1549. static _AddTagTo(obj: any, tag: string): void;
  1550. /**
  1551. * Removes specific tags from a specific object
  1552. * @param obj defines the object to use
  1553. * @param tagsString defines the tags to remove
  1554. */
  1555. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1556. /**
  1557. * @hidden
  1558. */
  1559. static _RemoveTagFrom(obj: any, tag: string): void;
  1560. /**
  1561. * Defines if tags hosted on an object match a given query
  1562. * @param obj defines the object to use
  1563. * @param tagsQuery defines the tag query
  1564. * @returns a boolean
  1565. */
  1566. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1567. }
  1568. }
  1569. declare module BABYLON {
  1570. /**
  1571. * Scalar computation library
  1572. */
  1573. export class Scalar {
  1574. /**
  1575. * Two pi constants convenient for computation.
  1576. */
  1577. static TwoPi: number;
  1578. /**
  1579. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1580. * @param a number
  1581. * @param b number
  1582. * @param epsilon (default = 1.401298E-45)
  1583. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1584. */
  1585. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1586. /**
  1587. * Returns a string : the upper case translation of the number i to hexadecimal.
  1588. * @param i number
  1589. * @returns the upper case translation of the number i to hexadecimal.
  1590. */
  1591. static ToHex(i: number): string;
  1592. /**
  1593. * Returns -1 if value is negative and +1 is value is positive.
  1594. * @param value the value
  1595. * @returns the value itself if it's equal to zero.
  1596. */
  1597. static Sign(value: number): number;
  1598. /**
  1599. * Returns the value itself if it's between min and max.
  1600. * Returns min if the value is lower than min.
  1601. * Returns max if the value is greater than max.
  1602. * @param value the value to clmap
  1603. * @param min the min value to clamp to (default: 0)
  1604. * @param max the max value to clamp to (default: 1)
  1605. * @returns the clamped value
  1606. */
  1607. static Clamp(value: number, min?: number, max?: number): number;
  1608. /**
  1609. * the log2 of value.
  1610. * @param value the value to compute log2 of
  1611. * @returns the log2 of value.
  1612. */
  1613. static Log2(value: number): number;
  1614. /**
  1615. * Loops the value, so that it is never larger than length and never smaller than 0.
  1616. *
  1617. * This is similar to the modulo operator but it works with floating point numbers.
  1618. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1619. * With t = 5 and length = 2.5, the result would be 0.0.
  1620. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1621. * @param value the value
  1622. * @param length the length
  1623. * @returns the looped value
  1624. */
  1625. static Repeat(value: number, length: number): number;
  1626. /**
  1627. * Normalize the value between 0.0 and 1.0 using min and max values
  1628. * @param value value to normalize
  1629. * @param min max to normalize between
  1630. * @param max min to normalize between
  1631. * @returns the normalized value
  1632. */
  1633. static Normalize(value: number, min: number, max: number): number;
  1634. /**
  1635. * Denormalize the value from 0.0 and 1.0 using min and max values
  1636. * @param normalized value to denormalize
  1637. * @param min max to denormalize between
  1638. * @param max min to denormalize between
  1639. * @returns the denormalized value
  1640. */
  1641. static Denormalize(normalized: number, min: number, max: number): number;
  1642. /**
  1643. * Calculates the shortest difference between two given angles given in degrees.
  1644. * @param current current angle in degrees
  1645. * @param target target angle in degrees
  1646. * @returns the delta
  1647. */
  1648. static DeltaAngle(current: number, target: number): number;
  1649. /**
  1650. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1651. * @param tx value
  1652. * @param length length
  1653. * @returns The returned value will move back and forth between 0 and length
  1654. */
  1655. static PingPong(tx: number, length: number): number;
  1656. /**
  1657. * Interpolates between min and max with smoothing at the limits.
  1658. *
  1659. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1660. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1661. * @param from from
  1662. * @param to to
  1663. * @param tx value
  1664. * @returns the smooth stepped value
  1665. */
  1666. static SmoothStep(from: number, to: number, tx: number): number;
  1667. /**
  1668. * Moves a value current towards target.
  1669. *
  1670. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1671. * Negative values of maxDelta pushes the value away from target.
  1672. * @param current current value
  1673. * @param target target value
  1674. * @param maxDelta max distance to move
  1675. * @returns resulting value
  1676. */
  1677. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1678. /**
  1679. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1680. *
  1681. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1682. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1683. * @param current current value
  1684. * @param target target value
  1685. * @param maxDelta max distance to move
  1686. * @returns resulting angle
  1687. */
  1688. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1689. /**
  1690. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1691. * @param start start value
  1692. * @param end target value
  1693. * @param amount amount to lerp between
  1694. * @returns the lerped value
  1695. */
  1696. static Lerp(start: number, end: number, amount: number): number;
  1697. /**
  1698. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1699. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1700. * @param start start value
  1701. * @param end target value
  1702. * @param amount amount to lerp between
  1703. * @returns the lerped value
  1704. */
  1705. static LerpAngle(start: number, end: number, amount: number): number;
  1706. /**
  1707. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1708. * @param a start value
  1709. * @param b target value
  1710. * @param value value between a and b
  1711. * @returns the inverseLerp value
  1712. */
  1713. static InverseLerp(a: number, b: number, value: number): number;
  1714. /**
  1715. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1716. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1717. * @param value1 spline value
  1718. * @param tangent1 spline value
  1719. * @param value2 spline value
  1720. * @param tangent2 spline value
  1721. * @param amount input value
  1722. * @returns hermite result
  1723. */
  1724. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1725. /**
  1726. * Returns a random float number between and min and max values
  1727. * @param min min value of random
  1728. * @param max max value of random
  1729. * @returns random value
  1730. */
  1731. static RandomRange(min: number, max: number): number;
  1732. /**
  1733. * This function returns percentage of a number in a given range.
  1734. *
  1735. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1736. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1737. * @param number to convert to percentage
  1738. * @param min min range
  1739. * @param max max range
  1740. * @returns the percentage
  1741. */
  1742. static RangeToPercent(number: number, min: number, max: number): number;
  1743. /**
  1744. * This function returns number that corresponds to the percentage in a given range.
  1745. *
  1746. * PercentToRange(0.34,0,100) will return 34.
  1747. * @param percent to convert to number
  1748. * @param min min range
  1749. * @param max max range
  1750. * @returns the number
  1751. */
  1752. static PercentToRange(percent: number, min: number, max: number): number;
  1753. /**
  1754. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1755. * @param angle The angle to normalize in radian.
  1756. * @return The converted angle.
  1757. */
  1758. static NormalizeRadians(angle: number): number;
  1759. }
  1760. }
  1761. declare module BABYLON {
  1762. /**
  1763. * Constant used to convert a value to gamma space
  1764. * @ignorenaming
  1765. */
  1766. export const ToGammaSpace: number;
  1767. /**
  1768. * Constant used to convert a value to linear space
  1769. * @ignorenaming
  1770. */
  1771. export const ToLinearSpace = 2.2;
  1772. /**
  1773. * Constant used to define the minimal number value in Babylon.js
  1774. * @ignorenaming
  1775. */
  1776. let Epsilon: number;
  1777. }
  1778. declare module BABYLON {
  1779. /**
  1780. * Class used to represent a viewport on screen
  1781. */
  1782. export class Viewport {
  1783. /** viewport left coordinate */
  1784. x: number;
  1785. /** viewport top coordinate */
  1786. y: number;
  1787. /**viewport width */
  1788. width: number;
  1789. /** viewport height */
  1790. height: number;
  1791. /**
  1792. * Creates a Viewport object located at (x, y) and sized (width, height)
  1793. * @param x defines viewport left coordinate
  1794. * @param y defines viewport top coordinate
  1795. * @param width defines the viewport width
  1796. * @param height defines the viewport height
  1797. */
  1798. constructor(
  1799. /** viewport left coordinate */
  1800. x: number,
  1801. /** viewport top coordinate */
  1802. y: number,
  1803. /**viewport width */
  1804. width: number,
  1805. /** viewport height */
  1806. height: number);
  1807. /**
  1808. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1809. * @param renderWidth defines the rendering width
  1810. * @param renderHeight defines the rendering height
  1811. * @returns a new Viewport
  1812. */
  1813. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1814. /**
  1815. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1816. * @param renderWidth defines the rendering width
  1817. * @param renderHeight defines the rendering height
  1818. * @param ref defines the target viewport
  1819. * @returns the current viewport
  1820. */
  1821. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1822. /**
  1823. * Returns a new Viewport copied from the current one
  1824. * @returns a new Viewport
  1825. */
  1826. clone(): Viewport;
  1827. }
  1828. }
  1829. declare module BABYLON {
  1830. /**
  1831. * Class containing a set of static utilities functions for arrays.
  1832. */
  1833. export class ArrayTools {
  1834. /**
  1835. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1836. * @param size the number of element to construct and put in the array
  1837. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1838. * @returns a new array filled with new objects
  1839. */
  1840. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1841. }
  1842. }
  1843. declare module BABYLON {
  1844. /**
  1845. * Class representing a vector containing 2 coordinates
  1846. */
  1847. export class Vector2 {
  1848. /** defines the first coordinate */
  1849. x: number;
  1850. /** defines the second coordinate */
  1851. y: number;
  1852. /**
  1853. * Creates a new Vector2 from the given x and y coordinates
  1854. * @param x defines the first coordinate
  1855. * @param y defines the second coordinate
  1856. */
  1857. constructor(
  1858. /** defines the first coordinate */
  1859. x?: number,
  1860. /** defines the second coordinate */
  1861. y?: number);
  1862. /**
  1863. * Gets a string with the Vector2 coordinates
  1864. * @returns a string with the Vector2 coordinates
  1865. */
  1866. toString(): string;
  1867. /**
  1868. * Gets class name
  1869. * @returns the string "Vector2"
  1870. */
  1871. getClassName(): string;
  1872. /**
  1873. * Gets current vector hash code
  1874. * @returns the Vector2 hash code as a number
  1875. */
  1876. getHashCode(): number;
  1877. /**
  1878. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1879. * @param array defines the source array
  1880. * @param index defines the offset in source array
  1881. * @returns the current Vector2
  1882. */
  1883. toArray(array: FloatArray, index?: number): Vector2;
  1884. /**
  1885. * Copy the current vector to an array
  1886. * @returns a new array with 2 elements: the Vector2 coordinates.
  1887. */
  1888. asArray(): number[];
  1889. /**
  1890. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1891. * @param source defines the source Vector2
  1892. * @returns the current updated Vector2
  1893. */
  1894. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1895. /**
  1896. * Sets the Vector2 coordinates with the given floats
  1897. * @param x defines the first coordinate
  1898. * @param y defines the second coordinate
  1899. * @returns the current updated Vector2
  1900. */
  1901. copyFromFloats(x: number, y: number): Vector2;
  1902. /**
  1903. * Sets the Vector2 coordinates with the given floats
  1904. * @param x defines the first coordinate
  1905. * @param y defines the second coordinate
  1906. * @returns the current updated Vector2
  1907. */
  1908. set(x: number, y: number): Vector2;
  1909. /**
  1910. * Add another vector with the current one
  1911. * @param otherVector defines the other vector
  1912. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1913. */
  1914. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1915. /**
  1916. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1917. * @param otherVector defines the other vector
  1918. * @param result defines the target vector
  1919. * @returns the unmodified current Vector2
  1920. */
  1921. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1922. /**
  1923. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1924. * @param otherVector defines the other vector
  1925. * @returns the current updated Vector2
  1926. */
  1927. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1928. /**
  1929. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1930. * @param otherVector defines the other vector
  1931. * @returns a new Vector2
  1932. */
  1933. addVector3(otherVector: Vector3): Vector2;
  1934. /**
  1935. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1936. * @param otherVector defines the other vector
  1937. * @returns a new Vector2
  1938. */
  1939. subtract(otherVector: Vector2): Vector2;
  1940. /**
  1941. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1942. * @param otherVector defines the other vector
  1943. * @param result defines the target vector
  1944. * @returns the unmodified current Vector2
  1945. */
  1946. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1947. /**
  1948. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1949. * @param otherVector defines the other vector
  1950. * @returns the current updated Vector2
  1951. */
  1952. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1953. /**
  1954. * Multiplies in place the current Vector2 coordinates by the given ones
  1955. * @param otherVector defines the other vector
  1956. * @returns the current updated Vector2
  1957. */
  1958. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1959. /**
  1960. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1961. * @param otherVector defines the other vector
  1962. * @returns a new Vector2
  1963. */
  1964. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1965. /**
  1966. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1967. * @param otherVector defines the other vector
  1968. * @param result defines the target vector
  1969. * @returns the unmodified current Vector2
  1970. */
  1971. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1972. /**
  1973. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1974. * @param x defines the first coordinate
  1975. * @param y defines the second coordinate
  1976. * @returns a new Vector2
  1977. */
  1978. multiplyByFloats(x: number, y: number): Vector2;
  1979. /**
  1980. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1981. * @param otherVector defines the other vector
  1982. * @returns a new Vector2
  1983. */
  1984. divide(otherVector: Vector2): Vector2;
  1985. /**
  1986. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1987. * @param otherVector defines the other vector
  1988. * @param result defines the target vector
  1989. * @returns the unmodified current Vector2
  1990. */
  1991. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1992. /**
  1993. * Divides the current Vector2 coordinates by the given ones
  1994. * @param otherVector defines the other vector
  1995. * @returns the current updated Vector2
  1996. */
  1997. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Gets a new Vector2 with current Vector2 negated coordinates
  2000. * @returns a new Vector2
  2001. */
  2002. negate(): Vector2;
  2003. /**
  2004. * Multiply the Vector2 coordinates by scale
  2005. * @param scale defines the scaling factor
  2006. * @returns the current updated Vector2
  2007. */
  2008. scaleInPlace(scale: number): Vector2;
  2009. /**
  2010. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2011. * @param scale defines the scaling factor
  2012. * @returns a new Vector2
  2013. */
  2014. scale(scale: number): Vector2;
  2015. /**
  2016. * Scale the current Vector2 values by a factor to a given Vector2
  2017. * @param scale defines the scale factor
  2018. * @param result defines the Vector2 object where to store the result
  2019. * @returns the unmodified current Vector2
  2020. */
  2021. scaleToRef(scale: number, result: Vector2): Vector2;
  2022. /**
  2023. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2024. * @param scale defines the scale factor
  2025. * @param result defines the Vector2 object where to store the result
  2026. * @returns the unmodified current Vector2
  2027. */
  2028. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2029. /**
  2030. * Gets a boolean if two vectors are equals
  2031. * @param otherVector defines the other vector
  2032. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2033. */
  2034. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2035. /**
  2036. * Gets a boolean if two vectors are equals (using an epsilon value)
  2037. * @param otherVector defines the other vector
  2038. * @param epsilon defines the minimal distance to consider equality
  2039. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2040. */
  2041. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2042. /**
  2043. * Gets a new Vector2 from current Vector2 floored values
  2044. * @returns a new Vector2
  2045. */
  2046. floor(): Vector2;
  2047. /**
  2048. * Gets a new Vector2 from current Vector2 floored values
  2049. * @returns a new Vector2
  2050. */
  2051. fract(): Vector2;
  2052. /**
  2053. * Gets the length of the vector
  2054. * @returns the vector length (float)
  2055. */
  2056. length(): number;
  2057. /**
  2058. * Gets the vector squared length
  2059. * @returns the vector squared length (float)
  2060. */
  2061. lengthSquared(): number;
  2062. /**
  2063. * Normalize the vector
  2064. * @returns the current updated Vector2
  2065. */
  2066. normalize(): Vector2;
  2067. /**
  2068. * Gets a new Vector2 copied from the Vector2
  2069. * @returns a new Vector2
  2070. */
  2071. clone(): Vector2;
  2072. /**
  2073. * Gets a new Vector2(0, 0)
  2074. * @returns a new Vector2
  2075. */
  2076. static Zero(): Vector2;
  2077. /**
  2078. * Gets a new Vector2(1, 1)
  2079. * @returns a new Vector2
  2080. */
  2081. static One(): Vector2;
  2082. /**
  2083. * Gets a new Vector2 set from the given index element of the given array
  2084. * @param array defines the data source
  2085. * @param offset defines the offset in the data source
  2086. * @returns a new Vector2
  2087. */
  2088. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2089. /**
  2090. * Sets "result" from the given index element of the given array
  2091. * @param array defines the data source
  2092. * @param offset defines the offset in the data source
  2093. * @param result defines the target vector
  2094. */
  2095. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2096. /**
  2097. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2098. * @param value1 defines 1st point of control
  2099. * @param value2 defines 2nd point of control
  2100. * @param value3 defines 3rd point of control
  2101. * @param value4 defines 4th point of control
  2102. * @param amount defines the interpolation factor
  2103. * @returns a new Vector2
  2104. */
  2105. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2106. /**
  2107. * 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".
  2108. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2109. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2110. * @param value defines the value to clamp
  2111. * @param min defines the lower limit
  2112. * @param max defines the upper limit
  2113. * @returns a new Vector2
  2114. */
  2115. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2116. /**
  2117. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2118. * @param value1 defines the 1st control point
  2119. * @param tangent1 defines the outgoing tangent
  2120. * @param value2 defines the 2nd control point
  2121. * @param tangent2 defines the incoming tangent
  2122. * @param amount defines the interpolation factor
  2123. * @returns a new Vector2
  2124. */
  2125. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2126. /**
  2127. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2128. * @param start defines the start vector
  2129. * @param end defines the end vector
  2130. * @param amount defines the interpolation factor
  2131. * @returns a new Vector2
  2132. */
  2133. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2134. /**
  2135. * Gets the dot product of the vector "left" and the vector "right"
  2136. * @param left defines first vector
  2137. * @param right defines second vector
  2138. * @returns the dot product (float)
  2139. */
  2140. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2141. /**
  2142. * Returns a new Vector2 equal to the normalized given vector
  2143. * @param vector defines the vector to normalize
  2144. * @returns a new Vector2
  2145. */
  2146. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2147. /**
  2148. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2149. * @param left defines 1st vector
  2150. * @param right defines 2nd vector
  2151. * @returns a new Vector2
  2152. */
  2153. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2154. /**
  2155. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2156. * @param left defines 1st vector
  2157. * @param right defines 2nd vector
  2158. * @returns a new Vector2
  2159. */
  2160. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2161. /**
  2162. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2163. * @param vector defines the vector to transform
  2164. * @param transformation defines the matrix to apply
  2165. * @returns a new Vector2
  2166. */
  2167. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2168. /**
  2169. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2170. * @param vector defines the vector to transform
  2171. * @param transformation defines the matrix to apply
  2172. * @param result defines the target vector
  2173. */
  2174. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2175. /**
  2176. * Determines if a given vector is included in a triangle
  2177. * @param p defines the vector to test
  2178. * @param p0 defines 1st triangle point
  2179. * @param p1 defines 2nd triangle point
  2180. * @param p2 defines 3rd triangle point
  2181. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2182. */
  2183. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2184. /**
  2185. * Gets the distance between the vectors "value1" and "value2"
  2186. * @param value1 defines first vector
  2187. * @param value2 defines second vector
  2188. * @returns the distance between vectors
  2189. */
  2190. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2191. /**
  2192. * Returns the squared distance between the vectors "value1" and "value2"
  2193. * @param value1 defines first vector
  2194. * @param value2 defines second vector
  2195. * @returns the squared distance between vectors
  2196. */
  2197. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2198. /**
  2199. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2200. * @param value1 defines first vector
  2201. * @param value2 defines second vector
  2202. * @returns a new Vector2
  2203. */
  2204. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2207. * @param p defines the middle point
  2208. * @param segA defines one point of the segment
  2209. * @param segB defines the other point of the segment
  2210. * @returns the shortest distance
  2211. */
  2212. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2213. }
  2214. /**
  2215. * Classed used to store (x,y,z) vector representation
  2216. * A Vector3 is the main object used in 3D geometry
  2217. * It can represent etiher the coordinates of a point the space, either a direction
  2218. * Reminder: js uses a left handed forward facing system
  2219. */
  2220. export class Vector3 {
  2221. /**
  2222. * Defines the first coordinates (on X axis)
  2223. */
  2224. x: number;
  2225. /**
  2226. * Defines the second coordinates (on Y axis)
  2227. */
  2228. y: number;
  2229. /**
  2230. * Defines the third coordinates (on Z axis)
  2231. */
  2232. z: number;
  2233. private static _UpReadOnly;
  2234. private static _ZeroReadOnly;
  2235. /**
  2236. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2237. * @param x defines the first coordinates (on X axis)
  2238. * @param y defines the second coordinates (on Y axis)
  2239. * @param z defines the third coordinates (on Z axis)
  2240. */
  2241. constructor(
  2242. /**
  2243. * Defines the first coordinates (on X axis)
  2244. */
  2245. x?: number,
  2246. /**
  2247. * Defines the second coordinates (on Y axis)
  2248. */
  2249. y?: number,
  2250. /**
  2251. * Defines the third coordinates (on Z axis)
  2252. */
  2253. z?: number);
  2254. /**
  2255. * Creates a string representation of the Vector3
  2256. * @returns a string with the Vector3 coordinates.
  2257. */
  2258. toString(): string;
  2259. /**
  2260. * Gets the class name
  2261. * @returns the string "Vector3"
  2262. */
  2263. getClassName(): string;
  2264. /**
  2265. * Creates the Vector3 hash code
  2266. * @returns a number which tends to be unique between Vector3 instances
  2267. */
  2268. getHashCode(): number;
  2269. /**
  2270. * Creates an array containing three elements : the coordinates of the Vector3
  2271. * @returns a new array of numbers
  2272. */
  2273. asArray(): number[];
  2274. /**
  2275. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2276. * @param array defines the destination array
  2277. * @param index defines the offset in the destination array
  2278. * @returns the current Vector3
  2279. */
  2280. toArray(array: FloatArray, index?: number): Vector3;
  2281. /**
  2282. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2283. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2284. */
  2285. toQuaternion(): Quaternion;
  2286. /**
  2287. * Adds the given vector to the current Vector3
  2288. * @param otherVector defines the second operand
  2289. * @returns the current updated Vector3
  2290. */
  2291. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2292. /**
  2293. * Adds the given coordinates to the current Vector3
  2294. * @param x defines the x coordinate of the operand
  2295. * @param y defines the y coordinate of the operand
  2296. * @param z defines the z coordinate of the operand
  2297. * @returns the current updated Vector3
  2298. */
  2299. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2300. /**
  2301. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2302. * @param otherVector defines the second operand
  2303. * @returns the resulting Vector3
  2304. */
  2305. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2306. /**
  2307. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2308. * @param otherVector defines the second operand
  2309. * @param result defines the Vector3 object where to store the result
  2310. * @returns the current Vector3
  2311. */
  2312. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2313. /**
  2314. * Subtract the given vector from the current Vector3
  2315. * @param otherVector defines the second operand
  2316. * @returns the current updated Vector3
  2317. */
  2318. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2319. /**
  2320. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2321. * @param otherVector defines the second operand
  2322. * @returns the resulting Vector3
  2323. */
  2324. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2325. /**
  2326. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2327. * @param otherVector defines the second operand
  2328. * @param result defines the Vector3 object where to store the result
  2329. * @returns the current Vector3
  2330. */
  2331. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2332. /**
  2333. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2334. * @param x defines the x coordinate of the operand
  2335. * @param y defines the y coordinate of the operand
  2336. * @param z defines the z coordinate of the operand
  2337. * @returns the resulting Vector3
  2338. */
  2339. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2340. /**
  2341. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2342. * @param x defines the x coordinate of the operand
  2343. * @param y defines the y coordinate of the operand
  2344. * @param z defines the z coordinate of the operand
  2345. * @param result defines the Vector3 object where to store the result
  2346. * @returns the current Vector3
  2347. */
  2348. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2349. /**
  2350. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2351. * @returns a new Vector3
  2352. */
  2353. negate(): Vector3;
  2354. /**
  2355. * Multiplies the Vector3 coordinates by the float "scale"
  2356. * @param scale defines the multiplier factor
  2357. * @returns the current updated Vector3
  2358. */
  2359. scaleInPlace(scale: number): Vector3;
  2360. /**
  2361. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2362. * @param scale defines the multiplier factor
  2363. * @returns a new Vector3
  2364. */
  2365. scale(scale: number): Vector3;
  2366. /**
  2367. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2368. * @param scale defines the multiplier factor
  2369. * @param result defines the Vector3 object where to store the result
  2370. * @returns the current Vector3
  2371. */
  2372. scaleToRef(scale: number, result: Vector3): Vector3;
  2373. /**
  2374. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2375. * @param scale defines the scale factor
  2376. * @param result defines the Vector3 object where to store the result
  2377. * @returns the unmodified current Vector3
  2378. */
  2379. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2380. /**
  2381. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2382. * @param otherVector defines the second operand
  2383. * @returns true if both vectors are equals
  2384. */
  2385. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2386. /**
  2387. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2388. * @param otherVector defines the second operand
  2389. * @param epsilon defines the minimal distance to define values as equals
  2390. * @returns true if both vectors are distant less than epsilon
  2391. */
  2392. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2393. /**
  2394. * Returns true if the current Vector3 coordinates equals the given floats
  2395. * @param x defines the x coordinate of the operand
  2396. * @param y defines the y coordinate of the operand
  2397. * @param z defines the z coordinate of the operand
  2398. * @returns true if both vectors are equals
  2399. */
  2400. equalsToFloats(x: number, y: number, z: number): boolean;
  2401. /**
  2402. * Multiplies the current Vector3 coordinates by the given ones
  2403. * @param otherVector defines the second operand
  2404. * @returns the current updated Vector3
  2405. */
  2406. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2407. /**
  2408. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2409. * @param otherVector defines the second operand
  2410. * @returns the new Vector3
  2411. */
  2412. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2413. /**
  2414. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2415. * @param otherVector defines the second operand
  2416. * @param result defines the Vector3 object where to store the result
  2417. * @returns the current Vector3
  2418. */
  2419. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2420. /**
  2421. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2422. * @param x defines the x coordinate of the operand
  2423. * @param y defines the y coordinate of the operand
  2424. * @param z defines the z coordinate of the operand
  2425. * @returns the new Vector3
  2426. */
  2427. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2428. /**
  2429. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2430. * @param otherVector defines the second operand
  2431. * @returns the new Vector3
  2432. */
  2433. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2434. /**
  2435. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2436. * @param otherVector defines the second operand
  2437. * @param result defines the Vector3 object where to store the result
  2438. * @returns the current Vector3
  2439. */
  2440. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2441. /**
  2442. * Divides the current Vector3 coordinates by the given ones.
  2443. * @param otherVector defines the second operand
  2444. * @returns the current updated Vector3
  2445. */
  2446. divideInPlace(otherVector: Vector3): Vector3;
  2447. /**
  2448. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2449. * @param other defines the second operand
  2450. * @returns the current updated Vector3
  2451. */
  2452. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2453. /**
  2454. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2455. * @param other defines the second operand
  2456. * @returns the current updated Vector3
  2457. */
  2458. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2459. /**
  2460. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2461. * @param x defines the x coordinate of the operand
  2462. * @param y defines the y coordinate of the operand
  2463. * @param z defines the z coordinate of the operand
  2464. * @returns the current updated Vector3
  2465. */
  2466. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2467. /**
  2468. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2469. * @param x defines the x coordinate of the operand
  2470. * @param y defines the y coordinate of the operand
  2471. * @param z defines the z coordinate of the operand
  2472. * @returns the current updated Vector3
  2473. */
  2474. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2475. /**
  2476. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2477. * Check if is non uniform within a certain amount of decimal places to account for this
  2478. * @param epsilon the amount the values can differ
  2479. * @returns if the the vector is non uniform to a certain number of decimal places
  2480. */
  2481. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2482. /**
  2483. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2484. */
  2485. readonly isNonUniform: boolean;
  2486. /**
  2487. * Gets a new Vector3 from current Vector3 floored values
  2488. * @returns a new Vector3
  2489. */
  2490. floor(): Vector3;
  2491. /**
  2492. * Gets a new Vector3 from current Vector3 floored values
  2493. * @returns a new Vector3
  2494. */
  2495. fract(): Vector3;
  2496. /**
  2497. * Gets the length of the Vector3
  2498. * @returns the length of the Vector3
  2499. */
  2500. length(): number;
  2501. /**
  2502. * Gets the squared length of the Vector3
  2503. * @returns squared length of the Vector3
  2504. */
  2505. lengthSquared(): number;
  2506. /**
  2507. * Normalize the current Vector3.
  2508. * Please note that this is an in place operation.
  2509. * @returns the current updated Vector3
  2510. */
  2511. normalize(): Vector3;
  2512. /**
  2513. * Reorders the x y z properties of the vector in place
  2514. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2515. * @returns the current updated vector
  2516. */
  2517. reorderInPlace(order: string): this;
  2518. /**
  2519. * Rotates the vector around 0,0,0 by a quaternion
  2520. * @param quaternion the rotation quaternion
  2521. * @param result vector to store the result
  2522. * @returns the resulting vector
  2523. */
  2524. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2525. /**
  2526. * Rotates a vector around a given point
  2527. * @param quaternion the rotation quaternion
  2528. * @param point the point to rotate around
  2529. * @param result vector to store the result
  2530. * @returns the resulting vector
  2531. */
  2532. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2533. /**
  2534. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2535. * The cross product is then orthogonal to both current and "other"
  2536. * @param other defines the right operand
  2537. * @returns the cross product
  2538. */
  2539. cross(other: Vector3): Vector3;
  2540. /**
  2541. * Normalize the current Vector3 with the given input length.
  2542. * Please note that this is an in place operation.
  2543. * @param len the length of the vector
  2544. * @returns the current updated Vector3
  2545. */
  2546. normalizeFromLength(len: number): Vector3;
  2547. /**
  2548. * Normalize the current Vector3 to a new vector
  2549. * @returns the new Vector3
  2550. */
  2551. normalizeToNew(): Vector3;
  2552. /**
  2553. * Normalize the current Vector3 to the reference
  2554. * @param reference define the Vector3 to update
  2555. * @returns the updated Vector3
  2556. */
  2557. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2558. /**
  2559. * Creates a new Vector3 copied from the current Vector3
  2560. * @returns the new Vector3
  2561. */
  2562. clone(): Vector3;
  2563. /**
  2564. * Copies the given vector coordinates to the current Vector3 ones
  2565. * @param source defines the source Vector3
  2566. * @returns the current updated Vector3
  2567. */
  2568. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2569. /**
  2570. * Copies the given floats to the current Vector3 coordinates
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @returns the current updated Vector3
  2575. */
  2576. copyFromFloats(x: number, y: number, z: number): Vector3;
  2577. /**
  2578. * Copies the given floats to the current Vector3 coordinates
  2579. * @param x defines the x coordinate of the operand
  2580. * @param y defines the y coordinate of the operand
  2581. * @param z defines the z coordinate of the operand
  2582. * @returns the current updated Vector3
  2583. */
  2584. set(x: number, y: number, z: number): Vector3;
  2585. /**
  2586. * Copies the given float to the current Vector3 coordinates
  2587. * @param v defines the x, y and z coordinates of the operand
  2588. * @returns the current updated Vector3
  2589. */
  2590. setAll(v: number): Vector3;
  2591. /**
  2592. * Get the clip factor between two vectors
  2593. * @param vector0 defines the first operand
  2594. * @param vector1 defines the second operand
  2595. * @param axis defines the axis to use
  2596. * @param size defines the size along the axis
  2597. * @returns the clip factor
  2598. */
  2599. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2600. /**
  2601. * Get angle between two vectors
  2602. * @param vector0 angle between vector0 and vector1
  2603. * @param vector1 angle between vector0 and vector1
  2604. * @param normal direction of the normal
  2605. * @return the angle between vector0 and vector1
  2606. */
  2607. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2608. /**
  2609. * Returns a new Vector3 set from the index "offset" of the given array
  2610. * @param array defines the source array
  2611. * @param offset defines the offset in the source array
  2612. * @returns the new Vector3
  2613. */
  2614. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2615. /**
  2616. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2617. * This function is deprecated. Use FromArray instead
  2618. * @param array defines the source array
  2619. * @param offset defines the offset in the source array
  2620. * @returns the new Vector3
  2621. */
  2622. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2623. /**
  2624. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2625. * @param array defines the source array
  2626. * @param offset defines the offset in the source array
  2627. * @param result defines the Vector3 where to store the result
  2628. */
  2629. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2630. /**
  2631. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2632. * This function is deprecated. Use FromArrayToRef instead.
  2633. * @param array defines the source array
  2634. * @param offset defines the offset in the source array
  2635. * @param result defines the Vector3 where to store the result
  2636. */
  2637. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2638. /**
  2639. * Sets the given vector "result" with the given floats.
  2640. * @param x defines the x coordinate of the source
  2641. * @param y defines the y coordinate of the source
  2642. * @param z defines the z coordinate of the source
  2643. * @param result defines the Vector3 where to store the result
  2644. */
  2645. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2646. /**
  2647. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2648. * @returns a new empty Vector3
  2649. */
  2650. static Zero(): Vector3;
  2651. /**
  2652. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2653. * @returns a new unit Vector3
  2654. */
  2655. static One(): Vector3;
  2656. /**
  2657. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2658. * @returns a new up Vector3
  2659. */
  2660. static Up(): Vector3;
  2661. /**
  2662. * Gets a up Vector3 that must not be updated
  2663. */
  2664. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2665. /**
  2666. * Gets a zero Vector3 that must not be updated
  2667. */
  2668. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2669. /**
  2670. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2671. * @returns a new down Vector3
  2672. */
  2673. static Down(): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2676. * @returns a new forward Vector3
  2677. */
  2678. static Forward(): Vector3;
  2679. /**
  2680. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2681. * @returns a new forward Vector3
  2682. */
  2683. static Backward(): Vector3;
  2684. /**
  2685. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2686. * @returns a new right Vector3
  2687. */
  2688. static Right(): Vector3;
  2689. /**
  2690. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2691. * @returns a new left Vector3
  2692. */
  2693. static Left(): Vector3;
  2694. /**
  2695. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2696. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2697. * @param vector defines the Vector3 to transform
  2698. * @param transformation defines the transformation matrix
  2699. * @returns the transformed Vector3
  2700. */
  2701. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2702. /**
  2703. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2704. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2705. * @param vector defines the Vector3 to transform
  2706. * @param transformation defines the transformation matrix
  2707. * @param result defines the Vector3 where to store the result
  2708. */
  2709. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2710. /**
  2711. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2712. * This method computes tranformed coordinates only, not transformed direction vectors
  2713. * @param x define the x coordinate of the source vector
  2714. * @param y define the y coordinate of the source vector
  2715. * @param z define the z coordinate of the source vector
  2716. * @param transformation defines the transformation matrix
  2717. * @param result defines the Vector3 where to store the result
  2718. */
  2719. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2720. /**
  2721. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2722. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2723. * @param vector defines the Vector3 to transform
  2724. * @param transformation defines the transformation matrix
  2725. * @returns the new Vector3
  2726. */
  2727. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2728. /**
  2729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2730. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2731. * @param vector defines the Vector3 to transform
  2732. * @param transformation defines the transformation matrix
  2733. * @param result defines the Vector3 where to store the result
  2734. */
  2735. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2736. /**
  2737. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2738. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2739. * @param x define the x coordinate of the source vector
  2740. * @param y define the y coordinate of the source vector
  2741. * @param z define the z coordinate of the source vector
  2742. * @param transformation defines the transformation matrix
  2743. * @param result defines the Vector3 where to store the result
  2744. */
  2745. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2746. /**
  2747. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2748. * @param value1 defines the first control point
  2749. * @param value2 defines the second control point
  2750. * @param value3 defines the third control point
  2751. * @param value4 defines the fourth control point
  2752. * @param amount defines the amount on the spline to use
  2753. * @returns the new Vector3
  2754. */
  2755. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2756. /**
  2757. * 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"
  2758. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2759. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2760. * @param value defines the current value
  2761. * @param min defines the lower range value
  2762. * @param max defines the upper range value
  2763. * @returns the new Vector3
  2764. */
  2765. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2766. /**
  2767. * 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"
  2768. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2769. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2770. * @param value defines the current value
  2771. * @param min defines the lower range value
  2772. * @param max defines the upper range value
  2773. * @param result defines the Vector3 where to store the result
  2774. */
  2775. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2776. /**
  2777. * Checks if a given vector is inside a specific range
  2778. * @param v defines the vector to test
  2779. * @param min defines the minimum range
  2780. * @param max defines the maximum range
  2781. */
  2782. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2783. /**
  2784. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2785. * @param value1 defines the first control point
  2786. * @param tangent1 defines the first tangent vector
  2787. * @param value2 defines the second control point
  2788. * @param tangent2 defines the second tangent vector
  2789. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2790. * @returns the new Vector3
  2791. */
  2792. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2793. /**
  2794. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2795. * @param start defines the start value
  2796. * @param end defines the end value
  2797. * @param amount max defines amount between both (between 0 and 1)
  2798. * @returns the new Vector3
  2799. */
  2800. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2801. /**
  2802. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2803. * @param start defines the start value
  2804. * @param end defines the end value
  2805. * @param amount max defines amount between both (between 0 and 1)
  2806. * @param result defines the Vector3 where to store the result
  2807. */
  2808. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2809. /**
  2810. * Returns the dot product (float) between the vectors "left" and "right"
  2811. * @param left defines the left operand
  2812. * @param right defines the right operand
  2813. * @returns the dot product
  2814. */
  2815. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2816. /**
  2817. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2818. * The cross product is then orthogonal to both "left" and "right"
  2819. * @param left defines the left operand
  2820. * @param right defines the right operand
  2821. * @returns the cross product
  2822. */
  2823. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2824. /**
  2825. * Sets the given vector "result" with the cross product of "left" and "right"
  2826. * The cross product is then orthogonal to both "left" and "right"
  2827. * @param left defines the left operand
  2828. * @param right defines the right operand
  2829. * @param result defines the Vector3 where to store the result
  2830. */
  2831. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2832. /**
  2833. * Returns a new Vector3 as the normalization of the given vector
  2834. * @param vector defines the Vector3 to normalize
  2835. * @returns the new Vector3
  2836. */
  2837. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2838. /**
  2839. * Sets the given vector "result" with the normalization of the given first vector
  2840. * @param vector defines the Vector3 to normalize
  2841. * @param result defines the Vector3 where to store the result
  2842. */
  2843. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2844. /**
  2845. * Project a Vector3 onto screen space
  2846. * @param vector defines the Vector3 to project
  2847. * @param world defines the world matrix to use
  2848. * @param transform defines the transform (view x projection) matrix to use
  2849. * @param viewport defines the screen viewport to use
  2850. * @returns the new Vector3
  2851. */
  2852. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2853. /** @hidden */
  2854. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2855. /**
  2856. * Unproject from screen space to object space
  2857. * @param source defines the screen space Vector3 to use
  2858. * @param viewportWidth defines the current width of the viewport
  2859. * @param viewportHeight defines the current height of the viewport
  2860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2861. * @param transform defines the transform (view x projection) matrix to use
  2862. * @returns the new Vector3
  2863. */
  2864. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2865. /**
  2866. * Unproject from screen space to object space
  2867. * @param source defines the screen space Vector3 to use
  2868. * @param viewportWidth defines the current width of the viewport
  2869. * @param viewportHeight defines the current height of the viewport
  2870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2871. * @param view defines the view matrix to use
  2872. * @param projection defines the projection matrix to use
  2873. * @returns the new Vector3
  2874. */
  2875. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2876. /**
  2877. * Unproject from screen space to object space
  2878. * @param source defines the screen space Vector3 to use
  2879. * @param viewportWidth defines the current width of the viewport
  2880. * @param viewportHeight defines the current height of the viewport
  2881. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2882. * @param view defines the view matrix to use
  2883. * @param projection defines the projection matrix to use
  2884. * @param result defines the Vector3 where to store the result
  2885. */
  2886. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2887. /**
  2888. * Unproject from screen space to object space
  2889. * @param sourceX defines the screen space x coordinate to use
  2890. * @param sourceY defines the screen space y coordinate to use
  2891. * @param sourceZ defines the screen space z coordinate to use
  2892. * @param viewportWidth defines the current width of the viewport
  2893. * @param viewportHeight defines the current height of the viewport
  2894. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2895. * @param view defines the view matrix to use
  2896. * @param projection defines the projection matrix to use
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2900. /**
  2901. * Gets the minimal coordinate values between two Vector3
  2902. * @param left defines the first operand
  2903. * @param right defines the second operand
  2904. * @returns the new Vector3
  2905. */
  2906. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Gets the maximal coordinate values between two Vector3
  2909. * @param left defines the first operand
  2910. * @param right defines the second operand
  2911. * @returns the new Vector3
  2912. */
  2913. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Returns the distance between the vectors "value1" and "value2"
  2916. * @param value1 defines the first operand
  2917. * @param value2 defines the second operand
  2918. * @returns the distance
  2919. */
  2920. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2921. /**
  2922. * Returns the squared distance between the vectors "value1" and "value2"
  2923. * @param value1 defines the first operand
  2924. * @param value2 defines the second operand
  2925. * @returns the squared distance
  2926. */
  2927. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2928. /**
  2929. * Returns a new Vector3 located at the center between "value1" and "value2"
  2930. * @param value1 defines the first operand
  2931. * @param value2 defines the second operand
  2932. * @returns the new Vector3
  2933. */
  2934. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2935. /**
  2936. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2937. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2938. * to something in order to rotate it from its local system to the given target system
  2939. * Note: axis1, axis2 and axis3 are normalized during this operation
  2940. * @param axis1 defines the first axis
  2941. * @param axis2 defines the second axis
  2942. * @param axis3 defines the third axis
  2943. * @returns a new Vector3
  2944. */
  2945. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2946. /**
  2947. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2948. * @param axis1 defines the first axis
  2949. * @param axis2 defines the second axis
  2950. * @param axis3 defines the third axis
  2951. * @param ref defines the Vector3 where to store the result
  2952. */
  2953. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2954. }
  2955. /**
  2956. * Vector4 class created for EulerAngle class conversion to Quaternion
  2957. */
  2958. export class Vector4 {
  2959. /** x value of the vector */
  2960. x: number;
  2961. /** y value of the vector */
  2962. y: number;
  2963. /** z value of the vector */
  2964. z: number;
  2965. /** w value of the vector */
  2966. w: number;
  2967. /**
  2968. * Creates a Vector4 object from the given floats.
  2969. * @param x x value of the vector
  2970. * @param y y value of the vector
  2971. * @param z z value of the vector
  2972. * @param w w value of the vector
  2973. */
  2974. constructor(
  2975. /** x value of the vector */
  2976. x: number,
  2977. /** y value of the vector */
  2978. y: number,
  2979. /** z value of the vector */
  2980. z: number,
  2981. /** w value of the vector */
  2982. w: number);
  2983. /**
  2984. * Returns the string with the Vector4 coordinates.
  2985. * @returns a string containing all the vector values
  2986. */
  2987. toString(): string;
  2988. /**
  2989. * Returns the string "Vector4".
  2990. * @returns "Vector4"
  2991. */
  2992. getClassName(): string;
  2993. /**
  2994. * Returns the Vector4 hash code.
  2995. * @returns a unique hash code
  2996. */
  2997. getHashCode(): number;
  2998. /**
  2999. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3000. * @returns the resulting array
  3001. */
  3002. asArray(): number[];
  3003. /**
  3004. * Populates the given array from the given index with the Vector4 coordinates.
  3005. * @param array array to populate
  3006. * @param index index of the array to start at (default: 0)
  3007. * @returns the Vector4.
  3008. */
  3009. toArray(array: FloatArray, index?: number): Vector4;
  3010. /**
  3011. * Adds the given vector to the current Vector4.
  3012. * @param otherVector the vector to add
  3013. * @returns the updated Vector4.
  3014. */
  3015. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3016. /**
  3017. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3018. * @param otherVector the vector to add
  3019. * @returns the resulting vector
  3020. */
  3021. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3022. /**
  3023. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3024. * @param otherVector the vector to add
  3025. * @param result the vector to store the result
  3026. * @returns the current Vector4.
  3027. */
  3028. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3029. /**
  3030. * Subtract in place the given vector from the current Vector4.
  3031. * @param otherVector the vector to subtract
  3032. * @returns the updated Vector4.
  3033. */
  3034. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3035. /**
  3036. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3037. * @param otherVector the vector to add
  3038. * @returns the new vector with the result
  3039. */
  3040. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3041. /**
  3042. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3043. * @param otherVector the vector to subtract
  3044. * @param result the vector to store the result
  3045. * @returns the current Vector4.
  3046. */
  3047. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3048. /**
  3049. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3050. */
  3051. /**
  3052. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3053. * @param x value to subtract
  3054. * @param y value to subtract
  3055. * @param z value to subtract
  3056. * @param w value to subtract
  3057. * @returns new vector containing the result
  3058. */
  3059. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3060. /**
  3061. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3062. * @param x value to subtract
  3063. * @param y value to subtract
  3064. * @param z value to subtract
  3065. * @param w value to subtract
  3066. * @param result the vector to store the result in
  3067. * @returns the current Vector4.
  3068. */
  3069. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3070. /**
  3071. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3072. * @returns a new vector with the negated values
  3073. */
  3074. negate(): Vector4;
  3075. /**
  3076. * Multiplies the current Vector4 coordinates by scale (float).
  3077. * @param scale the number to scale with
  3078. * @returns the updated Vector4.
  3079. */
  3080. scaleInPlace(scale: number): Vector4;
  3081. /**
  3082. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3083. * @param scale the number to scale with
  3084. * @returns a new vector with the result
  3085. */
  3086. scale(scale: number): Vector4;
  3087. /**
  3088. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3089. * @param scale the number to scale with
  3090. * @param result a vector to store the result in
  3091. * @returns the current Vector4.
  3092. */
  3093. scaleToRef(scale: number, result: Vector4): Vector4;
  3094. /**
  3095. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3096. * @param scale defines the scale factor
  3097. * @param result defines the Vector4 object where to store the result
  3098. * @returns the unmodified current Vector4
  3099. */
  3100. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3101. /**
  3102. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3103. * @param otherVector the vector to compare against
  3104. * @returns true if they are equal
  3105. */
  3106. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3107. /**
  3108. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3109. * @param otherVector vector to compare against
  3110. * @param epsilon (Default: very small number)
  3111. * @returns true if they are equal
  3112. */
  3113. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3114. /**
  3115. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3116. * @param x x value to compare against
  3117. * @param y y value to compare against
  3118. * @param z z value to compare against
  3119. * @param w w value to compare against
  3120. * @returns true if equal
  3121. */
  3122. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3123. /**
  3124. * Multiplies in place the current Vector4 by the given one.
  3125. * @param otherVector vector to multiple with
  3126. * @returns the updated Vector4.
  3127. */
  3128. multiplyInPlace(otherVector: Vector4): Vector4;
  3129. /**
  3130. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3131. * @param otherVector vector to multiple with
  3132. * @returns resulting new vector
  3133. */
  3134. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3135. /**
  3136. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3137. * @param otherVector vector to multiple with
  3138. * @param result vector to store the result
  3139. * @returns the current Vector4.
  3140. */
  3141. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3142. /**
  3143. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3144. * @param x x value multiply with
  3145. * @param y y value multiply with
  3146. * @param z z value multiply with
  3147. * @param w w value multiply with
  3148. * @returns resulting new vector
  3149. */
  3150. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3151. /**
  3152. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3153. * @param otherVector vector to devide with
  3154. * @returns resulting new vector
  3155. */
  3156. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3157. /**
  3158. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3159. * @param otherVector vector to devide with
  3160. * @param result vector to store the result
  3161. * @returns the current Vector4.
  3162. */
  3163. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3164. /**
  3165. * Divides the current Vector3 coordinates by the given ones.
  3166. * @param otherVector vector to devide with
  3167. * @returns the updated Vector3.
  3168. */
  3169. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3170. /**
  3171. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3172. * @param other defines the second operand
  3173. * @returns the current updated Vector4
  3174. */
  3175. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3176. /**
  3177. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3178. * @param other defines the second operand
  3179. * @returns the current updated Vector4
  3180. */
  3181. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3182. /**
  3183. * Gets a new Vector4 from current Vector4 floored values
  3184. * @returns a new Vector4
  3185. */
  3186. floor(): Vector4;
  3187. /**
  3188. * Gets a new Vector4 from current Vector3 floored values
  3189. * @returns a new Vector4
  3190. */
  3191. fract(): Vector4;
  3192. /**
  3193. * Returns the Vector4 length (float).
  3194. * @returns the length
  3195. */
  3196. length(): number;
  3197. /**
  3198. * Returns the Vector4 squared length (float).
  3199. * @returns the length squared
  3200. */
  3201. lengthSquared(): number;
  3202. /**
  3203. * Normalizes in place the Vector4.
  3204. * @returns the updated Vector4.
  3205. */
  3206. normalize(): Vector4;
  3207. /**
  3208. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3209. * @returns this converted to a new vector3
  3210. */
  3211. toVector3(): Vector3;
  3212. /**
  3213. * Returns a new Vector4 copied from the current one.
  3214. * @returns the new cloned vector
  3215. */
  3216. clone(): Vector4;
  3217. /**
  3218. * Updates the current Vector4 with the given one coordinates.
  3219. * @param source the source vector to copy from
  3220. * @returns the updated Vector4.
  3221. */
  3222. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3223. /**
  3224. * Updates the current Vector4 coordinates with the given floats.
  3225. * @param x float to copy from
  3226. * @param y float to copy from
  3227. * @param z float to copy from
  3228. * @param w float to copy from
  3229. * @returns the updated Vector4.
  3230. */
  3231. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3232. /**
  3233. * Updates the current Vector4 coordinates with the given floats.
  3234. * @param x float to set from
  3235. * @param y float to set from
  3236. * @param z float to set from
  3237. * @param w float to set from
  3238. * @returns the updated Vector4.
  3239. */
  3240. set(x: number, y: number, z: number, w: number): Vector4;
  3241. /**
  3242. * Copies the given float to the current Vector3 coordinates
  3243. * @param v defines the x, y, z and w coordinates of the operand
  3244. * @returns the current updated Vector3
  3245. */
  3246. setAll(v: number): Vector4;
  3247. /**
  3248. * Returns a new Vector4 set from the starting index of the given array.
  3249. * @param array the array to pull values from
  3250. * @param offset the offset into the array to start at
  3251. * @returns the new vector
  3252. */
  3253. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3254. /**
  3255. * Updates the given vector "result" from the starting index of the given array.
  3256. * @param array the array to pull values from
  3257. * @param offset the offset into the array to start at
  3258. * @param result the vector to store the result in
  3259. */
  3260. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3261. /**
  3262. * Updates the given vector "result" from the starting index of the given Float32Array.
  3263. * @param array the array to pull values from
  3264. * @param offset the offset into the array to start at
  3265. * @param result the vector to store the result in
  3266. */
  3267. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3268. /**
  3269. * Updates the given vector "result" coordinates from the given floats.
  3270. * @param x float to set from
  3271. * @param y float to set from
  3272. * @param z float to set from
  3273. * @param w float to set from
  3274. * @param result the vector to the floats in
  3275. */
  3276. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3277. /**
  3278. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3279. * @returns the new vector
  3280. */
  3281. static Zero(): Vector4;
  3282. /**
  3283. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3284. * @returns the new vector
  3285. */
  3286. static One(): Vector4;
  3287. /**
  3288. * Returns a new normalized Vector4 from the given one.
  3289. * @param vector the vector to normalize
  3290. * @returns the vector
  3291. */
  3292. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3293. /**
  3294. * Updates the given vector "result" from the normalization of the given one.
  3295. * @param vector the vector to normalize
  3296. * @param result the vector to store the result in
  3297. */
  3298. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3299. /**
  3300. * Returns a vector with the minimum values from the left and right vectors
  3301. * @param left left vector to minimize
  3302. * @param right right vector to minimize
  3303. * @returns a new vector with the minimum of the left and right vector values
  3304. */
  3305. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Returns a vector with the maximum values from the left and right vectors
  3308. * @param left left vector to maximize
  3309. * @param right right vector to maximize
  3310. * @returns a new vector with the maximum of the left and right vector values
  3311. */
  3312. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3313. /**
  3314. * Returns the distance (float) between the vectors "value1" and "value2".
  3315. * @param value1 value to calulate the distance between
  3316. * @param value2 value to calulate the distance between
  3317. * @return the distance between the two vectors
  3318. */
  3319. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3320. /**
  3321. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3322. * @param value1 value to calulate the distance between
  3323. * @param value2 value to calulate the distance between
  3324. * @return the distance between the two vectors squared
  3325. */
  3326. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3327. /**
  3328. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3329. * @param value1 value to calulate the center between
  3330. * @param value2 value to calulate the center between
  3331. * @return the center between the two vectors
  3332. */
  3333. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3336. * This methods computes transformed normalized direction vectors only.
  3337. * @param vector the vector to transform
  3338. * @param transformation the transformation matrix to apply
  3339. * @returns the new vector
  3340. */
  3341. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3342. /**
  3343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3344. * This methods computes transformed normalized direction vectors only.
  3345. * @param vector the vector to transform
  3346. * @param transformation the transformation matrix to apply
  3347. * @param result the vector to store the result in
  3348. */
  3349. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3350. /**
  3351. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3352. * This methods computes transformed normalized direction vectors only.
  3353. * @param x value to transform
  3354. * @param y value to transform
  3355. * @param z value to transform
  3356. * @param w value to transform
  3357. * @param transformation the transformation matrix to apply
  3358. * @param result the vector to store the results in
  3359. */
  3360. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3361. /**
  3362. * Creates a new Vector4 from a Vector3
  3363. * @param source defines the source data
  3364. * @param w defines the 4th component (default is 0)
  3365. * @returns a new Vector4
  3366. */
  3367. static FromVector3(source: Vector3, w?: number): Vector4;
  3368. }
  3369. /**
  3370. * Class used to store quaternion data
  3371. * @see https://en.wikipedia.org/wiki/Quaternion
  3372. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3373. */
  3374. export class Quaternion {
  3375. /** defines the first component (0 by default) */
  3376. x: number;
  3377. /** defines the second component (0 by default) */
  3378. y: number;
  3379. /** defines the third component (0 by default) */
  3380. z: number;
  3381. /** defines the fourth component (1.0 by default) */
  3382. w: number;
  3383. /**
  3384. * Creates a new Quaternion from the given floats
  3385. * @param x defines the first component (0 by default)
  3386. * @param y defines the second component (0 by default)
  3387. * @param z defines the third component (0 by default)
  3388. * @param w defines the fourth component (1.0 by default)
  3389. */
  3390. constructor(
  3391. /** defines the first component (0 by default) */
  3392. x?: number,
  3393. /** defines the second component (0 by default) */
  3394. y?: number,
  3395. /** defines the third component (0 by default) */
  3396. z?: number,
  3397. /** defines the fourth component (1.0 by default) */
  3398. w?: number);
  3399. /**
  3400. * Gets a string representation for the current quaternion
  3401. * @returns a string with the Quaternion coordinates
  3402. */
  3403. toString(): string;
  3404. /**
  3405. * Gets the class name of the quaternion
  3406. * @returns the string "Quaternion"
  3407. */
  3408. getClassName(): string;
  3409. /**
  3410. * Gets a hash code for this quaternion
  3411. * @returns the quaternion hash code
  3412. */
  3413. getHashCode(): number;
  3414. /**
  3415. * Copy the quaternion to an array
  3416. * @returns a new array populated with 4 elements from the quaternion coordinates
  3417. */
  3418. asArray(): number[];
  3419. /**
  3420. * Check if two quaternions are equals
  3421. * @param otherQuaternion defines the second operand
  3422. * @return true if the current quaternion and the given one coordinates are strictly equals
  3423. */
  3424. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3425. /**
  3426. * Clone the current quaternion
  3427. * @returns a new quaternion copied from the current one
  3428. */
  3429. clone(): Quaternion;
  3430. /**
  3431. * Copy a quaternion to the current one
  3432. * @param other defines the other quaternion
  3433. * @returns the updated current quaternion
  3434. */
  3435. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3436. /**
  3437. * Updates the current quaternion with the given float coordinates
  3438. * @param x defines the x coordinate
  3439. * @param y defines the y coordinate
  3440. * @param z defines the z coordinate
  3441. * @param w defines the w coordinate
  3442. * @returns the updated current quaternion
  3443. */
  3444. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3445. /**
  3446. * Updates the current quaternion from the given float coordinates
  3447. * @param x defines the x coordinate
  3448. * @param y defines the y coordinate
  3449. * @param z defines the z coordinate
  3450. * @param w defines the w coordinate
  3451. * @returns the updated current quaternion
  3452. */
  3453. set(x: number, y: number, z: number, w: number): Quaternion;
  3454. /**
  3455. * Adds two quaternions
  3456. * @param other defines the second operand
  3457. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3458. */
  3459. add(other: DeepImmutable<Quaternion>): Quaternion;
  3460. /**
  3461. * Add a quaternion to the current one
  3462. * @param other defines the quaternion to add
  3463. * @returns the current quaternion
  3464. */
  3465. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3466. /**
  3467. * Subtract two quaternions
  3468. * @param other defines the second operand
  3469. * @returns a new quaternion as the subtraction result of the given one from the current one
  3470. */
  3471. subtract(other: Quaternion): Quaternion;
  3472. /**
  3473. * Multiplies the current quaternion by a scale factor
  3474. * @param value defines the scale factor
  3475. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3476. */
  3477. scale(value: number): Quaternion;
  3478. /**
  3479. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3480. * @param scale defines the scale factor
  3481. * @param result defines the Quaternion object where to store the result
  3482. * @returns the unmodified current quaternion
  3483. */
  3484. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3485. /**
  3486. * Multiplies in place the current quaternion by a scale factor
  3487. * @param value defines the scale factor
  3488. * @returns the current modified quaternion
  3489. */
  3490. scaleInPlace(value: number): Quaternion;
  3491. /**
  3492. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3493. * @param scale defines the scale factor
  3494. * @param result defines the Quaternion object where to store the result
  3495. * @returns the unmodified current quaternion
  3496. */
  3497. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3498. /**
  3499. * Multiplies two quaternions
  3500. * @param q1 defines the second operand
  3501. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3502. */
  3503. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3504. /**
  3505. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3506. * @param q1 defines the second operand
  3507. * @param result defines the target quaternion
  3508. * @returns the current quaternion
  3509. */
  3510. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3511. /**
  3512. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3513. * @param q1 defines the second operand
  3514. * @returns the currentupdated quaternion
  3515. */
  3516. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3517. /**
  3518. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3519. * @param ref defines the target quaternion
  3520. * @returns the current quaternion
  3521. */
  3522. conjugateToRef(ref: Quaternion): Quaternion;
  3523. /**
  3524. * Conjugates in place (1-q) the current quaternion
  3525. * @returns the current updated quaternion
  3526. */
  3527. conjugateInPlace(): Quaternion;
  3528. /**
  3529. * Conjugates in place (1-q) the current quaternion
  3530. * @returns a new quaternion
  3531. */
  3532. conjugate(): Quaternion;
  3533. /**
  3534. * Gets length of current quaternion
  3535. * @returns the quaternion length (float)
  3536. */
  3537. length(): number;
  3538. /**
  3539. * Normalize in place the current quaternion
  3540. * @returns the current updated quaternion
  3541. */
  3542. normalize(): Quaternion;
  3543. /**
  3544. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3545. * @param order is a reserved parameter and is ignore for now
  3546. * @returns a new Vector3 containing the Euler angles
  3547. */
  3548. toEulerAngles(order?: string): Vector3;
  3549. /**
  3550. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3551. * @param result defines the vector which will be filled with the Euler angles
  3552. * @param order is a reserved parameter and is ignore for now
  3553. * @returns the current unchanged quaternion
  3554. */
  3555. toEulerAnglesToRef(result: Vector3): Quaternion;
  3556. /**
  3557. * Updates the given rotation matrix with the current quaternion values
  3558. * @param result defines the target matrix
  3559. * @returns the current unchanged quaternion
  3560. */
  3561. toRotationMatrix(result: Matrix): Quaternion;
  3562. /**
  3563. * Updates the current quaternion from the given rotation matrix values
  3564. * @param matrix defines the source matrix
  3565. * @returns the current updated quaternion
  3566. */
  3567. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3568. /**
  3569. * Creates a new quaternion from a rotation matrix
  3570. * @param matrix defines the source matrix
  3571. * @returns a new quaternion created from the given rotation matrix values
  3572. */
  3573. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3574. /**
  3575. * Updates the given quaternion with the given rotation matrix values
  3576. * @param matrix defines the source matrix
  3577. * @param result defines the target quaternion
  3578. */
  3579. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3580. /**
  3581. * Returns the dot product (float) between the quaternions "left" and "right"
  3582. * @param left defines the left operand
  3583. * @param right defines the right operand
  3584. * @returns the dot product
  3585. */
  3586. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3587. /**
  3588. * Checks if the two quaternions are close to each other
  3589. * @param quat0 defines the first quaternion to check
  3590. * @param quat1 defines the second quaternion to check
  3591. * @returns true if the two quaternions are close to each other
  3592. */
  3593. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3594. /**
  3595. * Creates an empty quaternion
  3596. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3597. */
  3598. static Zero(): Quaternion;
  3599. /**
  3600. * Inverse a given quaternion
  3601. * @param q defines the source quaternion
  3602. * @returns a new quaternion as the inverted current quaternion
  3603. */
  3604. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3605. /**
  3606. * Inverse a given quaternion
  3607. * @param q defines the source quaternion
  3608. * @param result the quaternion the result will be stored in
  3609. * @returns the result quaternion
  3610. */
  3611. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3612. /**
  3613. * Creates an identity quaternion
  3614. * @returns the identity quaternion
  3615. */
  3616. static Identity(): Quaternion;
  3617. /**
  3618. * Gets a boolean indicating if the given quaternion is identity
  3619. * @param quaternion defines the quaternion to check
  3620. * @returns true if the quaternion is identity
  3621. */
  3622. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3623. /**
  3624. * Creates a quaternion from a rotation around an axis
  3625. * @param axis defines the axis to use
  3626. * @param angle defines the angle to use
  3627. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3628. */
  3629. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3630. /**
  3631. * Creates a rotation around an axis and stores it into the given quaternion
  3632. * @param axis defines the axis to use
  3633. * @param angle defines the angle to use
  3634. * @param result defines the target quaternion
  3635. * @returns the target quaternion
  3636. */
  3637. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3638. /**
  3639. * Creates a new quaternion from data stored into an array
  3640. * @param array defines the data source
  3641. * @param offset defines the offset in the source array where the data starts
  3642. * @returns a new quaternion
  3643. */
  3644. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3645. /**
  3646. * Create a quaternion from Euler rotation angles
  3647. * @param x Pitch
  3648. * @param y Yaw
  3649. * @param z Roll
  3650. * @returns the new Quaternion
  3651. */
  3652. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3653. /**
  3654. * Updates a quaternion from Euler rotation angles
  3655. * @param x Pitch
  3656. * @param y Yaw
  3657. * @param z Roll
  3658. * @param result the quaternion to store the result
  3659. * @returns the updated quaternion
  3660. */
  3661. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3662. /**
  3663. * Create a quaternion from Euler rotation vector
  3664. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3665. * @returns the new Quaternion
  3666. */
  3667. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3668. /**
  3669. * Updates a quaternion from Euler rotation vector
  3670. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3671. * @param result the quaternion to store the result
  3672. * @returns the updated quaternion
  3673. */
  3674. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3675. /**
  3676. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3677. * @param yaw defines the rotation around Y axis
  3678. * @param pitch defines the rotation around X axis
  3679. * @param roll defines the rotation around Z axis
  3680. * @returns the new quaternion
  3681. */
  3682. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3683. /**
  3684. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3685. * @param yaw defines the rotation around Y axis
  3686. * @param pitch defines the rotation around X axis
  3687. * @param roll defines the rotation around Z axis
  3688. * @param result defines the target quaternion
  3689. */
  3690. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3691. /**
  3692. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3693. * @param alpha defines the rotation around first axis
  3694. * @param beta defines the rotation around second axis
  3695. * @param gamma defines the rotation around third axis
  3696. * @returns the new quaternion
  3697. */
  3698. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3699. /**
  3700. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3701. * @param alpha defines the rotation around first axis
  3702. * @param beta defines the rotation around second axis
  3703. * @param gamma defines the rotation around third axis
  3704. * @param result defines the target quaternion
  3705. */
  3706. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3707. /**
  3708. * 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)
  3709. * @param axis1 defines the first axis
  3710. * @param axis2 defines the second axis
  3711. * @param axis3 defines the third axis
  3712. * @returns the new quaternion
  3713. */
  3714. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3715. /**
  3716. * 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
  3717. * @param axis1 defines the first axis
  3718. * @param axis2 defines the second axis
  3719. * @param axis3 defines the third axis
  3720. * @param ref defines the target quaternion
  3721. */
  3722. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3723. /**
  3724. * Interpolates between two quaternions
  3725. * @param left defines first quaternion
  3726. * @param right defines second quaternion
  3727. * @param amount defines the gradient to use
  3728. * @returns the new interpolated quaternion
  3729. */
  3730. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3731. /**
  3732. * Interpolates between two quaternions and stores it into a target quaternion
  3733. * @param left defines first quaternion
  3734. * @param right defines second quaternion
  3735. * @param amount defines the gradient to use
  3736. * @param result defines the target quaternion
  3737. */
  3738. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3739. /**
  3740. * Interpolate between two quaternions using Hermite interpolation
  3741. * @param value1 defines first quaternion
  3742. * @param tangent1 defines the incoming tangent
  3743. * @param value2 defines second quaternion
  3744. * @param tangent2 defines the outgoing tangent
  3745. * @param amount defines the target quaternion
  3746. * @returns the new interpolated quaternion
  3747. */
  3748. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3749. }
  3750. /**
  3751. * Class used to store matrix data (4x4)
  3752. */
  3753. export class Matrix {
  3754. private static _updateFlagSeed;
  3755. private static _identityReadOnly;
  3756. private _isIdentity;
  3757. private _isIdentityDirty;
  3758. private _isIdentity3x2;
  3759. private _isIdentity3x2Dirty;
  3760. /**
  3761. * Gets the update flag of the matrix which is an unique number for the matrix.
  3762. * It will be incremented every time the matrix data change.
  3763. * You can use it to speed the comparison between two versions of the same matrix.
  3764. */
  3765. updateFlag: number;
  3766. private readonly _m;
  3767. /**
  3768. * Gets the internal data of the matrix
  3769. */
  3770. readonly m: DeepImmutable<Float32Array>;
  3771. /** @hidden */
  3772. _markAsUpdated(): void;
  3773. /** @hidden */
  3774. private _updateIdentityStatus;
  3775. /**
  3776. * Creates an empty matrix (filled with zeros)
  3777. */
  3778. constructor();
  3779. /**
  3780. * Check if the current matrix is identity
  3781. * @returns true is the matrix is the identity matrix
  3782. */
  3783. isIdentity(): boolean;
  3784. /**
  3785. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3786. * @returns true is the matrix is the identity matrix
  3787. */
  3788. isIdentityAs3x2(): boolean;
  3789. /**
  3790. * Gets the determinant of the matrix
  3791. * @returns the matrix determinant
  3792. */
  3793. determinant(): number;
  3794. /**
  3795. * Returns the matrix as a Float32Array
  3796. * @returns the matrix underlying array
  3797. */
  3798. toArray(): DeepImmutable<Float32Array>;
  3799. /**
  3800. * Returns the matrix as a Float32Array
  3801. * @returns the matrix underlying array.
  3802. */
  3803. asArray(): DeepImmutable<Float32Array>;
  3804. /**
  3805. * Inverts the current matrix in place
  3806. * @returns the current inverted matrix
  3807. */
  3808. invert(): Matrix;
  3809. /**
  3810. * Sets all the matrix elements to zero
  3811. * @returns the current matrix
  3812. */
  3813. reset(): Matrix;
  3814. /**
  3815. * Adds the current matrix with a second one
  3816. * @param other defines the matrix to add
  3817. * @returns a new matrix as the addition of the current matrix and the given one
  3818. */
  3819. add(other: DeepImmutable<Matrix>): Matrix;
  3820. /**
  3821. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3822. * @param other defines the matrix to add
  3823. * @param result defines the target matrix
  3824. * @returns the current matrix
  3825. */
  3826. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3827. /**
  3828. * Adds in place the given matrix to the current matrix
  3829. * @param other defines the second operand
  3830. * @returns the current updated matrix
  3831. */
  3832. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3833. /**
  3834. * Sets the given matrix to the current inverted Matrix
  3835. * @param other defines the target matrix
  3836. * @returns the unmodified current matrix
  3837. */
  3838. invertToRef(other: Matrix): Matrix;
  3839. /**
  3840. * add a value at the specified position in the current Matrix
  3841. * @param index the index of the value within the matrix. between 0 and 15.
  3842. * @param value the value to be added
  3843. * @returns the current updated matrix
  3844. */
  3845. addAtIndex(index: number, value: number): Matrix;
  3846. /**
  3847. * mutiply the specified position in the current Matrix by a value
  3848. * @param index the index of the value within the matrix. between 0 and 15.
  3849. * @param value the value to be added
  3850. * @returns the current updated matrix
  3851. */
  3852. multiplyAtIndex(index: number, value: number): Matrix;
  3853. /**
  3854. * Inserts the translation vector (using 3 floats) in the current matrix
  3855. * @param x defines the 1st component of the translation
  3856. * @param y defines the 2nd component of the translation
  3857. * @param z defines the 3rd component of the translation
  3858. * @returns the current updated matrix
  3859. */
  3860. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3861. /**
  3862. * Adds the translation vector (using 3 floats) in the current matrix
  3863. * @param x defines the 1st component of the translation
  3864. * @param y defines the 2nd component of the translation
  3865. * @param z defines the 3rd component of the translation
  3866. * @returns the current updated matrix
  3867. */
  3868. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3869. /**
  3870. * Inserts the translation vector in the current matrix
  3871. * @param vector3 defines the translation to insert
  3872. * @returns the current updated matrix
  3873. */
  3874. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3875. /**
  3876. * Gets the translation value of the current matrix
  3877. * @returns a new Vector3 as the extracted translation from the matrix
  3878. */
  3879. getTranslation(): Vector3;
  3880. /**
  3881. * Fill a Vector3 with the extracted translation from the matrix
  3882. * @param result defines the Vector3 where to store the translation
  3883. * @returns the current matrix
  3884. */
  3885. getTranslationToRef(result: Vector3): Matrix;
  3886. /**
  3887. * Remove rotation and scaling part from the matrix
  3888. * @returns the updated matrix
  3889. */
  3890. removeRotationAndScaling(): Matrix;
  3891. /**
  3892. * Multiply two matrices
  3893. * @param other defines the second operand
  3894. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3895. */
  3896. multiply(other: DeepImmutable<Matrix>): Matrix;
  3897. /**
  3898. * Copy the current matrix from the given one
  3899. * @param other defines the source matrix
  3900. * @returns the current updated matrix
  3901. */
  3902. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Populates the given array from the starting index with the current matrix values
  3905. * @param array defines the target array
  3906. * @param offset defines the offset in the target array where to start storing values
  3907. * @returns the current matrix
  3908. */
  3909. copyToArray(array: Float32Array, offset?: number): Matrix;
  3910. /**
  3911. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3912. * @param other defines the second operand
  3913. * @param result defines the matrix where to store the multiplication
  3914. * @returns the current matrix
  3915. */
  3916. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3917. /**
  3918. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3919. * @param other defines the second operand
  3920. * @param result defines the array where to store the multiplication
  3921. * @param offset defines the offset in the target array where to start storing values
  3922. * @returns the current matrix
  3923. */
  3924. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3925. /**
  3926. * Check equality between this matrix and a second one
  3927. * @param value defines the second matrix to compare
  3928. * @returns true is the current matrix and the given one values are strictly equal
  3929. */
  3930. equals(value: DeepImmutable<Matrix>): boolean;
  3931. /**
  3932. * Clone the current matrix
  3933. * @returns a new matrix from the current matrix
  3934. */
  3935. clone(): Matrix;
  3936. /**
  3937. * Returns the name of the current matrix class
  3938. * @returns the string "Matrix"
  3939. */
  3940. getClassName(): string;
  3941. /**
  3942. * Gets the hash code of the current matrix
  3943. * @returns the hash code
  3944. */
  3945. getHashCode(): number;
  3946. /**
  3947. * Decomposes the current Matrix into a translation, rotation and scaling components
  3948. * @param scale defines the scale vector3 given as a reference to update
  3949. * @param rotation defines the rotation quaternion given as a reference to update
  3950. * @param translation defines the translation vector3 given as a reference to update
  3951. * @returns true if operation was successful
  3952. */
  3953. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3954. /**
  3955. * Gets specific row of the matrix
  3956. * @param index defines the number of the row to get
  3957. * @returns the index-th row of the current matrix as a new Vector4
  3958. */
  3959. getRow(index: number): Nullable<Vector4>;
  3960. /**
  3961. * Sets the index-th row of the current matrix to the vector4 values
  3962. * @param index defines the number of the row to set
  3963. * @param row defines the target vector4
  3964. * @returns the updated current matrix
  3965. */
  3966. setRow(index: number, row: Vector4): Matrix;
  3967. /**
  3968. * Compute the transpose of the matrix
  3969. * @returns the new transposed matrix
  3970. */
  3971. transpose(): Matrix;
  3972. /**
  3973. * Compute the transpose of the matrix and store it in a given matrix
  3974. * @param result defines the target matrix
  3975. * @returns the current matrix
  3976. */
  3977. transposeToRef(result: Matrix): Matrix;
  3978. /**
  3979. * Sets the index-th row of the current matrix with the given 4 x float values
  3980. * @param index defines the row index
  3981. * @param x defines the x component to set
  3982. * @param y defines the y component to set
  3983. * @param z defines the z component to set
  3984. * @param w defines the w component to set
  3985. * @returns the updated current matrix
  3986. */
  3987. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3988. /**
  3989. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3990. * @param scale defines the scale factor
  3991. * @returns a new matrix
  3992. */
  3993. scale(scale: number): Matrix;
  3994. /**
  3995. * Scale the current matrix values by a factor to a given result matrix
  3996. * @param scale defines the scale factor
  3997. * @param result defines the matrix to store the result
  3998. * @returns the current matrix
  3999. */
  4000. scaleToRef(scale: number, result: Matrix): Matrix;
  4001. /**
  4002. * Scale the current matrix values by a factor and add the result to a given matrix
  4003. * @param scale defines the scale factor
  4004. * @param result defines the Matrix to store the result
  4005. * @returns the current matrix
  4006. */
  4007. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4008. /**
  4009. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4010. * @param ref matrix to store the result
  4011. */
  4012. toNormalMatrix(ref: Matrix): void;
  4013. /**
  4014. * Gets only rotation part of the current matrix
  4015. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4016. */
  4017. getRotationMatrix(): Matrix;
  4018. /**
  4019. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4020. * @param result defines the target matrix to store data to
  4021. * @returns the current matrix
  4022. */
  4023. getRotationMatrixToRef(result: Matrix): Matrix;
  4024. /**
  4025. * Toggles model matrix from being right handed to left handed in place and vice versa
  4026. */
  4027. toggleModelMatrixHandInPlace(): void;
  4028. /**
  4029. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4030. */
  4031. toggleProjectionMatrixHandInPlace(): void;
  4032. /**
  4033. * Creates a matrix from an array
  4034. * @param array defines the source array
  4035. * @param offset defines an offset in the source array
  4036. * @returns a new Matrix set from the starting index of the given array
  4037. */
  4038. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4039. /**
  4040. * Copy the content of an array into a given matrix
  4041. * @param array defines the source array
  4042. * @param offset defines an offset in the source array
  4043. * @param result defines the target matrix
  4044. */
  4045. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4046. /**
  4047. * Stores an array into a matrix after having multiplied each component by a given factor
  4048. * @param array defines the source array
  4049. * @param offset defines the offset in the source array
  4050. * @param scale defines the scaling factor
  4051. * @param result defines the target matrix
  4052. */
  4053. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4054. /**
  4055. * Gets an identity matrix that must not be updated
  4056. */
  4057. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4058. /**
  4059. * Stores a list of values (16) inside a given matrix
  4060. * @param initialM11 defines 1st value of 1st row
  4061. * @param initialM12 defines 2nd value of 1st row
  4062. * @param initialM13 defines 3rd value of 1st row
  4063. * @param initialM14 defines 4th value of 1st row
  4064. * @param initialM21 defines 1st value of 2nd row
  4065. * @param initialM22 defines 2nd value of 2nd row
  4066. * @param initialM23 defines 3rd value of 2nd row
  4067. * @param initialM24 defines 4th value of 2nd row
  4068. * @param initialM31 defines 1st value of 3rd row
  4069. * @param initialM32 defines 2nd value of 3rd row
  4070. * @param initialM33 defines 3rd value of 3rd row
  4071. * @param initialM34 defines 4th value of 3rd row
  4072. * @param initialM41 defines 1st value of 4th row
  4073. * @param initialM42 defines 2nd value of 4th row
  4074. * @param initialM43 defines 3rd value of 4th row
  4075. * @param initialM44 defines 4th value of 4th row
  4076. * @param result defines the target matrix
  4077. */
  4078. 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;
  4079. /**
  4080. * Creates new matrix from a list of values (16)
  4081. * @param initialM11 defines 1st value of 1st row
  4082. * @param initialM12 defines 2nd value of 1st row
  4083. * @param initialM13 defines 3rd value of 1st row
  4084. * @param initialM14 defines 4th value of 1st row
  4085. * @param initialM21 defines 1st value of 2nd row
  4086. * @param initialM22 defines 2nd value of 2nd row
  4087. * @param initialM23 defines 3rd value of 2nd row
  4088. * @param initialM24 defines 4th value of 2nd row
  4089. * @param initialM31 defines 1st value of 3rd row
  4090. * @param initialM32 defines 2nd value of 3rd row
  4091. * @param initialM33 defines 3rd value of 3rd row
  4092. * @param initialM34 defines 4th value of 3rd row
  4093. * @param initialM41 defines 1st value of 4th row
  4094. * @param initialM42 defines 2nd value of 4th row
  4095. * @param initialM43 defines 3rd value of 4th row
  4096. * @param initialM44 defines 4th value of 4th row
  4097. * @returns the new matrix
  4098. */
  4099. 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;
  4100. /**
  4101. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4102. * @param scale defines the scale vector3
  4103. * @param rotation defines the rotation quaternion
  4104. * @param translation defines the translation vector3
  4105. * @returns a new matrix
  4106. */
  4107. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4108. /**
  4109. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4110. * @param scale defines the scale vector3
  4111. * @param rotation defines the rotation quaternion
  4112. * @param translation defines the translation vector3
  4113. * @param result defines the target matrix
  4114. */
  4115. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4116. /**
  4117. * Creates a new identity matrix
  4118. * @returns a new identity matrix
  4119. */
  4120. static Identity(): Matrix;
  4121. /**
  4122. * Creates a new identity matrix and stores the result in a given matrix
  4123. * @param result defines the target matrix
  4124. */
  4125. static IdentityToRef(result: Matrix): void;
  4126. /**
  4127. * Creates a new zero matrix
  4128. * @returns a new zero matrix
  4129. */
  4130. static Zero(): Matrix;
  4131. /**
  4132. * Creates a new rotation matrix for "angle" radians around the X axis
  4133. * @param angle defines the angle (in radians) to use
  4134. * @return the new matrix
  4135. */
  4136. static RotationX(angle: number): Matrix;
  4137. /**
  4138. * Creates a new matrix as the invert of a given matrix
  4139. * @param source defines the source matrix
  4140. * @returns the new matrix
  4141. */
  4142. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4143. /**
  4144. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4145. * @param angle defines the angle (in radians) to use
  4146. * @param result defines the target matrix
  4147. */
  4148. static RotationXToRef(angle: number, result: Matrix): void;
  4149. /**
  4150. * Creates a new rotation matrix for "angle" radians around the Y axis
  4151. * @param angle defines the angle (in radians) to use
  4152. * @return the new matrix
  4153. */
  4154. static RotationY(angle: number): Matrix;
  4155. /**
  4156. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4157. * @param angle defines the angle (in radians) to use
  4158. * @param result defines the target matrix
  4159. */
  4160. static RotationYToRef(angle: number, result: Matrix): void;
  4161. /**
  4162. * Creates a new rotation matrix for "angle" radians around the Z axis
  4163. * @param angle defines the angle (in radians) to use
  4164. * @return the new matrix
  4165. */
  4166. static RotationZ(angle: number): Matrix;
  4167. /**
  4168. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4169. * @param angle defines the angle (in radians) to use
  4170. * @param result defines the target matrix
  4171. */
  4172. static RotationZToRef(angle: number, result: Matrix): void;
  4173. /**
  4174. * Creates a new rotation matrix for "angle" radians around the given axis
  4175. * @param axis defines the axis to use
  4176. * @param angle defines the angle (in radians) to use
  4177. * @return the new matrix
  4178. */
  4179. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4180. /**
  4181. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4182. * @param axis defines the axis to use
  4183. * @param angle defines the angle (in radians) to use
  4184. * @param result defines the target matrix
  4185. */
  4186. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4187. /**
  4188. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4189. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4190. * @param from defines the vector to align
  4191. * @param to defines the vector to align to
  4192. * @param result defines the target matrix
  4193. */
  4194. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4195. /**
  4196. * Creates a rotation matrix
  4197. * @param yaw defines the yaw angle in radians (Y axis)
  4198. * @param pitch defines the pitch angle in radians (X axis)
  4199. * @param roll defines the roll angle in radians (X axis)
  4200. * @returns the new rotation matrix
  4201. */
  4202. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4203. /**
  4204. * Creates a rotation matrix and stores it in a given matrix
  4205. * @param yaw defines the yaw angle in radians (Y axis)
  4206. * @param pitch defines the pitch angle in radians (X axis)
  4207. * @param roll defines the roll angle in radians (X axis)
  4208. * @param result defines the target matrix
  4209. */
  4210. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4211. /**
  4212. * Creates a scaling matrix
  4213. * @param x defines the scale factor on X axis
  4214. * @param y defines the scale factor on Y axis
  4215. * @param z defines the scale factor on Z axis
  4216. * @returns the new matrix
  4217. */
  4218. static Scaling(x: number, y: number, z: number): Matrix;
  4219. /**
  4220. * Creates a scaling matrix and stores it in a given matrix
  4221. * @param x defines the scale factor on X axis
  4222. * @param y defines the scale factor on Y axis
  4223. * @param z defines the scale factor on Z axis
  4224. * @param result defines the target matrix
  4225. */
  4226. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4227. /**
  4228. * Creates a translation matrix
  4229. * @param x defines the translation on X axis
  4230. * @param y defines the translation on Y axis
  4231. * @param z defines the translationon Z axis
  4232. * @returns the new matrix
  4233. */
  4234. static Translation(x: number, y: number, z: number): Matrix;
  4235. /**
  4236. * Creates a translation matrix and stores it in a given matrix
  4237. * @param x defines the translation on X axis
  4238. * @param y defines the translation on Y axis
  4239. * @param z defines the translationon Z axis
  4240. * @param result defines the target matrix
  4241. */
  4242. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4243. /**
  4244. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4245. * @param startValue defines the start value
  4246. * @param endValue defines the end value
  4247. * @param gradient defines the gradient factor
  4248. * @returns the new matrix
  4249. */
  4250. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4251. /**
  4252. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4253. * @param startValue defines the start value
  4254. * @param endValue defines the end value
  4255. * @param gradient defines the gradient factor
  4256. * @param result defines the Matrix object where to store data
  4257. */
  4258. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4259. /**
  4260. * Builds a new matrix whose values are computed by:
  4261. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4262. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4263. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4264. * @param startValue defines the first matrix
  4265. * @param endValue defines the second matrix
  4266. * @param gradient defines the gradient between the two matrices
  4267. * @returns the new matrix
  4268. */
  4269. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4270. /**
  4271. * Update a matrix to values which are computed by:
  4272. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4273. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4274. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4275. * @param startValue defines the first matrix
  4276. * @param endValue defines the second matrix
  4277. * @param gradient defines the gradient between the two matrices
  4278. * @param result defines the target matrix
  4279. */
  4280. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4281. /**
  4282. * 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"
  4283. * This function works in left handed mode
  4284. * @param eye defines the final position of the entity
  4285. * @param target defines where the entity should look at
  4286. * @param up defines the up vector for the entity
  4287. * @returns the new matrix
  4288. */
  4289. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4290. /**
  4291. * 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".
  4292. * This function works in left handed mode
  4293. * @param eye defines the final position of the entity
  4294. * @param target defines where the entity should look at
  4295. * @param up defines the up vector for the entity
  4296. * @param result defines the target matrix
  4297. */
  4298. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4299. /**
  4300. * 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"
  4301. * This function works in right handed mode
  4302. * @param eye defines the final position of the entity
  4303. * @param target defines where the entity should look at
  4304. * @param up defines the up vector for the entity
  4305. * @returns the new matrix
  4306. */
  4307. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4308. /**
  4309. * 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".
  4310. * This function works in right handed mode
  4311. * @param eye defines the final position of the entity
  4312. * @param target defines where the entity should look at
  4313. * @param up defines the up vector for the entity
  4314. * @param result defines the target matrix
  4315. */
  4316. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4317. /**
  4318. * Create a left-handed orthographic projection matrix
  4319. * @param width defines the viewport width
  4320. * @param height defines the viewport height
  4321. * @param znear defines the near clip plane
  4322. * @param zfar defines the far clip plane
  4323. * @returns a new matrix as a left-handed orthographic projection matrix
  4324. */
  4325. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4326. /**
  4327. * Store a left-handed orthographic projection to a given matrix
  4328. * @param width defines the viewport width
  4329. * @param height defines the viewport height
  4330. * @param znear defines the near clip plane
  4331. * @param zfar defines the far clip plane
  4332. * @param result defines the target matrix
  4333. */
  4334. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4335. /**
  4336. * Create a left-handed orthographic projection matrix
  4337. * @param left defines the viewport left coordinate
  4338. * @param right defines the viewport right coordinate
  4339. * @param bottom defines the viewport bottom coordinate
  4340. * @param top defines the viewport top coordinate
  4341. * @param znear defines the near clip plane
  4342. * @param zfar defines the far clip plane
  4343. * @returns a new matrix as a left-handed orthographic projection matrix
  4344. */
  4345. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4346. /**
  4347. * Stores a left-handed orthographic projection into a given matrix
  4348. * @param left defines the viewport left coordinate
  4349. * @param right defines the viewport right coordinate
  4350. * @param bottom defines the viewport bottom coordinate
  4351. * @param top defines the viewport top coordinate
  4352. * @param znear defines the near clip plane
  4353. * @param zfar defines the far clip plane
  4354. * @param result defines the target matrix
  4355. */
  4356. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4357. /**
  4358. * Creates a right-handed orthographic projection matrix
  4359. * @param left defines the viewport left coordinate
  4360. * @param right defines the viewport right coordinate
  4361. * @param bottom defines the viewport bottom coordinate
  4362. * @param top defines the viewport top coordinate
  4363. * @param znear defines the near clip plane
  4364. * @param zfar defines the far clip plane
  4365. * @returns a new matrix as a right-handed orthographic projection matrix
  4366. */
  4367. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4368. /**
  4369. * Stores a right-handed orthographic projection into a given matrix
  4370. * @param left defines the viewport left coordinate
  4371. * @param right defines the viewport right coordinate
  4372. * @param bottom defines the viewport bottom coordinate
  4373. * @param top defines the viewport top coordinate
  4374. * @param znear defines the near clip plane
  4375. * @param zfar defines the far clip plane
  4376. * @param result defines the target matrix
  4377. */
  4378. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4379. /**
  4380. * Creates a left-handed perspective projection matrix
  4381. * @param width defines the viewport width
  4382. * @param height defines the viewport height
  4383. * @param znear defines the near clip plane
  4384. * @param zfar defines the far clip plane
  4385. * @returns a new matrix as a left-handed perspective projection matrix
  4386. */
  4387. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4388. /**
  4389. * Creates a left-handed perspective projection matrix
  4390. * @param fov defines the horizontal field of view
  4391. * @param aspect defines the aspect ratio
  4392. * @param znear defines the near clip plane
  4393. * @param zfar defines the far clip plane
  4394. * @returns a new matrix as a left-handed perspective projection matrix
  4395. */
  4396. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4397. /**
  4398. * Stores a left-handed perspective projection into a given matrix
  4399. * @param fov defines the horizontal field of view
  4400. * @param aspect defines the aspect ratio
  4401. * @param znear defines the near clip plane
  4402. * @param zfar defines the far clip plane
  4403. * @param result defines the target matrix
  4404. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4405. */
  4406. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4407. /**
  4408. * Creates a right-handed perspective projection matrix
  4409. * @param fov defines the horizontal field of view
  4410. * @param aspect defines the aspect ratio
  4411. * @param znear defines the near clip plane
  4412. * @param zfar defines the far clip plane
  4413. * @returns a new matrix as a right-handed perspective projection matrix
  4414. */
  4415. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4416. /**
  4417. * Stores a right-handed perspective projection into a given matrix
  4418. * @param fov defines the horizontal field of view
  4419. * @param aspect defines the aspect ratio
  4420. * @param znear defines the near clip plane
  4421. * @param zfar defines the far clip plane
  4422. * @param result defines the target matrix
  4423. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4424. */
  4425. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4426. /**
  4427. * Stores a perspective projection for WebVR info a given matrix
  4428. * @param fov defines the field of view
  4429. * @param znear defines the near clip plane
  4430. * @param zfar defines the far clip plane
  4431. * @param result defines the target matrix
  4432. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4433. */
  4434. static PerspectiveFovWebVRToRef(fov: {
  4435. upDegrees: number;
  4436. downDegrees: number;
  4437. leftDegrees: number;
  4438. rightDegrees: number;
  4439. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4440. /**
  4441. * Computes a complete transformation matrix
  4442. * @param viewport defines the viewport to use
  4443. * @param world defines the world matrix
  4444. * @param view defines the view matrix
  4445. * @param projection defines the projection matrix
  4446. * @param zmin defines the near clip plane
  4447. * @param zmax defines the far clip plane
  4448. * @returns the transformation matrix
  4449. */
  4450. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4451. /**
  4452. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4453. * @param matrix defines the matrix to use
  4454. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4455. */
  4456. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4457. /**
  4458. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4459. * @param matrix defines the matrix to use
  4460. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4461. */
  4462. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4463. /**
  4464. * Compute the transpose of a given matrix
  4465. * @param matrix defines the matrix to transpose
  4466. * @returns the new matrix
  4467. */
  4468. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4469. /**
  4470. * Compute the transpose of a matrix and store it in a target matrix
  4471. * @param matrix defines the matrix to transpose
  4472. * @param result defines the target matrix
  4473. */
  4474. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4475. /**
  4476. * Computes a reflection matrix from a plane
  4477. * @param plane defines the reflection plane
  4478. * @returns a new matrix
  4479. */
  4480. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4481. /**
  4482. * Computes a reflection matrix from a plane
  4483. * @param plane defines the reflection plane
  4484. * @param result defines the target matrix
  4485. */
  4486. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4487. /**
  4488. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4489. * @param xaxis defines the value of the 1st axis
  4490. * @param yaxis defines the value of the 2nd axis
  4491. * @param zaxis defines the value of the 3rd axis
  4492. * @param result defines the target matrix
  4493. */
  4494. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4495. /**
  4496. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4497. * @param quat defines the quaternion to use
  4498. * @param result defines the target matrix
  4499. */
  4500. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4501. }
  4502. /**
  4503. * @hidden
  4504. */
  4505. export class TmpVectors {
  4506. static Vector2: Vector2[];
  4507. static Vector3: Vector3[];
  4508. static Vector4: Vector4[];
  4509. static Quaternion: Quaternion[];
  4510. static Matrix: Matrix[];
  4511. }
  4512. }
  4513. declare module BABYLON {
  4514. /**
  4515. * Defines potential orientation for back face culling
  4516. */
  4517. export enum Orientation {
  4518. /**
  4519. * Clockwise
  4520. */
  4521. CW = 0,
  4522. /** Counter clockwise */
  4523. CCW = 1
  4524. }
  4525. /** Class used to represent a Bezier curve */
  4526. export class BezierCurve {
  4527. /**
  4528. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4529. * @param t defines the time
  4530. * @param x1 defines the left coordinate on X axis
  4531. * @param y1 defines the left coordinate on Y axis
  4532. * @param x2 defines the right coordinate on X axis
  4533. * @param y2 defines the right coordinate on Y axis
  4534. * @returns the interpolated value
  4535. */
  4536. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4537. }
  4538. /**
  4539. * Defines angle representation
  4540. */
  4541. export class Angle {
  4542. private _radians;
  4543. /**
  4544. * Creates an Angle object of "radians" radians (float).
  4545. * @param radians the angle in radians
  4546. */
  4547. constructor(radians: number);
  4548. /**
  4549. * Get value in degrees
  4550. * @returns the Angle value in degrees (float)
  4551. */
  4552. degrees(): number;
  4553. /**
  4554. * Get value in radians
  4555. * @returns the Angle value in radians (float)
  4556. */
  4557. radians(): number;
  4558. /**
  4559. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4560. * @param a defines first vector
  4561. * @param b defines second vector
  4562. * @returns a new Angle
  4563. */
  4564. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4565. /**
  4566. * Gets a new Angle object from the given float in radians
  4567. * @param radians defines the angle value in radians
  4568. * @returns a new Angle
  4569. */
  4570. static FromRadians(radians: number): Angle;
  4571. /**
  4572. * Gets a new Angle object from the given float in degrees
  4573. * @param degrees defines the angle value in degrees
  4574. * @returns a new Angle
  4575. */
  4576. static FromDegrees(degrees: number): Angle;
  4577. }
  4578. /**
  4579. * This represents an arc in a 2d space.
  4580. */
  4581. export class Arc2 {
  4582. /** Defines the start point of the arc */
  4583. startPoint: Vector2;
  4584. /** Defines the mid point of the arc */
  4585. midPoint: Vector2;
  4586. /** Defines the end point of the arc */
  4587. endPoint: Vector2;
  4588. /**
  4589. * Defines the center point of the arc.
  4590. */
  4591. centerPoint: Vector2;
  4592. /**
  4593. * Defines the radius of the arc.
  4594. */
  4595. radius: number;
  4596. /**
  4597. * Defines the angle of the arc (from mid point to end point).
  4598. */
  4599. angle: Angle;
  4600. /**
  4601. * Defines the start angle of the arc (from start point to middle point).
  4602. */
  4603. startAngle: Angle;
  4604. /**
  4605. * Defines the orientation of the arc (clock wise/counter clock wise).
  4606. */
  4607. orientation: Orientation;
  4608. /**
  4609. * Creates an Arc object from the three given points : start, middle and end.
  4610. * @param startPoint Defines the start point of the arc
  4611. * @param midPoint Defines the midlle point of the arc
  4612. * @param endPoint Defines the end point of the arc
  4613. */
  4614. constructor(
  4615. /** Defines the start point of the arc */
  4616. startPoint: Vector2,
  4617. /** Defines the mid point of the arc */
  4618. midPoint: Vector2,
  4619. /** Defines the end point of the arc */
  4620. endPoint: Vector2);
  4621. }
  4622. /**
  4623. * Represents a 2D path made up of multiple 2D points
  4624. */
  4625. export class Path2 {
  4626. private _points;
  4627. private _length;
  4628. /**
  4629. * If the path start and end point are the same
  4630. */
  4631. closed: boolean;
  4632. /**
  4633. * Creates a Path2 object from the starting 2D coordinates x and y.
  4634. * @param x the starting points x value
  4635. * @param y the starting points y value
  4636. */
  4637. constructor(x: number, y: number);
  4638. /**
  4639. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4640. * @param x the added points x value
  4641. * @param y the added points y value
  4642. * @returns the updated Path2.
  4643. */
  4644. addLineTo(x: number, y: number): Path2;
  4645. /**
  4646. * 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.
  4647. * @param midX middle point x value
  4648. * @param midY middle point y value
  4649. * @param endX end point x value
  4650. * @param endY end point y value
  4651. * @param numberOfSegments (default: 36)
  4652. * @returns the updated Path2.
  4653. */
  4654. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4655. /**
  4656. * Closes the Path2.
  4657. * @returns the Path2.
  4658. */
  4659. close(): Path2;
  4660. /**
  4661. * Gets the sum of the distance between each sequential point in the path
  4662. * @returns the Path2 total length (float).
  4663. */
  4664. length(): number;
  4665. /**
  4666. * Gets the points which construct the path
  4667. * @returns the Path2 internal array of points.
  4668. */
  4669. getPoints(): Vector2[];
  4670. /**
  4671. * Retreives the point at the distance aways from the starting point
  4672. * @param normalizedLengthPosition the length along the path to retreive the point from
  4673. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4674. */
  4675. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4676. /**
  4677. * Creates a new path starting from an x and y position
  4678. * @param x starting x value
  4679. * @param y starting y value
  4680. * @returns a new Path2 starting at the coordinates (x, y).
  4681. */
  4682. static StartingAt(x: number, y: number): Path2;
  4683. }
  4684. /**
  4685. * Represents a 3D path made up of multiple 3D points
  4686. */
  4687. export class Path3D {
  4688. /**
  4689. * an array of Vector3, the curve axis of the Path3D
  4690. */
  4691. path: Vector3[];
  4692. private _curve;
  4693. private _distances;
  4694. private _tangents;
  4695. private _normals;
  4696. private _binormals;
  4697. private _raw;
  4698. /**
  4699. * new Path3D(path, normal, raw)
  4700. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4701. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4702. * @param path an array of Vector3, the curve axis of the Path3D
  4703. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4704. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4705. */
  4706. constructor(
  4707. /**
  4708. * an array of Vector3, the curve axis of the Path3D
  4709. */
  4710. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4711. /**
  4712. * Returns the Path3D array of successive Vector3 designing its curve.
  4713. * @returns the Path3D array of successive Vector3 designing its curve.
  4714. */
  4715. getCurve(): Vector3[];
  4716. /**
  4717. * Returns an array populated with tangent vectors on each Path3D curve point.
  4718. * @returns an array populated with tangent vectors on each Path3D curve point.
  4719. */
  4720. getTangents(): Vector3[];
  4721. /**
  4722. * Returns an array populated with normal vectors on each Path3D curve point.
  4723. * @returns an array populated with normal vectors on each Path3D curve point.
  4724. */
  4725. getNormals(): Vector3[];
  4726. /**
  4727. * Returns an array populated with binormal vectors on each Path3D curve point.
  4728. * @returns an array populated with binormal vectors on each Path3D curve point.
  4729. */
  4730. getBinormals(): Vector3[];
  4731. /**
  4732. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4733. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4734. */
  4735. getDistances(): number[];
  4736. /**
  4737. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4738. * @param path path which all values are copied into the curves points
  4739. * @param firstNormal which should be projected onto the curve
  4740. * @returns the same object updated.
  4741. */
  4742. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4743. private _compute;
  4744. private _getFirstNonNullVector;
  4745. private _getLastNonNullVector;
  4746. private _normalVector;
  4747. }
  4748. /**
  4749. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4750. * A Curve3 is designed from a series of successive Vector3.
  4751. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4752. */
  4753. export class Curve3 {
  4754. private _points;
  4755. private _length;
  4756. /**
  4757. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4758. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4759. * @param v1 (Vector3) the control point
  4760. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4761. * @param nbPoints (integer) the wanted number of points in the curve
  4762. * @returns the created Curve3
  4763. */
  4764. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4765. /**
  4766. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4767. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4768. * @param v1 (Vector3) the first control point
  4769. * @param v2 (Vector3) the second control point
  4770. * @param v3 (Vector3) the end point of the Cubic Bezier
  4771. * @param nbPoints (integer) the wanted number of points in the curve
  4772. * @returns the created Curve3
  4773. */
  4774. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4775. /**
  4776. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4777. * @param p1 (Vector3) the origin point of the Hermite Spline
  4778. * @param t1 (Vector3) the tangent vector at the origin point
  4779. * @param p2 (Vector3) the end point of the Hermite Spline
  4780. * @param t2 (Vector3) the tangent vector at the end point
  4781. * @param nbPoints (integer) the wanted number of points in the curve
  4782. * @returns the created Curve3
  4783. */
  4784. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4785. /**
  4786. * Returns a Curve3 object along a CatmullRom Spline curve :
  4787. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4788. * @param nbPoints (integer) the wanted number of points between each curve control points
  4789. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4790. * @returns the created Curve3
  4791. */
  4792. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4793. /**
  4794. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4795. * A Curve3 is designed from a series of successive Vector3.
  4796. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4797. * @param points points which make up the curve
  4798. */
  4799. constructor(points: Vector3[]);
  4800. /**
  4801. * @returns the Curve3 stored array of successive Vector3
  4802. */
  4803. getPoints(): Vector3[];
  4804. /**
  4805. * @returns the computed length (float) of the curve.
  4806. */
  4807. length(): number;
  4808. /**
  4809. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4810. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4811. * curveA and curveB keep unchanged.
  4812. * @param curve the curve to continue from this curve
  4813. * @returns the newly constructed curve
  4814. */
  4815. continue(curve: DeepImmutable<Curve3>): Curve3;
  4816. private _computeLength;
  4817. }
  4818. }
  4819. declare module BABYLON {
  4820. /**
  4821. * This represents the main contract an easing function should follow.
  4822. * Easing functions are used throughout the animation system.
  4823. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4824. */
  4825. export interface IEasingFunction {
  4826. /**
  4827. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4828. * of the easing function.
  4829. * The link below provides some of the most common examples of easing functions.
  4830. * @see https://easings.net/
  4831. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4832. * @returns the corresponding value on the curve defined by the easing function
  4833. */
  4834. ease(gradient: number): number;
  4835. }
  4836. /**
  4837. * Base class used for every default easing function.
  4838. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4839. */
  4840. export class EasingFunction implements IEasingFunction {
  4841. /**
  4842. * Interpolation follows the mathematical formula associated with the easing function.
  4843. */
  4844. static readonly EASINGMODE_EASEIN: number;
  4845. /**
  4846. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4847. */
  4848. static readonly EASINGMODE_EASEOUT: number;
  4849. /**
  4850. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4851. */
  4852. static readonly EASINGMODE_EASEINOUT: number;
  4853. private _easingMode;
  4854. /**
  4855. * Sets the easing mode of the current function.
  4856. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4857. */
  4858. setEasingMode(easingMode: number): void;
  4859. /**
  4860. * Gets the current easing mode.
  4861. * @returns the easing mode
  4862. */
  4863. getEasingMode(): number;
  4864. /**
  4865. * @hidden
  4866. */
  4867. easeInCore(gradient: number): number;
  4868. /**
  4869. * Given an input gradient between 0 and 1, this returns the corresponding value
  4870. * of the easing function.
  4871. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4872. * @returns the corresponding value on the curve defined by the easing function
  4873. */
  4874. ease(gradient: number): number;
  4875. }
  4876. /**
  4877. * Easing function with a circle shape (see link below).
  4878. * @see https://easings.net/#easeInCirc
  4879. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4880. */
  4881. export class CircleEase extends EasingFunction implements IEasingFunction {
  4882. /** @hidden */
  4883. easeInCore(gradient: number): number;
  4884. }
  4885. /**
  4886. * Easing function with a ease back shape (see link below).
  4887. * @see https://easings.net/#easeInBack
  4888. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4889. */
  4890. export class BackEase extends EasingFunction implements IEasingFunction {
  4891. /** Defines the amplitude of the function */
  4892. amplitude: number;
  4893. /**
  4894. * Instantiates a back ease easing
  4895. * @see https://easings.net/#easeInBack
  4896. * @param amplitude Defines the amplitude of the function
  4897. */
  4898. constructor(
  4899. /** Defines the amplitude of the function */
  4900. amplitude?: number);
  4901. /** @hidden */
  4902. easeInCore(gradient: number): number;
  4903. }
  4904. /**
  4905. * Easing function with a bouncing shape (see link below).
  4906. * @see https://easings.net/#easeInBounce
  4907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4908. */
  4909. export class BounceEase extends EasingFunction implements IEasingFunction {
  4910. /** Defines the number of bounces */
  4911. bounces: number;
  4912. /** Defines the amplitude of the bounce */
  4913. bounciness: number;
  4914. /**
  4915. * Instantiates a bounce easing
  4916. * @see https://easings.net/#easeInBounce
  4917. * @param bounces Defines the number of bounces
  4918. * @param bounciness Defines the amplitude of the bounce
  4919. */
  4920. constructor(
  4921. /** Defines the number of bounces */
  4922. bounces?: number,
  4923. /** Defines the amplitude of the bounce */
  4924. bounciness?: number);
  4925. /** @hidden */
  4926. easeInCore(gradient: number): number;
  4927. }
  4928. /**
  4929. * Easing function with a power of 3 shape (see link below).
  4930. * @see https://easings.net/#easeInCubic
  4931. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4932. */
  4933. export class CubicEase extends EasingFunction implements IEasingFunction {
  4934. /** @hidden */
  4935. easeInCore(gradient: number): number;
  4936. }
  4937. /**
  4938. * Easing function with an elastic shape (see link below).
  4939. * @see https://easings.net/#easeInElastic
  4940. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4941. */
  4942. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4943. /** Defines the number of oscillations*/
  4944. oscillations: number;
  4945. /** Defines the amplitude of the oscillations*/
  4946. springiness: number;
  4947. /**
  4948. * Instantiates an elastic easing function
  4949. * @see https://easings.net/#easeInElastic
  4950. * @param oscillations Defines the number of oscillations
  4951. * @param springiness Defines the amplitude of the oscillations
  4952. */
  4953. constructor(
  4954. /** Defines the number of oscillations*/
  4955. oscillations?: number,
  4956. /** Defines the amplitude of the oscillations*/
  4957. springiness?: number);
  4958. /** @hidden */
  4959. easeInCore(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with an exponential shape (see link below).
  4963. * @see https://easings.net/#easeInExpo
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4967. /** Defines the exponent of the function */
  4968. exponent: number;
  4969. /**
  4970. * Instantiates an exponential easing function
  4971. * @see https://easings.net/#easeInExpo
  4972. * @param exponent Defines the exponent of the function
  4973. */
  4974. constructor(
  4975. /** Defines the exponent of the function */
  4976. exponent?: number);
  4977. /** @hidden */
  4978. easeInCore(gradient: number): number;
  4979. }
  4980. /**
  4981. * Easing function with a power shape (see link below).
  4982. * @see https://easings.net/#easeInQuad
  4983. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4984. */
  4985. export class PowerEase extends EasingFunction implements IEasingFunction {
  4986. /** Defines the power of the function */
  4987. power: number;
  4988. /**
  4989. * Instantiates an power base easing function
  4990. * @see https://easings.net/#easeInQuad
  4991. * @param power Defines the power of the function
  4992. */
  4993. constructor(
  4994. /** Defines the power of the function */
  4995. power?: number);
  4996. /** @hidden */
  4997. easeInCore(gradient: number): number;
  4998. }
  4999. /**
  5000. * Easing function with a power of 2 shape (see link below).
  5001. * @see https://easings.net/#easeInQuad
  5002. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5003. */
  5004. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5005. /** @hidden */
  5006. easeInCore(gradient: number): number;
  5007. }
  5008. /**
  5009. * Easing function with a power of 4 shape (see link below).
  5010. * @see https://easings.net/#easeInQuart
  5011. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5012. */
  5013. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5014. /** @hidden */
  5015. easeInCore(gradient: number): number;
  5016. }
  5017. /**
  5018. * Easing function with a power of 5 shape (see link below).
  5019. * @see https://easings.net/#easeInQuint
  5020. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5021. */
  5022. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5023. /** @hidden */
  5024. easeInCore(gradient: number): number;
  5025. }
  5026. /**
  5027. * Easing function with a sin shape (see link below).
  5028. * @see https://easings.net/#easeInSine
  5029. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5030. */
  5031. export class SineEase extends EasingFunction implements IEasingFunction {
  5032. /** @hidden */
  5033. easeInCore(gradient: number): number;
  5034. }
  5035. /**
  5036. * Easing function with a bezier shape (see link below).
  5037. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5038. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5039. */
  5040. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5041. /** Defines the x component of the start tangent in the bezier curve */
  5042. x1: number;
  5043. /** Defines the y component of the start tangent in the bezier curve */
  5044. y1: number;
  5045. /** Defines the x component of the end tangent in the bezier curve */
  5046. x2: number;
  5047. /** Defines the y component of the end tangent in the bezier curve */
  5048. y2: number;
  5049. /**
  5050. * Instantiates a bezier function
  5051. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5052. * @param x1 Defines the x component of the start tangent in the bezier curve
  5053. * @param y1 Defines the y component of the start tangent in the bezier curve
  5054. * @param x2 Defines the x component of the end tangent in the bezier curve
  5055. * @param y2 Defines the y component of the end tangent in the bezier curve
  5056. */
  5057. constructor(
  5058. /** Defines the x component of the start tangent in the bezier curve */
  5059. x1?: number,
  5060. /** Defines the y component of the start tangent in the bezier curve */
  5061. y1?: number,
  5062. /** Defines the x component of the end tangent in the bezier curve */
  5063. x2?: number,
  5064. /** Defines the y component of the end tangent in the bezier curve */
  5065. y2?: number);
  5066. /** @hidden */
  5067. easeInCore(gradient: number): number;
  5068. }
  5069. }
  5070. declare module BABYLON {
  5071. /**
  5072. * Class used to hold a RBG color
  5073. */
  5074. export class Color3 {
  5075. /**
  5076. * Defines the red component (between 0 and 1, default is 0)
  5077. */
  5078. r: number;
  5079. /**
  5080. * Defines the green component (between 0 and 1, default is 0)
  5081. */
  5082. g: number;
  5083. /**
  5084. * Defines the blue component (between 0 and 1, default is 0)
  5085. */
  5086. b: number;
  5087. /**
  5088. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5089. * @param r defines the red component (between 0 and 1, default is 0)
  5090. * @param g defines the green component (between 0 and 1, default is 0)
  5091. * @param b defines the blue component (between 0 and 1, default is 0)
  5092. */
  5093. constructor(
  5094. /**
  5095. * Defines the red component (between 0 and 1, default is 0)
  5096. */
  5097. r?: number,
  5098. /**
  5099. * Defines the green component (between 0 and 1, default is 0)
  5100. */
  5101. g?: number,
  5102. /**
  5103. * Defines the blue component (between 0 and 1, default is 0)
  5104. */
  5105. b?: number);
  5106. /**
  5107. * Creates a string with the Color3 current values
  5108. * @returns the string representation of the Color3 object
  5109. */
  5110. toString(): string;
  5111. /**
  5112. * Returns the string "Color3"
  5113. * @returns "Color3"
  5114. */
  5115. getClassName(): string;
  5116. /**
  5117. * Compute the Color3 hash code
  5118. * @returns an unique number that can be used to hash Color3 objects
  5119. */
  5120. getHashCode(): number;
  5121. /**
  5122. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5123. * @param array defines the array where to store the r,g,b components
  5124. * @param index defines an optional index in the target array to define where to start storing values
  5125. * @returns the current Color3 object
  5126. */
  5127. toArray(array: FloatArray, index?: number): Color3;
  5128. /**
  5129. * Returns a new Color4 object from the current Color3 and the given alpha
  5130. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5131. * @returns a new Color4 object
  5132. */
  5133. toColor4(alpha?: number): Color4;
  5134. /**
  5135. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5136. * @returns the new array
  5137. */
  5138. asArray(): number[];
  5139. /**
  5140. * Returns the luminance value
  5141. * @returns a float value
  5142. */
  5143. toLuminance(): number;
  5144. /**
  5145. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5146. * @param otherColor defines the second operand
  5147. * @returns the new Color3 object
  5148. */
  5149. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5150. /**
  5151. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5152. * @param otherColor defines the second operand
  5153. * @param result defines the Color3 object where to store the result
  5154. * @returns the current Color3
  5155. */
  5156. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5157. /**
  5158. * Determines equality between Color3 objects
  5159. * @param otherColor defines the second operand
  5160. * @returns true if the rgb values are equal to the given ones
  5161. */
  5162. equals(otherColor: DeepImmutable<Color3>): boolean;
  5163. /**
  5164. * Determines equality between the current Color3 object and a set of r,b,g values
  5165. * @param r defines the red component to check
  5166. * @param g defines the green component to check
  5167. * @param b defines the blue component to check
  5168. * @returns true if the rgb values are equal to the given ones
  5169. */
  5170. equalsFloats(r: number, g: number, b: number): boolean;
  5171. /**
  5172. * Multiplies in place each rgb value by scale
  5173. * @param scale defines the scaling factor
  5174. * @returns the updated Color3
  5175. */
  5176. scale(scale: number): Color3;
  5177. /**
  5178. * Multiplies the rgb values by scale and stores the result into "result"
  5179. * @param scale defines the scaling factor
  5180. * @param result defines the Color3 object where to store the result
  5181. * @returns the unmodified current Color3
  5182. */
  5183. scaleToRef(scale: number, result: Color3): Color3;
  5184. /**
  5185. * Scale the current Color3 values by a factor and add the result to a given Color3
  5186. * @param scale defines the scale factor
  5187. * @param result defines color to store the result into
  5188. * @returns the unmodified current Color3
  5189. */
  5190. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5191. /**
  5192. * Clamps the rgb values by the min and max values and stores the result into "result"
  5193. * @param min defines minimum clamping value (default is 0)
  5194. * @param max defines maximum clamping value (default is 1)
  5195. * @param result defines color to store the result into
  5196. * @returns the original Color3
  5197. */
  5198. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5199. /**
  5200. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5201. * @param otherColor defines the second operand
  5202. * @returns the new Color3
  5203. */
  5204. add(otherColor: DeepImmutable<Color3>): Color3;
  5205. /**
  5206. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5207. * @param otherColor defines the second operand
  5208. * @param result defines Color3 object to store the result into
  5209. * @returns the unmodified current Color3
  5210. */
  5211. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5212. /**
  5213. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5214. * @param otherColor defines the second operand
  5215. * @returns the new Color3
  5216. */
  5217. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5218. /**
  5219. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5220. * @param otherColor defines the second operand
  5221. * @param result defines Color3 object to store the result into
  5222. * @returns the unmodified current Color3
  5223. */
  5224. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5225. /**
  5226. * Copy the current object
  5227. * @returns a new Color3 copied the current one
  5228. */
  5229. clone(): Color3;
  5230. /**
  5231. * Copies the rgb values from the source in the current Color3
  5232. * @param source defines the source Color3 object
  5233. * @returns the updated Color3 object
  5234. */
  5235. copyFrom(source: DeepImmutable<Color3>): Color3;
  5236. /**
  5237. * Updates the Color3 rgb values from the given floats
  5238. * @param r defines the red component to read from
  5239. * @param g defines the green component to read from
  5240. * @param b defines the blue component to read from
  5241. * @returns the current Color3 object
  5242. */
  5243. copyFromFloats(r: number, g: number, b: number): Color3;
  5244. /**
  5245. * Updates the Color3 rgb values from the given floats
  5246. * @param r defines the red component to read from
  5247. * @param g defines the green component to read from
  5248. * @param b defines the blue component to read from
  5249. * @returns the current Color3 object
  5250. */
  5251. set(r: number, g: number, b: number): Color3;
  5252. /**
  5253. * Compute the Color3 hexadecimal code as a string
  5254. * @returns a string containing the hexadecimal representation of the Color3 object
  5255. */
  5256. toHexString(): string;
  5257. /**
  5258. * Computes a new Color3 converted from the current one to linear space
  5259. * @returns a new Color3 object
  5260. */
  5261. toLinearSpace(): Color3;
  5262. /**
  5263. * Converts current color in rgb space to HSV values
  5264. * @returns a new color3 representing the HSV values
  5265. */
  5266. toHSV(): Color3;
  5267. /**
  5268. * Converts current color in rgb space to HSV values
  5269. * @param result defines the Color3 where to store the HSV values
  5270. */
  5271. toHSVToRef(result: Color3): void;
  5272. /**
  5273. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5274. * @param convertedColor defines the Color3 object where to store the linear space version
  5275. * @returns the unmodified Color3
  5276. */
  5277. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5278. /**
  5279. * Computes a new Color3 converted from the current one to gamma space
  5280. * @returns a new Color3 object
  5281. */
  5282. toGammaSpace(): Color3;
  5283. /**
  5284. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5285. * @param convertedColor defines the Color3 object where to store the gamma space version
  5286. * @returns the unmodified Color3
  5287. */
  5288. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5289. private static _BlackReadOnly;
  5290. /**
  5291. * Convert Hue, saturation and value to a Color3 (RGB)
  5292. * @param hue defines the hue
  5293. * @param saturation defines the saturation
  5294. * @param value defines the value
  5295. * @param result defines the Color3 where to store the RGB values
  5296. */
  5297. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5298. /**
  5299. * Creates a new Color3 from the string containing valid hexadecimal values
  5300. * @param hex defines a string containing valid hexadecimal values
  5301. * @returns a new Color3 object
  5302. */
  5303. static FromHexString(hex: string): Color3;
  5304. /**
  5305. * Creates a new Color3 from the starting index of the given array
  5306. * @param array defines the source array
  5307. * @param offset defines an offset in the source array
  5308. * @returns a new Color3 object
  5309. */
  5310. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5311. /**
  5312. * Creates a new Color3 from integer values (< 256)
  5313. * @param r defines the red component to read from (value between 0 and 255)
  5314. * @param g defines the green component to read from (value between 0 and 255)
  5315. * @param b defines the blue component to read from (value between 0 and 255)
  5316. * @returns a new Color3 object
  5317. */
  5318. static FromInts(r: number, g: number, b: number): Color3;
  5319. /**
  5320. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5321. * @param start defines the start Color3 value
  5322. * @param end defines the end Color3 value
  5323. * @param amount defines the gradient value between start and end
  5324. * @returns a new Color3 object
  5325. */
  5326. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5327. /**
  5328. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5329. * @param left defines the start value
  5330. * @param right defines the end value
  5331. * @param amount defines the gradient factor
  5332. * @param result defines the Color3 object where to store the result
  5333. */
  5334. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5335. /**
  5336. * Returns a Color3 value containing a red color
  5337. * @returns a new Color3 object
  5338. */
  5339. static Red(): Color3;
  5340. /**
  5341. * Returns a Color3 value containing a green color
  5342. * @returns a new Color3 object
  5343. */
  5344. static Green(): Color3;
  5345. /**
  5346. * Returns a Color3 value containing a blue color
  5347. * @returns a new Color3 object
  5348. */
  5349. static Blue(): Color3;
  5350. /**
  5351. * Returns a Color3 value containing a black color
  5352. * @returns a new Color3 object
  5353. */
  5354. static Black(): Color3;
  5355. /**
  5356. * Gets a Color3 value containing a black color that must not be updated
  5357. */
  5358. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5359. /**
  5360. * Returns a Color3 value containing a white color
  5361. * @returns a new Color3 object
  5362. */
  5363. static White(): Color3;
  5364. /**
  5365. * Returns a Color3 value containing a purple color
  5366. * @returns a new Color3 object
  5367. */
  5368. static Purple(): Color3;
  5369. /**
  5370. * Returns a Color3 value containing a magenta color
  5371. * @returns a new Color3 object
  5372. */
  5373. static Magenta(): Color3;
  5374. /**
  5375. * Returns a Color3 value containing a yellow color
  5376. * @returns a new Color3 object
  5377. */
  5378. static Yellow(): Color3;
  5379. /**
  5380. * Returns a Color3 value containing a gray color
  5381. * @returns a new Color3 object
  5382. */
  5383. static Gray(): Color3;
  5384. /**
  5385. * Returns a Color3 value containing a teal color
  5386. * @returns a new Color3 object
  5387. */
  5388. static Teal(): Color3;
  5389. /**
  5390. * Returns a Color3 value containing a random color
  5391. * @returns a new Color3 object
  5392. */
  5393. static Random(): Color3;
  5394. }
  5395. /**
  5396. * Class used to hold a RBGA color
  5397. */
  5398. export class Color4 {
  5399. /**
  5400. * Defines the red component (between 0 and 1, default is 0)
  5401. */
  5402. r: number;
  5403. /**
  5404. * Defines the green component (between 0 and 1, default is 0)
  5405. */
  5406. g: number;
  5407. /**
  5408. * Defines the blue component (between 0 and 1, default is 0)
  5409. */
  5410. b: number;
  5411. /**
  5412. * Defines the alpha component (between 0 and 1, default is 1)
  5413. */
  5414. a: number;
  5415. /**
  5416. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5417. * @param r defines the red component (between 0 and 1, default is 0)
  5418. * @param g defines the green component (between 0 and 1, default is 0)
  5419. * @param b defines the blue component (between 0 and 1, default is 0)
  5420. * @param a defines the alpha component (between 0 and 1, default is 1)
  5421. */
  5422. constructor(
  5423. /**
  5424. * Defines the red component (between 0 and 1, default is 0)
  5425. */
  5426. r?: number,
  5427. /**
  5428. * Defines the green component (between 0 and 1, default is 0)
  5429. */
  5430. g?: number,
  5431. /**
  5432. * Defines the blue component (between 0 and 1, default is 0)
  5433. */
  5434. b?: number,
  5435. /**
  5436. * Defines the alpha component (between 0 and 1, default is 1)
  5437. */
  5438. a?: number);
  5439. /**
  5440. * Adds in place the given Color4 values to the current Color4 object
  5441. * @param right defines the second operand
  5442. * @returns the current updated Color4 object
  5443. */
  5444. addInPlace(right: DeepImmutable<Color4>): Color4;
  5445. /**
  5446. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5447. * @returns the new array
  5448. */
  5449. asArray(): number[];
  5450. /**
  5451. * Stores from the starting index in the given array the Color4 successive values
  5452. * @param array defines the array where to store the r,g,b components
  5453. * @param index defines an optional index in the target array to define where to start storing values
  5454. * @returns the current Color4 object
  5455. */
  5456. toArray(array: number[], index?: number): Color4;
  5457. /**
  5458. * Determines equality between Color4 objects
  5459. * @param otherColor defines the second operand
  5460. * @returns true if the rgba values are equal to the given ones
  5461. */
  5462. equals(otherColor: DeepImmutable<Color4>): boolean;
  5463. /**
  5464. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5465. * @param right defines the second operand
  5466. * @returns a new Color4 object
  5467. */
  5468. add(right: DeepImmutable<Color4>): Color4;
  5469. /**
  5470. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5471. * @param right defines the second operand
  5472. * @returns a new Color4 object
  5473. */
  5474. subtract(right: DeepImmutable<Color4>): Color4;
  5475. /**
  5476. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5477. * @param right defines the second operand
  5478. * @param result defines the Color4 object where to store the result
  5479. * @returns the current Color4 object
  5480. */
  5481. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5482. /**
  5483. * Creates a new Color4 with the current Color4 values multiplied by scale
  5484. * @param scale defines the scaling factor to apply
  5485. * @returns a new Color4 object
  5486. */
  5487. scale(scale: number): Color4;
  5488. /**
  5489. * Multiplies the current Color4 values by scale and stores the result in "result"
  5490. * @param scale defines the scaling factor to apply
  5491. * @param result defines the Color4 object where to store the result
  5492. * @returns the current unmodified Color4
  5493. */
  5494. scaleToRef(scale: number, result: Color4): Color4;
  5495. /**
  5496. * Scale the current Color4 values by a factor and add the result to a given Color4
  5497. * @param scale defines the scale factor
  5498. * @param result defines the Color4 object where to store the result
  5499. * @returns the unmodified current Color4
  5500. */
  5501. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5502. /**
  5503. * Clamps the rgb values by the min and max values and stores the result into "result"
  5504. * @param min defines minimum clamping value (default is 0)
  5505. * @param max defines maximum clamping value (default is 1)
  5506. * @param result defines color to store the result into.
  5507. * @returns the cuurent Color4
  5508. */
  5509. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5510. /**
  5511. * Multipy an Color4 value by another and return a new Color4 object
  5512. * @param color defines the Color4 value to multiply by
  5513. * @returns a new Color4 object
  5514. */
  5515. multiply(color: Color4): Color4;
  5516. /**
  5517. * Multipy a Color4 value by another and push the result in a reference value
  5518. * @param color defines the Color4 value to multiply by
  5519. * @param result defines the Color4 to fill the result in
  5520. * @returns the result Color4
  5521. */
  5522. multiplyToRef(color: Color4, result: Color4): Color4;
  5523. /**
  5524. * Creates a string with the Color4 current values
  5525. * @returns the string representation of the Color4 object
  5526. */
  5527. toString(): string;
  5528. /**
  5529. * Returns the string "Color4"
  5530. * @returns "Color4"
  5531. */
  5532. getClassName(): string;
  5533. /**
  5534. * Compute the Color4 hash code
  5535. * @returns an unique number that can be used to hash Color4 objects
  5536. */
  5537. getHashCode(): number;
  5538. /**
  5539. * Creates a new Color4 copied from the current one
  5540. * @returns a new Color4 object
  5541. */
  5542. clone(): Color4;
  5543. /**
  5544. * Copies the given Color4 values into the current one
  5545. * @param source defines the source Color4 object
  5546. * @returns the current updated Color4 object
  5547. */
  5548. copyFrom(source: Color4): Color4;
  5549. /**
  5550. * Copies the given float values into the current one
  5551. * @param r defines the red component to read from
  5552. * @param g defines the green component to read from
  5553. * @param b defines the blue component to read from
  5554. * @param a defines the alpha component to read from
  5555. * @returns the current updated Color4 object
  5556. */
  5557. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5558. /**
  5559. * Copies the given float values into the current one
  5560. * @param r defines the red component to read from
  5561. * @param g defines the green component to read from
  5562. * @param b defines the blue component to read from
  5563. * @param a defines the alpha component to read from
  5564. * @returns the current updated Color4 object
  5565. */
  5566. set(r: number, g: number, b: number, a: number): Color4;
  5567. /**
  5568. * Compute the Color4 hexadecimal code as a string
  5569. * @returns a string containing the hexadecimal representation of the Color4 object
  5570. */
  5571. toHexString(): string;
  5572. /**
  5573. * Computes a new Color4 converted from the current one to linear space
  5574. * @returns a new Color4 object
  5575. */
  5576. toLinearSpace(): Color4;
  5577. /**
  5578. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5579. * @param convertedColor defines the Color4 object where to store the linear space version
  5580. * @returns the unmodified Color4
  5581. */
  5582. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5583. /**
  5584. * Computes a new Color4 converted from the current one to gamma space
  5585. * @returns a new Color4 object
  5586. */
  5587. toGammaSpace(): Color4;
  5588. /**
  5589. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5590. * @param convertedColor defines the Color4 object where to store the gamma space version
  5591. * @returns the unmodified Color4
  5592. */
  5593. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5594. /**
  5595. * Creates a new Color4 from the string containing valid hexadecimal values
  5596. * @param hex defines a string containing valid hexadecimal values
  5597. * @returns a new Color4 object
  5598. */
  5599. static FromHexString(hex: string): Color4;
  5600. /**
  5601. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5602. * @param left defines the start value
  5603. * @param right defines the end value
  5604. * @param amount defines the gradient factor
  5605. * @returns a new Color4 object
  5606. */
  5607. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5608. /**
  5609. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5610. * @param left defines the start value
  5611. * @param right defines the end value
  5612. * @param amount defines the gradient factor
  5613. * @param result defines the Color4 object where to store data
  5614. */
  5615. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5616. /**
  5617. * Creates a new Color4 from a Color3 and an alpha value
  5618. * @param color3 defines the source Color3 to read from
  5619. * @param alpha defines the alpha component (1.0 by default)
  5620. * @returns a new Color4 object
  5621. */
  5622. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5623. /**
  5624. * Creates a new Color4 from the starting index element of the given array
  5625. * @param array defines the source array to read from
  5626. * @param offset defines the offset in the source array
  5627. * @returns a new Color4 object
  5628. */
  5629. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5630. /**
  5631. * Creates a new Color3 from integer values (< 256)
  5632. * @param r defines the red component to read from (value between 0 and 255)
  5633. * @param g defines the green component to read from (value between 0 and 255)
  5634. * @param b defines the blue component to read from (value between 0 and 255)
  5635. * @param a defines the alpha component to read from (value between 0 and 255)
  5636. * @returns a new Color3 object
  5637. */
  5638. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5639. /**
  5640. * Check the content of a given array and convert it to an array containing RGBA data
  5641. * If the original array was already containing count * 4 values then it is returned directly
  5642. * @param colors defines the array to check
  5643. * @param count defines the number of RGBA data to expect
  5644. * @returns an array containing count * 4 values (RGBA)
  5645. */
  5646. static CheckColors4(colors: number[], count: number): number[];
  5647. }
  5648. /**
  5649. * @hidden
  5650. */
  5651. export class TmpColors {
  5652. static Color3: Color3[];
  5653. static Color4: Color4[];
  5654. }
  5655. }
  5656. declare module BABYLON {
  5657. /**
  5658. * Defines an interface which represents an animation key frame
  5659. */
  5660. export interface IAnimationKey {
  5661. /**
  5662. * Frame of the key frame
  5663. */
  5664. frame: number;
  5665. /**
  5666. * Value at the specifies key frame
  5667. */
  5668. value: any;
  5669. /**
  5670. * The input tangent for the cubic hermite spline
  5671. */
  5672. inTangent?: any;
  5673. /**
  5674. * The output tangent for the cubic hermite spline
  5675. */
  5676. outTangent?: any;
  5677. /**
  5678. * The animation interpolation type
  5679. */
  5680. interpolation?: AnimationKeyInterpolation;
  5681. }
  5682. /**
  5683. * Enum for the animation key frame interpolation type
  5684. */
  5685. export enum AnimationKeyInterpolation {
  5686. /**
  5687. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5688. */
  5689. STEP = 1
  5690. }
  5691. }
  5692. declare module BABYLON {
  5693. /**
  5694. * Represents the range of an animation
  5695. */
  5696. export class AnimationRange {
  5697. /**The name of the animation range**/
  5698. name: string;
  5699. /**The starting frame of the animation */
  5700. from: number;
  5701. /**The ending frame of the animation*/
  5702. to: number;
  5703. /**
  5704. * Initializes the range of an animation
  5705. * @param name The name of the animation range
  5706. * @param from The starting frame of the animation
  5707. * @param to The ending frame of the animation
  5708. */
  5709. constructor(
  5710. /**The name of the animation range**/
  5711. name: string,
  5712. /**The starting frame of the animation */
  5713. from: number,
  5714. /**The ending frame of the animation*/
  5715. to: number);
  5716. /**
  5717. * Makes a copy of the animation range
  5718. * @returns A copy of the animation range
  5719. */
  5720. clone(): AnimationRange;
  5721. }
  5722. }
  5723. declare module BABYLON {
  5724. /**
  5725. * Composed of a frame, and an action function
  5726. */
  5727. export class AnimationEvent {
  5728. /** The frame for which the event is triggered **/
  5729. frame: number;
  5730. /** The event to perform when triggered **/
  5731. action: (currentFrame: number) => void;
  5732. /** Specifies if the event should be triggered only once**/
  5733. onlyOnce?: boolean | undefined;
  5734. /**
  5735. * Specifies if the animation event is done
  5736. */
  5737. isDone: boolean;
  5738. /**
  5739. * Initializes the animation event
  5740. * @param frame The frame for which the event is triggered
  5741. * @param action The event to perform when triggered
  5742. * @param onlyOnce Specifies if the event should be triggered only once
  5743. */
  5744. constructor(
  5745. /** The frame for which the event is triggered **/
  5746. frame: number,
  5747. /** The event to perform when triggered **/
  5748. action: (currentFrame: number) => void,
  5749. /** Specifies if the event should be triggered only once**/
  5750. onlyOnce?: boolean | undefined);
  5751. /** @hidden */
  5752. _clone(): AnimationEvent;
  5753. }
  5754. }
  5755. declare module BABYLON {
  5756. /**
  5757. * Interface used to define a behavior
  5758. */
  5759. export interface Behavior<T> {
  5760. /** gets or sets behavior's name */
  5761. name: string;
  5762. /**
  5763. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5764. */
  5765. init(): void;
  5766. /**
  5767. * Called when the behavior is attached to a target
  5768. * @param target defines the target where the behavior is attached to
  5769. */
  5770. attach(target: T): void;
  5771. /**
  5772. * Called when the behavior is detached from its target
  5773. */
  5774. detach(): void;
  5775. }
  5776. /**
  5777. * Interface implemented by classes supporting behaviors
  5778. */
  5779. export interface IBehaviorAware<T> {
  5780. /**
  5781. * Attach a behavior
  5782. * @param behavior defines the behavior to attach
  5783. * @returns the current host
  5784. */
  5785. addBehavior(behavior: Behavior<T>): T;
  5786. /**
  5787. * Remove a behavior from the current object
  5788. * @param behavior defines the behavior to detach
  5789. * @returns the current host
  5790. */
  5791. removeBehavior(behavior: Behavior<T>): T;
  5792. /**
  5793. * Gets a behavior using its name to search
  5794. * @param name defines the name to search
  5795. * @returns the behavior or null if not found
  5796. */
  5797. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5798. }
  5799. }
  5800. declare module BABYLON {
  5801. /**
  5802. * Defines an array and its length.
  5803. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5804. */
  5805. export interface ISmartArrayLike<T> {
  5806. /**
  5807. * The data of the array.
  5808. */
  5809. data: Array<T>;
  5810. /**
  5811. * The active length of the array.
  5812. */
  5813. length: number;
  5814. }
  5815. /**
  5816. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5817. */
  5818. export class SmartArray<T> implements ISmartArrayLike<T> {
  5819. /**
  5820. * The full set of data from the array.
  5821. */
  5822. data: Array<T>;
  5823. /**
  5824. * The active length of the array.
  5825. */
  5826. length: number;
  5827. protected _id: number;
  5828. /**
  5829. * Instantiates a Smart Array.
  5830. * @param capacity defines the default capacity of the array.
  5831. */
  5832. constructor(capacity: number);
  5833. /**
  5834. * Pushes a value at the end of the active data.
  5835. * @param value defines the object to push in the array.
  5836. */
  5837. push(value: T): void;
  5838. /**
  5839. * Iterates over the active data and apply the lambda to them.
  5840. * @param func defines the action to apply on each value.
  5841. */
  5842. forEach(func: (content: T) => void): void;
  5843. /**
  5844. * Sorts the full sets of data.
  5845. * @param compareFn defines the comparison function to apply.
  5846. */
  5847. sort(compareFn: (a: T, b: T) => number): void;
  5848. /**
  5849. * Resets the active data to an empty array.
  5850. */
  5851. reset(): void;
  5852. /**
  5853. * Releases all the data from the array as well as the array.
  5854. */
  5855. dispose(): void;
  5856. /**
  5857. * Concats the active data with a given array.
  5858. * @param array defines the data to concatenate with.
  5859. */
  5860. concat(array: any): void;
  5861. /**
  5862. * Returns the position of a value in the active data.
  5863. * @param value defines the value to find the index for
  5864. * @returns the index if found in the active data otherwise -1
  5865. */
  5866. indexOf(value: T): number;
  5867. /**
  5868. * Returns whether an element is part of the active data.
  5869. * @param value defines the value to look for
  5870. * @returns true if found in the active data otherwise false
  5871. */
  5872. contains(value: T): boolean;
  5873. private static _GlobalId;
  5874. }
  5875. /**
  5876. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5877. * The data in this array can only be present once
  5878. */
  5879. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5880. private _duplicateId;
  5881. /**
  5882. * Pushes a value at the end of the active data.
  5883. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5884. * @param value defines the object to push in the array.
  5885. */
  5886. push(value: T): void;
  5887. /**
  5888. * Pushes a value at the end of the active data.
  5889. * If the data is already present, it won t be added again
  5890. * @param value defines the object to push in the array.
  5891. * @returns true if added false if it was already present
  5892. */
  5893. pushNoDuplicate(value: T): boolean;
  5894. /**
  5895. * Resets the active data to an empty array.
  5896. */
  5897. reset(): void;
  5898. /**
  5899. * Concats the active data with a given array.
  5900. * This ensures no dupplicate will be present in the result.
  5901. * @param array defines the data to concatenate with.
  5902. */
  5903. concatWithNoDuplicate(array: any): void;
  5904. }
  5905. }
  5906. declare module BABYLON {
  5907. /**
  5908. * @ignore
  5909. * This is a list of all the different input types that are available in the application.
  5910. * Fo instance: ArcRotateCameraGamepadInput...
  5911. */
  5912. export var CameraInputTypes: {};
  5913. /**
  5914. * This is the contract to implement in order to create a new input class.
  5915. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5916. */
  5917. export interface ICameraInput<TCamera extends Camera> {
  5918. /**
  5919. * Defines the camera the input is attached to.
  5920. */
  5921. camera: Nullable<TCamera>;
  5922. /**
  5923. * Gets the class name of the current intput.
  5924. * @returns the class name
  5925. */
  5926. getClassName(): string;
  5927. /**
  5928. * Get the friendly name associated with the input class.
  5929. * @returns the input friendly name
  5930. */
  5931. getSimpleName(): string;
  5932. /**
  5933. * Attach the input controls to a specific dom element to get the input from.
  5934. * @param element Defines the element the controls should be listened from
  5935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5936. */
  5937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5938. /**
  5939. * Detach the current controls from the specified dom element.
  5940. * @param element Defines the element to stop listening the inputs from
  5941. */
  5942. detachControl(element: Nullable<HTMLElement>): void;
  5943. /**
  5944. * Update the current camera state depending on the inputs that have been used this frame.
  5945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5946. */
  5947. checkInputs?: () => void;
  5948. }
  5949. /**
  5950. * Represents a map of input types to input instance or input index to input instance.
  5951. */
  5952. export interface CameraInputsMap<TCamera extends Camera> {
  5953. /**
  5954. * Accessor to the input by input type.
  5955. */
  5956. [name: string]: ICameraInput<TCamera>;
  5957. /**
  5958. * Accessor to the input by input index.
  5959. */
  5960. [idx: number]: ICameraInput<TCamera>;
  5961. }
  5962. /**
  5963. * This represents the input manager used within a camera.
  5964. * It helps dealing with all the different kind of input attached to a camera.
  5965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5966. */
  5967. export class CameraInputsManager<TCamera extends Camera> {
  5968. /**
  5969. * Defines the list of inputs attahed to the camera.
  5970. */
  5971. attached: CameraInputsMap<TCamera>;
  5972. /**
  5973. * Defines the dom element the camera is collecting inputs from.
  5974. * This is null if the controls have not been attached.
  5975. */
  5976. attachedElement: Nullable<HTMLElement>;
  5977. /**
  5978. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5979. */
  5980. noPreventDefault: boolean;
  5981. /**
  5982. * Defined the camera the input manager belongs to.
  5983. */
  5984. camera: TCamera;
  5985. /**
  5986. * Update the current camera state depending on the inputs that have been used this frame.
  5987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5988. */
  5989. checkInputs: () => void;
  5990. /**
  5991. * Instantiate a new Camera Input Manager.
  5992. * @param camera Defines the camera the input manager blongs to
  5993. */
  5994. constructor(camera: TCamera);
  5995. /**
  5996. * Add an input method to a camera
  5997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5998. * @param input camera input method
  5999. */
  6000. add(input: ICameraInput<TCamera>): void;
  6001. /**
  6002. * Remove a specific input method from a camera
  6003. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6004. * @param inputToRemove camera input method
  6005. */
  6006. remove(inputToRemove: ICameraInput<TCamera>): void;
  6007. /**
  6008. * Remove a specific input type from a camera
  6009. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6010. * @param inputType the type of the input to remove
  6011. */
  6012. removeByType(inputType: string): void;
  6013. private _addCheckInputs;
  6014. /**
  6015. * Attach the input controls to the currently attached dom element to listen the events from.
  6016. * @param input Defines the input to attach
  6017. */
  6018. attachInput(input: ICameraInput<TCamera>): void;
  6019. /**
  6020. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6021. * @param element Defines the dom element to collect the events from
  6022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6023. */
  6024. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6025. /**
  6026. * Detach the current manager inputs controls from a specific dom element.
  6027. * @param element Defines the dom element to collect the events from
  6028. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6029. */
  6030. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6031. /**
  6032. * Rebuild the dynamic inputCheck function from the current list of
  6033. * defined inputs in the manager.
  6034. */
  6035. rebuildInputCheck(): void;
  6036. /**
  6037. * Remove all attached input methods from a camera
  6038. */
  6039. clear(): void;
  6040. /**
  6041. * Serialize the current input manager attached to a camera.
  6042. * This ensures than once parsed,
  6043. * the input associated to the camera will be identical to the current ones
  6044. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6045. */
  6046. serialize(serializedCamera: any): void;
  6047. /**
  6048. * Parses an input manager serialized JSON to restore the previous list of inputs
  6049. * and states associated to a camera.
  6050. * @param parsedCamera Defines the JSON to parse
  6051. */
  6052. parse(parsedCamera: any): void;
  6053. }
  6054. }
  6055. declare module BABYLON {
  6056. /**
  6057. * Class used to store data that will be store in GPU memory
  6058. */
  6059. export class Buffer {
  6060. private _engine;
  6061. private _buffer;
  6062. /** @hidden */
  6063. _data: Nullable<DataArray>;
  6064. private _updatable;
  6065. private _instanced;
  6066. private _divisor;
  6067. /**
  6068. * Gets the byte stride.
  6069. */
  6070. readonly byteStride: number;
  6071. /**
  6072. * Constructor
  6073. * @param engine the engine
  6074. * @param data the data to use for this buffer
  6075. * @param updatable whether the data is updatable
  6076. * @param stride the stride (optional)
  6077. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6078. * @param instanced whether the buffer is instanced (optional)
  6079. * @param useBytes set to true if the stride in in bytes (optional)
  6080. * @param divisor sets an optional divisor for instances (1 by default)
  6081. */
  6082. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6083. /**
  6084. * Create a new VertexBuffer based on the current buffer
  6085. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6086. * @param offset defines offset in the buffer (0 by default)
  6087. * @param size defines the size in floats of attributes (position is 3 for instance)
  6088. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6089. * @param instanced defines if the vertex buffer contains indexed data
  6090. * @param useBytes defines if the offset and stride are in bytes *
  6091. * @param divisor sets an optional divisor for instances (1 by default)
  6092. * @returns the new vertex buffer
  6093. */
  6094. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6095. /**
  6096. * Gets a boolean indicating if the Buffer is updatable?
  6097. * @returns true if the buffer is updatable
  6098. */
  6099. isUpdatable(): boolean;
  6100. /**
  6101. * Gets current buffer's data
  6102. * @returns a DataArray or null
  6103. */
  6104. getData(): Nullable<DataArray>;
  6105. /**
  6106. * Gets underlying native buffer
  6107. * @returns underlying native buffer
  6108. */
  6109. getBuffer(): Nullable<DataBuffer>;
  6110. /**
  6111. * Gets the stride in float32 units (i.e. byte stride / 4).
  6112. * May not be an integer if the byte stride is not divisible by 4.
  6113. * DEPRECATED. Use byteStride instead.
  6114. * @returns the stride in float32 units
  6115. */
  6116. getStrideSize(): number;
  6117. /**
  6118. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6119. * @param data defines the data to store
  6120. */
  6121. create(data?: Nullable<DataArray>): void;
  6122. /** @hidden */
  6123. _rebuild(): void;
  6124. /**
  6125. * Update current buffer data
  6126. * @param data defines the data to store
  6127. */
  6128. update(data: DataArray): void;
  6129. /**
  6130. * Updates the data directly.
  6131. * @param data the new data
  6132. * @param offset the new offset
  6133. * @param vertexCount the vertex count (optional)
  6134. * @param useBytes set to true if the offset is in bytes
  6135. */
  6136. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6137. /**
  6138. * Release all resources
  6139. */
  6140. dispose(): void;
  6141. }
  6142. /**
  6143. * Specialized buffer used to store vertex data
  6144. */
  6145. export class VertexBuffer {
  6146. /** @hidden */
  6147. _buffer: Buffer;
  6148. private _kind;
  6149. private _size;
  6150. private _ownsBuffer;
  6151. private _instanced;
  6152. private _instanceDivisor;
  6153. /**
  6154. * The byte type.
  6155. */
  6156. static readonly BYTE: number;
  6157. /**
  6158. * The unsigned byte type.
  6159. */
  6160. static readonly UNSIGNED_BYTE: number;
  6161. /**
  6162. * The short type.
  6163. */
  6164. static readonly SHORT: number;
  6165. /**
  6166. * The unsigned short type.
  6167. */
  6168. static readonly UNSIGNED_SHORT: number;
  6169. /**
  6170. * The integer type.
  6171. */
  6172. static readonly INT: number;
  6173. /**
  6174. * The unsigned integer type.
  6175. */
  6176. static readonly UNSIGNED_INT: number;
  6177. /**
  6178. * The float type.
  6179. */
  6180. static readonly FLOAT: number;
  6181. /**
  6182. * Gets or sets the instance divisor when in instanced mode
  6183. */
  6184. instanceDivisor: number;
  6185. /**
  6186. * Gets the byte stride.
  6187. */
  6188. readonly byteStride: number;
  6189. /**
  6190. * Gets the byte offset.
  6191. */
  6192. readonly byteOffset: number;
  6193. /**
  6194. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6195. */
  6196. readonly normalized: boolean;
  6197. /**
  6198. * Gets the data type of each component in the array.
  6199. */
  6200. readonly type: number;
  6201. /**
  6202. * Constructor
  6203. * @param engine the engine
  6204. * @param data the data to use for this vertex buffer
  6205. * @param kind the vertex buffer kind
  6206. * @param updatable whether the data is updatable
  6207. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6208. * @param stride the stride (optional)
  6209. * @param instanced whether the buffer is instanced (optional)
  6210. * @param offset the offset of the data (optional)
  6211. * @param size the number of components (optional)
  6212. * @param type the type of the component (optional)
  6213. * @param normalized whether the data contains normalized data (optional)
  6214. * @param useBytes set to true if stride and offset are in bytes (optional)
  6215. * @param divisor defines the instance divisor to use (1 by default)
  6216. */
  6217. 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);
  6218. /** @hidden */
  6219. _rebuild(): void;
  6220. /**
  6221. * Returns the kind of the VertexBuffer (string)
  6222. * @returns a string
  6223. */
  6224. getKind(): string;
  6225. /**
  6226. * Gets a boolean indicating if the VertexBuffer is updatable?
  6227. * @returns true if the buffer is updatable
  6228. */
  6229. isUpdatable(): boolean;
  6230. /**
  6231. * Gets current buffer's data
  6232. * @returns a DataArray or null
  6233. */
  6234. getData(): Nullable<DataArray>;
  6235. /**
  6236. * Gets underlying native buffer
  6237. * @returns underlying native buffer
  6238. */
  6239. getBuffer(): Nullable<DataBuffer>;
  6240. /**
  6241. * Gets the stride in float32 units (i.e. byte stride / 4).
  6242. * May not be an integer if the byte stride is not divisible by 4.
  6243. * DEPRECATED. Use byteStride instead.
  6244. * @returns the stride in float32 units
  6245. */
  6246. getStrideSize(): number;
  6247. /**
  6248. * Returns the offset as a multiple of the type byte length.
  6249. * DEPRECATED. Use byteOffset instead.
  6250. * @returns the offset in bytes
  6251. */
  6252. getOffset(): number;
  6253. /**
  6254. * Returns the number of components per vertex attribute (integer)
  6255. * @returns the size in float
  6256. */
  6257. getSize(): number;
  6258. /**
  6259. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6260. * @returns true if this buffer is instanced
  6261. */
  6262. getIsInstanced(): boolean;
  6263. /**
  6264. * Returns the instancing divisor, zero for non-instanced (integer).
  6265. * @returns a number
  6266. */
  6267. getInstanceDivisor(): number;
  6268. /**
  6269. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6270. * @param data defines the data to store
  6271. */
  6272. create(data?: DataArray): void;
  6273. /**
  6274. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6275. * This function will create a new buffer if the current one is not updatable
  6276. * @param data defines the data to store
  6277. */
  6278. update(data: DataArray): void;
  6279. /**
  6280. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6281. * Returns the directly updated WebGLBuffer.
  6282. * @param data the new data
  6283. * @param offset the new offset
  6284. * @param useBytes set to true if the offset is in bytes
  6285. */
  6286. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6287. /**
  6288. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6289. */
  6290. dispose(): void;
  6291. /**
  6292. * Enumerates each value of this vertex buffer as numbers.
  6293. * @param count the number of values to enumerate
  6294. * @param callback the callback function called for each value
  6295. */
  6296. forEach(count: number, callback: (value: number, index: number) => void): void;
  6297. /**
  6298. * Positions
  6299. */
  6300. static readonly PositionKind: string;
  6301. /**
  6302. * Normals
  6303. */
  6304. static readonly NormalKind: string;
  6305. /**
  6306. * Tangents
  6307. */
  6308. static readonly TangentKind: string;
  6309. /**
  6310. * Texture coordinates
  6311. */
  6312. static readonly UVKind: string;
  6313. /**
  6314. * Texture coordinates 2
  6315. */
  6316. static readonly UV2Kind: string;
  6317. /**
  6318. * Texture coordinates 3
  6319. */
  6320. static readonly UV3Kind: string;
  6321. /**
  6322. * Texture coordinates 4
  6323. */
  6324. static readonly UV4Kind: string;
  6325. /**
  6326. * Texture coordinates 5
  6327. */
  6328. static readonly UV5Kind: string;
  6329. /**
  6330. * Texture coordinates 6
  6331. */
  6332. static readonly UV6Kind: string;
  6333. /**
  6334. * Colors
  6335. */
  6336. static readonly ColorKind: string;
  6337. /**
  6338. * Matrix indices (for bones)
  6339. */
  6340. static readonly MatricesIndicesKind: string;
  6341. /**
  6342. * Matrix weights (for bones)
  6343. */
  6344. static readonly MatricesWeightsKind: string;
  6345. /**
  6346. * Additional matrix indices (for bones)
  6347. */
  6348. static readonly MatricesIndicesExtraKind: string;
  6349. /**
  6350. * Additional matrix weights (for bones)
  6351. */
  6352. static readonly MatricesWeightsExtraKind: string;
  6353. /**
  6354. * Deduces the stride given a kind.
  6355. * @param kind The kind string to deduce
  6356. * @returns The deduced stride
  6357. */
  6358. static DeduceStride(kind: string): number;
  6359. /**
  6360. * Gets the byte length of the given type.
  6361. * @param type the type
  6362. * @returns the number of bytes
  6363. */
  6364. static GetTypeByteLength(type: number): number;
  6365. /**
  6366. * Enumerates each value of the given parameters as numbers.
  6367. * @param data the data to enumerate
  6368. * @param byteOffset the byte offset of the data
  6369. * @param byteStride the byte stride of the data
  6370. * @param componentCount the number of components per element
  6371. * @param componentType the type of the component
  6372. * @param count the number of values to enumerate
  6373. * @param normalized whether the data is normalized
  6374. * @param callback the callback function called for each value
  6375. */
  6376. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6377. private static _GetFloatValue;
  6378. }
  6379. }
  6380. declare module BABYLON {
  6381. /**
  6382. * @hidden
  6383. */
  6384. export class IntersectionInfo {
  6385. bu: Nullable<number>;
  6386. bv: Nullable<number>;
  6387. distance: number;
  6388. faceId: number;
  6389. subMeshId: number;
  6390. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6391. }
  6392. }
  6393. declare module BABYLON {
  6394. /**
  6395. * Represens a plane by the equation ax + by + cz + d = 0
  6396. */
  6397. export class Plane {
  6398. private static _TmpMatrix;
  6399. /**
  6400. * Normal of the plane (a,b,c)
  6401. */
  6402. normal: Vector3;
  6403. /**
  6404. * d component of the plane
  6405. */
  6406. d: number;
  6407. /**
  6408. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6409. * @param a a component of the plane
  6410. * @param b b component of the plane
  6411. * @param c c component of the plane
  6412. * @param d d component of the plane
  6413. */
  6414. constructor(a: number, b: number, c: number, d: number);
  6415. /**
  6416. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6417. */
  6418. asArray(): number[];
  6419. /**
  6420. * @returns a new plane copied from the current Plane.
  6421. */
  6422. clone(): Plane;
  6423. /**
  6424. * @returns the string "Plane".
  6425. */
  6426. getClassName(): string;
  6427. /**
  6428. * @returns the Plane hash code.
  6429. */
  6430. getHashCode(): number;
  6431. /**
  6432. * Normalize the current Plane in place.
  6433. * @returns the updated Plane.
  6434. */
  6435. normalize(): Plane;
  6436. /**
  6437. * Applies a transformation the plane and returns the result
  6438. * @param transformation the transformation matrix to be applied to the plane
  6439. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6440. */
  6441. transform(transformation: DeepImmutable<Matrix>): Plane;
  6442. /**
  6443. * Calcualtte the dot product between the point and the plane normal
  6444. * @param point point to calculate the dot product with
  6445. * @returns the dot product (float) of the point coordinates and the plane normal.
  6446. */
  6447. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6448. /**
  6449. * Updates the current Plane from the plane defined by the three given points.
  6450. * @param point1 one of the points used to contruct the plane
  6451. * @param point2 one of the points used to contruct the plane
  6452. * @param point3 one of the points used to contruct the plane
  6453. * @returns the updated Plane.
  6454. */
  6455. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6456. /**
  6457. * Checks if the plane is facing a given direction
  6458. * @param direction the direction to check if the plane is facing
  6459. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6460. * @returns True is the vector "direction" is the same side than the plane normal.
  6461. */
  6462. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6463. /**
  6464. * Calculates the distance to a point
  6465. * @param point point to calculate distance to
  6466. * @returns the signed distance (float) from the given point to the Plane.
  6467. */
  6468. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6469. /**
  6470. * Creates a plane from an array
  6471. * @param array the array to create a plane from
  6472. * @returns a new Plane from the given array.
  6473. */
  6474. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6475. /**
  6476. * Creates a plane from three points
  6477. * @param point1 point used to create the plane
  6478. * @param point2 point used to create the plane
  6479. * @param point3 point used to create the plane
  6480. * @returns a new Plane defined by the three given points.
  6481. */
  6482. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6483. /**
  6484. * Creates a plane from an origin point and a normal
  6485. * @param origin origin of the plane to be constructed
  6486. * @param normal normal of the plane to be constructed
  6487. * @returns a new Plane the normal vector to this plane at the given origin point.
  6488. * Note : the vector "normal" is updated because normalized.
  6489. */
  6490. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6491. /**
  6492. * Calculates the distance from a plane and a point
  6493. * @param origin origin of the plane to be constructed
  6494. * @param normal normal of the plane to be constructed
  6495. * @param point point to calculate distance to
  6496. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6497. */
  6498. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6499. }
  6500. }
  6501. declare module BABYLON {
  6502. /**
  6503. * Class used to store bounding sphere information
  6504. */
  6505. export class BoundingSphere {
  6506. /**
  6507. * Gets the center of the bounding sphere in local space
  6508. */
  6509. readonly center: Vector3;
  6510. /**
  6511. * Radius of the bounding sphere in local space
  6512. */
  6513. radius: number;
  6514. /**
  6515. * Gets the center of the bounding sphere in world space
  6516. */
  6517. readonly centerWorld: Vector3;
  6518. /**
  6519. * Radius of the bounding sphere in world space
  6520. */
  6521. radiusWorld: number;
  6522. /**
  6523. * Gets the minimum vector in local space
  6524. */
  6525. readonly minimum: Vector3;
  6526. /**
  6527. * Gets the maximum vector in local space
  6528. */
  6529. readonly maximum: Vector3;
  6530. private _worldMatrix;
  6531. private static readonly TmpVector3;
  6532. /**
  6533. * Creates a new bounding sphere
  6534. * @param min defines the minimum vector (in local space)
  6535. * @param max defines the maximum vector (in local space)
  6536. * @param worldMatrix defines the new world matrix
  6537. */
  6538. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6539. /**
  6540. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6541. * @param min defines the new minimum vector (in local space)
  6542. * @param max defines the new maximum vector (in local space)
  6543. * @param worldMatrix defines the new world matrix
  6544. */
  6545. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6546. /**
  6547. * Scale the current bounding sphere by applying a scale factor
  6548. * @param factor defines the scale factor to apply
  6549. * @returns the current bounding box
  6550. */
  6551. scale(factor: number): BoundingSphere;
  6552. /**
  6553. * Gets the world matrix of the bounding box
  6554. * @returns a matrix
  6555. */
  6556. getWorldMatrix(): DeepImmutable<Matrix>;
  6557. /** @hidden */
  6558. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6559. /**
  6560. * Tests if the bounding sphere is intersecting the frustum planes
  6561. * @param frustumPlanes defines the frustum planes to test
  6562. * @returns true if there is an intersection
  6563. */
  6564. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6565. /**
  6566. * Tests if the bounding sphere center is in between the frustum planes.
  6567. * Used for optimistic fast inclusion.
  6568. * @param frustumPlanes defines the frustum planes to test
  6569. * @returns true if the sphere center is in between the frustum planes
  6570. */
  6571. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6572. /**
  6573. * Tests if a point is inside the bounding sphere
  6574. * @param point defines the point to test
  6575. * @returns true if the point is inside the bounding sphere
  6576. */
  6577. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6578. /**
  6579. * Checks if two sphere intersct
  6580. * @param sphere0 sphere 0
  6581. * @param sphere1 sphere 1
  6582. * @returns true if the speres intersect
  6583. */
  6584. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6585. }
  6586. }
  6587. declare module BABYLON {
  6588. /**
  6589. * Class used to store bounding box information
  6590. */
  6591. export class BoundingBox implements ICullable {
  6592. /**
  6593. * Gets the 8 vectors representing the bounding box in local space
  6594. */
  6595. readonly vectors: Vector3[];
  6596. /**
  6597. * Gets the center of the bounding box in local space
  6598. */
  6599. readonly center: Vector3;
  6600. /**
  6601. * Gets the center of the bounding box in world space
  6602. */
  6603. readonly centerWorld: Vector3;
  6604. /**
  6605. * Gets the extend size in local space
  6606. */
  6607. readonly extendSize: Vector3;
  6608. /**
  6609. * Gets the extend size in world space
  6610. */
  6611. readonly extendSizeWorld: Vector3;
  6612. /**
  6613. * Gets the OBB (object bounding box) directions
  6614. */
  6615. readonly directions: Vector3[];
  6616. /**
  6617. * Gets the 8 vectors representing the bounding box in world space
  6618. */
  6619. readonly vectorsWorld: Vector3[];
  6620. /**
  6621. * Gets the minimum vector in world space
  6622. */
  6623. readonly minimumWorld: Vector3;
  6624. /**
  6625. * Gets the maximum vector in world space
  6626. */
  6627. readonly maximumWorld: Vector3;
  6628. /**
  6629. * Gets the minimum vector in local space
  6630. */
  6631. readonly minimum: Vector3;
  6632. /**
  6633. * Gets the maximum vector in local space
  6634. */
  6635. readonly maximum: Vector3;
  6636. private _worldMatrix;
  6637. private static readonly TmpVector3;
  6638. /**
  6639. * @hidden
  6640. */
  6641. _tag: number;
  6642. /**
  6643. * Creates a new bounding box
  6644. * @param min defines the minimum vector (in local space)
  6645. * @param max defines the maximum vector (in local space)
  6646. * @param worldMatrix defines the new world matrix
  6647. */
  6648. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6649. /**
  6650. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6651. * @param min defines the new minimum vector (in local space)
  6652. * @param max defines the new maximum vector (in local space)
  6653. * @param worldMatrix defines the new world matrix
  6654. */
  6655. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6656. /**
  6657. * Scale the current bounding box by applying a scale factor
  6658. * @param factor defines the scale factor to apply
  6659. * @returns the current bounding box
  6660. */
  6661. scale(factor: number): BoundingBox;
  6662. /**
  6663. * Gets the world matrix of the bounding box
  6664. * @returns a matrix
  6665. */
  6666. getWorldMatrix(): DeepImmutable<Matrix>;
  6667. /** @hidden */
  6668. _update(world: DeepImmutable<Matrix>): void;
  6669. /**
  6670. * Tests if the bounding box is intersecting the frustum planes
  6671. * @param frustumPlanes defines the frustum planes to test
  6672. * @returns true if there is an intersection
  6673. */
  6674. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6675. /**
  6676. * Tests if the bounding box is entirely inside the frustum planes
  6677. * @param frustumPlanes defines the frustum planes to test
  6678. * @returns true if there is an inclusion
  6679. */
  6680. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6681. /**
  6682. * Tests if a point is inside the bounding box
  6683. * @param point defines the point to test
  6684. * @returns true if the point is inside the bounding box
  6685. */
  6686. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6687. /**
  6688. * Tests if the bounding box intersects with a bounding sphere
  6689. * @param sphere defines the sphere to test
  6690. * @returns true if there is an intersection
  6691. */
  6692. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6693. /**
  6694. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6695. * @param min defines the min vector to use
  6696. * @param max defines the max vector to use
  6697. * @returns true if there is an intersection
  6698. */
  6699. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6700. /**
  6701. * Tests if two bounding boxes are intersections
  6702. * @param box0 defines the first box to test
  6703. * @param box1 defines the second box to test
  6704. * @returns true if there is an intersection
  6705. */
  6706. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6707. /**
  6708. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6709. * @param minPoint defines the minimum vector of the bounding box
  6710. * @param maxPoint defines the maximum vector of the bounding box
  6711. * @param sphereCenter defines the sphere center
  6712. * @param sphereRadius defines the sphere radius
  6713. * @returns true if there is an intersection
  6714. */
  6715. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6716. /**
  6717. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6718. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6719. * @param frustumPlanes defines the frustum planes to test
  6720. * @return true if there is an inclusion
  6721. */
  6722. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6723. /**
  6724. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6725. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6726. * @param frustumPlanes defines the frustum planes to test
  6727. * @return true if there is an intersection
  6728. */
  6729. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6730. }
  6731. }
  6732. declare module BABYLON {
  6733. /** @hidden */
  6734. export class Collider {
  6735. /** Define if a collision was found */
  6736. collisionFound: boolean;
  6737. /**
  6738. * Define last intersection point in local space
  6739. */
  6740. intersectionPoint: Vector3;
  6741. /**
  6742. * Define last collided mesh
  6743. */
  6744. collidedMesh: Nullable<AbstractMesh>;
  6745. private _collisionPoint;
  6746. private _planeIntersectionPoint;
  6747. private _tempVector;
  6748. private _tempVector2;
  6749. private _tempVector3;
  6750. private _tempVector4;
  6751. private _edge;
  6752. private _baseToVertex;
  6753. private _destinationPoint;
  6754. private _slidePlaneNormal;
  6755. private _displacementVector;
  6756. /** @hidden */
  6757. _radius: Vector3;
  6758. /** @hidden */
  6759. _retry: number;
  6760. private _velocity;
  6761. private _basePoint;
  6762. private _epsilon;
  6763. /** @hidden */
  6764. _velocityWorldLength: number;
  6765. /** @hidden */
  6766. _basePointWorld: Vector3;
  6767. private _velocityWorld;
  6768. private _normalizedVelocity;
  6769. /** @hidden */
  6770. _initialVelocity: Vector3;
  6771. /** @hidden */
  6772. _initialPosition: Vector3;
  6773. private _nearestDistance;
  6774. private _collisionMask;
  6775. collisionMask: number;
  6776. /**
  6777. * Gets the plane normal used to compute the sliding response (in local space)
  6778. */
  6779. readonly slidePlaneNormal: Vector3;
  6780. /** @hidden */
  6781. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6782. /** @hidden */
  6783. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6784. /** @hidden */
  6785. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6786. /** @hidden */
  6787. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6788. /** @hidden */
  6789. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6790. /** @hidden */
  6791. _getResponse(pos: Vector3, vel: Vector3): void;
  6792. }
  6793. }
  6794. declare module BABYLON {
  6795. /**
  6796. * Interface for cullable objects
  6797. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6798. */
  6799. export interface ICullable {
  6800. /**
  6801. * Checks if the object or part of the object is in the frustum
  6802. * @param frustumPlanes Camera near/planes
  6803. * @returns true if the object is in frustum otherwise false
  6804. */
  6805. isInFrustum(frustumPlanes: Plane[]): boolean;
  6806. /**
  6807. * Checks if a cullable object (mesh...) is in the camera frustum
  6808. * Unlike isInFrustum this cheks the full bounding box
  6809. * @param frustumPlanes Camera near/planes
  6810. * @returns true if the object is in frustum otherwise false
  6811. */
  6812. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6813. }
  6814. /**
  6815. * Info for a bounding data of a mesh
  6816. */
  6817. export class BoundingInfo implements ICullable {
  6818. /**
  6819. * Bounding box for the mesh
  6820. */
  6821. readonly boundingBox: BoundingBox;
  6822. /**
  6823. * Bounding sphere for the mesh
  6824. */
  6825. readonly boundingSphere: BoundingSphere;
  6826. private _isLocked;
  6827. private static readonly TmpVector3;
  6828. /**
  6829. * Constructs bounding info
  6830. * @param minimum min vector of the bounding box/sphere
  6831. * @param maximum max vector of the bounding box/sphere
  6832. * @param worldMatrix defines the new world matrix
  6833. */
  6834. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6835. /**
  6836. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6837. * @param min defines the new minimum vector (in local space)
  6838. * @param max defines the new maximum vector (in local space)
  6839. * @param worldMatrix defines the new world matrix
  6840. */
  6841. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6842. /**
  6843. * min vector of the bounding box/sphere
  6844. */
  6845. readonly minimum: Vector3;
  6846. /**
  6847. * max vector of the bounding box/sphere
  6848. */
  6849. readonly maximum: Vector3;
  6850. /**
  6851. * If the info is locked and won't be updated to avoid perf overhead
  6852. */
  6853. isLocked: boolean;
  6854. /**
  6855. * Updates the bounding sphere and box
  6856. * @param world world matrix to be used to update
  6857. */
  6858. update(world: DeepImmutable<Matrix>): void;
  6859. /**
  6860. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6861. * @param center New center of the bounding info
  6862. * @param extend New extend of the bounding info
  6863. * @returns the current bounding info
  6864. */
  6865. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6866. /**
  6867. * Scale the current bounding info by applying a scale factor
  6868. * @param factor defines the scale factor to apply
  6869. * @returns the current bounding info
  6870. */
  6871. scale(factor: number): BoundingInfo;
  6872. /**
  6873. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6874. * @param frustumPlanes defines the frustum to test
  6875. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6876. * @returns true if the bounding info is in the frustum planes
  6877. */
  6878. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6879. /**
  6880. * Gets the world distance between the min and max points of the bounding box
  6881. */
  6882. readonly diagonalLength: number;
  6883. /**
  6884. * Checks if a cullable object (mesh...) is in the camera frustum
  6885. * Unlike isInFrustum this cheks the full bounding box
  6886. * @param frustumPlanes Camera near/planes
  6887. * @returns true if the object is in frustum otherwise false
  6888. */
  6889. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6890. /** @hidden */
  6891. _checkCollision(collider: Collider): boolean;
  6892. /**
  6893. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6894. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6895. * @param point the point to check intersection with
  6896. * @returns if the point intersects
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6901. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6902. * @param boundingInfo the bounding info to check intersection with
  6903. * @param precise if the intersection should be done using OBB
  6904. * @returns if the bounding info intersects
  6905. */
  6906. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6907. }
  6908. }
  6909. declare module BABYLON {
  6910. /**
  6911. * Extracts minimum and maximum values from a list of indexed positions
  6912. * @param positions defines the positions to use
  6913. * @param indices defines the indices to the positions
  6914. * @param indexStart defines the start index
  6915. * @param indexCount defines the end index
  6916. * @param bias defines bias value to add to the result
  6917. * @return minimum and maximum values
  6918. */
  6919. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6920. minimum: Vector3;
  6921. maximum: Vector3;
  6922. };
  6923. /**
  6924. * Extracts minimum and maximum values from a list of positions
  6925. * @param positions defines the positions to use
  6926. * @param start defines the start index in the positions array
  6927. * @param count defines the number of positions to handle
  6928. * @param bias defines bias value to add to the result
  6929. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6930. * @return minimum and maximum values
  6931. */
  6932. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6933. minimum: Vector3;
  6934. maximum: Vector3;
  6935. };
  6936. }
  6937. declare module BABYLON {
  6938. /** @hidden */
  6939. export class WebGLDataBuffer extends DataBuffer {
  6940. private _buffer;
  6941. constructor(resource: WebGLBuffer);
  6942. readonly underlyingResource: any;
  6943. }
  6944. }
  6945. declare module BABYLON {
  6946. /** @hidden */
  6947. export class WebGLPipelineContext implements IPipelineContext {
  6948. engine: ThinEngine;
  6949. program: Nullable<WebGLProgram>;
  6950. context?: WebGLRenderingContext;
  6951. vertexShader?: WebGLShader;
  6952. fragmentShader?: WebGLShader;
  6953. isParallelCompiled: boolean;
  6954. onCompiled?: () => void;
  6955. transformFeedback?: WebGLTransformFeedback | null;
  6956. readonly isAsync: boolean;
  6957. readonly isReady: boolean;
  6958. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  6959. }
  6960. }
  6961. declare module BABYLON {
  6962. interface ThinEngine {
  6963. /**
  6964. * Create an uniform buffer
  6965. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6966. * @param elements defines the content of the uniform buffer
  6967. * @returns the webGL uniform buffer
  6968. */
  6969. createUniformBuffer(elements: FloatArray): DataBuffer;
  6970. /**
  6971. * Create a dynamic uniform buffer
  6972. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6973. * @param elements defines the content of the uniform buffer
  6974. * @returns the webGL uniform buffer
  6975. */
  6976. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  6977. /**
  6978. * Update an existing uniform buffer
  6979. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6980. * @param uniformBuffer defines the target uniform buffer
  6981. * @param elements defines the content to update
  6982. * @param offset defines the offset in the uniform buffer where update should start
  6983. * @param count defines the size of the data to update
  6984. */
  6985. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6986. /**
  6987. * Bind an uniform buffer to the current webGL context
  6988. * @param buffer defines the buffer to bind
  6989. */
  6990. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  6991. /**
  6992. * Bind a buffer to the current webGL context at a given location
  6993. * @param buffer defines the buffer to bind
  6994. * @param location defines the index where to bind the buffer
  6995. */
  6996. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  6997. /**
  6998. * Bind a specific block at a given index in a specific shader program
  6999. * @param pipelineContext defines the pipeline context to use
  7000. * @param blockName defines the block name
  7001. * @param index defines the index where to bind the block
  7002. */
  7003. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7004. }
  7005. }
  7006. declare module BABYLON {
  7007. /**
  7008. * Uniform buffer objects.
  7009. *
  7010. * Handles blocks of uniform on the GPU.
  7011. *
  7012. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7013. *
  7014. * For more information, please refer to :
  7015. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7016. */
  7017. export class UniformBuffer {
  7018. private _engine;
  7019. private _buffer;
  7020. private _data;
  7021. private _bufferData;
  7022. private _dynamic?;
  7023. private _uniformLocations;
  7024. private _uniformSizes;
  7025. private _uniformLocationPointer;
  7026. private _needSync;
  7027. private _noUBO;
  7028. private _currentEffect;
  7029. private static _MAX_UNIFORM_SIZE;
  7030. private static _tempBuffer;
  7031. /**
  7032. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7033. * This is dynamic to allow compat with webgl 1 and 2.
  7034. * You will need to pass the name of the uniform as well as the value.
  7035. */
  7036. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7037. /**
  7038. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7039. * This is dynamic to allow compat with webgl 1 and 2.
  7040. * You will need to pass the name of the uniform as well as the value.
  7041. */
  7042. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7043. /**
  7044. * Lambda to Update a single float in a uniform buffer.
  7045. * This is dynamic to allow compat with webgl 1 and 2.
  7046. * You will need to pass the name of the uniform as well as the value.
  7047. */
  7048. updateFloat: (name: string, x: number) => void;
  7049. /**
  7050. * Lambda to Update a vec2 of float in a uniform buffer.
  7051. * This is dynamic to allow compat with webgl 1 and 2.
  7052. * You will need to pass the name of the uniform as well as the value.
  7053. */
  7054. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7055. /**
  7056. * Lambda to Update a vec3 of float in a uniform buffer.
  7057. * This is dynamic to allow compat with webgl 1 and 2.
  7058. * You will need to pass the name of the uniform as well as the value.
  7059. */
  7060. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7061. /**
  7062. * Lambda to Update a vec4 of float in a uniform buffer.
  7063. * This is dynamic to allow compat with webgl 1 and 2.
  7064. * You will need to pass the name of the uniform as well as the value.
  7065. */
  7066. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7067. /**
  7068. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7069. * This is dynamic to allow compat with webgl 1 and 2.
  7070. * You will need to pass the name of the uniform as well as the value.
  7071. */
  7072. updateMatrix: (name: string, mat: Matrix) => void;
  7073. /**
  7074. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7075. * This is dynamic to allow compat with webgl 1 and 2.
  7076. * You will need to pass the name of the uniform as well as the value.
  7077. */
  7078. updateVector3: (name: string, vector: Vector3) => void;
  7079. /**
  7080. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7081. * This is dynamic to allow compat with webgl 1 and 2.
  7082. * You will need to pass the name of the uniform as well as the value.
  7083. */
  7084. updateVector4: (name: string, vector: Vector4) => void;
  7085. /**
  7086. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7087. * This is dynamic to allow compat with webgl 1 and 2.
  7088. * You will need to pass the name of the uniform as well as the value.
  7089. */
  7090. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7091. /**
  7092. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7093. * This is dynamic to allow compat with webgl 1 and 2.
  7094. * You will need to pass the name of the uniform as well as the value.
  7095. */
  7096. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7097. /**
  7098. * Instantiates a new Uniform buffer objects.
  7099. *
  7100. * Handles blocks of uniform on the GPU.
  7101. *
  7102. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7103. *
  7104. * For more information, please refer to :
  7105. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7106. * @param engine Define the engine the buffer is associated with
  7107. * @param data Define the data contained in the buffer
  7108. * @param dynamic Define if the buffer is updatable
  7109. */
  7110. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7111. /**
  7112. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7113. * or just falling back on setUniformXXX calls.
  7114. */
  7115. readonly useUbo: boolean;
  7116. /**
  7117. * Indicates if the WebGL underlying uniform buffer is in sync
  7118. * with the javascript cache data.
  7119. */
  7120. readonly isSync: boolean;
  7121. /**
  7122. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7123. * Also, a dynamic UniformBuffer will disable cache verification and always
  7124. * update the underlying WebGL uniform buffer to the GPU.
  7125. * @returns if Dynamic, otherwise false
  7126. */
  7127. isDynamic(): boolean;
  7128. /**
  7129. * The data cache on JS side.
  7130. * @returns the underlying data as a float array
  7131. */
  7132. getData(): Float32Array;
  7133. /**
  7134. * The underlying WebGL Uniform buffer.
  7135. * @returns the webgl buffer
  7136. */
  7137. getBuffer(): Nullable<DataBuffer>;
  7138. /**
  7139. * std140 layout specifies how to align data within an UBO structure.
  7140. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7141. * for specs.
  7142. */
  7143. private _fillAlignment;
  7144. /**
  7145. * Adds an uniform in the buffer.
  7146. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7147. * for the layout to be correct !
  7148. * @param name Name of the uniform, as used in the uniform block in the shader.
  7149. * @param size Data size, or data directly.
  7150. */
  7151. addUniform(name: string, size: number | number[]): void;
  7152. /**
  7153. * Adds a Matrix 4x4 to the uniform buffer.
  7154. * @param name Name of the uniform, as used in the uniform block in the shader.
  7155. * @param mat A 4x4 matrix.
  7156. */
  7157. addMatrix(name: string, mat: Matrix): void;
  7158. /**
  7159. * Adds a vec2 to the uniform buffer.
  7160. * @param name Name of the uniform, as used in the uniform block in the shader.
  7161. * @param x Define the x component value of the vec2
  7162. * @param y Define the y component value of the vec2
  7163. */
  7164. addFloat2(name: string, x: number, y: number): void;
  7165. /**
  7166. * Adds a vec3 to the uniform buffer.
  7167. * @param name Name of the uniform, as used in the uniform block in the shader.
  7168. * @param x Define the x component value of the vec3
  7169. * @param y Define the y component value of the vec3
  7170. * @param z Define the z component value of the vec3
  7171. */
  7172. addFloat3(name: string, x: number, y: number, z: number): void;
  7173. /**
  7174. * Adds a vec3 to the uniform buffer.
  7175. * @param name Name of the uniform, as used in the uniform block in the shader.
  7176. * @param color Define the vec3 from a Color
  7177. */
  7178. addColor3(name: string, color: Color3): void;
  7179. /**
  7180. * Adds a vec4 to the uniform buffer.
  7181. * @param name Name of the uniform, as used in the uniform block in the shader.
  7182. * @param color Define the rgb components from a Color
  7183. * @param alpha Define the a component of the vec4
  7184. */
  7185. addColor4(name: string, color: Color3, alpha: number): void;
  7186. /**
  7187. * Adds a vec3 to the uniform buffer.
  7188. * @param name Name of the uniform, as used in the uniform block in the shader.
  7189. * @param vector Define the vec3 components from a Vector
  7190. */
  7191. addVector3(name: string, vector: Vector3): void;
  7192. /**
  7193. * Adds a Matrix 3x3 to the uniform buffer.
  7194. * @param name Name of the uniform, as used in the uniform block in the shader.
  7195. */
  7196. addMatrix3x3(name: string): void;
  7197. /**
  7198. * Adds a Matrix 2x2 to the uniform buffer.
  7199. * @param name Name of the uniform, as used in the uniform block in the shader.
  7200. */
  7201. addMatrix2x2(name: string): void;
  7202. /**
  7203. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7204. */
  7205. create(): void;
  7206. /** @hidden */
  7207. _rebuild(): void;
  7208. /**
  7209. * Updates the WebGL Uniform Buffer on the GPU.
  7210. * If the `dynamic` flag is set to true, no cache comparison is done.
  7211. * Otherwise, the buffer will be updated only if the cache differs.
  7212. */
  7213. update(): void;
  7214. /**
  7215. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7216. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7217. * @param data Define the flattened data
  7218. * @param size Define the size of the data.
  7219. */
  7220. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7221. private _valueCache;
  7222. private _cacheMatrix;
  7223. private _updateMatrix3x3ForUniform;
  7224. private _updateMatrix3x3ForEffect;
  7225. private _updateMatrix2x2ForEffect;
  7226. private _updateMatrix2x2ForUniform;
  7227. private _updateFloatForEffect;
  7228. private _updateFloatForUniform;
  7229. private _updateFloat2ForEffect;
  7230. private _updateFloat2ForUniform;
  7231. private _updateFloat3ForEffect;
  7232. private _updateFloat3ForUniform;
  7233. private _updateFloat4ForEffect;
  7234. private _updateFloat4ForUniform;
  7235. private _updateMatrixForEffect;
  7236. private _updateMatrixForUniform;
  7237. private _updateVector3ForEffect;
  7238. private _updateVector3ForUniform;
  7239. private _updateVector4ForEffect;
  7240. private _updateVector4ForUniform;
  7241. private _updateColor3ForEffect;
  7242. private _updateColor3ForUniform;
  7243. private _updateColor4ForEffect;
  7244. private _updateColor4ForUniform;
  7245. /**
  7246. * Sets a sampler uniform on the effect.
  7247. * @param name Define the name of the sampler.
  7248. * @param texture Define the texture to set in the sampler
  7249. */
  7250. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7251. /**
  7252. * Directly updates the value of the uniform in the cache AND on the GPU.
  7253. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7254. * @param data Define the flattened data
  7255. */
  7256. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7257. /**
  7258. * Binds this uniform buffer to an effect.
  7259. * @param effect Define the effect to bind the buffer to
  7260. * @param name Name of the uniform block in the shader.
  7261. */
  7262. bindToEffect(effect: Effect, name: string): void;
  7263. /**
  7264. * Disposes the uniform buffer.
  7265. */
  7266. dispose(): void;
  7267. }
  7268. }
  7269. declare module BABYLON {
  7270. /**
  7271. * Enum that determines the text-wrapping mode to use.
  7272. */
  7273. export enum InspectableType {
  7274. /**
  7275. * Checkbox for booleans
  7276. */
  7277. Checkbox = 0,
  7278. /**
  7279. * Sliders for numbers
  7280. */
  7281. Slider = 1,
  7282. /**
  7283. * Vector3
  7284. */
  7285. Vector3 = 2,
  7286. /**
  7287. * Quaternions
  7288. */
  7289. Quaternion = 3,
  7290. /**
  7291. * Color3
  7292. */
  7293. Color3 = 4,
  7294. /**
  7295. * String
  7296. */
  7297. String = 5
  7298. }
  7299. /**
  7300. * Interface used to define custom inspectable properties.
  7301. * This interface is used by the inspector to display custom property grids
  7302. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7303. */
  7304. export interface IInspectable {
  7305. /**
  7306. * Gets the label to display
  7307. */
  7308. label: string;
  7309. /**
  7310. * Gets the name of the property to edit
  7311. */
  7312. propertyName: string;
  7313. /**
  7314. * Gets the type of the editor to use
  7315. */
  7316. type: InspectableType;
  7317. /**
  7318. * Gets the minimum value of the property when using in "slider" mode
  7319. */
  7320. min?: number;
  7321. /**
  7322. * Gets the maximum value of the property when using in "slider" mode
  7323. */
  7324. max?: number;
  7325. /**
  7326. * Gets the setp to use when using in "slider" mode
  7327. */
  7328. step?: number;
  7329. }
  7330. }
  7331. declare module BABYLON {
  7332. /**
  7333. * Class used to provide helper for timing
  7334. */
  7335. export class TimingTools {
  7336. /**
  7337. * Polyfill for setImmediate
  7338. * @param action defines the action to execute after the current execution block
  7339. */
  7340. static SetImmediate(action: () => void): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Class used to enable instatition of objects by class name
  7346. */
  7347. export class InstantiationTools {
  7348. /**
  7349. * Use this object to register external classes like custom textures or material
  7350. * to allow the laoders to instantiate them
  7351. */
  7352. static RegisteredExternalClasses: {
  7353. [key: string]: Object;
  7354. };
  7355. /**
  7356. * Tries to instantiate a new object from a given class name
  7357. * @param className defines the class name to instantiate
  7358. * @returns the new object or null if the system was not able to do the instantiation
  7359. */
  7360. static Instantiate(className: string): any;
  7361. }
  7362. }
  7363. declare module BABYLON {
  7364. /**
  7365. * Define options used to create a depth texture
  7366. */
  7367. export class DepthTextureCreationOptions {
  7368. /** Specifies whether or not a stencil should be allocated in the texture */
  7369. generateStencil?: boolean;
  7370. /** Specifies whether or not bilinear filtering is enable on the texture */
  7371. bilinearFiltering?: boolean;
  7372. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7373. comparisonFunction?: number;
  7374. /** Specifies if the created texture is a cube texture */
  7375. isCube?: boolean;
  7376. }
  7377. }
  7378. declare module BABYLON {
  7379. interface ThinEngine {
  7380. /**
  7381. * Creates a depth stencil cube texture.
  7382. * This is only available in WebGL 2.
  7383. * @param size The size of face edge in the cube texture.
  7384. * @param options The options defining the cube texture.
  7385. * @returns The cube texture
  7386. */
  7387. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7388. /**
  7389. * Creates a cube texture
  7390. * @param rootUrl defines the url where the files to load is located
  7391. * @param scene defines the current scene
  7392. * @param files defines the list of files to load (1 per face)
  7393. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7394. * @param onLoad defines an optional callback raised when the texture is loaded
  7395. * @param onError defines an optional callback raised if there is an issue to load the texture
  7396. * @param format defines the format of the data
  7397. * @param forcedExtension defines the extension to use to pick the right loader
  7398. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7399. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7400. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7401. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7402. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7403. * @returns the cube texture as an InternalTexture
  7404. */
  7405. 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;
  7406. /**
  7407. * Creates a cube texture
  7408. * @param rootUrl defines the url where the files to load is located
  7409. * @param scene defines the current scene
  7410. * @param files defines the list of files to load (1 per face)
  7411. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7412. * @param onLoad defines an optional callback raised when the texture is loaded
  7413. * @param onError defines an optional callback raised if there is an issue to load the texture
  7414. * @param format defines the format of the data
  7415. * @param forcedExtension defines the extension to use to pick the right loader
  7416. * @returns the cube texture as an InternalTexture
  7417. */
  7418. 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;
  7419. /**
  7420. * Creates a cube texture
  7421. * @param rootUrl defines the url where the files to load is located
  7422. * @param scene defines the current scene
  7423. * @param files defines the list of files to load (1 per face)
  7424. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7425. * @param onLoad defines an optional callback raised when the texture is loaded
  7426. * @param onError defines an optional callback raised if there is an issue to load the texture
  7427. * @param format defines the format of the data
  7428. * @param forcedExtension defines the extension to use to pick the right loader
  7429. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7430. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7431. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7432. * @returns the cube texture as an InternalTexture
  7433. */
  7434. 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;
  7435. /** @hidden */
  7436. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7437. /** @hidden */
  7438. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7439. /** @hidden */
  7440. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7441. /** @hidden */
  7442. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7443. }
  7444. }
  7445. declare module BABYLON {
  7446. /**
  7447. * Class for creating a cube texture
  7448. */
  7449. export class CubeTexture extends BaseTexture {
  7450. private _delayedOnLoad;
  7451. /**
  7452. * The url of the texture
  7453. */
  7454. url: string;
  7455. /**
  7456. * Gets or sets the center of the bounding box associated with the cube texture.
  7457. * It must define where the camera used to render the texture was set
  7458. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7459. */
  7460. boundingBoxPosition: Vector3;
  7461. private _boundingBoxSize;
  7462. /**
  7463. * Gets or sets the size of the bounding box associated with the cube texture
  7464. * When defined, the cubemap will switch to local mode
  7465. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7466. * @example https://www.babylonjs-playground.com/#RNASML
  7467. */
  7468. /**
  7469. * Returns the bounding box size
  7470. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7471. */
  7472. boundingBoxSize: Vector3;
  7473. protected _rotationY: number;
  7474. /**
  7475. * Sets texture matrix rotation angle around Y axis in radians.
  7476. */
  7477. /**
  7478. * Gets texture matrix rotation angle around Y axis radians.
  7479. */
  7480. rotationY: number;
  7481. /**
  7482. * Are mip maps generated for this texture or not.
  7483. */
  7484. readonly noMipmap: boolean;
  7485. private _noMipmap;
  7486. private _files;
  7487. protected _forcedExtension: Nullable<string>;
  7488. private _extensions;
  7489. private _textureMatrix;
  7490. private _format;
  7491. private _createPolynomials;
  7492. /** @hidden */
  7493. _prefiltered: boolean;
  7494. /**
  7495. * Creates a cube texture from an array of image urls
  7496. * @param files defines an array of image urls
  7497. * @param scene defines the hosting scene
  7498. * @param noMipmap specifies if mip maps are not used
  7499. * @returns a cube texture
  7500. */
  7501. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7502. /**
  7503. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7504. * @param url defines the url of the prefiltered texture
  7505. * @param scene defines the scene the texture is attached to
  7506. * @param forcedExtension defines the extension of the file if different from the url
  7507. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7508. * @return the prefiltered texture
  7509. */
  7510. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7511. /**
  7512. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7513. * as prefiltered data.
  7514. * @param rootUrl defines the url of the texture or the root name of the six images
  7515. * @param scene defines the scene the texture is attached to
  7516. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7517. * @param noMipmap defines if mipmaps should be created or not
  7518. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7519. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7520. * @param onError defines a callback triggered in case of error during load
  7521. * @param format defines the internal format to use for the texture once loaded
  7522. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7523. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7524. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7525. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7526. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7527. * @return the cube texture
  7528. */
  7529. 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);
  7530. /**
  7531. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7532. */
  7533. readonly isPrefiltered: boolean;
  7534. /**
  7535. * Get the current class name of the texture useful for serialization or dynamic coding.
  7536. * @returns "CubeTexture"
  7537. */
  7538. getClassName(): string;
  7539. /**
  7540. * Update the url (and optional buffer) of this texture if url was null during construction.
  7541. * @param url the url of the texture
  7542. * @param forcedExtension defines the extension to use
  7543. * @param onLoad callback called when the texture is loaded (defaults to null)
  7544. */
  7545. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7546. /**
  7547. * Delays loading of the cube texture
  7548. * @param forcedExtension defines the extension to use
  7549. */
  7550. delayLoad(forcedExtension?: string): void;
  7551. /**
  7552. * Returns the reflection texture matrix
  7553. * @returns the reflection texture matrix
  7554. */
  7555. getReflectionTextureMatrix(): Matrix;
  7556. /**
  7557. * Sets the reflection texture matrix
  7558. * @param value Reflection texture matrix
  7559. */
  7560. setReflectionTextureMatrix(value: Matrix): void;
  7561. /**
  7562. * Parses text to create a cube texture
  7563. * @param parsedTexture define the serialized text to read from
  7564. * @param scene defines the hosting scene
  7565. * @param rootUrl defines the root url of the cube texture
  7566. * @returns a cube texture
  7567. */
  7568. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7569. /**
  7570. * Makes a clone, or deep copy, of the cube texture
  7571. * @returns a new cube texture
  7572. */
  7573. clone(): CubeTexture;
  7574. }
  7575. }
  7576. declare module BABYLON {
  7577. /**
  7578. * Manages the defines for the Material
  7579. */
  7580. export class MaterialDefines {
  7581. /** @hidden */
  7582. protected _keys: string[];
  7583. private _isDirty;
  7584. /** @hidden */
  7585. _renderId: number;
  7586. /** @hidden */
  7587. _areLightsDirty: boolean;
  7588. /** @hidden */
  7589. _areLightsDisposed: boolean;
  7590. /** @hidden */
  7591. _areAttributesDirty: boolean;
  7592. /** @hidden */
  7593. _areTexturesDirty: boolean;
  7594. /** @hidden */
  7595. _areFresnelDirty: boolean;
  7596. /** @hidden */
  7597. _areMiscDirty: boolean;
  7598. /** @hidden */
  7599. _areImageProcessingDirty: boolean;
  7600. /** @hidden */
  7601. _normals: boolean;
  7602. /** @hidden */
  7603. _uvs: boolean;
  7604. /** @hidden */
  7605. _needNormals: boolean;
  7606. /** @hidden */
  7607. _needUVs: boolean;
  7608. [id: string]: any;
  7609. /**
  7610. * Specifies if the material needs to be re-calculated
  7611. */
  7612. readonly isDirty: boolean;
  7613. /**
  7614. * Marks the material to indicate that it has been re-calculated
  7615. */
  7616. markAsProcessed(): void;
  7617. /**
  7618. * Marks the material to indicate that it needs to be re-calculated
  7619. */
  7620. markAsUnprocessed(): void;
  7621. /**
  7622. * Marks the material to indicate all of its defines need to be re-calculated
  7623. */
  7624. markAllAsDirty(): void;
  7625. /**
  7626. * Marks the material to indicate that image processing needs to be re-calculated
  7627. */
  7628. markAsImageProcessingDirty(): void;
  7629. /**
  7630. * Marks the material to indicate the lights need to be re-calculated
  7631. * @param disposed Defines whether the light is dirty due to dispose or not
  7632. */
  7633. markAsLightDirty(disposed?: boolean): void;
  7634. /**
  7635. * Marks the attribute state as changed
  7636. */
  7637. markAsAttributesDirty(): void;
  7638. /**
  7639. * Marks the texture state as changed
  7640. */
  7641. markAsTexturesDirty(): void;
  7642. /**
  7643. * Marks the fresnel state as changed
  7644. */
  7645. markAsFresnelDirty(): void;
  7646. /**
  7647. * Marks the misc state as changed
  7648. */
  7649. markAsMiscDirty(): void;
  7650. /**
  7651. * Rebuilds the material defines
  7652. */
  7653. rebuild(): void;
  7654. /**
  7655. * Specifies if two material defines are equal
  7656. * @param other - A material define instance to compare to
  7657. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7658. */
  7659. isEqual(other: MaterialDefines): boolean;
  7660. /**
  7661. * Clones this instance's defines to another instance
  7662. * @param other - material defines to clone values to
  7663. */
  7664. cloneTo(other: MaterialDefines): void;
  7665. /**
  7666. * Resets the material define values
  7667. */
  7668. reset(): void;
  7669. /**
  7670. * Converts the material define values to a string
  7671. * @returns - String of material define information
  7672. */
  7673. toString(): string;
  7674. }
  7675. }
  7676. declare module BABYLON {
  7677. /**
  7678. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7679. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7680. * 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;
  7681. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7682. */
  7683. export class ColorCurves {
  7684. private _dirty;
  7685. private _tempColor;
  7686. private _globalCurve;
  7687. private _highlightsCurve;
  7688. private _midtonesCurve;
  7689. private _shadowsCurve;
  7690. private _positiveCurve;
  7691. private _negativeCurve;
  7692. private _globalHue;
  7693. private _globalDensity;
  7694. private _globalSaturation;
  7695. private _globalExposure;
  7696. /**
  7697. * Gets the global Hue value.
  7698. * 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).
  7699. */
  7700. /**
  7701. * Sets the global Hue value.
  7702. * 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).
  7703. */
  7704. globalHue: number;
  7705. /**
  7706. * Gets the global Density value.
  7707. * 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.
  7708. * Values less than zero provide a filter of opposite hue.
  7709. */
  7710. /**
  7711. * Sets the global Density value.
  7712. * 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.
  7713. * Values less than zero provide a filter of opposite hue.
  7714. */
  7715. globalDensity: number;
  7716. /**
  7717. * Gets the global Saturation value.
  7718. * 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.
  7719. */
  7720. /**
  7721. * Sets the global Saturation value.
  7722. * 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.
  7723. */
  7724. globalSaturation: number;
  7725. /**
  7726. * Gets the global Exposure value.
  7727. * 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.
  7728. */
  7729. /**
  7730. * Sets the global Exposure value.
  7731. * 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.
  7732. */
  7733. globalExposure: number;
  7734. private _highlightsHue;
  7735. private _highlightsDensity;
  7736. private _highlightsSaturation;
  7737. private _highlightsExposure;
  7738. /**
  7739. * Gets the highlights Hue value.
  7740. * 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).
  7741. */
  7742. /**
  7743. * Sets the highlights Hue value.
  7744. * 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).
  7745. */
  7746. highlightsHue: number;
  7747. /**
  7748. * Gets the highlights Density value.
  7749. * 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.
  7750. * Values less than zero provide a filter of opposite hue.
  7751. */
  7752. /**
  7753. * Sets the highlights Density value.
  7754. * 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.
  7755. * Values less than zero provide a filter of opposite hue.
  7756. */
  7757. highlightsDensity: number;
  7758. /**
  7759. * Gets the highlights Saturation value.
  7760. * 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.
  7761. */
  7762. /**
  7763. * Sets the highlights Saturation value.
  7764. * 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.
  7765. */
  7766. highlightsSaturation: number;
  7767. /**
  7768. * Gets the highlights Exposure value.
  7769. * 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.
  7770. */
  7771. /**
  7772. * Sets the highlights Exposure value.
  7773. * 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.
  7774. */
  7775. highlightsExposure: number;
  7776. private _midtonesHue;
  7777. private _midtonesDensity;
  7778. private _midtonesSaturation;
  7779. private _midtonesExposure;
  7780. /**
  7781. * Gets the midtones Hue value.
  7782. * 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).
  7783. */
  7784. /**
  7785. * Sets the midtones Hue value.
  7786. * 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).
  7787. */
  7788. midtonesHue: number;
  7789. /**
  7790. * Gets the midtones Density value.
  7791. * 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.
  7792. * Values less than zero provide a filter of opposite hue.
  7793. */
  7794. /**
  7795. * Sets the midtones Density value.
  7796. * 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.
  7797. * Values less than zero provide a filter of opposite hue.
  7798. */
  7799. midtonesDensity: number;
  7800. /**
  7801. * Gets the midtones Saturation value.
  7802. * 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.
  7803. */
  7804. /**
  7805. * Sets the midtones Saturation value.
  7806. * 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.
  7807. */
  7808. midtonesSaturation: number;
  7809. /**
  7810. * Gets the midtones Exposure value.
  7811. * 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.
  7812. */
  7813. /**
  7814. * Sets the midtones Exposure value.
  7815. * 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.
  7816. */
  7817. midtonesExposure: number;
  7818. private _shadowsHue;
  7819. private _shadowsDensity;
  7820. private _shadowsSaturation;
  7821. private _shadowsExposure;
  7822. /**
  7823. * Gets the shadows Hue value.
  7824. * 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).
  7825. */
  7826. /**
  7827. * Sets the shadows Hue value.
  7828. * 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).
  7829. */
  7830. shadowsHue: number;
  7831. /**
  7832. * Gets the shadows Density value.
  7833. * 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.
  7834. * Values less than zero provide a filter of opposite hue.
  7835. */
  7836. /**
  7837. * Sets the shadows Density value.
  7838. * 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.
  7839. * Values less than zero provide a filter of opposite hue.
  7840. */
  7841. shadowsDensity: number;
  7842. /**
  7843. * Gets the shadows Saturation value.
  7844. * 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.
  7845. */
  7846. /**
  7847. * Sets the shadows Saturation value.
  7848. * 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.
  7849. */
  7850. shadowsSaturation: number;
  7851. /**
  7852. * Gets the shadows Exposure value.
  7853. * 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.
  7854. */
  7855. /**
  7856. * Sets the shadows Exposure value.
  7857. * 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.
  7858. */
  7859. shadowsExposure: number;
  7860. /**
  7861. * Returns the class name
  7862. * @returns The class name
  7863. */
  7864. getClassName(): string;
  7865. /**
  7866. * Binds the color curves to the shader.
  7867. * @param colorCurves The color curve to bind
  7868. * @param effect The effect to bind to
  7869. * @param positiveUniform The positive uniform shader parameter
  7870. * @param neutralUniform The neutral uniform shader parameter
  7871. * @param negativeUniform The negative uniform shader parameter
  7872. */
  7873. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7874. /**
  7875. * Prepare the list of uniforms associated with the ColorCurves effects.
  7876. * @param uniformsList The list of uniforms used in the effect
  7877. */
  7878. static PrepareUniforms(uniformsList: string[]): void;
  7879. /**
  7880. * Returns color grading data based on a hue, density, saturation and exposure value.
  7881. * @param filterHue The hue of the color filter.
  7882. * @param filterDensity The density of the color filter.
  7883. * @param saturation The saturation.
  7884. * @param exposure The exposure.
  7885. * @param result The result data container.
  7886. */
  7887. private getColorGradingDataToRef;
  7888. /**
  7889. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7890. * @param value The input slider value in range [-100,100].
  7891. * @returns Adjusted value.
  7892. */
  7893. private static applyColorGradingSliderNonlinear;
  7894. /**
  7895. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7896. * @param hue The hue (H) input.
  7897. * @param saturation The saturation (S) input.
  7898. * @param brightness The brightness (B) input.
  7899. * @result An RGBA color represented as Vector4.
  7900. */
  7901. private static fromHSBToRef;
  7902. /**
  7903. * Returns a value clamped between min and max
  7904. * @param value The value to clamp
  7905. * @param min The minimum of value
  7906. * @param max The maximum of value
  7907. * @returns The clamped value.
  7908. */
  7909. private static clamp;
  7910. /**
  7911. * Clones the current color curve instance.
  7912. * @return The cloned curves
  7913. */
  7914. clone(): ColorCurves;
  7915. /**
  7916. * Serializes the current color curve instance to a json representation.
  7917. * @return a JSON representation
  7918. */
  7919. serialize(): any;
  7920. /**
  7921. * Parses the color curve from a json representation.
  7922. * @param source the JSON source to parse
  7923. * @return The parsed curves
  7924. */
  7925. static Parse(source: any): ColorCurves;
  7926. }
  7927. }
  7928. declare module BABYLON {
  7929. /**
  7930. * Interface to follow in your material defines to integrate easily the
  7931. * Image proccessing functions.
  7932. * @hidden
  7933. */
  7934. export interface IImageProcessingConfigurationDefines {
  7935. IMAGEPROCESSING: boolean;
  7936. VIGNETTE: boolean;
  7937. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7938. VIGNETTEBLENDMODEOPAQUE: boolean;
  7939. TONEMAPPING: boolean;
  7940. TONEMAPPING_ACES: boolean;
  7941. CONTRAST: boolean;
  7942. EXPOSURE: boolean;
  7943. COLORCURVES: boolean;
  7944. COLORGRADING: boolean;
  7945. COLORGRADING3D: boolean;
  7946. SAMPLER3DGREENDEPTH: boolean;
  7947. SAMPLER3DBGRMAP: boolean;
  7948. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7949. }
  7950. /**
  7951. * @hidden
  7952. */
  7953. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7954. IMAGEPROCESSING: boolean;
  7955. VIGNETTE: boolean;
  7956. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7957. VIGNETTEBLENDMODEOPAQUE: boolean;
  7958. TONEMAPPING: boolean;
  7959. TONEMAPPING_ACES: boolean;
  7960. CONTRAST: boolean;
  7961. COLORCURVES: boolean;
  7962. COLORGRADING: boolean;
  7963. COLORGRADING3D: boolean;
  7964. SAMPLER3DGREENDEPTH: boolean;
  7965. SAMPLER3DBGRMAP: boolean;
  7966. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7967. EXPOSURE: boolean;
  7968. constructor();
  7969. }
  7970. /**
  7971. * This groups together the common properties used for image processing either in direct forward pass
  7972. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7973. * or not.
  7974. */
  7975. export class ImageProcessingConfiguration {
  7976. /**
  7977. * Default tone mapping applied in BabylonJS.
  7978. */
  7979. static readonly TONEMAPPING_STANDARD: number;
  7980. /**
  7981. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7982. * to other engines rendering to increase portability.
  7983. */
  7984. static readonly TONEMAPPING_ACES: number;
  7985. /**
  7986. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7987. */
  7988. colorCurves: Nullable<ColorCurves>;
  7989. private _colorCurvesEnabled;
  7990. /**
  7991. * Gets wether the color curves effect is enabled.
  7992. */
  7993. /**
  7994. * Sets wether the color curves effect is enabled.
  7995. */
  7996. colorCurvesEnabled: boolean;
  7997. private _colorGradingTexture;
  7998. /**
  7999. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8000. */
  8001. /**
  8002. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8003. */
  8004. colorGradingTexture: Nullable<BaseTexture>;
  8005. private _colorGradingEnabled;
  8006. /**
  8007. * Gets wether the color grading effect is enabled.
  8008. */
  8009. /**
  8010. * Sets wether the color grading effect is enabled.
  8011. */
  8012. colorGradingEnabled: boolean;
  8013. private _colorGradingWithGreenDepth;
  8014. /**
  8015. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8016. */
  8017. /**
  8018. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8019. */
  8020. colorGradingWithGreenDepth: boolean;
  8021. private _colorGradingBGR;
  8022. /**
  8023. * Gets wether the color grading texture contains BGR values.
  8024. */
  8025. /**
  8026. * Sets wether the color grading texture contains BGR values.
  8027. */
  8028. colorGradingBGR: boolean;
  8029. /** @hidden */
  8030. _exposure: number;
  8031. /**
  8032. * Gets the Exposure used in the effect.
  8033. */
  8034. /**
  8035. * Sets the Exposure used in the effect.
  8036. */
  8037. exposure: number;
  8038. private _toneMappingEnabled;
  8039. /**
  8040. * Gets wether the tone mapping effect is enabled.
  8041. */
  8042. /**
  8043. * Sets wether the tone mapping effect is enabled.
  8044. */
  8045. toneMappingEnabled: boolean;
  8046. private _toneMappingType;
  8047. /**
  8048. * Gets the type of tone mapping effect.
  8049. */
  8050. /**
  8051. * Sets the type of tone mapping effect used in BabylonJS.
  8052. */
  8053. toneMappingType: number;
  8054. protected _contrast: number;
  8055. /**
  8056. * Gets the contrast used in the effect.
  8057. */
  8058. /**
  8059. * Sets the contrast used in the effect.
  8060. */
  8061. contrast: number;
  8062. /**
  8063. * Vignette stretch size.
  8064. */
  8065. vignetteStretch: number;
  8066. /**
  8067. * Vignette centre X Offset.
  8068. */
  8069. vignetteCentreX: number;
  8070. /**
  8071. * Vignette centre Y Offset.
  8072. */
  8073. vignetteCentreY: number;
  8074. /**
  8075. * Vignette weight or intensity of the vignette effect.
  8076. */
  8077. vignetteWeight: number;
  8078. /**
  8079. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8080. * if vignetteEnabled is set to true.
  8081. */
  8082. vignetteColor: Color4;
  8083. /**
  8084. * Camera field of view used by the Vignette effect.
  8085. */
  8086. vignetteCameraFov: number;
  8087. private _vignetteBlendMode;
  8088. /**
  8089. * Gets the vignette blend mode allowing different kind of effect.
  8090. */
  8091. /**
  8092. * Sets the vignette blend mode allowing different kind of effect.
  8093. */
  8094. vignetteBlendMode: number;
  8095. private _vignetteEnabled;
  8096. /**
  8097. * Gets wether the vignette effect is enabled.
  8098. */
  8099. /**
  8100. * Sets wether the vignette effect is enabled.
  8101. */
  8102. vignetteEnabled: boolean;
  8103. private _applyByPostProcess;
  8104. /**
  8105. * Gets wether the image processing is applied through a post process or not.
  8106. */
  8107. /**
  8108. * Sets wether the image processing is applied through a post process or not.
  8109. */
  8110. applyByPostProcess: boolean;
  8111. private _isEnabled;
  8112. /**
  8113. * Gets wether the image processing is enabled or not.
  8114. */
  8115. /**
  8116. * Sets wether the image processing is enabled or not.
  8117. */
  8118. isEnabled: boolean;
  8119. /**
  8120. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8121. */
  8122. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8123. /**
  8124. * Method called each time the image processing information changes requires to recompile the effect.
  8125. */
  8126. protected _updateParameters(): void;
  8127. /**
  8128. * Gets the current class name.
  8129. * @return "ImageProcessingConfiguration"
  8130. */
  8131. getClassName(): string;
  8132. /**
  8133. * Prepare the list of uniforms associated with the Image Processing effects.
  8134. * @param uniforms The list of uniforms used in the effect
  8135. * @param defines the list of defines currently in use
  8136. */
  8137. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8138. /**
  8139. * Prepare the list of samplers associated with the Image Processing effects.
  8140. * @param samplersList The list of uniforms used in the effect
  8141. * @param defines the list of defines currently in use
  8142. */
  8143. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8144. /**
  8145. * Prepare the list of defines associated to the shader.
  8146. * @param defines the list of defines to complete
  8147. * @param forPostProcess Define if we are currently in post process mode or not
  8148. */
  8149. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8150. /**
  8151. * Returns true if all the image processing information are ready.
  8152. * @returns True if ready, otherwise, false
  8153. */
  8154. isReady(): boolean;
  8155. /**
  8156. * Binds the image processing to the shader.
  8157. * @param effect The effect to bind to
  8158. * @param aspectRatio Define the current aspect ratio of the effect
  8159. */
  8160. bind(effect: Effect, aspectRatio?: number): void;
  8161. /**
  8162. * Clones the current image processing instance.
  8163. * @return The cloned image processing
  8164. */
  8165. clone(): ImageProcessingConfiguration;
  8166. /**
  8167. * Serializes the current image processing instance to a json representation.
  8168. * @return a JSON representation
  8169. */
  8170. serialize(): any;
  8171. /**
  8172. * Parses the image processing from a json representation.
  8173. * @param source the JSON source to parse
  8174. * @return The parsed image processing
  8175. */
  8176. static Parse(source: any): ImageProcessingConfiguration;
  8177. private static _VIGNETTEMODE_MULTIPLY;
  8178. private static _VIGNETTEMODE_OPAQUE;
  8179. /**
  8180. * Used to apply the vignette as a mix with the pixel color.
  8181. */
  8182. static readonly VIGNETTEMODE_MULTIPLY: number;
  8183. /**
  8184. * Used to apply the vignette as a replacement of the pixel color.
  8185. */
  8186. static readonly VIGNETTEMODE_OPAQUE: number;
  8187. }
  8188. }
  8189. declare module BABYLON {
  8190. /** @hidden */
  8191. export var postprocessVertexShader: {
  8192. name: string;
  8193. shader: string;
  8194. };
  8195. }
  8196. declare module BABYLON {
  8197. interface ThinEngine {
  8198. /**
  8199. * Creates a new render target texture
  8200. * @param size defines the size of the texture
  8201. * @param options defines the options used to create the texture
  8202. * @returns a new render target texture stored in an InternalTexture
  8203. */
  8204. createRenderTargetTexture(size: number | {
  8205. width: number;
  8206. height: number;
  8207. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8208. }
  8209. }
  8210. declare module BABYLON {
  8211. /** Defines supported spaces */
  8212. export enum Space {
  8213. /** Local (object) space */
  8214. LOCAL = 0,
  8215. /** World space */
  8216. WORLD = 1,
  8217. /** Bone space */
  8218. BONE = 2
  8219. }
  8220. /** Defines the 3 main axes */
  8221. export class Axis {
  8222. /** X axis */
  8223. static X: Vector3;
  8224. /** Y axis */
  8225. static Y: Vector3;
  8226. /** Z axis */
  8227. static Z: Vector3;
  8228. }
  8229. }
  8230. declare module BABYLON {
  8231. /**
  8232. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8233. * This is the base of the follow, arc rotate cameras and Free camera
  8234. * @see http://doc.babylonjs.com/features/cameras
  8235. */
  8236. export class TargetCamera extends Camera {
  8237. private static _RigCamTransformMatrix;
  8238. private static _TargetTransformMatrix;
  8239. private static _TargetFocalPoint;
  8240. /**
  8241. * Define the current direction the camera is moving to
  8242. */
  8243. cameraDirection: Vector3;
  8244. /**
  8245. * Define the current rotation the camera is rotating to
  8246. */
  8247. cameraRotation: Vector2;
  8248. /**
  8249. * When set, the up vector of the camera will be updated by the rotation of the camera
  8250. */
  8251. updateUpVectorFromRotation: boolean;
  8252. private _tmpQuaternion;
  8253. /**
  8254. * Define the current rotation of the camera
  8255. */
  8256. rotation: Vector3;
  8257. /**
  8258. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8259. */
  8260. rotationQuaternion: Quaternion;
  8261. /**
  8262. * Define the current speed of the camera
  8263. */
  8264. speed: number;
  8265. /**
  8266. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8267. * around all axis.
  8268. */
  8269. noRotationConstraint: boolean;
  8270. /**
  8271. * Define the current target of the camera as an object or a position.
  8272. */
  8273. lockedTarget: any;
  8274. /** @hidden */
  8275. _currentTarget: Vector3;
  8276. /** @hidden */
  8277. _initialFocalDistance: number;
  8278. /** @hidden */
  8279. _viewMatrix: Matrix;
  8280. /** @hidden */
  8281. _camMatrix: Matrix;
  8282. /** @hidden */
  8283. _cameraTransformMatrix: Matrix;
  8284. /** @hidden */
  8285. _cameraRotationMatrix: Matrix;
  8286. /** @hidden */
  8287. _referencePoint: Vector3;
  8288. /** @hidden */
  8289. _transformedReferencePoint: Vector3;
  8290. protected _globalCurrentTarget: Vector3;
  8291. protected _globalCurrentUpVector: Vector3;
  8292. /** @hidden */
  8293. _reset: () => void;
  8294. private _defaultUp;
  8295. /**
  8296. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8297. * This is the base of the follow, arc rotate cameras and Free camera
  8298. * @see http://doc.babylonjs.com/features/cameras
  8299. * @param name Defines the name of the camera in the scene
  8300. * @param position Defines the start position of the camera in the scene
  8301. * @param scene Defines the scene the camera belongs to
  8302. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8303. */
  8304. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8305. /**
  8306. * Gets the position in front of the camera at a given distance.
  8307. * @param distance The distance from the camera we want the position to be
  8308. * @returns the position
  8309. */
  8310. getFrontPosition(distance: number): Vector3;
  8311. /** @hidden */
  8312. _getLockedTargetPosition(): Nullable<Vector3>;
  8313. private _storedPosition;
  8314. private _storedRotation;
  8315. private _storedRotationQuaternion;
  8316. /**
  8317. * Store current camera state of the camera (fov, position, rotation, etc..)
  8318. * @returns the camera
  8319. */
  8320. storeState(): Camera;
  8321. /**
  8322. * Restored camera state. You must call storeState() first
  8323. * @returns whether it was successful or not
  8324. * @hidden
  8325. */
  8326. _restoreStateValues(): boolean;
  8327. /** @hidden */
  8328. _initCache(): void;
  8329. /** @hidden */
  8330. _updateCache(ignoreParentClass?: boolean): void;
  8331. /** @hidden */
  8332. _isSynchronizedViewMatrix(): boolean;
  8333. /** @hidden */
  8334. _computeLocalCameraSpeed(): number;
  8335. /**
  8336. * Defines the target the camera should look at.
  8337. * @param target Defines the new target as a Vector or a mesh
  8338. */
  8339. setTarget(target: Vector3): void;
  8340. /**
  8341. * Return the current target position of the camera. This value is expressed in local space.
  8342. * @returns the target position
  8343. */
  8344. getTarget(): Vector3;
  8345. /** @hidden */
  8346. _decideIfNeedsToMove(): boolean;
  8347. /** @hidden */
  8348. _updatePosition(): void;
  8349. /** @hidden */
  8350. _checkInputs(): void;
  8351. protected _updateCameraRotationMatrix(): void;
  8352. /**
  8353. * 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)
  8354. * @returns the current camera
  8355. */
  8356. private _rotateUpVectorWithCameraRotationMatrix;
  8357. private _cachedRotationZ;
  8358. private _cachedQuaternionRotationZ;
  8359. /** @hidden */
  8360. _getViewMatrix(): Matrix;
  8361. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8362. /**
  8363. * @hidden
  8364. */
  8365. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8366. /**
  8367. * @hidden
  8368. */
  8369. _updateRigCameras(): void;
  8370. private _getRigCamPositionAndTarget;
  8371. /**
  8372. * Gets the current object class name.
  8373. * @return the class name
  8374. */
  8375. getClassName(): string;
  8376. }
  8377. }
  8378. declare module BABYLON {
  8379. /**
  8380. * Gather the list of keyboard event types as constants.
  8381. */
  8382. export class KeyboardEventTypes {
  8383. /**
  8384. * The keydown event is fired when a key becomes active (pressed).
  8385. */
  8386. static readonly KEYDOWN: number;
  8387. /**
  8388. * The keyup event is fired when a key has been released.
  8389. */
  8390. static readonly KEYUP: number;
  8391. }
  8392. /**
  8393. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8394. */
  8395. export class KeyboardInfo {
  8396. /**
  8397. * Defines the type of event (KeyboardEventTypes)
  8398. */
  8399. type: number;
  8400. /**
  8401. * Defines the related dom event
  8402. */
  8403. event: KeyboardEvent;
  8404. /**
  8405. * Instantiates a new keyboard info.
  8406. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8407. * @param type Defines the type of event (KeyboardEventTypes)
  8408. * @param event Defines the related dom event
  8409. */
  8410. constructor(
  8411. /**
  8412. * Defines the type of event (KeyboardEventTypes)
  8413. */
  8414. type: number,
  8415. /**
  8416. * Defines the related dom event
  8417. */
  8418. event: KeyboardEvent);
  8419. }
  8420. /**
  8421. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8422. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8423. */
  8424. export class KeyboardInfoPre extends KeyboardInfo {
  8425. /**
  8426. * Defines the type of event (KeyboardEventTypes)
  8427. */
  8428. type: number;
  8429. /**
  8430. * Defines the related dom event
  8431. */
  8432. event: KeyboardEvent;
  8433. /**
  8434. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8435. */
  8436. skipOnPointerObservable: boolean;
  8437. /**
  8438. * Instantiates a new keyboard pre info.
  8439. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8440. * @param type Defines the type of event (KeyboardEventTypes)
  8441. * @param event Defines the related dom event
  8442. */
  8443. constructor(
  8444. /**
  8445. * Defines the type of event (KeyboardEventTypes)
  8446. */
  8447. type: number,
  8448. /**
  8449. * Defines the related dom event
  8450. */
  8451. event: KeyboardEvent);
  8452. }
  8453. }
  8454. declare module BABYLON {
  8455. /**
  8456. * Manage the keyboard inputs to control the movement of a free camera.
  8457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8458. */
  8459. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8460. /**
  8461. * Defines the camera the input is attached to.
  8462. */
  8463. camera: FreeCamera;
  8464. /**
  8465. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8466. */
  8467. keysUp: number[];
  8468. /**
  8469. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8470. */
  8471. keysDown: number[];
  8472. /**
  8473. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8474. */
  8475. keysLeft: number[];
  8476. /**
  8477. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8478. */
  8479. keysRight: number[];
  8480. private _keys;
  8481. private _onCanvasBlurObserver;
  8482. private _onKeyboardObserver;
  8483. private _engine;
  8484. private _scene;
  8485. /**
  8486. * Attach the input controls to a specific dom element to get the input from.
  8487. * @param element Defines the element the controls should be listened from
  8488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8489. */
  8490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8491. /**
  8492. * Detach the current controls from the specified dom element.
  8493. * @param element Defines the element to stop listening the inputs from
  8494. */
  8495. detachControl(element: Nullable<HTMLElement>): void;
  8496. /**
  8497. * Update the current camera state depending on the inputs that have been used this frame.
  8498. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8499. */
  8500. checkInputs(): void;
  8501. /**
  8502. * Gets the class name of the current intput.
  8503. * @returns the class name
  8504. */
  8505. getClassName(): string;
  8506. /** @hidden */
  8507. _onLostFocus(): void;
  8508. /**
  8509. * Get the friendly name associated with the input class.
  8510. * @returns the input friendly name
  8511. */
  8512. getSimpleName(): string;
  8513. }
  8514. }
  8515. declare module BABYLON {
  8516. /**
  8517. * Interface describing all the common properties and methods a shadow light needs to implement.
  8518. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8519. * as well as binding the different shadow properties to the effects.
  8520. */
  8521. export interface IShadowLight extends Light {
  8522. /**
  8523. * The light id in the scene (used in scene.findLighById for instance)
  8524. */
  8525. id: string;
  8526. /**
  8527. * The position the shdow will be casted from.
  8528. */
  8529. position: Vector3;
  8530. /**
  8531. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8532. */
  8533. direction: Vector3;
  8534. /**
  8535. * The transformed position. Position of the light in world space taking parenting in account.
  8536. */
  8537. transformedPosition: Vector3;
  8538. /**
  8539. * The transformed direction. Direction of the light in world space taking parenting in account.
  8540. */
  8541. transformedDirection: Vector3;
  8542. /**
  8543. * The friendly name of the light in the scene.
  8544. */
  8545. name: string;
  8546. /**
  8547. * Defines the shadow projection clipping minimum z value.
  8548. */
  8549. shadowMinZ: number;
  8550. /**
  8551. * Defines the shadow projection clipping maximum z value.
  8552. */
  8553. shadowMaxZ: number;
  8554. /**
  8555. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8556. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8557. */
  8558. computeTransformedInformation(): boolean;
  8559. /**
  8560. * Gets the scene the light belongs to.
  8561. * @returns The scene
  8562. */
  8563. getScene(): Scene;
  8564. /**
  8565. * Callback defining a custom Projection Matrix Builder.
  8566. * This can be used to override the default projection matrix computation.
  8567. */
  8568. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8569. /**
  8570. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8571. * @param matrix The materix to updated with the projection information
  8572. * @param viewMatrix The transform matrix of the light
  8573. * @param renderList The list of mesh to render in the map
  8574. * @returns The current light
  8575. */
  8576. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8577. /**
  8578. * Gets the current depth scale used in ESM.
  8579. * @returns The scale
  8580. */
  8581. getDepthScale(): number;
  8582. /**
  8583. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8584. * @returns true if a cube texture needs to be use
  8585. */
  8586. needCube(): boolean;
  8587. /**
  8588. * Detects if the projection matrix requires to be recomputed this frame.
  8589. * @returns true if it requires to be recomputed otherwise, false.
  8590. */
  8591. needProjectionMatrixCompute(): boolean;
  8592. /**
  8593. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8594. */
  8595. forceProjectionMatrixCompute(): void;
  8596. /**
  8597. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8598. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8599. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8600. */
  8601. getShadowDirection(faceIndex?: number): Vector3;
  8602. /**
  8603. * Gets the minZ used for shadow according to both the scene and the light.
  8604. * @param activeCamera The camera we are returning the min for
  8605. * @returns the depth min z
  8606. */
  8607. getDepthMinZ(activeCamera: Camera): number;
  8608. /**
  8609. * Gets the maxZ used for shadow according to both the scene and the light.
  8610. * @param activeCamera The camera we are returning the max for
  8611. * @returns the depth max z
  8612. */
  8613. getDepthMaxZ(activeCamera: Camera): number;
  8614. }
  8615. /**
  8616. * Base implementation IShadowLight
  8617. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8618. */
  8619. export abstract class ShadowLight extends Light implements IShadowLight {
  8620. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8621. protected _position: Vector3;
  8622. protected _setPosition(value: Vector3): void;
  8623. /**
  8624. * Sets the position the shadow will be casted from. Also use as the light position for both
  8625. * point and spot lights.
  8626. */
  8627. /**
  8628. * Sets the position the shadow will be casted from. Also use as the light position for both
  8629. * point and spot lights.
  8630. */
  8631. position: Vector3;
  8632. protected _direction: Vector3;
  8633. protected _setDirection(value: Vector3): void;
  8634. /**
  8635. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8636. * Also use as the light direction on spot and directional lights.
  8637. */
  8638. /**
  8639. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8640. * Also use as the light direction on spot and directional lights.
  8641. */
  8642. direction: Vector3;
  8643. private _shadowMinZ;
  8644. /**
  8645. * Gets the shadow projection clipping minimum z value.
  8646. */
  8647. /**
  8648. * Sets the shadow projection clipping minimum z value.
  8649. */
  8650. shadowMinZ: number;
  8651. private _shadowMaxZ;
  8652. /**
  8653. * Sets the shadow projection clipping maximum z value.
  8654. */
  8655. /**
  8656. * Gets the shadow projection clipping maximum z value.
  8657. */
  8658. shadowMaxZ: number;
  8659. /**
  8660. * Callback defining a custom Projection Matrix Builder.
  8661. * This can be used to override the default projection matrix computation.
  8662. */
  8663. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8664. /**
  8665. * The transformed position. Position of the light in world space taking parenting in account.
  8666. */
  8667. transformedPosition: Vector3;
  8668. /**
  8669. * The transformed direction. Direction of the light in world space taking parenting in account.
  8670. */
  8671. transformedDirection: Vector3;
  8672. private _needProjectionMatrixCompute;
  8673. /**
  8674. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8675. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8676. */
  8677. computeTransformedInformation(): boolean;
  8678. /**
  8679. * Return the depth scale used for the shadow map.
  8680. * @returns the depth scale.
  8681. */
  8682. getDepthScale(): number;
  8683. /**
  8684. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8685. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8686. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8687. */
  8688. getShadowDirection(faceIndex?: number): Vector3;
  8689. /**
  8690. * Returns the ShadowLight absolute position in the World.
  8691. * @returns the position vector in world space
  8692. */
  8693. getAbsolutePosition(): Vector3;
  8694. /**
  8695. * Sets the ShadowLight direction toward the passed target.
  8696. * @param target The point to target in local space
  8697. * @returns the updated ShadowLight direction
  8698. */
  8699. setDirectionToTarget(target: Vector3): Vector3;
  8700. /**
  8701. * Returns the light rotation in euler definition.
  8702. * @returns the x y z rotation in local space.
  8703. */
  8704. getRotation(): Vector3;
  8705. /**
  8706. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8707. * @returns true if a cube texture needs to be use
  8708. */
  8709. needCube(): boolean;
  8710. /**
  8711. * Detects if the projection matrix requires to be recomputed this frame.
  8712. * @returns true if it requires to be recomputed otherwise, false.
  8713. */
  8714. needProjectionMatrixCompute(): boolean;
  8715. /**
  8716. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8717. */
  8718. forceProjectionMatrixCompute(): void;
  8719. /** @hidden */
  8720. _initCache(): void;
  8721. /** @hidden */
  8722. _isSynchronized(): boolean;
  8723. /**
  8724. * Computes the world matrix of the node
  8725. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8726. * @returns the world matrix
  8727. */
  8728. computeWorldMatrix(force?: boolean): Matrix;
  8729. /**
  8730. * Gets the minZ used for shadow according to both the scene and the light.
  8731. * @param activeCamera The camera we are returning the min for
  8732. * @returns the depth min z
  8733. */
  8734. getDepthMinZ(activeCamera: Camera): number;
  8735. /**
  8736. * Gets the maxZ used for shadow according to both the scene and the light.
  8737. * @param activeCamera The camera we are returning the max for
  8738. * @returns the depth max z
  8739. */
  8740. getDepthMaxZ(activeCamera: Camera): number;
  8741. /**
  8742. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8743. * @param matrix The materix to updated with the projection information
  8744. * @param viewMatrix The transform matrix of the light
  8745. * @param renderList The list of mesh to render in the map
  8746. * @returns The current light
  8747. */
  8748. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8749. }
  8750. }
  8751. declare module BABYLON {
  8752. /**
  8753. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8754. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8755. */
  8756. export class EffectFallbacks implements IEffectFallbacks {
  8757. private _defines;
  8758. private _currentRank;
  8759. private _maxRank;
  8760. private _mesh;
  8761. /**
  8762. * Removes the fallback from the bound mesh.
  8763. */
  8764. unBindMesh(): void;
  8765. /**
  8766. * Adds a fallback on the specified property.
  8767. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8768. * @param define The name of the define in the shader
  8769. */
  8770. addFallback(rank: number, define: string): void;
  8771. /**
  8772. * Sets the mesh to use CPU skinning when needing to fallback.
  8773. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8774. * @param mesh The mesh to use the fallbacks.
  8775. */
  8776. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8777. /**
  8778. * Checks to see if more fallbacks are still availible.
  8779. */
  8780. readonly hasMoreFallbacks: boolean;
  8781. /**
  8782. * Removes the defines that should be removed when falling back.
  8783. * @param currentDefines defines the current define statements for the shader.
  8784. * @param effect defines the current effect we try to compile
  8785. * @returns The resulting defines with defines of the current rank removed.
  8786. */
  8787. reduce(currentDefines: string, effect: Effect): string;
  8788. }
  8789. }
  8790. declare module BABYLON {
  8791. /**
  8792. * "Static Class" containing the most commonly used helper while dealing with material for
  8793. * rendering purpose.
  8794. *
  8795. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8796. *
  8797. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8798. */
  8799. export class MaterialHelper {
  8800. /**
  8801. * Bind the current view position to an effect.
  8802. * @param effect The effect to be bound
  8803. * @param scene The scene the eyes position is used from
  8804. */
  8805. static BindEyePosition(effect: Effect, scene: Scene): void;
  8806. /**
  8807. * Helps preparing the defines values about the UVs in used in the effect.
  8808. * UVs are shared as much as we can accross channels in the shaders.
  8809. * @param texture The texture we are preparing the UVs for
  8810. * @param defines The defines to update
  8811. * @param key The channel key "diffuse", "specular"... used in the shader
  8812. */
  8813. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8814. /**
  8815. * Binds a texture matrix value to its corrsponding uniform
  8816. * @param texture The texture to bind the matrix for
  8817. * @param uniformBuffer The uniform buffer receivin the data
  8818. * @param key The channel key "diffuse", "specular"... used in the shader
  8819. */
  8820. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8821. /**
  8822. * Gets the current status of the fog (should it be enabled?)
  8823. * @param mesh defines the mesh to evaluate for fog support
  8824. * @param scene defines the hosting scene
  8825. * @returns true if fog must be enabled
  8826. */
  8827. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8828. /**
  8829. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8830. * @param mesh defines the current mesh
  8831. * @param scene defines the current scene
  8832. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8833. * @param pointsCloud defines if point cloud rendering has to be turned on
  8834. * @param fogEnabled defines if fog has to be turned on
  8835. * @param alphaTest defines if alpha testing has to be turned on
  8836. * @param defines defines the current list of defines
  8837. */
  8838. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8839. /**
  8840. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8841. * @param scene defines the current scene
  8842. * @param engine defines the current engine
  8843. * @param defines specifies the list of active defines
  8844. * @param useInstances defines if instances have to be turned on
  8845. * @param useClipPlane defines if clip plane have to be turned on
  8846. */
  8847. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8848. /**
  8849. * Prepares the defines for bones
  8850. * @param mesh The mesh containing the geometry data we will draw
  8851. * @param defines The defines to update
  8852. */
  8853. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8854. /**
  8855. * Prepares the defines for morph targets
  8856. * @param mesh The mesh containing the geometry data we will draw
  8857. * @param defines The defines to update
  8858. */
  8859. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8860. /**
  8861. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8862. * @param mesh The mesh containing the geometry data we will draw
  8863. * @param defines The defines to update
  8864. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8865. * @param useBones Precise whether bones should be used or not (override mesh info)
  8866. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8867. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8868. * @returns false if defines are considered not dirty and have not been checked
  8869. */
  8870. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8871. /**
  8872. * Prepares the defines related to multiview
  8873. * @param scene The scene we are intending to draw
  8874. * @param defines The defines to update
  8875. */
  8876. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8877. /**
  8878. * Prepares the defines related to the light information passed in parameter
  8879. * @param scene The scene we are intending to draw
  8880. * @param mesh The mesh the effect is compiling for
  8881. * @param light The light the effect is compiling for
  8882. * @param lightIndex The index of the light
  8883. * @param defines The defines to update
  8884. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8885. * @param state Defines the current state regarding what is needed (normals, etc...)
  8886. */
  8887. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8888. needNormals: boolean;
  8889. needRebuild: boolean;
  8890. shadowEnabled: boolean;
  8891. specularEnabled: boolean;
  8892. lightmapMode: boolean;
  8893. }): void;
  8894. /**
  8895. * Prepares the defines related to the light information passed in parameter
  8896. * @param scene The scene we are intending to draw
  8897. * @param mesh The mesh the effect is compiling for
  8898. * @param defines The defines to update
  8899. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8900. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8901. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8902. * @returns true if normals will be required for the rest of the effect
  8903. */
  8904. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8905. /**
  8906. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8907. * @param lightIndex defines the light index
  8908. * @param uniformsList The uniform list
  8909. * @param samplersList The sampler list
  8910. * @param projectedLightTexture defines if projected texture must be used
  8911. * @param uniformBuffersList defines an optional list of uniform buffers
  8912. */
  8913. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8914. /**
  8915. * Prepares the uniforms and samplers list to be used in the effect
  8916. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8917. * @param samplersList The sampler list
  8918. * @param defines The defines helping in the list generation
  8919. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8920. */
  8921. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8922. /**
  8923. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8924. * @param defines The defines to update while falling back
  8925. * @param fallbacks The authorized effect fallbacks
  8926. * @param maxSimultaneousLights The maximum number of lights allowed
  8927. * @param rank the current rank of the Effect
  8928. * @returns The newly affected rank
  8929. */
  8930. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8931. private static _TmpMorphInfluencers;
  8932. /**
  8933. * Prepares the list of attributes required for morph targets according to the effect defines.
  8934. * @param attribs The current list of supported attribs
  8935. * @param mesh The mesh to prepare the morph targets attributes for
  8936. * @param influencers The number of influencers
  8937. */
  8938. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8939. /**
  8940. * Prepares the list of attributes required for morph targets according to the effect defines.
  8941. * @param attribs The current list of supported attribs
  8942. * @param mesh The mesh to prepare the morph targets attributes for
  8943. * @param defines The current Defines of the effect
  8944. */
  8945. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8946. /**
  8947. * Prepares the list of attributes required for bones according to the effect defines.
  8948. * @param attribs The current list of supported attribs
  8949. * @param mesh The mesh to prepare the bones attributes for
  8950. * @param defines The current Defines of the effect
  8951. * @param fallbacks The current efffect fallback strategy
  8952. */
  8953. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8954. /**
  8955. * Check and prepare the list of attributes required for instances according to the effect defines.
  8956. * @param attribs The current list of supported attribs
  8957. * @param defines The current MaterialDefines of the effect
  8958. */
  8959. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8960. /**
  8961. * Add the list of attributes required for instances to the attribs array.
  8962. * @param attribs The current list of supported attribs
  8963. */
  8964. static PushAttributesForInstances(attribs: string[]): void;
  8965. /**
  8966. * Binds the light shadow information to the effect for the given mesh.
  8967. * @param light The light containing the generator
  8968. * @param scene The scene the lights belongs to
  8969. * @param mesh The mesh we are binding the information to render
  8970. * @param lightIndex The light index in the effect used to render the mesh
  8971. * @param effect The effect we are binding the data to
  8972. */
  8973. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8974. /**
  8975. * Binds the light information to the effect.
  8976. * @param light The light containing the generator
  8977. * @param effect The effect we are binding the data to
  8978. * @param lightIndex The light index in the effect used to render
  8979. */
  8980. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8981. /**
  8982. * Binds the lights information from the scene to the effect for the given mesh.
  8983. * @param light Light to bind
  8984. * @param lightIndex Light index
  8985. * @param scene The scene where the light belongs to
  8986. * @param mesh The mesh we are binding the information to render
  8987. * @param effect The effect we are binding the data to
  8988. * @param useSpecular Defines if specular is supported
  8989. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8990. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8991. */
  8992. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8993. /**
  8994. * Binds the lights information from the scene to the effect for the given mesh.
  8995. * @param scene The scene the lights belongs to
  8996. * @param mesh The mesh we are binding the information to render
  8997. * @param effect The effect we are binding the data to
  8998. * @param defines The generated defines for the effect
  8999. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9000. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9001. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9002. */
  9003. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9004. private static _tempFogColor;
  9005. /**
  9006. * Binds the fog information from the scene to the effect for the given mesh.
  9007. * @param scene The scene the lights belongs to
  9008. * @param mesh The mesh we are binding the information to render
  9009. * @param effect The effect we are binding the data to
  9010. * @param linearSpace Defines if the fog effect is applied in linear space
  9011. */
  9012. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9013. /**
  9014. * Binds the bones information from the mesh to the effect.
  9015. * @param mesh The mesh we are binding the information to render
  9016. * @param effect The effect we are binding the data to
  9017. */
  9018. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9019. /**
  9020. * Binds the morph targets information from the mesh to the effect.
  9021. * @param abstractMesh The mesh we are binding the information to render
  9022. * @param effect The effect we are binding the data to
  9023. */
  9024. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9025. /**
  9026. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9027. * @param defines The generated defines used in the effect
  9028. * @param effect The effect we are binding the data to
  9029. * @param scene The scene we are willing to render with logarithmic scale for
  9030. */
  9031. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9032. /**
  9033. * Binds the clip plane information from the scene to the effect.
  9034. * @param scene The scene the clip plane information are extracted from
  9035. * @param effect The effect we are binding the data to
  9036. */
  9037. static BindClipPlane(effect: Effect, scene: Scene): void;
  9038. }
  9039. }
  9040. declare module BABYLON {
  9041. /** @hidden */
  9042. export var packingFunctions: {
  9043. name: string;
  9044. shader: string;
  9045. };
  9046. }
  9047. declare module BABYLON {
  9048. /** @hidden */
  9049. export var shadowMapPixelShader: {
  9050. name: string;
  9051. shader: string;
  9052. };
  9053. }
  9054. declare module BABYLON {
  9055. /** @hidden */
  9056. export var bonesDeclaration: {
  9057. name: string;
  9058. shader: string;
  9059. };
  9060. }
  9061. declare module BABYLON {
  9062. /** @hidden */
  9063. export var morphTargetsVertexGlobalDeclaration: {
  9064. name: string;
  9065. shader: string;
  9066. };
  9067. }
  9068. declare module BABYLON {
  9069. /** @hidden */
  9070. export var morphTargetsVertexDeclaration: {
  9071. name: string;
  9072. shader: string;
  9073. };
  9074. }
  9075. declare module BABYLON {
  9076. /** @hidden */
  9077. export var instancesDeclaration: {
  9078. name: string;
  9079. shader: string;
  9080. };
  9081. }
  9082. declare module BABYLON {
  9083. /** @hidden */
  9084. export var helperFunctions: {
  9085. name: string;
  9086. shader: string;
  9087. };
  9088. }
  9089. declare module BABYLON {
  9090. /** @hidden */
  9091. export var morphTargetsVertex: {
  9092. name: string;
  9093. shader: string;
  9094. };
  9095. }
  9096. declare module BABYLON {
  9097. /** @hidden */
  9098. export var instancesVertex: {
  9099. name: string;
  9100. shader: string;
  9101. };
  9102. }
  9103. declare module BABYLON {
  9104. /** @hidden */
  9105. export var bonesVertex: {
  9106. name: string;
  9107. shader: string;
  9108. };
  9109. }
  9110. declare module BABYLON {
  9111. /** @hidden */
  9112. export var shadowMapVertexShader: {
  9113. name: string;
  9114. shader: string;
  9115. };
  9116. }
  9117. declare module BABYLON {
  9118. /** @hidden */
  9119. export var depthBoxBlurPixelShader: {
  9120. name: string;
  9121. shader: string;
  9122. };
  9123. }
  9124. declare module BABYLON {
  9125. /**
  9126. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9127. */
  9128. export interface ICustomShaderOptions {
  9129. /**
  9130. * Gets or sets the custom shader name to use
  9131. */
  9132. shaderName: string;
  9133. /**
  9134. * The list of attribute names used in the shader
  9135. */
  9136. attributes?: string[];
  9137. /**
  9138. * The list of unifrom names used in the shader
  9139. */
  9140. uniforms?: string[];
  9141. /**
  9142. * The list of sampler names used in the shader
  9143. */
  9144. samplers?: string[];
  9145. /**
  9146. * The list of defines used in the shader
  9147. */
  9148. defines?: string[];
  9149. }
  9150. /**
  9151. * Interface to implement to create a shadow generator compatible with BJS.
  9152. */
  9153. export interface IShadowGenerator {
  9154. /**
  9155. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9156. * @returns The render target texture if present otherwise, null
  9157. */
  9158. getShadowMap(): Nullable<RenderTargetTexture>;
  9159. /**
  9160. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9161. * @returns The render target texture if the shadow map is present otherwise, null
  9162. */
  9163. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9164. /**
  9165. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9166. * @param subMesh The submesh we want to render in the shadow map
  9167. * @param useInstances Defines wether will draw in the map using instances
  9168. * @returns true if ready otherwise, false
  9169. */
  9170. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9171. /**
  9172. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9173. * @param defines Defines of the material we want to update
  9174. * @param lightIndex Index of the light in the enabled light list of the material
  9175. */
  9176. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9177. /**
  9178. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9179. * defined in the generator but impacting the effect).
  9180. * It implies the unifroms available on the materials are the standard BJS ones.
  9181. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9182. * @param effect The effect we are binfing the information for
  9183. */
  9184. bindShadowLight(lightIndex: string, effect: Effect): void;
  9185. /**
  9186. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9187. * (eq to shadow prjection matrix * light transform matrix)
  9188. * @returns The transform matrix used to create the shadow map
  9189. */
  9190. getTransformMatrix(): Matrix;
  9191. /**
  9192. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9193. * Cube and 2D textures for instance.
  9194. */
  9195. recreateShadowMap(): void;
  9196. /**
  9197. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9198. * @param onCompiled Callback triggered at the and of the effects compilation
  9199. * @param options Sets of optional options forcing the compilation with different modes
  9200. */
  9201. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9202. useInstances: boolean;
  9203. }>): void;
  9204. /**
  9205. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9206. * @param options Sets of optional options forcing the compilation with different modes
  9207. * @returns A promise that resolves when the compilation completes
  9208. */
  9209. forceCompilationAsync(options?: Partial<{
  9210. useInstances: boolean;
  9211. }>): Promise<void>;
  9212. /**
  9213. * Serializes the shadow generator setup to a json object.
  9214. * @returns The serialized JSON object
  9215. */
  9216. serialize(): any;
  9217. /**
  9218. * Disposes the Shadow map and related Textures and effects.
  9219. */
  9220. dispose(): void;
  9221. }
  9222. /**
  9223. * Default implementation IShadowGenerator.
  9224. * This is the main object responsible of generating shadows in the framework.
  9225. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9226. */
  9227. export class ShadowGenerator implements IShadowGenerator {
  9228. /**
  9229. * Shadow generator mode None: no filtering applied.
  9230. */
  9231. static readonly FILTER_NONE: number;
  9232. /**
  9233. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9234. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9235. */
  9236. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9237. /**
  9238. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9239. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9240. */
  9241. static readonly FILTER_POISSONSAMPLING: number;
  9242. /**
  9243. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9244. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9245. */
  9246. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9247. /**
  9248. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9249. * edge artifacts on steep falloff.
  9250. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9251. */
  9252. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9253. /**
  9254. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9255. * edge artifacts on steep falloff.
  9256. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9257. */
  9258. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9259. /**
  9260. * Shadow generator mode PCF: Percentage Closer Filtering
  9261. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9262. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9263. */
  9264. static readonly FILTER_PCF: number;
  9265. /**
  9266. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9267. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9268. * Contact Hardening
  9269. */
  9270. static readonly FILTER_PCSS: number;
  9271. /**
  9272. * Reserved for PCF and PCSS
  9273. * Highest Quality.
  9274. *
  9275. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9276. *
  9277. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9278. */
  9279. static readonly QUALITY_HIGH: number;
  9280. /**
  9281. * Reserved for PCF and PCSS
  9282. * Good tradeoff for quality/perf cross devices
  9283. *
  9284. * Execute PCF on a 3*3 kernel.
  9285. *
  9286. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9287. */
  9288. static readonly QUALITY_MEDIUM: number;
  9289. /**
  9290. * Reserved for PCF and PCSS
  9291. * The lowest quality but the fastest.
  9292. *
  9293. * Execute PCF on a 1*1 kernel.
  9294. *
  9295. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9296. */
  9297. static readonly QUALITY_LOW: number;
  9298. /** Gets or sets the custom shader name to use */
  9299. customShaderOptions: ICustomShaderOptions;
  9300. /**
  9301. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9302. */
  9303. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9304. /**
  9305. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9306. */
  9307. onAfterShadowMapRenderObservable: Observable<Effect>;
  9308. /**
  9309. * Observable triggered before a mesh is rendered in the shadow map.
  9310. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9311. */
  9312. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9313. /**
  9314. * Observable triggered after a mesh is rendered in the shadow map.
  9315. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9316. */
  9317. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9318. private _bias;
  9319. /**
  9320. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9321. */
  9322. /**
  9323. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9324. */
  9325. bias: number;
  9326. private _normalBias;
  9327. /**
  9328. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9329. */
  9330. /**
  9331. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9332. */
  9333. normalBias: number;
  9334. private _blurBoxOffset;
  9335. /**
  9336. * Gets the blur box offset: offset applied during the blur pass.
  9337. * Only useful if useKernelBlur = false
  9338. */
  9339. /**
  9340. * Sets the blur box offset: offset applied during the blur pass.
  9341. * Only useful if useKernelBlur = false
  9342. */
  9343. blurBoxOffset: number;
  9344. private _blurScale;
  9345. /**
  9346. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9347. * 2 means half of the size.
  9348. */
  9349. /**
  9350. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9351. * 2 means half of the size.
  9352. */
  9353. blurScale: number;
  9354. private _blurKernel;
  9355. /**
  9356. * Gets the blur kernel: kernel size of the blur pass.
  9357. * Only useful if useKernelBlur = true
  9358. */
  9359. /**
  9360. * Sets the blur kernel: kernel size of the blur pass.
  9361. * Only useful if useKernelBlur = true
  9362. */
  9363. blurKernel: number;
  9364. private _useKernelBlur;
  9365. /**
  9366. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9367. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9368. */
  9369. /**
  9370. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9371. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9372. */
  9373. useKernelBlur: boolean;
  9374. private _depthScale;
  9375. /**
  9376. * Gets the depth scale used in ESM mode.
  9377. */
  9378. /**
  9379. * Sets the depth scale used in ESM mode.
  9380. * This can override the scale stored on the light.
  9381. */
  9382. depthScale: number;
  9383. private _filter;
  9384. /**
  9385. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9386. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9387. */
  9388. /**
  9389. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9390. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9391. */
  9392. filter: number;
  9393. /**
  9394. * Gets if the current filter is set to Poisson Sampling.
  9395. */
  9396. /**
  9397. * Sets the current filter to Poisson Sampling.
  9398. */
  9399. usePoissonSampling: boolean;
  9400. /**
  9401. * Gets if the current filter is set to ESM.
  9402. */
  9403. /**
  9404. * Sets the current filter is to ESM.
  9405. */
  9406. useExponentialShadowMap: boolean;
  9407. /**
  9408. * Gets if the current filter is set to filtered ESM.
  9409. */
  9410. /**
  9411. * Gets if the current filter is set to filtered ESM.
  9412. */
  9413. useBlurExponentialShadowMap: boolean;
  9414. /**
  9415. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9416. * exponential to prevent steep falloff artifacts).
  9417. */
  9418. /**
  9419. * Sets the current filter to "close ESM" (using the inverse of the
  9420. * exponential to prevent steep falloff artifacts).
  9421. */
  9422. useCloseExponentialShadowMap: boolean;
  9423. /**
  9424. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9425. * exponential to prevent steep falloff artifacts).
  9426. */
  9427. /**
  9428. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9429. * exponential to prevent steep falloff artifacts).
  9430. */
  9431. useBlurCloseExponentialShadowMap: boolean;
  9432. /**
  9433. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9434. */
  9435. /**
  9436. * Sets the current filter to "PCF" (percentage closer filtering).
  9437. */
  9438. usePercentageCloserFiltering: boolean;
  9439. private _filteringQuality;
  9440. /**
  9441. * Gets the PCF or PCSS Quality.
  9442. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9443. */
  9444. /**
  9445. * Sets the PCF or PCSS Quality.
  9446. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9447. */
  9448. filteringQuality: number;
  9449. /**
  9450. * Gets if the current filter is set to "PCSS" (contact hardening).
  9451. */
  9452. /**
  9453. * Sets the current filter to "PCSS" (contact hardening).
  9454. */
  9455. useContactHardeningShadow: boolean;
  9456. private _contactHardeningLightSizeUVRatio;
  9457. /**
  9458. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9459. * Using a ratio helps keeping shape stability independently of the map size.
  9460. *
  9461. * It does not account for the light projection as it was having too much
  9462. * instability during the light setup or during light position changes.
  9463. *
  9464. * Only valid if useContactHardeningShadow is true.
  9465. */
  9466. /**
  9467. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9468. * Using a ratio helps keeping shape stability independently of the map size.
  9469. *
  9470. * It does not account for the light projection as it was having too much
  9471. * instability during the light setup or during light position changes.
  9472. *
  9473. * Only valid if useContactHardeningShadow is true.
  9474. */
  9475. contactHardeningLightSizeUVRatio: number;
  9476. private _darkness;
  9477. /** Gets or sets the actual darkness of a shadow */
  9478. darkness: number;
  9479. /**
  9480. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9481. * 0 means strongest and 1 would means no shadow.
  9482. * @returns the darkness.
  9483. */
  9484. getDarkness(): number;
  9485. /**
  9486. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9487. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9488. * @returns the shadow generator allowing fluent coding.
  9489. */
  9490. setDarkness(darkness: number): ShadowGenerator;
  9491. private _transparencyShadow;
  9492. /** Gets or sets the ability to have transparent shadow */
  9493. transparencyShadow: boolean;
  9494. /**
  9495. * Sets the ability to have transparent shadow (boolean).
  9496. * @param transparent True if transparent else False
  9497. * @returns the shadow generator allowing fluent coding
  9498. */
  9499. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9500. private _shadowMap;
  9501. private _shadowMap2;
  9502. /**
  9503. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9504. * @returns The render target texture if present otherwise, null
  9505. */
  9506. getShadowMap(): Nullable<RenderTargetTexture>;
  9507. /**
  9508. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9509. * @returns The render target texture if the shadow map is present otherwise, null
  9510. */
  9511. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9512. /**
  9513. * Gets the class name of that object
  9514. * @returns "ShadowGenerator"
  9515. */
  9516. getClassName(): string;
  9517. /**
  9518. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9519. * @param mesh Mesh to add
  9520. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9521. * @returns the Shadow Generator itself
  9522. */
  9523. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9524. /**
  9525. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9526. * @param mesh Mesh to remove
  9527. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9528. * @returns the Shadow Generator itself
  9529. */
  9530. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9531. /**
  9532. * Controls the extent to which the shadows fade out at the edge of the frustum
  9533. * Used only by directionals and spots
  9534. */
  9535. frustumEdgeFalloff: number;
  9536. private _light;
  9537. /**
  9538. * Returns the associated light object.
  9539. * @returns the light generating the shadow
  9540. */
  9541. getLight(): IShadowLight;
  9542. /**
  9543. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9544. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9545. * It might on the other hand introduce peter panning.
  9546. */
  9547. forceBackFacesOnly: boolean;
  9548. private _scene;
  9549. private _lightDirection;
  9550. private _effect;
  9551. private _viewMatrix;
  9552. private _projectionMatrix;
  9553. private _transformMatrix;
  9554. private _cachedPosition;
  9555. private _cachedDirection;
  9556. private _cachedDefines;
  9557. private _currentRenderID;
  9558. private _boxBlurPostprocess;
  9559. private _kernelBlurXPostprocess;
  9560. private _kernelBlurYPostprocess;
  9561. private _blurPostProcesses;
  9562. private _mapSize;
  9563. private _currentFaceIndex;
  9564. private _currentFaceIndexCache;
  9565. private _textureType;
  9566. private _defaultTextureMatrix;
  9567. private _storedUniqueId;
  9568. /** @hidden */
  9569. static _SceneComponentInitialization: (scene: Scene) => void;
  9570. /**
  9571. * Creates a ShadowGenerator object.
  9572. * A ShadowGenerator is the required tool to use the shadows.
  9573. * Each light casting shadows needs to use its own ShadowGenerator.
  9574. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9575. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9576. * @param light The light object generating the shadows.
  9577. * @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.
  9578. */
  9579. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9580. private _initializeGenerator;
  9581. private _initializeShadowMap;
  9582. private _initializeBlurRTTAndPostProcesses;
  9583. private _renderForShadowMap;
  9584. private _renderSubMeshForShadowMap;
  9585. private _applyFilterValues;
  9586. /**
  9587. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9588. * @param onCompiled Callback triggered at the and of the effects compilation
  9589. * @param options Sets of optional options forcing the compilation with different modes
  9590. */
  9591. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9592. useInstances: boolean;
  9593. }>): void;
  9594. /**
  9595. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9596. * @param options Sets of optional options forcing the compilation with different modes
  9597. * @returns A promise that resolves when the compilation completes
  9598. */
  9599. forceCompilationAsync(options?: Partial<{
  9600. useInstances: boolean;
  9601. }>): Promise<void>;
  9602. /**
  9603. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9604. * @param subMesh The submesh we want to render in the shadow map
  9605. * @param useInstances Defines wether will draw in the map using instances
  9606. * @returns true if ready otherwise, false
  9607. */
  9608. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9609. /**
  9610. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9611. * @param defines Defines of the material we want to update
  9612. * @param lightIndex Index of the light in the enabled light list of the material
  9613. */
  9614. prepareDefines(defines: any, lightIndex: number): void;
  9615. /**
  9616. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9617. * defined in the generator but impacting the effect).
  9618. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9619. * @param effect The effect we are binfing the information for
  9620. */
  9621. bindShadowLight(lightIndex: string, effect: Effect): void;
  9622. /**
  9623. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9624. * (eq to shadow prjection matrix * light transform matrix)
  9625. * @returns The transform matrix used to create the shadow map
  9626. */
  9627. getTransformMatrix(): Matrix;
  9628. /**
  9629. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9630. * Cube and 2D textures for instance.
  9631. */
  9632. recreateShadowMap(): void;
  9633. private _disposeBlurPostProcesses;
  9634. private _disposeRTTandPostProcesses;
  9635. /**
  9636. * Disposes the ShadowGenerator.
  9637. * Returns nothing.
  9638. */
  9639. dispose(): void;
  9640. /**
  9641. * Serializes the shadow generator setup to a json object.
  9642. * @returns The serialized JSON object
  9643. */
  9644. serialize(): any;
  9645. /**
  9646. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9647. * @param parsedShadowGenerator The JSON object to parse
  9648. * @param scene The scene to create the shadow map for
  9649. * @returns The parsed shadow generator
  9650. */
  9651. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9652. }
  9653. }
  9654. declare module BABYLON {
  9655. /**
  9656. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9657. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9658. * 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.
  9659. */
  9660. export abstract class Light extends Node {
  9661. /**
  9662. * Falloff Default: light is falling off following the material specification:
  9663. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9664. */
  9665. static readonly FALLOFF_DEFAULT: number;
  9666. /**
  9667. * Falloff Physical: light is falling off following the inverse squared distance law.
  9668. */
  9669. static readonly FALLOFF_PHYSICAL: number;
  9670. /**
  9671. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9672. * to enhance interoperability with other engines.
  9673. */
  9674. static readonly FALLOFF_GLTF: number;
  9675. /**
  9676. * Falloff Standard: light is falling off like in the standard material
  9677. * to enhance interoperability with other materials.
  9678. */
  9679. static readonly FALLOFF_STANDARD: number;
  9680. /**
  9681. * If every light affecting the material is in this lightmapMode,
  9682. * material.lightmapTexture adds or multiplies
  9683. * (depends on material.useLightmapAsShadowmap)
  9684. * after every other light calculations.
  9685. */
  9686. static readonly LIGHTMAP_DEFAULT: number;
  9687. /**
  9688. * material.lightmapTexture as only diffuse lighting from this light
  9689. * adds only specular lighting from this light
  9690. * adds dynamic shadows
  9691. */
  9692. static readonly LIGHTMAP_SPECULAR: number;
  9693. /**
  9694. * material.lightmapTexture as only lighting
  9695. * no light calculation from this light
  9696. * only adds dynamic shadows from this light
  9697. */
  9698. static readonly LIGHTMAP_SHADOWSONLY: number;
  9699. /**
  9700. * Each light type uses the default quantity according to its type:
  9701. * point/spot lights use luminous intensity
  9702. * directional lights use illuminance
  9703. */
  9704. static readonly INTENSITYMODE_AUTOMATIC: number;
  9705. /**
  9706. * lumen (lm)
  9707. */
  9708. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9709. /**
  9710. * candela (lm/sr)
  9711. */
  9712. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9713. /**
  9714. * lux (lm/m^2)
  9715. */
  9716. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9717. /**
  9718. * nit (cd/m^2)
  9719. */
  9720. static readonly INTENSITYMODE_LUMINANCE: number;
  9721. /**
  9722. * Light type const id of the point light.
  9723. */
  9724. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9725. /**
  9726. * Light type const id of the directional light.
  9727. */
  9728. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9729. /**
  9730. * Light type const id of the spot light.
  9731. */
  9732. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9733. /**
  9734. * Light type const id of the hemispheric light.
  9735. */
  9736. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9737. /**
  9738. * Diffuse gives the basic color to an object.
  9739. */
  9740. diffuse: Color3;
  9741. /**
  9742. * Specular produces a highlight color on an object.
  9743. * Note: This is note affecting PBR materials.
  9744. */
  9745. specular: Color3;
  9746. /**
  9747. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9748. * falling off base on range or angle.
  9749. * This can be set to any values in Light.FALLOFF_x.
  9750. *
  9751. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9752. * other types of materials.
  9753. */
  9754. falloffType: number;
  9755. /**
  9756. * Strength of the light.
  9757. * Note: By default it is define in the framework own unit.
  9758. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9759. */
  9760. intensity: number;
  9761. private _range;
  9762. protected _inverseSquaredRange: number;
  9763. /**
  9764. * Defines how far from the source the light is impacting in scene units.
  9765. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9766. */
  9767. /**
  9768. * Defines how far from the source the light is impacting in scene units.
  9769. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9770. */
  9771. range: number;
  9772. /**
  9773. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9774. * of light.
  9775. */
  9776. private _photometricScale;
  9777. private _intensityMode;
  9778. /**
  9779. * Gets the photometric scale used to interpret the intensity.
  9780. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9781. */
  9782. /**
  9783. * Sets the photometric scale used to interpret the intensity.
  9784. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9785. */
  9786. intensityMode: number;
  9787. private _radius;
  9788. /**
  9789. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9790. */
  9791. /**
  9792. * sets the light radius used by PBR Materials to simulate soft area lights.
  9793. */
  9794. radius: number;
  9795. private _renderPriority;
  9796. /**
  9797. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9798. * exceeding the number allowed of the materials.
  9799. */
  9800. renderPriority: number;
  9801. private _shadowEnabled;
  9802. /**
  9803. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9804. * the current shadow generator.
  9805. */
  9806. /**
  9807. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9808. * the current shadow generator.
  9809. */
  9810. shadowEnabled: boolean;
  9811. private _includedOnlyMeshes;
  9812. /**
  9813. * Gets the only meshes impacted by this light.
  9814. */
  9815. /**
  9816. * Sets the only meshes impacted by this light.
  9817. */
  9818. includedOnlyMeshes: AbstractMesh[];
  9819. private _excludedMeshes;
  9820. /**
  9821. * Gets the meshes not impacted by this light.
  9822. */
  9823. /**
  9824. * Sets the meshes not impacted by this light.
  9825. */
  9826. excludedMeshes: AbstractMesh[];
  9827. private _excludeWithLayerMask;
  9828. /**
  9829. * Gets the layer id use to find what meshes are not impacted by the light.
  9830. * Inactive if 0
  9831. */
  9832. /**
  9833. * Sets the layer id use to find what meshes are not impacted by the light.
  9834. * Inactive if 0
  9835. */
  9836. excludeWithLayerMask: number;
  9837. private _includeOnlyWithLayerMask;
  9838. /**
  9839. * Gets the layer id use to find what meshes are impacted by the light.
  9840. * Inactive if 0
  9841. */
  9842. /**
  9843. * Sets the layer id use to find what meshes are impacted by the light.
  9844. * Inactive if 0
  9845. */
  9846. includeOnlyWithLayerMask: number;
  9847. private _lightmapMode;
  9848. /**
  9849. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9850. */
  9851. /**
  9852. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9853. */
  9854. lightmapMode: number;
  9855. /**
  9856. * Shadow generator associted to the light.
  9857. * @hidden Internal use only.
  9858. */
  9859. _shadowGenerator: Nullable<IShadowGenerator>;
  9860. /**
  9861. * @hidden Internal use only.
  9862. */
  9863. _excludedMeshesIds: string[];
  9864. /**
  9865. * @hidden Internal use only.
  9866. */
  9867. _includedOnlyMeshesIds: string[];
  9868. /**
  9869. * The current light unifom buffer.
  9870. * @hidden Internal use only.
  9871. */
  9872. _uniformBuffer: UniformBuffer;
  9873. /**
  9874. * Creates a Light object in the scene.
  9875. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9876. * @param name The firendly name of the light
  9877. * @param scene The scene the light belongs too
  9878. */
  9879. constructor(name: string, scene: Scene);
  9880. protected abstract _buildUniformLayout(): void;
  9881. /**
  9882. * Sets the passed Effect "effect" with the Light information.
  9883. * @param effect The effect to update
  9884. * @param lightIndex The index of the light in the effect to update
  9885. * @returns The light
  9886. */
  9887. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9888. /**
  9889. * Sets the passed Effect "effect" with the Light information.
  9890. * @param effect The effect to update
  9891. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9892. * @returns The light
  9893. */
  9894. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9895. /**
  9896. * Returns the string "Light".
  9897. * @returns the class name
  9898. */
  9899. getClassName(): string;
  9900. /** @hidden */
  9901. readonly _isLight: boolean;
  9902. /**
  9903. * Converts the light information to a readable string for debug purpose.
  9904. * @param fullDetails Supports for multiple levels of logging within scene loading
  9905. * @returns the human readable light info
  9906. */
  9907. toString(fullDetails?: boolean): string;
  9908. /** @hidden */
  9909. protected _syncParentEnabledState(): void;
  9910. /**
  9911. * Set the enabled state of this node.
  9912. * @param value - the new enabled state
  9913. */
  9914. setEnabled(value: boolean): void;
  9915. /**
  9916. * Returns the Light associated shadow generator if any.
  9917. * @return the associated shadow generator.
  9918. */
  9919. getShadowGenerator(): Nullable<IShadowGenerator>;
  9920. /**
  9921. * Returns a Vector3, the absolute light position in the World.
  9922. * @returns the world space position of the light
  9923. */
  9924. getAbsolutePosition(): Vector3;
  9925. /**
  9926. * Specifies if the light will affect the passed mesh.
  9927. * @param mesh The mesh to test against the light
  9928. * @return true the mesh is affected otherwise, false.
  9929. */
  9930. canAffectMesh(mesh: AbstractMesh): boolean;
  9931. /**
  9932. * Sort function to order lights for rendering.
  9933. * @param a First Light object to compare to second.
  9934. * @param b Second Light object to compare first.
  9935. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9936. */
  9937. static CompareLightsPriority(a: Light, b: Light): number;
  9938. /**
  9939. * Releases resources associated with this node.
  9940. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9941. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9942. */
  9943. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9944. /**
  9945. * Returns the light type ID (integer).
  9946. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9947. */
  9948. getTypeID(): number;
  9949. /**
  9950. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9951. * @returns the scaled intensity in intensity mode unit
  9952. */
  9953. getScaledIntensity(): number;
  9954. /**
  9955. * Returns a new Light object, named "name", from the current one.
  9956. * @param name The name of the cloned light
  9957. * @returns the new created light
  9958. */
  9959. clone(name: string): Nullable<Light>;
  9960. /**
  9961. * Serializes the current light into a Serialization object.
  9962. * @returns the serialized object.
  9963. */
  9964. serialize(): any;
  9965. /**
  9966. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9967. * This new light is named "name" and added to the passed scene.
  9968. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9969. * @param name The friendly name of the light
  9970. * @param scene The scene the new light will belong to
  9971. * @returns the constructor function
  9972. */
  9973. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9974. /**
  9975. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9976. * @param parsedLight The JSON representation of the light
  9977. * @param scene The scene to create the parsed light in
  9978. * @returns the created light after parsing
  9979. */
  9980. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9981. private _hookArrayForExcluded;
  9982. private _hookArrayForIncludedOnly;
  9983. private _resyncMeshes;
  9984. /**
  9985. * Forces the meshes to update their light related information in their rendering used effects
  9986. * @hidden Internal Use Only
  9987. */
  9988. _markMeshesAsLightDirty(): void;
  9989. /**
  9990. * Recomputes the cached photometric scale if needed.
  9991. */
  9992. private _computePhotometricScale;
  9993. /**
  9994. * Returns the Photometric Scale according to the light type and intensity mode.
  9995. */
  9996. private _getPhotometricScale;
  9997. /**
  9998. * Reorder the light in the scene according to their defined priority.
  9999. * @hidden Internal Use Only
  10000. */
  10001. _reorderLightsInScene(): void;
  10002. /**
  10003. * Prepares the list of defines specific to the light type.
  10004. * @param defines the list of defines
  10005. * @param lightIndex defines the index of the light for the effect
  10006. */
  10007. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10008. }
  10009. }
  10010. declare module BABYLON {
  10011. /**
  10012. * Interface used to define Action
  10013. */
  10014. export interface IAction {
  10015. /**
  10016. * Trigger for the action
  10017. */
  10018. trigger: number;
  10019. /** Options of the trigger */
  10020. triggerOptions: any;
  10021. /**
  10022. * Gets the trigger parameters
  10023. * @returns the trigger parameters
  10024. */
  10025. getTriggerParameter(): any;
  10026. /**
  10027. * Internal only - executes current action event
  10028. * @hidden
  10029. */
  10030. _executeCurrent(evt?: ActionEvent): void;
  10031. /**
  10032. * Serialize placeholder for child classes
  10033. * @param parent of child
  10034. * @returns the serialized object
  10035. */
  10036. serialize(parent: any): any;
  10037. /**
  10038. * Internal only
  10039. * @hidden
  10040. */
  10041. _prepare(): void;
  10042. /**
  10043. * Internal only - manager for action
  10044. * @hidden
  10045. */
  10046. _actionManager: AbstractActionManager;
  10047. /**
  10048. * Adds action to chain of actions, may be a DoNothingAction
  10049. * @param action defines the next action to execute
  10050. * @returns The action passed in
  10051. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10052. */
  10053. then(action: IAction): IAction;
  10054. }
  10055. /**
  10056. * The action to be carried out following a trigger
  10057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10058. */
  10059. export class Action implements IAction {
  10060. /** the trigger, with or without parameters, for the action */
  10061. triggerOptions: any;
  10062. /**
  10063. * Trigger for the action
  10064. */
  10065. trigger: number;
  10066. /**
  10067. * Internal only - manager for action
  10068. * @hidden
  10069. */
  10070. _actionManager: ActionManager;
  10071. private _nextActiveAction;
  10072. private _child;
  10073. private _condition?;
  10074. private _triggerParameter;
  10075. /**
  10076. * An event triggered prior to action being executed.
  10077. */
  10078. onBeforeExecuteObservable: Observable<Action>;
  10079. /**
  10080. * Creates a new Action
  10081. * @param triggerOptions the trigger, with or without parameters, for the action
  10082. * @param condition an optional determinant of action
  10083. */
  10084. constructor(
  10085. /** the trigger, with or without parameters, for the action */
  10086. triggerOptions: any, condition?: Condition);
  10087. /**
  10088. * Internal only
  10089. * @hidden
  10090. */
  10091. _prepare(): void;
  10092. /**
  10093. * Gets the trigger parameters
  10094. * @returns the trigger parameters
  10095. */
  10096. getTriggerParameter(): any;
  10097. /**
  10098. * Internal only - executes current action event
  10099. * @hidden
  10100. */
  10101. _executeCurrent(evt?: ActionEvent): void;
  10102. /**
  10103. * Execute placeholder for child classes
  10104. * @param evt optional action event
  10105. */
  10106. execute(evt?: ActionEvent): void;
  10107. /**
  10108. * Skips to next active action
  10109. */
  10110. skipToNextActiveAction(): void;
  10111. /**
  10112. * Adds action to chain of actions, may be a DoNothingAction
  10113. * @param action defines the next action to execute
  10114. * @returns The action passed in
  10115. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10116. */
  10117. then(action: Action): Action;
  10118. /**
  10119. * Internal only
  10120. * @hidden
  10121. */
  10122. _getProperty(propertyPath: string): string;
  10123. /**
  10124. * Internal only
  10125. * @hidden
  10126. */
  10127. _getEffectiveTarget(target: any, propertyPath: string): any;
  10128. /**
  10129. * Serialize placeholder for child classes
  10130. * @param parent of child
  10131. * @returns the serialized object
  10132. */
  10133. serialize(parent: any): any;
  10134. /**
  10135. * Internal only called by serialize
  10136. * @hidden
  10137. */
  10138. protected _serialize(serializedAction: any, parent?: any): any;
  10139. /**
  10140. * Internal only
  10141. * @hidden
  10142. */
  10143. static _SerializeValueAsString: (value: any) => string;
  10144. /**
  10145. * Internal only
  10146. * @hidden
  10147. */
  10148. static _GetTargetProperty: (target: Node | Scene) => {
  10149. name: string;
  10150. targetType: string;
  10151. value: string;
  10152. };
  10153. }
  10154. }
  10155. declare module BABYLON {
  10156. /**
  10157. * A Condition applied to an Action
  10158. */
  10159. export class Condition {
  10160. /**
  10161. * Internal only - manager for action
  10162. * @hidden
  10163. */
  10164. _actionManager: ActionManager;
  10165. /**
  10166. * Internal only
  10167. * @hidden
  10168. */
  10169. _evaluationId: number;
  10170. /**
  10171. * Internal only
  10172. * @hidden
  10173. */
  10174. _currentResult: boolean;
  10175. /**
  10176. * Creates a new Condition
  10177. * @param actionManager the manager of the action the condition is applied to
  10178. */
  10179. constructor(actionManager: ActionManager);
  10180. /**
  10181. * Check if the current condition is valid
  10182. * @returns a boolean
  10183. */
  10184. isValid(): boolean;
  10185. /**
  10186. * Internal only
  10187. * @hidden
  10188. */
  10189. _getProperty(propertyPath: string): string;
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _getEffectiveTarget(target: any, propertyPath: string): any;
  10195. /**
  10196. * Serialize placeholder for child classes
  10197. * @returns the serialized object
  10198. */
  10199. serialize(): any;
  10200. /**
  10201. * Internal only
  10202. * @hidden
  10203. */
  10204. protected _serialize(serializedCondition: any): any;
  10205. }
  10206. /**
  10207. * Defines specific conditional operators as extensions of Condition
  10208. */
  10209. export class ValueCondition extends Condition {
  10210. /** path to specify the property of the target the conditional operator uses */
  10211. propertyPath: string;
  10212. /** the value compared by the conditional operator against the current value of the property */
  10213. value: any;
  10214. /** the conditional operator, default ValueCondition.IsEqual */
  10215. operator: number;
  10216. /**
  10217. * Internal only
  10218. * @hidden
  10219. */
  10220. private static _IsEqual;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. private static _IsDifferent;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. private static _IsGreater;
  10231. /**
  10232. * Internal only
  10233. * @hidden
  10234. */
  10235. private static _IsLesser;
  10236. /**
  10237. * returns the number for IsEqual
  10238. */
  10239. static readonly IsEqual: number;
  10240. /**
  10241. * Returns the number for IsDifferent
  10242. */
  10243. static readonly IsDifferent: number;
  10244. /**
  10245. * Returns the number for IsGreater
  10246. */
  10247. static readonly IsGreater: number;
  10248. /**
  10249. * Returns the number for IsLesser
  10250. */
  10251. static readonly IsLesser: number;
  10252. /**
  10253. * Internal only The action manager for the condition
  10254. * @hidden
  10255. */
  10256. _actionManager: ActionManager;
  10257. /**
  10258. * Internal only
  10259. * @hidden
  10260. */
  10261. private _target;
  10262. /**
  10263. * Internal only
  10264. * @hidden
  10265. */
  10266. private _effectiveTarget;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. private _property;
  10272. /**
  10273. * Creates a new ValueCondition
  10274. * @param actionManager manager for the action the condition applies to
  10275. * @param target for the action
  10276. * @param propertyPath path to specify the property of the target the conditional operator uses
  10277. * @param value the value compared by the conditional operator against the current value of the property
  10278. * @param operator the conditional operator, default ValueCondition.IsEqual
  10279. */
  10280. constructor(actionManager: ActionManager, target: any,
  10281. /** path to specify the property of the target the conditional operator uses */
  10282. propertyPath: string,
  10283. /** the value compared by the conditional operator against the current value of the property */
  10284. value: any,
  10285. /** the conditional operator, default ValueCondition.IsEqual */
  10286. operator?: number);
  10287. /**
  10288. * Compares the given value with the property value for the specified conditional operator
  10289. * @returns the result of the comparison
  10290. */
  10291. isValid(): boolean;
  10292. /**
  10293. * Serialize the ValueCondition into a JSON compatible object
  10294. * @returns serialization object
  10295. */
  10296. serialize(): any;
  10297. /**
  10298. * Gets the name of the conditional operator for the ValueCondition
  10299. * @param operator the conditional operator
  10300. * @returns the name
  10301. */
  10302. static GetOperatorName(operator: number): string;
  10303. }
  10304. /**
  10305. * Defines a predicate condition as an extension of Condition
  10306. */
  10307. export class PredicateCondition extends Condition {
  10308. /** defines the predicate function used to validate the condition */
  10309. predicate: () => boolean;
  10310. /**
  10311. * Internal only - manager for action
  10312. * @hidden
  10313. */
  10314. _actionManager: ActionManager;
  10315. /**
  10316. * Creates a new PredicateCondition
  10317. * @param actionManager manager for the action the condition applies to
  10318. * @param predicate defines the predicate function used to validate the condition
  10319. */
  10320. constructor(actionManager: ActionManager,
  10321. /** defines the predicate function used to validate the condition */
  10322. predicate: () => boolean);
  10323. /**
  10324. * @returns the validity of the predicate condition
  10325. */
  10326. isValid(): boolean;
  10327. }
  10328. /**
  10329. * Defines a state condition as an extension of Condition
  10330. */
  10331. export class StateCondition extends Condition {
  10332. /** Value to compare with target state */
  10333. value: string;
  10334. /**
  10335. * Internal only - manager for action
  10336. * @hidden
  10337. */
  10338. _actionManager: ActionManager;
  10339. /**
  10340. * Internal only
  10341. * @hidden
  10342. */
  10343. private _target;
  10344. /**
  10345. * Creates a new StateCondition
  10346. * @param actionManager manager for the action the condition applies to
  10347. * @param target of the condition
  10348. * @param value to compare with target state
  10349. */
  10350. constructor(actionManager: ActionManager, target: any,
  10351. /** Value to compare with target state */
  10352. value: string);
  10353. /**
  10354. * Gets a boolean indicating if the current condition is met
  10355. * @returns the validity of the state
  10356. */
  10357. isValid(): boolean;
  10358. /**
  10359. * Serialize the StateCondition into a JSON compatible object
  10360. * @returns serialization object
  10361. */
  10362. serialize(): any;
  10363. }
  10364. }
  10365. declare module BABYLON {
  10366. /**
  10367. * This defines an action responsible to toggle a boolean once triggered.
  10368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10369. */
  10370. export class SwitchBooleanAction extends Action {
  10371. /**
  10372. * The path to the boolean property in the target object
  10373. */
  10374. propertyPath: string;
  10375. private _target;
  10376. private _effectiveTarget;
  10377. private _property;
  10378. /**
  10379. * Instantiate the action
  10380. * @param triggerOptions defines the trigger options
  10381. * @param target defines the object containing the boolean
  10382. * @param propertyPath defines the path to the boolean property in the target object
  10383. * @param condition defines the trigger related conditions
  10384. */
  10385. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10386. /** @hidden */
  10387. _prepare(): void;
  10388. /**
  10389. * Execute the action toggle the boolean value.
  10390. */
  10391. execute(): void;
  10392. /**
  10393. * Serializes the actions and its related information.
  10394. * @param parent defines the object to serialize in
  10395. * @returns the serialized object
  10396. */
  10397. serialize(parent: any): any;
  10398. }
  10399. /**
  10400. * This defines an action responsible to set a the state field of the target
  10401. * to a desired value once triggered.
  10402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10403. */
  10404. export class SetStateAction extends Action {
  10405. /**
  10406. * The value to store in the state field.
  10407. */
  10408. value: string;
  10409. private _target;
  10410. /**
  10411. * Instantiate the action
  10412. * @param triggerOptions defines the trigger options
  10413. * @param target defines the object containing the state property
  10414. * @param value defines the value to store in the state field
  10415. * @param condition defines the trigger related conditions
  10416. */
  10417. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10418. /**
  10419. * Execute the action and store the value on the target state property.
  10420. */
  10421. execute(): void;
  10422. /**
  10423. * Serializes the actions and its related information.
  10424. * @param parent defines the object to serialize in
  10425. * @returns the serialized object
  10426. */
  10427. serialize(parent: any): any;
  10428. }
  10429. /**
  10430. * This defines an action responsible to set a property of the target
  10431. * to a desired value once triggered.
  10432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10433. */
  10434. export class SetValueAction extends Action {
  10435. /**
  10436. * The path of the property to set in the target.
  10437. */
  10438. propertyPath: string;
  10439. /**
  10440. * The value to set in the property
  10441. */
  10442. value: any;
  10443. private _target;
  10444. private _effectiveTarget;
  10445. private _property;
  10446. /**
  10447. * Instantiate the action
  10448. * @param triggerOptions defines the trigger options
  10449. * @param target defines the object containing the property
  10450. * @param propertyPath defines the path of the property to set in the target
  10451. * @param value defines the value to set in the property
  10452. * @param condition defines the trigger related conditions
  10453. */
  10454. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10455. /** @hidden */
  10456. _prepare(): void;
  10457. /**
  10458. * Execute the action and set the targetted property to the desired value.
  10459. */
  10460. execute(): void;
  10461. /**
  10462. * Serializes the actions and its related information.
  10463. * @param parent defines the object to serialize in
  10464. * @returns the serialized object
  10465. */
  10466. serialize(parent: any): any;
  10467. }
  10468. /**
  10469. * This defines an action responsible to increment the target value
  10470. * to a desired value once triggered.
  10471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10472. */
  10473. export class IncrementValueAction extends Action {
  10474. /**
  10475. * The path of the property to increment in the target.
  10476. */
  10477. propertyPath: string;
  10478. /**
  10479. * The value we should increment the property by.
  10480. */
  10481. value: any;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the property
  10489. * @param propertyPath defines the path of the property to increment in the target
  10490. * @param value defines the value value we should increment the property by
  10491. * @param condition defines the trigger related conditions
  10492. */
  10493. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10494. /** @hidden */
  10495. _prepare(): void;
  10496. /**
  10497. * Execute the action and increment the target of the value amount.
  10498. */
  10499. execute(): void;
  10500. /**
  10501. * Serializes the actions and its related information.
  10502. * @param parent defines the object to serialize in
  10503. * @returns the serialized object
  10504. */
  10505. serialize(parent: any): any;
  10506. }
  10507. /**
  10508. * This defines an action responsible to start an animation once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class PlayAnimationAction extends Action {
  10512. /**
  10513. * Where the animation should start (animation frame)
  10514. */
  10515. from: number;
  10516. /**
  10517. * Where the animation should stop (animation frame)
  10518. */
  10519. to: number;
  10520. /**
  10521. * Define if the animation should loop or stop after the first play.
  10522. */
  10523. loop?: boolean;
  10524. private _target;
  10525. /**
  10526. * Instantiate the action
  10527. * @param triggerOptions defines the trigger options
  10528. * @param target defines the target animation or animation name
  10529. * @param from defines from where the animation should start (animation frame)
  10530. * @param end defines where the animation should stop (animation frame)
  10531. * @param loop defines if the animation should loop or stop after the first play
  10532. * @param condition defines the trigger related conditions
  10533. */
  10534. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10535. /** @hidden */
  10536. _prepare(): void;
  10537. /**
  10538. * Execute the action and play the animation.
  10539. */
  10540. execute(): void;
  10541. /**
  10542. * Serializes the actions and its related information.
  10543. * @param parent defines the object to serialize in
  10544. * @returns the serialized object
  10545. */
  10546. serialize(parent: any): any;
  10547. }
  10548. /**
  10549. * This defines an action responsible to stop an animation once triggered.
  10550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10551. */
  10552. export class StopAnimationAction extends Action {
  10553. private _target;
  10554. /**
  10555. * Instantiate the action
  10556. * @param triggerOptions defines the trigger options
  10557. * @param target defines the target animation or animation name
  10558. * @param condition defines the trigger related conditions
  10559. */
  10560. constructor(triggerOptions: any, target: any, condition?: Condition);
  10561. /** @hidden */
  10562. _prepare(): void;
  10563. /**
  10564. * Execute the action and stop the animation.
  10565. */
  10566. execute(): void;
  10567. /**
  10568. * Serializes the actions and its related information.
  10569. * @param parent defines the object to serialize in
  10570. * @returns the serialized object
  10571. */
  10572. serialize(parent: any): any;
  10573. }
  10574. /**
  10575. * This defines an action responsible that does nothing once triggered.
  10576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10577. */
  10578. export class DoNothingAction extends Action {
  10579. /**
  10580. * Instantiate the action
  10581. * @param triggerOptions defines the trigger options
  10582. * @param condition defines the trigger related conditions
  10583. */
  10584. constructor(triggerOptions?: any, condition?: Condition);
  10585. /**
  10586. * Execute the action and do nothing.
  10587. */
  10588. execute(): void;
  10589. /**
  10590. * Serializes the actions and its related information.
  10591. * @param parent defines the object to serialize in
  10592. * @returns the serialized object
  10593. */
  10594. serialize(parent: any): any;
  10595. }
  10596. /**
  10597. * This defines an action responsible to trigger several actions once triggered.
  10598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10599. */
  10600. export class CombineAction extends Action {
  10601. /**
  10602. * The list of aggregated animations to run.
  10603. */
  10604. children: Action[];
  10605. /**
  10606. * Instantiate the action
  10607. * @param triggerOptions defines the trigger options
  10608. * @param children defines the list of aggregated animations to run
  10609. * @param condition defines the trigger related conditions
  10610. */
  10611. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10612. /** @hidden */
  10613. _prepare(): void;
  10614. /**
  10615. * Execute the action and executes all the aggregated actions.
  10616. */
  10617. execute(evt: ActionEvent): void;
  10618. /**
  10619. * Serializes the actions and its related information.
  10620. * @param parent defines the object to serialize in
  10621. * @returns the serialized object
  10622. */
  10623. serialize(parent: any): any;
  10624. }
  10625. /**
  10626. * This defines an action responsible to run code (external event) once triggered.
  10627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10628. */
  10629. export class ExecuteCodeAction extends Action {
  10630. /**
  10631. * The callback function to run.
  10632. */
  10633. func: (evt: ActionEvent) => void;
  10634. /**
  10635. * Instantiate the action
  10636. * @param triggerOptions defines the trigger options
  10637. * @param func defines the callback function to run
  10638. * @param condition defines the trigger related conditions
  10639. */
  10640. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10641. /**
  10642. * Execute the action and run the attached code.
  10643. */
  10644. execute(evt: ActionEvent): void;
  10645. }
  10646. /**
  10647. * This defines an action responsible to set the parent property of the target once triggered.
  10648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10649. */
  10650. export class SetParentAction extends Action {
  10651. private _parent;
  10652. private _target;
  10653. /**
  10654. * Instantiate the action
  10655. * @param triggerOptions defines the trigger options
  10656. * @param target defines the target containing the parent property
  10657. * @param parent defines from where the animation should start (animation frame)
  10658. * @param condition defines the trigger related conditions
  10659. */
  10660. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10661. /** @hidden */
  10662. _prepare(): void;
  10663. /**
  10664. * Execute the action and set the parent property.
  10665. */
  10666. execute(): void;
  10667. /**
  10668. * Serializes the actions and its related information.
  10669. * @param parent defines the object to serialize in
  10670. * @returns the serialized object
  10671. */
  10672. serialize(parent: any): any;
  10673. }
  10674. }
  10675. declare module BABYLON {
  10676. /**
  10677. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10678. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10680. */
  10681. export class ActionManager extends AbstractActionManager {
  10682. /**
  10683. * Nothing
  10684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10685. */
  10686. static readonly NothingTrigger: number;
  10687. /**
  10688. * On pick
  10689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10690. */
  10691. static readonly OnPickTrigger: number;
  10692. /**
  10693. * On left pick
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10695. */
  10696. static readonly OnLeftPickTrigger: number;
  10697. /**
  10698. * On right pick
  10699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10700. */
  10701. static readonly OnRightPickTrigger: number;
  10702. /**
  10703. * On center pick
  10704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10705. */
  10706. static readonly OnCenterPickTrigger: number;
  10707. /**
  10708. * On pick down
  10709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10710. */
  10711. static readonly OnPickDownTrigger: number;
  10712. /**
  10713. * On double pick
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10715. */
  10716. static readonly OnDoublePickTrigger: number;
  10717. /**
  10718. * On pick up
  10719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10720. */
  10721. static readonly OnPickUpTrigger: number;
  10722. /**
  10723. * On pick out.
  10724. * This trigger will only be raised if you also declared a OnPickDown
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10726. */
  10727. static readonly OnPickOutTrigger: number;
  10728. /**
  10729. * On long press
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly OnLongPressTrigger: number;
  10733. /**
  10734. * On pointer over
  10735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnPointerOverTrigger: number;
  10738. /**
  10739. * On pointer out
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnPointerOutTrigger: number;
  10743. /**
  10744. * On every frame
  10745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10746. */
  10747. static readonly OnEveryFrameTrigger: number;
  10748. /**
  10749. * On intersection enter
  10750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10751. */
  10752. static readonly OnIntersectionEnterTrigger: number;
  10753. /**
  10754. * On intersection exit
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10756. */
  10757. static readonly OnIntersectionExitTrigger: number;
  10758. /**
  10759. * On key down
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10761. */
  10762. static readonly OnKeyDownTrigger: number;
  10763. /**
  10764. * On key up
  10765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10766. */
  10767. static readonly OnKeyUpTrigger: number;
  10768. private _scene;
  10769. /**
  10770. * Creates a new action manager
  10771. * @param scene defines the hosting scene
  10772. */
  10773. constructor(scene: Scene);
  10774. /**
  10775. * Releases all associated resources
  10776. */
  10777. dispose(): void;
  10778. /**
  10779. * Gets hosting scene
  10780. * @returns the hosting scene
  10781. */
  10782. getScene(): Scene;
  10783. /**
  10784. * Does this action manager handles actions of any of the given triggers
  10785. * @param triggers defines the triggers to be tested
  10786. * @return a boolean indicating whether one (or more) of the triggers is handled
  10787. */
  10788. hasSpecificTriggers(triggers: number[]): boolean;
  10789. /**
  10790. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10791. * speed.
  10792. * @param triggerA defines the trigger to be tested
  10793. * @param triggerB defines the trigger to be tested
  10794. * @return a boolean indicating whether one (or more) of the triggers is handled
  10795. */
  10796. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10797. /**
  10798. * Does this action manager handles actions of a given trigger
  10799. * @param trigger defines the trigger to be tested
  10800. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10801. * @return whether the trigger is handled
  10802. */
  10803. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10804. /**
  10805. * Does this action manager has pointer triggers
  10806. */
  10807. readonly hasPointerTriggers: boolean;
  10808. /**
  10809. * Does this action manager has pick triggers
  10810. */
  10811. readonly hasPickTriggers: boolean;
  10812. /**
  10813. * Registers an action to this action manager
  10814. * @param action defines the action to be registered
  10815. * @return the action amended (prepared) after registration
  10816. */
  10817. registerAction(action: IAction): Nullable<IAction>;
  10818. /**
  10819. * Unregisters an action to this action manager
  10820. * @param action defines the action to be unregistered
  10821. * @return a boolean indicating whether the action has been unregistered
  10822. */
  10823. unregisterAction(action: IAction): Boolean;
  10824. /**
  10825. * Process a specific trigger
  10826. * @param trigger defines the trigger to process
  10827. * @param evt defines the event details to be processed
  10828. */
  10829. processTrigger(trigger: number, evt?: IActionEvent): void;
  10830. /** @hidden */
  10831. _getEffectiveTarget(target: any, propertyPath: string): any;
  10832. /** @hidden */
  10833. _getProperty(propertyPath: string): string;
  10834. /**
  10835. * Serialize this manager to a JSON object
  10836. * @param name defines the property name to store this manager
  10837. * @returns a JSON representation of this manager
  10838. */
  10839. serialize(name: string): any;
  10840. /**
  10841. * Creates a new ActionManager from a JSON data
  10842. * @param parsedActions defines the JSON data to read from
  10843. * @param object defines the hosting mesh
  10844. * @param scene defines the hosting scene
  10845. */
  10846. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10847. /**
  10848. * Get a trigger name by index
  10849. * @param trigger defines the trigger index
  10850. * @returns a trigger name
  10851. */
  10852. static GetTriggerName(trigger: number): string;
  10853. }
  10854. }
  10855. declare module BABYLON {
  10856. /**
  10857. * Class representing a ray with position and direction
  10858. */
  10859. export class Ray {
  10860. /** origin point */
  10861. origin: Vector3;
  10862. /** direction */
  10863. direction: Vector3;
  10864. /** length of the ray */
  10865. length: number;
  10866. private static readonly TmpVector3;
  10867. private _tmpRay;
  10868. /**
  10869. * Creates a new ray
  10870. * @param origin origin point
  10871. * @param direction direction
  10872. * @param length length of the ray
  10873. */
  10874. constructor(
  10875. /** origin point */
  10876. origin: Vector3,
  10877. /** direction */
  10878. direction: Vector3,
  10879. /** length of the ray */
  10880. length?: number);
  10881. /**
  10882. * Checks if the ray intersects a box
  10883. * @param minimum bound of the box
  10884. * @param maximum bound of the box
  10885. * @param intersectionTreshold extra extend to be added to the box in all direction
  10886. * @returns if the box was hit
  10887. */
  10888. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10889. /**
  10890. * Checks if the ray intersects a box
  10891. * @param box the bounding box to check
  10892. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10893. * @returns if the box was hit
  10894. */
  10895. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10896. /**
  10897. * If the ray hits a sphere
  10898. * @param sphere the bounding sphere to check
  10899. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10900. * @returns true if it hits the sphere
  10901. */
  10902. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10903. /**
  10904. * If the ray hits a triange
  10905. * @param vertex0 triangle vertex
  10906. * @param vertex1 triangle vertex
  10907. * @param vertex2 triangle vertex
  10908. * @returns intersection information if hit
  10909. */
  10910. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10911. /**
  10912. * Checks if ray intersects a plane
  10913. * @param plane the plane to check
  10914. * @returns the distance away it was hit
  10915. */
  10916. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10917. /**
  10918. * Calculate the intercept of a ray on a given axis
  10919. * @param axis to check 'x' | 'y' | 'z'
  10920. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10921. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10922. */
  10923. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10924. /**
  10925. * Checks if ray intersects a mesh
  10926. * @param mesh the mesh to check
  10927. * @param fastCheck if only the bounding box should checked
  10928. * @returns picking info of the intersecton
  10929. */
  10930. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10931. /**
  10932. * Checks if ray intersects a mesh
  10933. * @param meshes the meshes to check
  10934. * @param fastCheck if only the bounding box should checked
  10935. * @param results array to store result in
  10936. * @returns Array of picking infos
  10937. */
  10938. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10939. private _comparePickingInfo;
  10940. private static smallnum;
  10941. private static rayl;
  10942. /**
  10943. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10944. * @param sega the first point of the segment to test the intersection against
  10945. * @param segb the second point of the segment to test the intersection against
  10946. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10947. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10948. */
  10949. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10950. /**
  10951. * Update the ray from viewport position
  10952. * @param x position
  10953. * @param y y position
  10954. * @param viewportWidth viewport width
  10955. * @param viewportHeight viewport height
  10956. * @param world world matrix
  10957. * @param view view matrix
  10958. * @param projection projection matrix
  10959. * @returns this ray updated
  10960. */
  10961. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10962. /**
  10963. * Creates a ray with origin and direction of 0,0,0
  10964. * @returns the new ray
  10965. */
  10966. static Zero(): Ray;
  10967. /**
  10968. * Creates a new ray from screen space and viewport
  10969. * @param x position
  10970. * @param y y position
  10971. * @param viewportWidth viewport width
  10972. * @param viewportHeight viewport height
  10973. * @param world world matrix
  10974. * @param view view matrix
  10975. * @param projection projection matrix
  10976. * @returns new ray
  10977. */
  10978. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10979. /**
  10980. * 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
  10981. * transformed to the given world matrix.
  10982. * @param origin The origin point
  10983. * @param end The end point
  10984. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10985. * @returns the new ray
  10986. */
  10987. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10988. /**
  10989. * Transforms a ray by a matrix
  10990. * @param ray ray to transform
  10991. * @param matrix matrix to apply
  10992. * @returns the resulting new ray
  10993. */
  10994. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10995. /**
  10996. * Transforms a ray by a matrix
  10997. * @param ray ray to transform
  10998. * @param matrix matrix to apply
  10999. * @param result ray to store result in
  11000. */
  11001. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11002. /**
  11003. * Unproject a ray from screen space to object space
  11004. * @param sourceX defines the screen space x coordinate to use
  11005. * @param sourceY defines the screen space y coordinate to use
  11006. * @param viewportWidth defines the current width of the viewport
  11007. * @param viewportHeight defines the current height of the viewport
  11008. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11009. * @param view defines the view matrix to use
  11010. * @param projection defines the projection matrix to use
  11011. */
  11012. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11013. }
  11014. /**
  11015. * Type used to define predicate used to select faces when a mesh intersection is detected
  11016. */
  11017. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11018. interface Scene {
  11019. /** @hidden */
  11020. _tempPickingRay: Nullable<Ray>;
  11021. /** @hidden */
  11022. _cachedRayForTransform: Ray;
  11023. /** @hidden */
  11024. _pickWithRayInverseMatrix: Matrix;
  11025. /** @hidden */
  11026. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11027. /** @hidden */
  11028. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11029. }
  11030. }
  11031. declare module BABYLON {
  11032. /**
  11033. * Groups all the scene component constants in one place to ease maintenance.
  11034. * @hidden
  11035. */
  11036. export class SceneComponentConstants {
  11037. static readonly NAME_EFFECTLAYER: string;
  11038. static readonly NAME_LAYER: string;
  11039. static readonly NAME_LENSFLARESYSTEM: string;
  11040. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11041. static readonly NAME_PARTICLESYSTEM: string;
  11042. static readonly NAME_GAMEPAD: string;
  11043. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11044. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11045. static readonly NAME_DEPTHRENDERER: string;
  11046. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11047. static readonly NAME_SPRITE: string;
  11048. static readonly NAME_OUTLINERENDERER: string;
  11049. static readonly NAME_PROCEDURALTEXTURE: string;
  11050. static readonly NAME_SHADOWGENERATOR: string;
  11051. static readonly NAME_OCTREE: string;
  11052. static readonly NAME_PHYSICSENGINE: string;
  11053. static readonly NAME_AUDIO: string;
  11054. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11055. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11056. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11057. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11058. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11059. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11060. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11061. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11062. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11063. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11064. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11065. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11066. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11067. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11068. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11069. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11070. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11071. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11072. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11073. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11074. static readonly STEP_AFTERRENDER_AUDIO: number;
  11075. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11076. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11077. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11078. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11079. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11080. static readonly STEP_POINTERMOVE_SPRITE: number;
  11081. static readonly STEP_POINTERDOWN_SPRITE: number;
  11082. static readonly STEP_POINTERUP_SPRITE: number;
  11083. }
  11084. /**
  11085. * This represents a scene component.
  11086. *
  11087. * This is used to decouple the dependency the scene is having on the different workloads like
  11088. * layers, post processes...
  11089. */
  11090. export interface ISceneComponent {
  11091. /**
  11092. * The name of the component. Each component must have a unique name.
  11093. */
  11094. name: string;
  11095. /**
  11096. * The scene the component belongs to.
  11097. */
  11098. scene: Scene;
  11099. /**
  11100. * Register the component to one instance of a scene.
  11101. */
  11102. register(): void;
  11103. /**
  11104. * Rebuilds the elements related to this component in case of
  11105. * context lost for instance.
  11106. */
  11107. rebuild(): void;
  11108. /**
  11109. * Disposes the component and the associated ressources.
  11110. */
  11111. dispose(): void;
  11112. }
  11113. /**
  11114. * This represents a SERIALIZABLE scene component.
  11115. *
  11116. * This extends Scene Component to add Serialization methods on top.
  11117. */
  11118. export interface ISceneSerializableComponent extends ISceneComponent {
  11119. /**
  11120. * Adds all the elements from the container to the scene
  11121. * @param container the container holding the elements
  11122. */
  11123. addFromContainer(container: AbstractScene): void;
  11124. /**
  11125. * Removes all the elements in the container from the scene
  11126. * @param container contains the elements to remove
  11127. * @param dispose if the removed element should be disposed (default: false)
  11128. */
  11129. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11130. /**
  11131. * Serializes the component data to the specified json object
  11132. * @param serializationObject The object to serialize to
  11133. */
  11134. serialize(serializationObject: any): void;
  11135. }
  11136. /**
  11137. * Strong typing of a Mesh related stage step action
  11138. */
  11139. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11140. /**
  11141. * Strong typing of a Evaluate Sub Mesh related stage step action
  11142. */
  11143. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11144. /**
  11145. * Strong typing of a Active Mesh related stage step action
  11146. */
  11147. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11148. /**
  11149. * Strong typing of a Camera related stage step action
  11150. */
  11151. export type CameraStageAction = (camera: Camera) => void;
  11152. /**
  11153. * Strong typing of a Camera Frame buffer related stage step action
  11154. */
  11155. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11156. /**
  11157. * Strong typing of a Render Target related stage step action
  11158. */
  11159. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11160. /**
  11161. * Strong typing of a RenderingGroup related stage step action
  11162. */
  11163. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11164. /**
  11165. * Strong typing of a Mesh Render related stage step action
  11166. */
  11167. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11168. /**
  11169. * Strong typing of a simple stage step action
  11170. */
  11171. export type SimpleStageAction = () => void;
  11172. /**
  11173. * Strong typing of a render target action.
  11174. */
  11175. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11176. /**
  11177. * Strong typing of a pointer move action.
  11178. */
  11179. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11180. /**
  11181. * Strong typing of a pointer up/down action.
  11182. */
  11183. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11184. /**
  11185. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11186. * @hidden
  11187. */
  11188. export class Stage<T extends Function> extends Array<{
  11189. index: number;
  11190. component: ISceneComponent;
  11191. action: T;
  11192. }> {
  11193. /**
  11194. * Hide ctor from the rest of the world.
  11195. * @param items The items to add.
  11196. */
  11197. private constructor();
  11198. /**
  11199. * Creates a new Stage.
  11200. * @returns A new instance of a Stage
  11201. */
  11202. static Create<T extends Function>(): Stage<T>;
  11203. /**
  11204. * Registers a step in an ordered way in the targeted stage.
  11205. * @param index Defines the position to register the step in
  11206. * @param component Defines the component attached to the step
  11207. * @param action Defines the action to launch during the step
  11208. */
  11209. registerStep(index: number, component: ISceneComponent, action: T): void;
  11210. /**
  11211. * Clears all the steps from the stage.
  11212. */
  11213. clear(): void;
  11214. }
  11215. }
  11216. declare module BABYLON {
  11217. interface Scene {
  11218. /** @hidden */
  11219. _pointerOverSprite: Nullable<Sprite>;
  11220. /** @hidden */
  11221. _pickedDownSprite: Nullable<Sprite>;
  11222. /** @hidden */
  11223. _tempSpritePickingRay: Nullable<Ray>;
  11224. /**
  11225. * All of the sprite managers added to this scene
  11226. * @see http://doc.babylonjs.com/babylon101/sprites
  11227. */
  11228. spriteManagers: Array<ISpriteManager>;
  11229. /**
  11230. * An event triggered when sprites rendering is about to start
  11231. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11232. */
  11233. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11234. /**
  11235. * An event triggered when sprites rendering is done
  11236. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11237. */
  11238. onAfterSpritesRenderingObservable: Observable<Scene>;
  11239. /** @hidden */
  11240. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11241. /** Launch a ray to try to pick a sprite in the scene
  11242. * @param x position on screen
  11243. * @param y position on screen
  11244. * @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
  11245. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11246. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11247. * @returns a PickingInfo
  11248. */
  11249. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11250. /** Use the given ray to pick a sprite in the scene
  11251. * @param ray The ray (in world space) to use to pick meshes
  11252. * @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
  11253. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11254. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11255. * @returns a PickingInfo
  11256. */
  11257. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11258. /** @hidden */
  11259. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11260. /** Launch a ray to try to pick sprites in the scene
  11261. * @param x position on screen
  11262. * @param y position on screen
  11263. * @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
  11264. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11265. * @returns a PickingInfo array
  11266. */
  11267. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11268. /** Use the given ray to pick sprites in the scene
  11269. * @param ray The ray (in world space) to use to pick meshes
  11270. * @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
  11271. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11272. * @returns a PickingInfo array
  11273. */
  11274. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11275. /**
  11276. * Force the sprite under the pointer
  11277. * @param sprite defines the sprite to use
  11278. */
  11279. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11280. /**
  11281. * Gets the sprite under the pointer
  11282. * @returns a Sprite or null if no sprite is under the pointer
  11283. */
  11284. getPointerOverSprite(): Nullable<Sprite>;
  11285. }
  11286. /**
  11287. * Defines the sprite scene component responsible to manage sprites
  11288. * in a given scene.
  11289. */
  11290. export class SpriteSceneComponent implements ISceneComponent {
  11291. /**
  11292. * The component name helpfull to identify the component in the list of scene components.
  11293. */
  11294. readonly name: string;
  11295. /**
  11296. * The scene the component belongs to.
  11297. */
  11298. scene: Scene;
  11299. /** @hidden */
  11300. private _spritePredicate;
  11301. /**
  11302. * Creates a new instance of the component for the given scene
  11303. * @param scene Defines the scene to register the component in
  11304. */
  11305. constructor(scene: Scene);
  11306. /**
  11307. * Registers the component in a given scene
  11308. */
  11309. register(): void;
  11310. /**
  11311. * Rebuilds the elements related to this component in case of
  11312. * context lost for instance.
  11313. */
  11314. rebuild(): void;
  11315. /**
  11316. * Disposes the component and the associated ressources.
  11317. */
  11318. dispose(): void;
  11319. private _pickSpriteButKeepRay;
  11320. private _pointerMove;
  11321. private _pointerDown;
  11322. private _pointerUp;
  11323. }
  11324. }
  11325. declare module BABYLON {
  11326. /** @hidden */
  11327. export var fogFragmentDeclaration: {
  11328. name: string;
  11329. shader: string;
  11330. };
  11331. }
  11332. declare module BABYLON {
  11333. /** @hidden */
  11334. export var fogFragment: {
  11335. name: string;
  11336. shader: string;
  11337. };
  11338. }
  11339. declare module BABYLON {
  11340. /** @hidden */
  11341. export var spritesPixelShader: {
  11342. name: string;
  11343. shader: string;
  11344. };
  11345. }
  11346. declare module BABYLON {
  11347. /** @hidden */
  11348. export var fogVertexDeclaration: {
  11349. name: string;
  11350. shader: string;
  11351. };
  11352. }
  11353. declare module BABYLON {
  11354. /** @hidden */
  11355. export var spritesVertexShader: {
  11356. name: string;
  11357. shader: string;
  11358. };
  11359. }
  11360. declare module BABYLON {
  11361. /**
  11362. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11363. */
  11364. export interface ISpriteManager extends IDisposable {
  11365. /**
  11366. * Restricts the camera to viewing objects with the same layerMask.
  11367. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11368. */
  11369. layerMask: number;
  11370. /**
  11371. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11372. */
  11373. isPickable: boolean;
  11374. /**
  11375. * Specifies the rendering group id for this mesh (0 by default)
  11376. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11377. */
  11378. renderingGroupId: number;
  11379. /**
  11380. * Defines the list of sprites managed by the manager.
  11381. */
  11382. sprites: Array<Sprite>;
  11383. /**
  11384. * Tests the intersection of a sprite with a specific ray.
  11385. * @param ray The ray we are sending to test the collision
  11386. * @param camera The camera space we are sending rays in
  11387. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11388. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11389. * @returns picking info or null.
  11390. */
  11391. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11392. /**
  11393. * Intersects the sprites with a ray
  11394. * @param ray defines the ray to intersect with
  11395. * @param camera defines the current active camera
  11396. * @param predicate defines a predicate used to select candidate sprites
  11397. * @returns null if no hit or a PickingInfo array
  11398. */
  11399. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11400. /**
  11401. * Renders the list of sprites on screen.
  11402. */
  11403. render(): void;
  11404. }
  11405. /**
  11406. * Class used to manage multiple sprites on the same spritesheet
  11407. * @see http://doc.babylonjs.com/babylon101/sprites
  11408. */
  11409. export class SpriteManager implements ISpriteManager {
  11410. /** defines the manager's name */
  11411. name: string;
  11412. /** Gets the list of sprites */
  11413. sprites: Sprite[];
  11414. /** Gets or sets the rendering group id (0 by default) */
  11415. renderingGroupId: number;
  11416. /** Gets or sets camera layer mask */
  11417. layerMask: number;
  11418. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11419. fogEnabled: boolean;
  11420. /** Gets or sets a boolean indicating if the sprites are pickable */
  11421. isPickable: boolean;
  11422. /** Defines the default width of a cell in the spritesheet */
  11423. cellWidth: number;
  11424. /** Defines the default height of a cell in the spritesheet */
  11425. cellHeight: number;
  11426. /** Associative array from JSON sprite data file */
  11427. private _cellData;
  11428. /** Array of sprite names from JSON sprite data file */
  11429. private _spriteMap;
  11430. /** True when packed cell data from JSON file is ready*/
  11431. private _packedAndReady;
  11432. /**
  11433. * An event triggered when the manager is disposed.
  11434. */
  11435. onDisposeObservable: Observable<SpriteManager>;
  11436. private _onDisposeObserver;
  11437. /**
  11438. * Callback called when the manager is disposed
  11439. */
  11440. onDispose: () => void;
  11441. private _capacity;
  11442. private _fromPacked;
  11443. private _spriteTexture;
  11444. private _epsilon;
  11445. private _scene;
  11446. private _vertexData;
  11447. private _buffer;
  11448. private _vertexBuffers;
  11449. private _indexBuffer;
  11450. private _effectBase;
  11451. private _effectFog;
  11452. /**
  11453. * Gets or sets the spritesheet texture
  11454. */
  11455. texture: Texture;
  11456. /**
  11457. * Creates a new sprite manager
  11458. * @param name defines the manager's name
  11459. * @param imgUrl defines the sprite sheet url
  11460. * @param capacity defines the maximum allowed number of sprites
  11461. * @param cellSize defines the size of a sprite cell
  11462. * @param scene defines the hosting scene
  11463. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11464. * @param samplingMode defines the smapling mode to use with spritesheet
  11465. * @param fromPacked set to false; do not alter
  11466. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11467. */
  11468. constructor(
  11469. /** defines the manager's name */
  11470. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11471. private _makePacked;
  11472. private _appendSpriteVertex;
  11473. /**
  11474. * Intersects the sprites with a ray
  11475. * @param ray defines the ray to intersect with
  11476. * @param camera defines the current active camera
  11477. * @param predicate defines a predicate used to select candidate sprites
  11478. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11479. * @returns null if no hit or a PickingInfo
  11480. */
  11481. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11482. /**
  11483. * Intersects the sprites with a ray
  11484. * @param ray defines the ray to intersect with
  11485. * @param camera defines the current active camera
  11486. * @param predicate defines a predicate used to select candidate sprites
  11487. * @returns null if no hit or a PickingInfo array
  11488. */
  11489. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11490. /**
  11491. * Render all child sprites
  11492. */
  11493. render(): void;
  11494. /**
  11495. * Release associated resources
  11496. */
  11497. dispose(): void;
  11498. }
  11499. }
  11500. declare module BABYLON {
  11501. /**
  11502. * Class used to represent a sprite
  11503. * @see http://doc.babylonjs.com/babylon101/sprites
  11504. */
  11505. export class Sprite {
  11506. /** defines the name */
  11507. name: string;
  11508. /** Gets or sets the current world position */
  11509. position: Vector3;
  11510. /** Gets or sets the main color */
  11511. color: Color4;
  11512. /** Gets or sets the width */
  11513. width: number;
  11514. /** Gets or sets the height */
  11515. height: number;
  11516. /** Gets or sets rotation angle */
  11517. angle: number;
  11518. /** Gets or sets the cell index in the sprite sheet */
  11519. cellIndex: number;
  11520. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11521. cellRef: string;
  11522. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11523. invertU: number;
  11524. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11525. invertV: number;
  11526. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11527. disposeWhenFinishedAnimating: boolean;
  11528. /** Gets the list of attached animations */
  11529. animations: Animation[];
  11530. /** Gets or sets a boolean indicating if the sprite can be picked */
  11531. isPickable: boolean;
  11532. /**
  11533. * Gets or sets the associated action manager
  11534. */
  11535. actionManager: Nullable<ActionManager>;
  11536. private _animationStarted;
  11537. private _loopAnimation;
  11538. private _fromIndex;
  11539. private _toIndex;
  11540. private _delay;
  11541. private _direction;
  11542. private _manager;
  11543. private _time;
  11544. private _onAnimationEnd;
  11545. /**
  11546. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11547. */
  11548. isVisible: boolean;
  11549. /**
  11550. * Gets or sets the sprite size
  11551. */
  11552. size: number;
  11553. /**
  11554. * Creates a new Sprite
  11555. * @param name defines the name
  11556. * @param manager defines the manager
  11557. */
  11558. constructor(
  11559. /** defines the name */
  11560. name: string, manager: ISpriteManager);
  11561. /**
  11562. * Starts an animation
  11563. * @param from defines the initial key
  11564. * @param to defines the end key
  11565. * @param loop defines if the animation must loop
  11566. * @param delay defines the start delay (in ms)
  11567. * @param onAnimationEnd defines a callback to call when animation ends
  11568. */
  11569. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11570. /** Stops current animation (if any) */
  11571. stopAnimation(): void;
  11572. /** @hidden */
  11573. _animate(deltaTime: number): void;
  11574. /** Release associated resources */
  11575. dispose(): void;
  11576. }
  11577. }
  11578. declare module BABYLON {
  11579. /**
  11580. * Information about the result of picking within a scene
  11581. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11582. */
  11583. export class PickingInfo {
  11584. /** @hidden */
  11585. _pickingUnavailable: boolean;
  11586. /**
  11587. * If the pick collided with an object
  11588. */
  11589. hit: boolean;
  11590. /**
  11591. * Distance away where the pick collided
  11592. */
  11593. distance: number;
  11594. /**
  11595. * The location of pick collision
  11596. */
  11597. pickedPoint: Nullable<Vector3>;
  11598. /**
  11599. * The mesh corresponding the the pick collision
  11600. */
  11601. pickedMesh: Nullable<AbstractMesh>;
  11602. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11603. bu: number;
  11604. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11605. bv: number;
  11606. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11607. faceId: number;
  11608. /** Id of the the submesh that was picked */
  11609. subMeshId: number;
  11610. /** If a sprite was picked, this will be the sprite the pick collided with */
  11611. pickedSprite: Nullable<Sprite>;
  11612. /**
  11613. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11614. */
  11615. originMesh: Nullable<AbstractMesh>;
  11616. /**
  11617. * The ray that was used to perform the picking.
  11618. */
  11619. ray: Nullable<Ray>;
  11620. /**
  11621. * Gets the normal correspodning to the face the pick collided with
  11622. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11623. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11624. * @returns The normal correspodning to the face the pick collided with
  11625. */
  11626. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11627. /**
  11628. * Gets the texture coordinates of where the pick occured
  11629. * @returns the vector containing the coordnates of the texture
  11630. */
  11631. getTextureCoordinates(): Nullable<Vector2>;
  11632. }
  11633. }
  11634. declare module BABYLON {
  11635. /**
  11636. * Gather the list of pointer event types as constants.
  11637. */
  11638. export class PointerEventTypes {
  11639. /**
  11640. * 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.
  11641. */
  11642. static readonly POINTERDOWN: number;
  11643. /**
  11644. * The pointerup event is fired when a pointer is no longer active.
  11645. */
  11646. static readonly POINTERUP: number;
  11647. /**
  11648. * The pointermove event is fired when a pointer changes coordinates.
  11649. */
  11650. static readonly POINTERMOVE: number;
  11651. /**
  11652. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11653. */
  11654. static readonly POINTERWHEEL: number;
  11655. /**
  11656. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11657. */
  11658. static readonly POINTERPICK: number;
  11659. /**
  11660. * The pointertap event is fired when a the object has been touched and released without drag.
  11661. */
  11662. static readonly POINTERTAP: number;
  11663. /**
  11664. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11665. */
  11666. static readonly POINTERDOUBLETAP: number;
  11667. }
  11668. /**
  11669. * Base class of pointer info types.
  11670. */
  11671. export class PointerInfoBase {
  11672. /**
  11673. * Defines the type of event (PointerEventTypes)
  11674. */
  11675. type: number;
  11676. /**
  11677. * Defines the related dom event
  11678. */
  11679. event: PointerEvent | MouseWheelEvent;
  11680. /**
  11681. * Instantiates the base class of pointers info.
  11682. * @param type Defines the type of event (PointerEventTypes)
  11683. * @param event Defines the related dom event
  11684. */
  11685. constructor(
  11686. /**
  11687. * Defines the type of event (PointerEventTypes)
  11688. */
  11689. type: number,
  11690. /**
  11691. * Defines the related dom event
  11692. */
  11693. event: PointerEvent | MouseWheelEvent);
  11694. }
  11695. /**
  11696. * This class is used to store pointer related info for the onPrePointerObservable event.
  11697. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11698. */
  11699. export class PointerInfoPre extends PointerInfoBase {
  11700. /**
  11701. * Ray from a pointer if availible (eg. 6dof controller)
  11702. */
  11703. ray: Nullable<Ray>;
  11704. /**
  11705. * Defines the local position of the pointer on the canvas.
  11706. */
  11707. localPosition: Vector2;
  11708. /**
  11709. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11710. */
  11711. skipOnPointerObservable: boolean;
  11712. /**
  11713. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11714. * @param type Defines the type of event (PointerEventTypes)
  11715. * @param event Defines the related dom event
  11716. * @param localX Defines the local x coordinates of the pointer when the event occured
  11717. * @param localY Defines the local y coordinates of the pointer when the event occured
  11718. */
  11719. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11720. }
  11721. /**
  11722. * This type contains all the data related to a pointer event in Babylon.js.
  11723. * 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.
  11724. */
  11725. export class PointerInfo extends PointerInfoBase {
  11726. /**
  11727. * Defines the picking info associated to the info (if any)\
  11728. */
  11729. pickInfo: Nullable<PickingInfo>;
  11730. /**
  11731. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11732. * @param type Defines the type of event (PointerEventTypes)
  11733. * @param event Defines the related dom event
  11734. * @param pickInfo Defines the picking info associated to the info (if any)\
  11735. */
  11736. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11737. /**
  11738. * Defines the picking info associated to the info (if any)\
  11739. */
  11740. pickInfo: Nullable<PickingInfo>);
  11741. }
  11742. /**
  11743. * Data relating to a touch event on the screen.
  11744. */
  11745. export interface PointerTouch {
  11746. /**
  11747. * X coordinate of touch.
  11748. */
  11749. x: number;
  11750. /**
  11751. * Y coordinate of touch.
  11752. */
  11753. y: number;
  11754. /**
  11755. * Id of touch. Unique for each finger.
  11756. */
  11757. pointerId: number;
  11758. /**
  11759. * Event type passed from DOM.
  11760. */
  11761. type: any;
  11762. }
  11763. }
  11764. declare module BABYLON {
  11765. /**
  11766. * Manage the mouse inputs to control the movement of a free camera.
  11767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11768. */
  11769. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11770. /**
  11771. * Define if touch is enabled in the mouse input
  11772. */
  11773. touchEnabled: boolean;
  11774. /**
  11775. * Defines the camera the input is attached to.
  11776. */
  11777. camera: FreeCamera;
  11778. /**
  11779. * Defines the buttons associated with the input to handle camera move.
  11780. */
  11781. buttons: number[];
  11782. /**
  11783. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11784. */
  11785. angularSensibility: number;
  11786. private _pointerInput;
  11787. private _onMouseMove;
  11788. private _observer;
  11789. private previousPosition;
  11790. /**
  11791. * Observable for when a pointer move event occurs containing the move offset
  11792. */
  11793. onPointerMovedObservable: Observable<{
  11794. offsetX: number;
  11795. offsetY: number;
  11796. }>;
  11797. /**
  11798. * @hidden
  11799. * If the camera should be rotated automatically based on pointer movement
  11800. */
  11801. _allowCameraRotation: boolean;
  11802. /**
  11803. * Manage the mouse inputs to control the movement of a free camera.
  11804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11805. * @param touchEnabled Defines if touch is enabled or not
  11806. */
  11807. constructor(
  11808. /**
  11809. * Define if touch is enabled in the mouse input
  11810. */
  11811. touchEnabled?: boolean);
  11812. /**
  11813. * Attach the input controls to a specific dom element to get the input from.
  11814. * @param element Defines the element the controls should be listened from
  11815. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11816. */
  11817. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11818. /**
  11819. * Called on JS contextmenu event.
  11820. * Override this method to provide functionality.
  11821. */
  11822. protected onContextMenu(evt: PointerEvent): void;
  11823. /**
  11824. * Detach the current controls from the specified dom element.
  11825. * @param element Defines the element to stop listening the inputs from
  11826. */
  11827. detachControl(element: Nullable<HTMLElement>): void;
  11828. /**
  11829. * Gets the class name of the current intput.
  11830. * @returns the class name
  11831. */
  11832. getClassName(): string;
  11833. /**
  11834. * Get the friendly name associated with the input class.
  11835. * @returns the input friendly name
  11836. */
  11837. getSimpleName(): string;
  11838. }
  11839. }
  11840. declare module BABYLON {
  11841. /**
  11842. * Manage the touch inputs to control the movement of a free camera.
  11843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11844. */
  11845. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11846. /**
  11847. * Defines the camera the input is attached to.
  11848. */
  11849. camera: FreeCamera;
  11850. /**
  11851. * Defines the touch sensibility for rotation.
  11852. * The higher the faster.
  11853. */
  11854. touchAngularSensibility: number;
  11855. /**
  11856. * Defines the touch sensibility for move.
  11857. * The higher the faster.
  11858. */
  11859. touchMoveSensibility: number;
  11860. private _offsetX;
  11861. private _offsetY;
  11862. private _pointerPressed;
  11863. private _pointerInput;
  11864. private _observer;
  11865. private _onLostFocus;
  11866. /**
  11867. * Attach the input controls to a specific dom element to get the input from.
  11868. * @param element Defines the element the controls should be listened from
  11869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11870. */
  11871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11872. /**
  11873. * Detach the current controls from the specified dom element.
  11874. * @param element Defines the element to stop listening the inputs from
  11875. */
  11876. detachControl(element: Nullable<HTMLElement>): void;
  11877. /**
  11878. * Update the current camera state depending on the inputs that have been used this frame.
  11879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11880. */
  11881. checkInputs(): void;
  11882. /**
  11883. * Gets the class name of the current intput.
  11884. * @returns the class name
  11885. */
  11886. getClassName(): string;
  11887. /**
  11888. * Get the friendly name associated with the input class.
  11889. * @returns the input friendly name
  11890. */
  11891. getSimpleName(): string;
  11892. }
  11893. }
  11894. declare module BABYLON {
  11895. /**
  11896. * Default Inputs manager for the FreeCamera.
  11897. * It groups all the default supported inputs for ease of use.
  11898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11899. */
  11900. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11901. /**
  11902. * @hidden
  11903. */
  11904. _mouseInput: Nullable<FreeCameraMouseInput>;
  11905. /**
  11906. * Instantiates a new FreeCameraInputsManager.
  11907. * @param camera Defines the camera the inputs belong to
  11908. */
  11909. constructor(camera: FreeCamera);
  11910. /**
  11911. * Add keyboard input support to the input manager.
  11912. * @returns the current input manager
  11913. */
  11914. addKeyboard(): FreeCameraInputsManager;
  11915. /**
  11916. * Add mouse input support to the input manager.
  11917. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11918. * @returns the current input manager
  11919. */
  11920. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11921. /**
  11922. * Removes the mouse input support from the manager
  11923. * @returns the current input manager
  11924. */
  11925. removeMouse(): FreeCameraInputsManager;
  11926. /**
  11927. * Add touch input support to the input manager.
  11928. * @returns the current input manager
  11929. */
  11930. addTouch(): FreeCameraInputsManager;
  11931. /**
  11932. * Remove all attached input methods from a camera
  11933. */
  11934. clear(): void;
  11935. }
  11936. }
  11937. declare module BABYLON {
  11938. /**
  11939. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11940. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11941. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11942. */
  11943. export class FreeCamera extends TargetCamera {
  11944. /**
  11945. * Define the collision ellipsoid of the camera.
  11946. * This is helpful to simulate a camera body like the player body around the camera
  11947. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11948. */
  11949. ellipsoid: Vector3;
  11950. /**
  11951. * Define an offset for the position of the ellipsoid around the camera.
  11952. * This can be helpful to determine the center of the body near the gravity center of the body
  11953. * instead of its head.
  11954. */
  11955. ellipsoidOffset: Vector3;
  11956. /**
  11957. * Enable or disable collisions of the camera with the rest of the scene objects.
  11958. */
  11959. checkCollisions: boolean;
  11960. /**
  11961. * Enable or disable gravity on the camera.
  11962. */
  11963. applyGravity: boolean;
  11964. /**
  11965. * Define the input manager associated to the camera.
  11966. */
  11967. inputs: FreeCameraInputsManager;
  11968. /**
  11969. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11970. * Higher values reduce sensitivity.
  11971. */
  11972. /**
  11973. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11974. * Higher values reduce sensitivity.
  11975. */
  11976. angularSensibility: number;
  11977. /**
  11978. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11979. */
  11980. keysUp: number[];
  11981. /**
  11982. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11983. */
  11984. keysDown: number[];
  11985. /**
  11986. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11987. */
  11988. keysLeft: number[];
  11989. /**
  11990. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11991. */
  11992. keysRight: number[];
  11993. /**
  11994. * Event raised when the camera collide with a mesh in the scene.
  11995. */
  11996. onCollide: (collidedMesh: AbstractMesh) => void;
  11997. private _collider;
  11998. private _needMoveForGravity;
  11999. private _oldPosition;
  12000. private _diffPosition;
  12001. private _newPosition;
  12002. /** @hidden */
  12003. _localDirection: Vector3;
  12004. /** @hidden */
  12005. _transformedDirection: Vector3;
  12006. /**
  12007. * Instantiates a Free Camera.
  12008. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12009. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12010. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12011. * @param name Define the name of the camera in the scene
  12012. * @param position Define the start position of the camera in the scene
  12013. * @param scene Define the scene the camera belongs to
  12014. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12015. */
  12016. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12017. /**
  12018. * Attached controls to the current camera.
  12019. * @param element Defines the element the controls should be listened from
  12020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12021. */
  12022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12023. /**
  12024. * Detach the current controls from the camera.
  12025. * The camera will stop reacting to inputs.
  12026. * @param element Defines the element to stop listening the inputs from
  12027. */
  12028. detachControl(element: HTMLElement): void;
  12029. private _collisionMask;
  12030. /**
  12031. * Define a collision mask to limit the list of object the camera can collide with
  12032. */
  12033. collisionMask: number;
  12034. /** @hidden */
  12035. _collideWithWorld(displacement: Vector3): void;
  12036. private _onCollisionPositionChange;
  12037. /** @hidden */
  12038. _checkInputs(): void;
  12039. /** @hidden */
  12040. _decideIfNeedsToMove(): boolean;
  12041. /** @hidden */
  12042. _updatePosition(): void;
  12043. /**
  12044. * Destroy the camera and release the current resources hold by it.
  12045. */
  12046. dispose(): void;
  12047. /**
  12048. * Gets the current object class name.
  12049. * @return the class name
  12050. */
  12051. getClassName(): string;
  12052. }
  12053. }
  12054. declare module BABYLON {
  12055. /**
  12056. * Represents a gamepad control stick position
  12057. */
  12058. export class StickValues {
  12059. /**
  12060. * The x component of the control stick
  12061. */
  12062. x: number;
  12063. /**
  12064. * The y component of the control stick
  12065. */
  12066. y: number;
  12067. /**
  12068. * Initializes the gamepad x and y control stick values
  12069. * @param x The x component of the gamepad control stick value
  12070. * @param y The y component of the gamepad control stick value
  12071. */
  12072. constructor(
  12073. /**
  12074. * The x component of the control stick
  12075. */
  12076. x: number,
  12077. /**
  12078. * The y component of the control stick
  12079. */
  12080. y: number);
  12081. }
  12082. /**
  12083. * An interface which manages callbacks for gamepad button changes
  12084. */
  12085. export interface GamepadButtonChanges {
  12086. /**
  12087. * Called when a gamepad has been changed
  12088. */
  12089. changed: boolean;
  12090. /**
  12091. * Called when a gamepad press event has been triggered
  12092. */
  12093. pressChanged: boolean;
  12094. /**
  12095. * Called when a touch event has been triggered
  12096. */
  12097. touchChanged: boolean;
  12098. /**
  12099. * Called when a value has changed
  12100. */
  12101. valueChanged: boolean;
  12102. }
  12103. /**
  12104. * Represents a gamepad
  12105. */
  12106. export class Gamepad {
  12107. /**
  12108. * The id of the gamepad
  12109. */
  12110. id: string;
  12111. /**
  12112. * The index of the gamepad
  12113. */
  12114. index: number;
  12115. /**
  12116. * The browser gamepad
  12117. */
  12118. browserGamepad: any;
  12119. /**
  12120. * Specifies what type of gamepad this represents
  12121. */
  12122. type: number;
  12123. private _leftStick;
  12124. private _rightStick;
  12125. /** @hidden */
  12126. _isConnected: boolean;
  12127. private _leftStickAxisX;
  12128. private _leftStickAxisY;
  12129. private _rightStickAxisX;
  12130. private _rightStickAxisY;
  12131. /**
  12132. * Triggered when the left control stick has been changed
  12133. */
  12134. private _onleftstickchanged;
  12135. /**
  12136. * Triggered when the right control stick has been changed
  12137. */
  12138. private _onrightstickchanged;
  12139. /**
  12140. * Represents a gamepad controller
  12141. */
  12142. static GAMEPAD: number;
  12143. /**
  12144. * Represents a generic controller
  12145. */
  12146. static GENERIC: number;
  12147. /**
  12148. * Represents an XBox controller
  12149. */
  12150. static XBOX: number;
  12151. /**
  12152. * Represents a pose-enabled controller
  12153. */
  12154. static POSE_ENABLED: number;
  12155. /**
  12156. * Represents an Dual Shock controller
  12157. */
  12158. static DUALSHOCK: number;
  12159. /**
  12160. * Specifies whether the left control stick should be Y-inverted
  12161. */
  12162. protected _invertLeftStickY: boolean;
  12163. /**
  12164. * Specifies if the gamepad has been connected
  12165. */
  12166. readonly isConnected: boolean;
  12167. /**
  12168. * Initializes the gamepad
  12169. * @param id The id of the gamepad
  12170. * @param index The index of the gamepad
  12171. * @param browserGamepad The browser gamepad
  12172. * @param leftStickX The x component of the left joystick
  12173. * @param leftStickY The y component of the left joystick
  12174. * @param rightStickX The x component of the right joystick
  12175. * @param rightStickY The y component of the right joystick
  12176. */
  12177. constructor(
  12178. /**
  12179. * The id of the gamepad
  12180. */
  12181. id: string,
  12182. /**
  12183. * The index of the gamepad
  12184. */
  12185. index: number,
  12186. /**
  12187. * The browser gamepad
  12188. */
  12189. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12190. /**
  12191. * Callback triggered when the left joystick has changed
  12192. * @param callback
  12193. */
  12194. onleftstickchanged(callback: (values: StickValues) => void): void;
  12195. /**
  12196. * Callback triggered when the right joystick has changed
  12197. * @param callback
  12198. */
  12199. onrightstickchanged(callback: (values: StickValues) => void): void;
  12200. /**
  12201. * Gets the left joystick
  12202. */
  12203. /**
  12204. * Sets the left joystick values
  12205. */
  12206. leftStick: StickValues;
  12207. /**
  12208. * Gets the right joystick
  12209. */
  12210. /**
  12211. * Sets the right joystick value
  12212. */
  12213. rightStick: StickValues;
  12214. /**
  12215. * Updates the gamepad joystick positions
  12216. */
  12217. update(): void;
  12218. /**
  12219. * Disposes the gamepad
  12220. */
  12221. dispose(): void;
  12222. }
  12223. /**
  12224. * Represents a generic gamepad
  12225. */
  12226. export class GenericPad extends Gamepad {
  12227. private _buttons;
  12228. private _onbuttondown;
  12229. private _onbuttonup;
  12230. /**
  12231. * Observable triggered when a button has been pressed
  12232. */
  12233. onButtonDownObservable: Observable<number>;
  12234. /**
  12235. * Observable triggered when a button has been released
  12236. */
  12237. onButtonUpObservable: Observable<number>;
  12238. /**
  12239. * Callback triggered when a button has been pressed
  12240. * @param callback Called when a button has been pressed
  12241. */
  12242. onbuttondown(callback: (buttonPressed: number) => void): void;
  12243. /**
  12244. * Callback triggered when a button has been released
  12245. * @param callback Called when a button has been released
  12246. */
  12247. onbuttonup(callback: (buttonReleased: number) => void): void;
  12248. /**
  12249. * Initializes the generic gamepad
  12250. * @param id The id of the generic gamepad
  12251. * @param index The index of the generic gamepad
  12252. * @param browserGamepad The browser gamepad
  12253. */
  12254. constructor(id: string, index: number, browserGamepad: any);
  12255. private _setButtonValue;
  12256. /**
  12257. * Updates the generic gamepad
  12258. */
  12259. update(): void;
  12260. /**
  12261. * Disposes the generic gamepad
  12262. */
  12263. dispose(): void;
  12264. }
  12265. }
  12266. declare module BABYLON {
  12267. interface Engine {
  12268. /**
  12269. * Creates a raw texture
  12270. * @param data defines the data to store in the texture
  12271. * @param width defines the width of the texture
  12272. * @param height defines the height of the texture
  12273. * @param format defines the format of the data
  12274. * @param generateMipMaps defines if the engine should generate the mip levels
  12275. * @param invertY defines if data must be stored with Y axis inverted
  12276. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12277. * @param compression defines the compression used (null by default)
  12278. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12279. * @returns the raw texture inside an InternalTexture
  12280. */
  12281. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12282. /**
  12283. * Update a raw texture
  12284. * @param texture defines the texture to update
  12285. * @param data defines the data to store in the texture
  12286. * @param format defines the format of the data
  12287. * @param invertY defines if data must be stored with Y axis inverted
  12288. */
  12289. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12290. /**
  12291. * Update a raw texture
  12292. * @param texture defines the texture to update
  12293. * @param data defines the data to store in the texture
  12294. * @param format defines the format of the data
  12295. * @param invertY defines if data must be stored with Y axis inverted
  12296. * @param compression defines the compression used (null by default)
  12297. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12298. */
  12299. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12300. /**
  12301. * Creates a new raw cube texture
  12302. * @param data defines the array of data to use to create each face
  12303. * @param size defines the size of the textures
  12304. * @param format defines the format of the data
  12305. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12306. * @param generateMipMaps defines if the engine should generate the mip levels
  12307. * @param invertY defines if data must be stored with Y axis inverted
  12308. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12309. * @param compression defines the compression used (null by default)
  12310. * @returns the cube texture as an InternalTexture
  12311. */
  12312. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12313. /**
  12314. * Update a raw cube texture
  12315. * @param texture defines the texture to udpdate
  12316. * @param data defines the data to store
  12317. * @param format defines the data format
  12318. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12319. * @param invertY defines if data must be stored with Y axis inverted
  12320. */
  12321. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12322. /**
  12323. * Update a raw cube texture
  12324. * @param texture defines the texture to udpdate
  12325. * @param data defines the data to store
  12326. * @param format defines the data format
  12327. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12328. * @param invertY defines if data must be stored with Y axis inverted
  12329. * @param compression defines the compression used (null by default)
  12330. */
  12331. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12332. /**
  12333. * Update a raw cube texture
  12334. * @param texture defines the texture to udpdate
  12335. * @param data defines the data to store
  12336. * @param format defines the data format
  12337. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12338. * @param invertY defines if data must be stored with Y axis inverted
  12339. * @param compression defines the compression used (null by default)
  12340. * @param level defines which level of the texture to update
  12341. */
  12342. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12343. /**
  12344. * Creates a new raw cube texture from a specified url
  12345. * @param url defines the url where the data is located
  12346. * @param scene defines the current scene
  12347. * @param size defines the size of the textures
  12348. * @param format defines the format of the data
  12349. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12350. * @param noMipmap defines if the engine should avoid generating the mip levels
  12351. * @param callback defines a callback used to extract texture data from loaded data
  12352. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12353. * @param onLoad defines a callback called when texture is loaded
  12354. * @param onError defines a callback called if there is an error
  12355. * @returns the cube texture as an InternalTexture
  12356. */
  12357. 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;
  12358. /**
  12359. * Creates a new raw cube texture from a specified url
  12360. * @param url defines the url where the data is located
  12361. * @param scene defines the current scene
  12362. * @param size defines the size of the textures
  12363. * @param format defines the format of the data
  12364. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12365. * @param noMipmap defines if the engine should avoid generating the mip levels
  12366. * @param callback defines a callback used to extract texture data from loaded data
  12367. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12368. * @param onLoad defines a callback called when texture is loaded
  12369. * @param onError defines a callback called if there is an error
  12370. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12371. * @param invertY defines if data must be stored with Y axis inverted
  12372. * @returns the cube texture as an InternalTexture
  12373. */
  12374. 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;
  12375. /**
  12376. * Creates a new raw 3D texture
  12377. * @param data defines the data used to create the texture
  12378. * @param width defines the width of the texture
  12379. * @param height defines the height of the texture
  12380. * @param depth defines the depth of the texture
  12381. * @param format defines the format of the texture
  12382. * @param generateMipMaps defines if the engine must generate mip levels
  12383. * @param invertY defines if data must be stored with Y axis inverted
  12384. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12385. * @param compression defines the compressed used (can be null)
  12386. * @param textureType defines the compressed used (can be null)
  12387. * @returns a new raw 3D texture (stored in an InternalTexture)
  12388. */
  12389. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12390. /**
  12391. * Update a raw 3D texture
  12392. * @param texture defines the texture to update
  12393. * @param data defines the data to store
  12394. * @param format defines the data format
  12395. * @param invertY defines if data must be stored with Y axis inverted
  12396. */
  12397. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12398. /**
  12399. * Update a raw 3D texture
  12400. * @param texture defines the texture to update
  12401. * @param data defines the data to store
  12402. * @param format defines the data format
  12403. * @param invertY defines if data must be stored with Y axis inverted
  12404. * @param compression defines the used compression (can be null)
  12405. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12406. */
  12407. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12408. }
  12409. }
  12410. declare module BABYLON {
  12411. /**
  12412. * Raw texture can help creating a texture directly from an array of data.
  12413. * This can be super useful if you either get the data from an uncompressed source or
  12414. * if you wish to create your texture pixel by pixel.
  12415. */
  12416. export class RawTexture extends Texture {
  12417. /**
  12418. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12419. */
  12420. format: number;
  12421. private _engine;
  12422. /**
  12423. * Instantiates a new RawTexture.
  12424. * Raw texture can help creating a texture directly from an array of data.
  12425. * This can be super useful if you either get the data from an uncompressed source or
  12426. * if you wish to create your texture pixel by pixel.
  12427. * @param data define the array of data to use to create the texture
  12428. * @param width define the width of the texture
  12429. * @param height define the height of the texture
  12430. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12431. * @param scene define the scene the texture belongs to
  12432. * @param generateMipMaps define whether mip maps should be generated or not
  12433. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12434. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12435. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12436. */
  12437. constructor(data: ArrayBufferView, width: number, height: number,
  12438. /**
  12439. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12440. */
  12441. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12442. /**
  12443. * Updates the texture underlying data.
  12444. * @param data Define the new data of the texture
  12445. */
  12446. update(data: ArrayBufferView): void;
  12447. /**
  12448. * Creates a luminance texture from some data.
  12449. * @param data Define the texture data
  12450. * @param width Define the width of the texture
  12451. * @param height Define the height of the texture
  12452. * @param scene Define the scene the texture belongs to
  12453. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12456. * @returns the luminance texture
  12457. */
  12458. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12459. /**
  12460. * Creates a luminance alpha texture from some data.
  12461. * @param data Define the texture data
  12462. * @param width Define the width of the texture
  12463. * @param height Define the height of the texture
  12464. * @param scene Define the scene the texture belongs to
  12465. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12466. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12467. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12468. * @returns the luminance alpha texture
  12469. */
  12470. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12471. /**
  12472. * Creates an alpha texture from some data.
  12473. * @param data Define the texture data
  12474. * @param width Define the width of the texture
  12475. * @param height Define the height of the texture
  12476. * @param scene Define the scene the texture belongs to
  12477. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12478. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12479. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12480. * @returns the alpha texture
  12481. */
  12482. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12483. /**
  12484. * Creates a RGB texture from some data.
  12485. * @param data Define the texture data
  12486. * @param width Define the width of the texture
  12487. * @param height Define the height of the texture
  12488. * @param scene Define the scene the texture belongs to
  12489. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12490. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12491. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12492. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12493. * @returns the RGB alpha texture
  12494. */
  12495. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12496. /**
  12497. * Creates a RGBA texture from some data.
  12498. * @param data Define the texture data
  12499. * @param width Define the width of the texture
  12500. * @param height Define the height of the texture
  12501. * @param scene Define the scene the texture belongs to
  12502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12505. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12506. * @returns the RGBA texture
  12507. */
  12508. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12509. /**
  12510. * Creates a R texture from some data.
  12511. * @param data Define the texture data
  12512. * @param width Define the width of the texture
  12513. * @param height Define the height of the texture
  12514. * @param scene Define the scene the texture belongs to
  12515. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12516. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12517. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12518. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12519. * @returns the R texture
  12520. */
  12521. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12522. }
  12523. }
  12524. declare module BABYLON {
  12525. /**
  12526. * Interface for the size containing width and height
  12527. */
  12528. export interface ISize {
  12529. /**
  12530. * Width
  12531. */
  12532. width: number;
  12533. /**
  12534. * Heighht
  12535. */
  12536. height: number;
  12537. }
  12538. /**
  12539. * Size containing widht and height
  12540. */
  12541. export class Size implements ISize {
  12542. /**
  12543. * Width
  12544. */
  12545. width: number;
  12546. /**
  12547. * Height
  12548. */
  12549. height: number;
  12550. /**
  12551. * Creates a Size object from the given width and height (floats).
  12552. * @param width width of the new size
  12553. * @param height height of the new size
  12554. */
  12555. constructor(width: number, height: number);
  12556. /**
  12557. * Returns a string with the Size width and height
  12558. * @returns a string with the Size width and height
  12559. */
  12560. toString(): string;
  12561. /**
  12562. * "Size"
  12563. * @returns the string "Size"
  12564. */
  12565. getClassName(): string;
  12566. /**
  12567. * Returns the Size hash code.
  12568. * @returns a hash code for a unique width and height
  12569. */
  12570. getHashCode(): number;
  12571. /**
  12572. * Updates the current size from the given one.
  12573. * @param src the given size
  12574. */
  12575. copyFrom(src: Size): void;
  12576. /**
  12577. * Updates in place the current Size from the given floats.
  12578. * @param width width of the new size
  12579. * @param height height of the new size
  12580. * @returns the updated Size.
  12581. */
  12582. copyFromFloats(width: number, height: number): Size;
  12583. /**
  12584. * Updates in place the current Size from the given floats.
  12585. * @param width width to set
  12586. * @param height height to set
  12587. * @returns the updated Size.
  12588. */
  12589. set(width: number, height: number): Size;
  12590. /**
  12591. * Multiplies the width and height by numbers
  12592. * @param w factor to multiple the width by
  12593. * @param h factor to multiple the height by
  12594. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12595. */
  12596. multiplyByFloats(w: number, h: number): Size;
  12597. /**
  12598. * Clones the size
  12599. * @returns a new Size copied from the given one.
  12600. */
  12601. clone(): Size;
  12602. /**
  12603. * True if the current Size and the given one width and height are strictly equal.
  12604. * @param other the other size to compare against
  12605. * @returns True if the current Size and the given one width and height are strictly equal.
  12606. */
  12607. equals(other: Size): boolean;
  12608. /**
  12609. * The surface of the Size : width * height (float).
  12610. */
  12611. readonly surface: number;
  12612. /**
  12613. * Create a new size of zero
  12614. * @returns a new Size set to (0.0, 0.0)
  12615. */
  12616. static Zero(): Size;
  12617. /**
  12618. * Sums the width and height of two sizes
  12619. * @param otherSize size to add to this size
  12620. * @returns a new Size set as the addition result of the current Size and the given one.
  12621. */
  12622. add(otherSize: Size): Size;
  12623. /**
  12624. * Subtracts the width and height of two
  12625. * @param otherSize size to subtract to this size
  12626. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12627. */
  12628. subtract(otherSize: Size): Size;
  12629. /**
  12630. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12631. * @param start starting size to lerp between
  12632. * @param end end size to lerp between
  12633. * @param amount amount to lerp between the start and end values
  12634. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12635. */
  12636. static Lerp(start: Size, end: Size, amount: number): Size;
  12637. }
  12638. }
  12639. declare module BABYLON {
  12640. /**
  12641. * Defines a runtime animation
  12642. */
  12643. export class RuntimeAnimation {
  12644. private _events;
  12645. /**
  12646. * The current frame of the runtime animation
  12647. */
  12648. private _currentFrame;
  12649. /**
  12650. * The animation used by the runtime animation
  12651. */
  12652. private _animation;
  12653. /**
  12654. * The target of the runtime animation
  12655. */
  12656. private _target;
  12657. /**
  12658. * The initiating animatable
  12659. */
  12660. private _host;
  12661. /**
  12662. * The original value of the runtime animation
  12663. */
  12664. private _originalValue;
  12665. /**
  12666. * The original blend value of the runtime animation
  12667. */
  12668. private _originalBlendValue;
  12669. /**
  12670. * The offsets cache of the runtime animation
  12671. */
  12672. private _offsetsCache;
  12673. /**
  12674. * The high limits cache of the runtime animation
  12675. */
  12676. private _highLimitsCache;
  12677. /**
  12678. * Specifies if the runtime animation has been stopped
  12679. */
  12680. private _stopped;
  12681. /**
  12682. * The blending factor of the runtime animation
  12683. */
  12684. private _blendingFactor;
  12685. /**
  12686. * The BabylonJS scene
  12687. */
  12688. private _scene;
  12689. /**
  12690. * The current value of the runtime animation
  12691. */
  12692. private _currentValue;
  12693. /** @hidden */
  12694. _animationState: _IAnimationState;
  12695. /**
  12696. * The active target of the runtime animation
  12697. */
  12698. private _activeTargets;
  12699. private _currentActiveTarget;
  12700. private _directTarget;
  12701. /**
  12702. * The target path of the runtime animation
  12703. */
  12704. private _targetPath;
  12705. /**
  12706. * The weight of the runtime animation
  12707. */
  12708. private _weight;
  12709. /**
  12710. * The ratio offset of the runtime animation
  12711. */
  12712. private _ratioOffset;
  12713. /**
  12714. * The previous delay of the runtime animation
  12715. */
  12716. private _previousDelay;
  12717. /**
  12718. * The previous ratio of the runtime animation
  12719. */
  12720. private _previousRatio;
  12721. private _enableBlending;
  12722. private _keys;
  12723. private _minFrame;
  12724. private _maxFrame;
  12725. private _minValue;
  12726. private _maxValue;
  12727. private _targetIsArray;
  12728. /**
  12729. * Gets the current frame of the runtime animation
  12730. */
  12731. readonly currentFrame: number;
  12732. /**
  12733. * Gets the weight of the runtime animation
  12734. */
  12735. readonly weight: number;
  12736. /**
  12737. * Gets the current value of the runtime animation
  12738. */
  12739. readonly currentValue: any;
  12740. /**
  12741. * Gets the target path of the runtime animation
  12742. */
  12743. readonly targetPath: string;
  12744. /**
  12745. * Gets the actual target of the runtime animation
  12746. */
  12747. readonly target: any;
  12748. /** @hidden */
  12749. _onLoop: () => void;
  12750. /**
  12751. * Create a new RuntimeAnimation object
  12752. * @param target defines the target of the animation
  12753. * @param animation defines the source animation object
  12754. * @param scene defines the hosting scene
  12755. * @param host defines the initiating Animatable
  12756. */
  12757. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12758. private _preparePath;
  12759. /**
  12760. * Gets the animation from the runtime animation
  12761. */
  12762. readonly animation: Animation;
  12763. /**
  12764. * Resets the runtime animation to the beginning
  12765. * @param restoreOriginal defines whether to restore the target property to the original value
  12766. */
  12767. reset(restoreOriginal?: boolean): void;
  12768. /**
  12769. * Specifies if the runtime animation is stopped
  12770. * @returns Boolean specifying if the runtime animation is stopped
  12771. */
  12772. isStopped(): boolean;
  12773. /**
  12774. * Disposes of the runtime animation
  12775. */
  12776. dispose(): void;
  12777. /**
  12778. * Apply the interpolated value to the target
  12779. * @param currentValue defines the value computed by the animation
  12780. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12781. */
  12782. setValue(currentValue: any, weight: number): void;
  12783. private _getOriginalValues;
  12784. private _setValue;
  12785. /**
  12786. * Gets the loop pmode of the runtime animation
  12787. * @returns Loop Mode
  12788. */
  12789. private _getCorrectLoopMode;
  12790. /**
  12791. * Move the current animation to a given frame
  12792. * @param frame defines the frame to move to
  12793. */
  12794. goToFrame(frame: number): void;
  12795. /**
  12796. * @hidden Internal use only
  12797. */
  12798. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12799. /**
  12800. * Execute the current animation
  12801. * @param delay defines the delay to add to the current frame
  12802. * @param from defines the lower bound of the animation range
  12803. * @param to defines the upper bound of the animation range
  12804. * @param loop defines if the current animation must loop
  12805. * @param speedRatio defines the current speed ratio
  12806. * @param weight defines the weight of the animation (default is -1 so no weight)
  12807. * @param onLoop optional callback called when animation loops
  12808. * @returns a boolean indicating if the animation is running
  12809. */
  12810. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12811. }
  12812. }
  12813. declare module BABYLON {
  12814. /**
  12815. * Class used to store an actual running animation
  12816. */
  12817. export class Animatable {
  12818. /** defines the target object */
  12819. target: any;
  12820. /** defines the starting frame number (default is 0) */
  12821. fromFrame: number;
  12822. /** defines the ending frame number (default is 100) */
  12823. toFrame: number;
  12824. /** defines if the animation must loop (default is false) */
  12825. loopAnimation: boolean;
  12826. /** defines a callback to call when animation ends if it is not looping */
  12827. onAnimationEnd?: (() => void) | null | undefined;
  12828. /** defines a callback to call when animation loops */
  12829. onAnimationLoop?: (() => void) | null | undefined;
  12830. private _localDelayOffset;
  12831. private _pausedDelay;
  12832. private _runtimeAnimations;
  12833. private _paused;
  12834. private _scene;
  12835. private _speedRatio;
  12836. private _weight;
  12837. private _syncRoot;
  12838. /**
  12839. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12840. * This will only apply for non looping animation (default is true)
  12841. */
  12842. disposeOnEnd: boolean;
  12843. /**
  12844. * Gets a boolean indicating if the animation has started
  12845. */
  12846. animationStarted: boolean;
  12847. /**
  12848. * Observer raised when the animation ends
  12849. */
  12850. onAnimationEndObservable: Observable<Animatable>;
  12851. /**
  12852. * Observer raised when the animation loops
  12853. */
  12854. onAnimationLoopObservable: Observable<Animatable>;
  12855. /**
  12856. * Gets the root Animatable used to synchronize and normalize animations
  12857. */
  12858. readonly syncRoot: Nullable<Animatable>;
  12859. /**
  12860. * Gets the current frame of the first RuntimeAnimation
  12861. * Used to synchronize Animatables
  12862. */
  12863. readonly masterFrame: number;
  12864. /**
  12865. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12866. */
  12867. weight: number;
  12868. /**
  12869. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12870. */
  12871. speedRatio: number;
  12872. /**
  12873. * Creates a new Animatable
  12874. * @param scene defines the hosting scene
  12875. * @param target defines the target object
  12876. * @param fromFrame defines the starting frame number (default is 0)
  12877. * @param toFrame defines the ending frame number (default is 100)
  12878. * @param loopAnimation defines if the animation must loop (default is false)
  12879. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12880. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12881. * @param animations defines a group of animation to add to the new Animatable
  12882. * @param onAnimationLoop defines a callback to call when animation loops
  12883. */
  12884. constructor(scene: Scene,
  12885. /** defines the target object */
  12886. target: any,
  12887. /** defines the starting frame number (default is 0) */
  12888. fromFrame?: number,
  12889. /** defines the ending frame number (default is 100) */
  12890. toFrame?: number,
  12891. /** defines if the animation must loop (default is false) */
  12892. loopAnimation?: boolean, speedRatio?: number,
  12893. /** defines a callback to call when animation ends if it is not looping */
  12894. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12895. /** defines a callback to call when animation loops */
  12896. onAnimationLoop?: (() => void) | null | undefined);
  12897. /**
  12898. * Synchronize and normalize current Animatable with a source Animatable
  12899. * This is useful when using animation weights and when animations are not of the same length
  12900. * @param root defines the root Animatable to synchronize with
  12901. * @returns the current Animatable
  12902. */
  12903. syncWith(root: Animatable): Animatable;
  12904. /**
  12905. * Gets the list of runtime animations
  12906. * @returns an array of RuntimeAnimation
  12907. */
  12908. getAnimations(): RuntimeAnimation[];
  12909. /**
  12910. * Adds more animations to the current animatable
  12911. * @param target defines the target of the animations
  12912. * @param animations defines the new animations to add
  12913. */
  12914. appendAnimations(target: any, animations: Animation[]): void;
  12915. /**
  12916. * Gets the source animation for a specific property
  12917. * @param property defines the propertyu to look for
  12918. * @returns null or the source animation for the given property
  12919. */
  12920. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12921. /**
  12922. * Gets the runtime animation for a specific property
  12923. * @param property defines the propertyu to look for
  12924. * @returns null or the runtime animation for the given property
  12925. */
  12926. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12927. /**
  12928. * Resets the animatable to its original state
  12929. */
  12930. reset(): void;
  12931. /**
  12932. * Allows the animatable to blend with current running animations
  12933. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12934. * @param blendingSpeed defines the blending speed to use
  12935. */
  12936. enableBlending(blendingSpeed: number): void;
  12937. /**
  12938. * Disable animation blending
  12939. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12940. */
  12941. disableBlending(): void;
  12942. /**
  12943. * Jump directly to a given frame
  12944. * @param frame defines the frame to jump to
  12945. */
  12946. goToFrame(frame: number): void;
  12947. /**
  12948. * Pause the animation
  12949. */
  12950. pause(): void;
  12951. /**
  12952. * Restart the animation
  12953. */
  12954. restart(): void;
  12955. private _raiseOnAnimationEnd;
  12956. /**
  12957. * Stop and delete the current animation
  12958. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12959. * @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)
  12960. */
  12961. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12962. /**
  12963. * Wait asynchronously for the animation to end
  12964. * @returns a promise which will be fullfilled when the animation ends
  12965. */
  12966. waitAsync(): Promise<Animatable>;
  12967. /** @hidden */
  12968. _animate(delay: number): boolean;
  12969. }
  12970. interface Scene {
  12971. /** @hidden */
  12972. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12973. /** @hidden */
  12974. _processLateAnimationBindingsForMatrices(holder: {
  12975. totalWeight: number;
  12976. animations: RuntimeAnimation[];
  12977. originalValue: Matrix;
  12978. }): any;
  12979. /** @hidden */
  12980. _processLateAnimationBindingsForQuaternions(holder: {
  12981. totalWeight: number;
  12982. animations: RuntimeAnimation[];
  12983. originalValue: Quaternion;
  12984. }, refQuaternion: Quaternion): Quaternion;
  12985. /** @hidden */
  12986. _processLateAnimationBindings(): void;
  12987. /**
  12988. * Will start the animation sequence of a given target
  12989. * @param target defines the target
  12990. * @param from defines from which frame should animation start
  12991. * @param to defines until which frame should animation run.
  12992. * @param weight defines the weight to apply to the animation (1.0 by default)
  12993. * @param loop defines if the animation loops
  12994. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12995. * @param onAnimationEnd defines the function to be executed when the animation ends
  12996. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12997. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12998. * @param onAnimationLoop defines the callback to call when an animation loops
  12999. * @returns the animatable object created for this animation
  13000. */
  13001. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13002. /**
  13003. * Will start the animation sequence of a given target
  13004. * @param target defines the target
  13005. * @param from defines from which frame should animation start
  13006. * @param to defines until which frame should animation run.
  13007. * @param loop defines if the animation loops
  13008. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13009. * @param onAnimationEnd defines the function to be executed when the animation ends
  13010. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13011. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13012. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13013. * @param onAnimationLoop defines the callback to call when an animation loops
  13014. * @returns the animatable object created for this animation
  13015. */
  13016. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13017. /**
  13018. * Will start the animation sequence of a given target and its hierarchy
  13019. * @param target defines the target
  13020. * @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.
  13021. * @param from defines from which frame should animation start
  13022. * @param to defines until which frame should animation run.
  13023. * @param loop defines if the animation loops
  13024. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13025. * @param onAnimationEnd defines the function to be executed when the animation ends
  13026. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13027. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13028. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13029. * @param onAnimationLoop defines the callback to call when an animation loops
  13030. * @returns the list of created animatables
  13031. */
  13032. 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[];
  13033. /**
  13034. * Begin a new animation on a given node
  13035. * @param target defines the target where the animation will take place
  13036. * @param animations defines the list of animations to start
  13037. * @param from defines the initial value
  13038. * @param to defines the final value
  13039. * @param loop defines if you want animation to loop (off by default)
  13040. * @param speedRatio defines the speed ratio to apply to all animations
  13041. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13042. * @param onAnimationLoop defines the callback to call when an animation loops
  13043. * @returns the list of created animatables
  13044. */
  13045. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13046. /**
  13047. * Begin a new animation on a given node and its hierarchy
  13048. * @param target defines the root node where the animation will take place
  13049. * @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.
  13050. * @param animations defines the list of animations to start
  13051. * @param from defines the initial value
  13052. * @param to defines the final value
  13053. * @param loop defines if you want animation to loop (off by default)
  13054. * @param speedRatio defines the speed ratio to apply to all animations
  13055. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13056. * @param onAnimationLoop defines the callback to call when an animation loops
  13057. * @returns the list of animatables created for all nodes
  13058. */
  13059. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13060. /**
  13061. * Gets the animatable associated with a specific target
  13062. * @param target defines the target of the animatable
  13063. * @returns the required animatable if found
  13064. */
  13065. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13066. /**
  13067. * Gets all animatables associated with a given target
  13068. * @param target defines the target to look animatables for
  13069. * @returns an array of Animatables
  13070. */
  13071. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13072. /**
  13073. * Stops and removes all animations that have been applied to the scene
  13074. */
  13075. stopAllAnimations(): void;
  13076. /**
  13077. * Gets the current delta time used by animation engine
  13078. */
  13079. deltaTime: number;
  13080. }
  13081. interface Bone {
  13082. /**
  13083. * Copy an animation range from another bone
  13084. * @param source defines the source bone
  13085. * @param rangeName defines the range name to copy
  13086. * @param frameOffset defines the frame offset
  13087. * @param rescaleAsRequired defines if rescaling must be applied if required
  13088. * @param skelDimensionsRatio defines the scaling ratio
  13089. * @returns true if operation was successful
  13090. */
  13091. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13092. }
  13093. }
  13094. declare module BABYLON {
  13095. /**
  13096. * Class used to override all child animations of a given target
  13097. */
  13098. export class AnimationPropertiesOverride {
  13099. /**
  13100. * Gets or sets a value indicating if animation blending must be used
  13101. */
  13102. enableBlending: boolean;
  13103. /**
  13104. * Gets or sets the blending speed to use when enableBlending is true
  13105. */
  13106. blendingSpeed: number;
  13107. /**
  13108. * Gets or sets the default loop mode to use
  13109. */
  13110. loopMode: number;
  13111. }
  13112. }
  13113. declare module BABYLON {
  13114. /**
  13115. * Class used to handle skinning animations
  13116. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13117. */
  13118. export class Skeleton implements IAnimatable {
  13119. /** defines the skeleton name */
  13120. name: string;
  13121. /** defines the skeleton Id */
  13122. id: string;
  13123. /**
  13124. * Defines the list of child bones
  13125. */
  13126. bones: Bone[];
  13127. /**
  13128. * Defines an estimate of the dimension of the skeleton at rest
  13129. */
  13130. dimensionsAtRest: Vector3;
  13131. /**
  13132. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13133. */
  13134. needInitialSkinMatrix: boolean;
  13135. /**
  13136. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13137. */
  13138. overrideMesh: Nullable<AbstractMesh>;
  13139. /**
  13140. * Gets the list of animations attached to this skeleton
  13141. */
  13142. animations: Array<Animation>;
  13143. private _scene;
  13144. private _isDirty;
  13145. private _transformMatrices;
  13146. private _transformMatrixTexture;
  13147. private _meshesWithPoseMatrix;
  13148. private _animatables;
  13149. private _identity;
  13150. private _synchronizedWithMesh;
  13151. private _ranges;
  13152. private _lastAbsoluteTransformsUpdateId;
  13153. private _canUseTextureForBones;
  13154. private _uniqueId;
  13155. /** @hidden */
  13156. _numBonesWithLinkedTransformNode: number;
  13157. /** @hidden */
  13158. _hasWaitingData: Nullable<boolean>;
  13159. /**
  13160. * Specifies if the skeleton should be serialized
  13161. */
  13162. doNotSerialize: boolean;
  13163. private _useTextureToStoreBoneMatrices;
  13164. /**
  13165. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13166. * Please note that this option is not available if the hardware does not support it
  13167. */
  13168. useTextureToStoreBoneMatrices: boolean;
  13169. private _animationPropertiesOverride;
  13170. /**
  13171. * Gets or sets the animation properties override
  13172. */
  13173. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13174. /**
  13175. * List of inspectable custom properties (used by the Inspector)
  13176. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13177. */
  13178. inspectableCustomProperties: IInspectable[];
  13179. /**
  13180. * An observable triggered before computing the skeleton's matrices
  13181. */
  13182. onBeforeComputeObservable: Observable<Skeleton>;
  13183. /**
  13184. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13185. */
  13186. readonly isUsingTextureForMatrices: boolean;
  13187. /**
  13188. * Gets the unique ID of this skeleton
  13189. */
  13190. readonly uniqueId: number;
  13191. /**
  13192. * Creates a new skeleton
  13193. * @param name defines the skeleton name
  13194. * @param id defines the skeleton Id
  13195. * @param scene defines the hosting scene
  13196. */
  13197. constructor(
  13198. /** defines the skeleton name */
  13199. name: string,
  13200. /** defines the skeleton Id */
  13201. id: string, scene: Scene);
  13202. /**
  13203. * Gets the current object class name.
  13204. * @return the class name
  13205. */
  13206. getClassName(): string;
  13207. /**
  13208. * Returns an array containing the root bones
  13209. * @returns an array containing the root bones
  13210. */
  13211. getChildren(): Array<Bone>;
  13212. /**
  13213. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13214. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13215. * @returns a Float32Array containing matrices data
  13216. */
  13217. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13218. /**
  13219. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13220. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13221. * @returns a raw texture containing the data
  13222. */
  13223. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13224. /**
  13225. * Gets the current hosting scene
  13226. * @returns a scene object
  13227. */
  13228. getScene(): Scene;
  13229. /**
  13230. * Gets a string representing the current skeleton data
  13231. * @param fullDetails defines a boolean indicating if we want a verbose version
  13232. * @returns a string representing the current skeleton data
  13233. */
  13234. toString(fullDetails?: boolean): string;
  13235. /**
  13236. * Get bone's index searching by name
  13237. * @param name defines bone's name to search for
  13238. * @return the indice of the bone. Returns -1 if not found
  13239. */
  13240. getBoneIndexByName(name: string): number;
  13241. /**
  13242. * Creater a new animation range
  13243. * @param name defines the name of the range
  13244. * @param from defines the start key
  13245. * @param to defines the end key
  13246. */
  13247. createAnimationRange(name: string, from: number, to: number): void;
  13248. /**
  13249. * Delete a specific animation range
  13250. * @param name defines the name of the range
  13251. * @param deleteFrames defines if frames must be removed as well
  13252. */
  13253. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13254. /**
  13255. * Gets a specific animation range
  13256. * @param name defines the name of the range to look for
  13257. * @returns the requested animation range or null if not found
  13258. */
  13259. getAnimationRange(name: string): Nullable<AnimationRange>;
  13260. /**
  13261. * Gets the list of all animation ranges defined on this skeleton
  13262. * @returns an array
  13263. */
  13264. getAnimationRanges(): Nullable<AnimationRange>[];
  13265. /**
  13266. * Copy animation range from a source skeleton.
  13267. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13268. * @param source defines the source skeleton
  13269. * @param name defines the name of the range to copy
  13270. * @param rescaleAsRequired defines if rescaling must be applied if required
  13271. * @returns true if operation was successful
  13272. */
  13273. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13274. /**
  13275. * Forces the skeleton to go to rest pose
  13276. */
  13277. returnToRest(): void;
  13278. private _getHighestAnimationFrame;
  13279. /**
  13280. * Begin a specific animation range
  13281. * @param name defines the name of the range to start
  13282. * @param loop defines if looping must be turned on (false by default)
  13283. * @param speedRatio defines the speed ratio to apply (1 by default)
  13284. * @param onAnimationEnd defines a callback which will be called when animation will end
  13285. * @returns a new animatable
  13286. */
  13287. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13288. /** @hidden */
  13289. _markAsDirty(): void;
  13290. /** @hidden */
  13291. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13292. /** @hidden */
  13293. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13294. private _computeTransformMatrices;
  13295. /**
  13296. * Build all resources required to render a skeleton
  13297. */
  13298. prepare(): void;
  13299. /**
  13300. * Gets the list of animatables currently running for this skeleton
  13301. * @returns an array of animatables
  13302. */
  13303. getAnimatables(): IAnimatable[];
  13304. /**
  13305. * Clone the current skeleton
  13306. * @param name defines the name of the new skeleton
  13307. * @param id defines the id of the new skeleton
  13308. * @returns the new skeleton
  13309. */
  13310. clone(name: string, id: string): Skeleton;
  13311. /**
  13312. * Enable animation blending for this skeleton
  13313. * @param blendingSpeed defines the blending speed to apply
  13314. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13315. */
  13316. enableBlending(blendingSpeed?: number): void;
  13317. /**
  13318. * Releases all resources associated with the current skeleton
  13319. */
  13320. dispose(): void;
  13321. /**
  13322. * Serialize the skeleton in a JSON object
  13323. * @returns a JSON object
  13324. */
  13325. serialize(): any;
  13326. /**
  13327. * Creates a new skeleton from serialized data
  13328. * @param parsedSkeleton defines the serialized data
  13329. * @param scene defines the hosting scene
  13330. * @returns a new skeleton
  13331. */
  13332. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13333. /**
  13334. * Compute all node absolute transforms
  13335. * @param forceUpdate defines if computation must be done even if cache is up to date
  13336. */
  13337. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13338. /**
  13339. * Gets the root pose matrix
  13340. * @returns a matrix
  13341. */
  13342. getPoseMatrix(): Nullable<Matrix>;
  13343. /**
  13344. * Sorts bones per internal index
  13345. */
  13346. sortBones(): void;
  13347. private _sortBones;
  13348. }
  13349. }
  13350. declare module BABYLON {
  13351. /**
  13352. * Class used to store bone information
  13353. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13354. */
  13355. export class Bone extends Node {
  13356. /**
  13357. * defines the bone name
  13358. */
  13359. name: string;
  13360. private static _tmpVecs;
  13361. private static _tmpQuat;
  13362. private static _tmpMats;
  13363. /**
  13364. * Gets the list of child bones
  13365. */
  13366. children: Bone[];
  13367. /** Gets the animations associated with this bone */
  13368. animations: Animation[];
  13369. /**
  13370. * Gets or sets bone length
  13371. */
  13372. length: number;
  13373. /**
  13374. * @hidden Internal only
  13375. * Set this value to map this bone to a different index in the transform matrices
  13376. * Set this value to -1 to exclude the bone from the transform matrices
  13377. */
  13378. _index: Nullable<number>;
  13379. private _skeleton;
  13380. private _localMatrix;
  13381. private _restPose;
  13382. private _baseMatrix;
  13383. private _absoluteTransform;
  13384. private _invertedAbsoluteTransform;
  13385. private _parent;
  13386. private _scalingDeterminant;
  13387. private _worldTransform;
  13388. private _localScaling;
  13389. private _localRotation;
  13390. private _localPosition;
  13391. private _needToDecompose;
  13392. private _needToCompose;
  13393. /** @hidden */
  13394. _linkedTransformNode: Nullable<TransformNode>;
  13395. /** @hidden */
  13396. _waitingTransformNodeId: Nullable<string>;
  13397. /** @hidden */
  13398. /** @hidden */
  13399. _matrix: Matrix;
  13400. /**
  13401. * Create a new bone
  13402. * @param name defines the bone name
  13403. * @param skeleton defines the parent skeleton
  13404. * @param parentBone defines the parent (can be null if the bone is the root)
  13405. * @param localMatrix defines the local matrix
  13406. * @param restPose defines the rest pose matrix
  13407. * @param baseMatrix defines the base matrix
  13408. * @param index defines index of the bone in the hiearchy
  13409. */
  13410. constructor(
  13411. /**
  13412. * defines the bone name
  13413. */
  13414. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13415. /**
  13416. * Gets the current object class name.
  13417. * @return the class name
  13418. */
  13419. getClassName(): string;
  13420. /**
  13421. * Gets the parent skeleton
  13422. * @returns a skeleton
  13423. */
  13424. getSkeleton(): Skeleton;
  13425. /**
  13426. * Gets parent bone
  13427. * @returns a bone or null if the bone is the root of the bone hierarchy
  13428. */
  13429. getParent(): Nullable<Bone>;
  13430. /**
  13431. * Returns an array containing the root bones
  13432. * @returns an array containing the root bones
  13433. */
  13434. getChildren(): Array<Bone>;
  13435. /**
  13436. * Sets the parent bone
  13437. * @param parent defines the parent (can be null if the bone is the root)
  13438. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13439. */
  13440. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13441. /**
  13442. * Gets the local matrix
  13443. * @returns a matrix
  13444. */
  13445. getLocalMatrix(): Matrix;
  13446. /**
  13447. * Gets the base matrix (initial matrix which remains unchanged)
  13448. * @returns a matrix
  13449. */
  13450. getBaseMatrix(): Matrix;
  13451. /**
  13452. * Gets the rest pose matrix
  13453. * @returns a matrix
  13454. */
  13455. getRestPose(): Matrix;
  13456. /**
  13457. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13458. */
  13459. getWorldMatrix(): Matrix;
  13460. /**
  13461. * Sets the local matrix to rest pose matrix
  13462. */
  13463. returnToRest(): void;
  13464. /**
  13465. * Gets the inverse of the absolute transform matrix.
  13466. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13467. * @returns a matrix
  13468. */
  13469. getInvertedAbsoluteTransform(): Matrix;
  13470. /**
  13471. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13472. * @returns a matrix
  13473. */
  13474. getAbsoluteTransform(): Matrix;
  13475. /**
  13476. * Links with the given transform node.
  13477. * The local matrix of this bone is copied from the transform node every frame.
  13478. * @param transformNode defines the transform node to link to
  13479. */
  13480. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13481. /**
  13482. * Gets the node used to drive the bone's transformation
  13483. * @returns a transform node or null
  13484. */
  13485. getTransformNode(): Nullable<TransformNode>;
  13486. /** Gets or sets current position (in local space) */
  13487. position: Vector3;
  13488. /** Gets or sets current rotation (in local space) */
  13489. rotation: Vector3;
  13490. /** Gets or sets current rotation quaternion (in local space) */
  13491. rotationQuaternion: Quaternion;
  13492. /** Gets or sets current scaling (in local space) */
  13493. scaling: Vector3;
  13494. /**
  13495. * Gets the animation properties override
  13496. */
  13497. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13498. private _decompose;
  13499. private _compose;
  13500. /**
  13501. * Update the base and local matrices
  13502. * @param matrix defines the new base or local matrix
  13503. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13504. * @param updateLocalMatrix defines if the local matrix should be updated
  13505. */
  13506. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13507. /** @hidden */
  13508. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13509. /**
  13510. * Flag the bone as dirty (Forcing it to update everything)
  13511. */
  13512. markAsDirty(): void;
  13513. /** @hidden */
  13514. _markAsDirtyAndCompose(): void;
  13515. private _markAsDirtyAndDecompose;
  13516. /**
  13517. * Translate the bone in local or world space
  13518. * @param vec The amount to translate the bone
  13519. * @param space The space that the translation is in
  13520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13521. */
  13522. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13523. /**
  13524. * Set the postion of the bone in local or world space
  13525. * @param position The position to set the bone
  13526. * @param space The space that the position is in
  13527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13528. */
  13529. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13530. /**
  13531. * Set the absolute position of the bone (world space)
  13532. * @param position The position to set the bone
  13533. * @param mesh The mesh that this bone is attached to
  13534. */
  13535. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13536. /**
  13537. * Scale the bone on the x, y and z axes (in local space)
  13538. * @param x The amount to scale the bone on the x axis
  13539. * @param y The amount to scale the bone on the y axis
  13540. * @param z The amount to scale the bone on the z axis
  13541. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13542. */
  13543. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13544. /**
  13545. * Set the bone scaling in local space
  13546. * @param scale defines the scaling vector
  13547. */
  13548. setScale(scale: Vector3): void;
  13549. /**
  13550. * Gets the current scaling in local space
  13551. * @returns the current scaling vector
  13552. */
  13553. getScale(): Vector3;
  13554. /**
  13555. * Gets the current scaling in local space and stores it in a target vector
  13556. * @param result defines the target vector
  13557. */
  13558. getScaleToRef(result: Vector3): void;
  13559. /**
  13560. * Set the yaw, pitch, and roll of the bone in local or world space
  13561. * @param yaw The rotation of the bone on the y axis
  13562. * @param pitch The rotation of the bone on the x axis
  13563. * @param roll The rotation of the bone on the z axis
  13564. * @param space The space that the axes of rotation are in
  13565. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13566. */
  13567. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13568. /**
  13569. * Add a rotation to the bone on an axis in local or world space
  13570. * @param axis The axis to rotate the bone on
  13571. * @param amount The amount to rotate the bone
  13572. * @param space The space that the axis is in
  13573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13574. */
  13575. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13576. /**
  13577. * Set the rotation of the bone to a particular axis angle in local or world space
  13578. * @param axis The axis to rotate the bone on
  13579. * @param angle The angle that the bone should be rotated to
  13580. * @param space The space that the axis is in
  13581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13582. */
  13583. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13584. /**
  13585. * Set the euler rotation of the bone in local of world space
  13586. * @param rotation The euler rotation that the bone should be set to
  13587. * @param space The space that the rotation is in
  13588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13589. */
  13590. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13591. /**
  13592. * Set the quaternion rotation of the bone in local of world space
  13593. * @param quat The quaternion rotation that the bone should be set to
  13594. * @param space The space that the rotation is in
  13595. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13596. */
  13597. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13598. /**
  13599. * Set the rotation matrix of the bone in local of world space
  13600. * @param rotMat The rotation matrix that the bone should be set to
  13601. * @param space The space that the rotation is in
  13602. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13603. */
  13604. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13605. private _rotateWithMatrix;
  13606. private _getNegativeRotationToRef;
  13607. /**
  13608. * Get the position of the bone in local or world space
  13609. * @param space The space that the returned position is in
  13610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13611. * @returns The position of the bone
  13612. */
  13613. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13614. /**
  13615. * Copy the position of the bone to a vector3 in local or world space
  13616. * @param space The space that the returned position is in
  13617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13618. * @param result The vector3 to copy the position to
  13619. */
  13620. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13621. /**
  13622. * Get the absolute position of the bone (world space)
  13623. * @param mesh The mesh that this bone is attached to
  13624. * @returns The absolute position of the bone
  13625. */
  13626. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13627. /**
  13628. * Copy the absolute position of the bone (world space) to the result param
  13629. * @param mesh The mesh that this bone is attached to
  13630. * @param result The vector3 to copy the absolute position to
  13631. */
  13632. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13633. /**
  13634. * Compute the absolute transforms of this bone and its children
  13635. */
  13636. computeAbsoluteTransforms(): void;
  13637. /**
  13638. * Get the world direction from an axis that is in the local space of the bone
  13639. * @param localAxis The local direction that is used to compute the world direction
  13640. * @param mesh The mesh that this bone is attached to
  13641. * @returns The world direction
  13642. */
  13643. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13644. /**
  13645. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13646. * @param localAxis The local direction that is used to compute the world direction
  13647. * @param mesh The mesh that this bone is attached to
  13648. * @param result The vector3 that the world direction will be copied to
  13649. */
  13650. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13651. /**
  13652. * Get the euler rotation of the bone in local or world space
  13653. * @param space The space that the rotation should be in
  13654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13655. * @returns The euler rotation
  13656. */
  13657. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13658. /**
  13659. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13660. * @param space The space that the rotation should be in
  13661. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13662. * @param result The vector3 that the rotation should be copied to
  13663. */
  13664. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13665. /**
  13666. * Get the quaternion rotation of the bone in either local or world space
  13667. * @param space The space that the rotation should be in
  13668. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13669. * @returns The quaternion rotation
  13670. */
  13671. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13672. /**
  13673. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13674. * @param space The space that the rotation should be in
  13675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13676. * @param result The quaternion that the rotation should be copied to
  13677. */
  13678. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13679. /**
  13680. * Get the rotation matrix of the bone in local or world space
  13681. * @param space The space that the rotation should be in
  13682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13683. * @returns The rotation matrix
  13684. */
  13685. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13686. /**
  13687. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13688. * @param space The space that the rotation should be in
  13689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13690. * @param result The quaternion that the rotation should be copied to
  13691. */
  13692. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13693. /**
  13694. * Get the world position of a point that is in the local space of the bone
  13695. * @param position The local position
  13696. * @param mesh The mesh that this bone is attached to
  13697. * @returns The world position
  13698. */
  13699. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13700. /**
  13701. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13702. * @param position The local position
  13703. * @param mesh The mesh that this bone is attached to
  13704. * @param result The vector3 that the world position should be copied to
  13705. */
  13706. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13707. /**
  13708. * Get the local position of a point that is in world space
  13709. * @param position The world position
  13710. * @param mesh The mesh that this bone is attached to
  13711. * @returns The local position
  13712. */
  13713. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13714. /**
  13715. * Get the local position of a point that is in world space and copy it to the result param
  13716. * @param position The world position
  13717. * @param mesh The mesh that this bone is attached to
  13718. * @param result The vector3 that the local position should be copied to
  13719. */
  13720. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13721. }
  13722. }
  13723. declare module BABYLON {
  13724. /**
  13725. * 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.
  13726. * @see https://doc.babylonjs.com/how_to/transformnode
  13727. */
  13728. export class TransformNode extends Node {
  13729. /**
  13730. * Object will not rotate to face the camera
  13731. */
  13732. static BILLBOARDMODE_NONE: number;
  13733. /**
  13734. * Object will rotate to face the camera but only on the x axis
  13735. */
  13736. static BILLBOARDMODE_X: number;
  13737. /**
  13738. * Object will rotate to face the camera but only on the y axis
  13739. */
  13740. static BILLBOARDMODE_Y: number;
  13741. /**
  13742. * Object will rotate to face the camera but only on the z axis
  13743. */
  13744. static BILLBOARDMODE_Z: number;
  13745. /**
  13746. * Object will rotate to face the camera
  13747. */
  13748. static BILLBOARDMODE_ALL: number;
  13749. /**
  13750. * Object will rotate to face the camera's position instead of orientation
  13751. */
  13752. static BILLBOARDMODE_USE_POSITION: number;
  13753. private _forward;
  13754. private _forwardInverted;
  13755. private _up;
  13756. private _right;
  13757. private _rightInverted;
  13758. private _position;
  13759. private _rotation;
  13760. private _rotationQuaternion;
  13761. protected _scaling: Vector3;
  13762. protected _isDirty: boolean;
  13763. private _transformToBoneReferal;
  13764. private _isAbsoluteSynced;
  13765. private _billboardMode;
  13766. /**
  13767. * Gets or sets the billboard mode. Default is 0.
  13768. *
  13769. * | Value | Type | Description |
  13770. * | --- | --- | --- |
  13771. * | 0 | BILLBOARDMODE_NONE | |
  13772. * | 1 | BILLBOARDMODE_X | |
  13773. * | 2 | BILLBOARDMODE_Y | |
  13774. * | 4 | BILLBOARDMODE_Z | |
  13775. * | 7 | BILLBOARDMODE_ALL | |
  13776. *
  13777. */
  13778. billboardMode: number;
  13779. private _preserveParentRotationForBillboard;
  13780. /**
  13781. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13782. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13783. */
  13784. preserveParentRotationForBillboard: boolean;
  13785. /**
  13786. * 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
  13787. */
  13788. scalingDeterminant: number;
  13789. private _infiniteDistance;
  13790. /**
  13791. * Gets or sets the distance of the object to max, often used by skybox
  13792. */
  13793. infiniteDistance: boolean;
  13794. /**
  13795. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13796. * By default the system will update normals to compensate
  13797. */
  13798. ignoreNonUniformScaling: boolean;
  13799. /**
  13800. * 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
  13801. */
  13802. reIntegrateRotationIntoRotationQuaternion: boolean;
  13803. /** @hidden */
  13804. _poseMatrix: Nullable<Matrix>;
  13805. /** @hidden */
  13806. _localMatrix: Matrix;
  13807. private _usePivotMatrix;
  13808. private _absolutePosition;
  13809. private _absoluteScaling;
  13810. private _absoluteRotationQuaternion;
  13811. private _pivotMatrix;
  13812. private _pivotMatrixInverse;
  13813. protected _postMultiplyPivotMatrix: boolean;
  13814. protected _isWorldMatrixFrozen: boolean;
  13815. /** @hidden */
  13816. _indexInSceneTransformNodesArray: number;
  13817. /**
  13818. * An event triggered after the world matrix is updated
  13819. */
  13820. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13821. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13822. /**
  13823. * Gets a string identifying the name of the class
  13824. * @returns "TransformNode" string
  13825. */
  13826. getClassName(): string;
  13827. /**
  13828. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13829. */
  13830. position: Vector3;
  13831. /**
  13832. * 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)).
  13833. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13834. */
  13835. rotation: Vector3;
  13836. /**
  13837. * 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)).
  13838. */
  13839. scaling: Vector3;
  13840. /**
  13841. * 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).
  13842. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13843. */
  13844. rotationQuaternion: Nullable<Quaternion>;
  13845. /**
  13846. * The forward direction of that transform in world space.
  13847. */
  13848. readonly forward: Vector3;
  13849. /**
  13850. * The up direction of that transform in world space.
  13851. */
  13852. readonly up: Vector3;
  13853. /**
  13854. * The right direction of that transform in world space.
  13855. */
  13856. readonly right: Vector3;
  13857. /**
  13858. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13859. * @param matrix the matrix to copy the pose from
  13860. * @returns this TransformNode.
  13861. */
  13862. updatePoseMatrix(matrix: Matrix): TransformNode;
  13863. /**
  13864. * Returns the mesh Pose matrix.
  13865. * @returns the pose matrix
  13866. */
  13867. getPoseMatrix(): Matrix;
  13868. /** @hidden */
  13869. _isSynchronized(): boolean;
  13870. /** @hidden */
  13871. _initCache(): void;
  13872. /**
  13873. * Flag the transform node as dirty (Forcing it to update everything)
  13874. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13875. * @returns this transform node
  13876. */
  13877. markAsDirty(property: string): TransformNode;
  13878. /**
  13879. * Returns the current mesh absolute position.
  13880. * Returns a Vector3.
  13881. */
  13882. readonly absolutePosition: Vector3;
  13883. /**
  13884. * Returns the current mesh absolute scaling.
  13885. * Returns a Vector3.
  13886. */
  13887. readonly absoluteScaling: Vector3;
  13888. /**
  13889. * Returns the current mesh absolute rotation.
  13890. * Returns a Quaternion.
  13891. */
  13892. readonly absoluteRotationQuaternion: Quaternion;
  13893. /**
  13894. * Sets a new matrix to apply before all other transformation
  13895. * @param matrix defines the transform matrix
  13896. * @returns the current TransformNode
  13897. */
  13898. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13899. /**
  13900. * Sets a new pivot matrix to the current node
  13901. * @param matrix defines the new pivot matrix to use
  13902. * @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
  13903. * @returns the current TransformNode
  13904. */
  13905. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13906. /**
  13907. * Returns the mesh pivot matrix.
  13908. * Default : Identity.
  13909. * @returns the matrix
  13910. */
  13911. getPivotMatrix(): Matrix;
  13912. /**
  13913. * Instantiate (when possible) or clone that node with its hierarchy
  13914. * @param newParent defines the new parent to use for the instance (or clone)
  13915. * @returns an instance (or a clone) of the current node with its hiearchy
  13916. */
  13917. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13918. /**
  13919. * Prevents the World matrix to be computed any longer
  13920. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13921. * @returns the TransformNode.
  13922. */
  13923. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13924. /**
  13925. * Allows back the World matrix computation.
  13926. * @returns the TransformNode.
  13927. */
  13928. unfreezeWorldMatrix(): this;
  13929. /**
  13930. * True if the World matrix has been frozen.
  13931. */
  13932. readonly isWorldMatrixFrozen: boolean;
  13933. /**
  13934. * Retuns the mesh absolute position in the World.
  13935. * @returns a Vector3.
  13936. */
  13937. getAbsolutePosition(): Vector3;
  13938. /**
  13939. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13940. * @param absolutePosition the absolute position to set
  13941. * @returns the TransformNode.
  13942. */
  13943. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13944. /**
  13945. * Sets the mesh position in its local space.
  13946. * @param vector3 the position to set in localspace
  13947. * @returns the TransformNode.
  13948. */
  13949. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13950. /**
  13951. * Returns the mesh position in the local space from the current World matrix values.
  13952. * @returns a new Vector3.
  13953. */
  13954. getPositionExpressedInLocalSpace(): Vector3;
  13955. /**
  13956. * Translates the mesh along the passed Vector3 in its local space.
  13957. * @param vector3 the distance to translate in localspace
  13958. * @returns the TransformNode.
  13959. */
  13960. locallyTranslate(vector3: Vector3): TransformNode;
  13961. private static _lookAtVectorCache;
  13962. /**
  13963. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13964. * @param targetPoint the position (must be in same space as current mesh) to look at
  13965. * @param yawCor optional yaw (y-axis) correction in radians
  13966. * @param pitchCor optional pitch (x-axis) correction in radians
  13967. * @param rollCor optional roll (z-axis) correction in radians
  13968. * @param space the choosen space of the target
  13969. * @returns the TransformNode.
  13970. */
  13971. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13972. /**
  13973. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13974. * This Vector3 is expressed in the World space.
  13975. * @param localAxis axis to rotate
  13976. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13977. */
  13978. getDirection(localAxis: Vector3): Vector3;
  13979. /**
  13980. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13981. * localAxis is expressed in the mesh local space.
  13982. * result is computed in the Wordl space from the mesh World matrix.
  13983. * @param localAxis axis to rotate
  13984. * @param result the resulting transformnode
  13985. * @returns this TransformNode.
  13986. */
  13987. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13988. /**
  13989. * Sets this transform node rotation to the given local axis.
  13990. * @param localAxis the axis in local space
  13991. * @param yawCor optional yaw (y-axis) correction in radians
  13992. * @param pitchCor optional pitch (x-axis) correction in radians
  13993. * @param rollCor optional roll (z-axis) correction in radians
  13994. * @returns this TransformNode
  13995. */
  13996. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13997. /**
  13998. * Sets a new pivot point to the current node
  13999. * @param point defines the new pivot point to use
  14000. * @param space defines if the point is in world or local space (local by default)
  14001. * @returns the current TransformNode
  14002. */
  14003. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14004. /**
  14005. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14006. * @returns the pivot point
  14007. */
  14008. getPivotPoint(): Vector3;
  14009. /**
  14010. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14011. * @param result the vector3 to store the result
  14012. * @returns this TransformNode.
  14013. */
  14014. getPivotPointToRef(result: Vector3): TransformNode;
  14015. /**
  14016. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14017. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14018. */
  14019. getAbsolutePivotPoint(): Vector3;
  14020. /**
  14021. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14022. * @param result vector3 to store the result
  14023. * @returns this TransformNode.
  14024. */
  14025. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14026. /**
  14027. * Defines the passed node as the parent of the current node.
  14028. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14029. * @see https://doc.babylonjs.com/how_to/parenting
  14030. * @param node the node ot set as the parent
  14031. * @returns this TransformNode.
  14032. */
  14033. setParent(node: Nullable<Node>): TransformNode;
  14034. private _nonUniformScaling;
  14035. /**
  14036. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14037. */
  14038. readonly nonUniformScaling: boolean;
  14039. /** @hidden */
  14040. _updateNonUniformScalingState(value: boolean): boolean;
  14041. /**
  14042. * Attach the current TransformNode to another TransformNode associated with a bone
  14043. * @param bone Bone affecting the TransformNode
  14044. * @param affectedTransformNode TransformNode associated with the bone
  14045. * @returns this object
  14046. */
  14047. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14048. /**
  14049. * Detach the transform node if its associated with a bone
  14050. * @returns this object
  14051. */
  14052. detachFromBone(): TransformNode;
  14053. private static _rotationAxisCache;
  14054. /**
  14055. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14056. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14057. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14058. * The passed axis is also normalized.
  14059. * @param axis the axis to rotate around
  14060. * @param amount the amount to rotate in radians
  14061. * @param space Space to rotate in (Default: local)
  14062. * @returns the TransformNode.
  14063. */
  14064. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14065. /**
  14066. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14067. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14068. * The passed axis is also normalized. .
  14069. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14070. * @param point the point to rotate around
  14071. * @param axis the axis to rotate around
  14072. * @param amount the amount to rotate in radians
  14073. * @returns the TransformNode
  14074. */
  14075. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14076. /**
  14077. * Translates the mesh along the axis vector for the passed distance in the given space.
  14078. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14079. * @param axis the axis to translate in
  14080. * @param distance the distance to translate
  14081. * @param space Space to rotate in (Default: local)
  14082. * @returns the TransformNode.
  14083. */
  14084. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14085. /**
  14086. * Adds a rotation step to the mesh current rotation.
  14087. * x, y, z are Euler angles expressed in radians.
  14088. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14089. * This means this rotation is made in the mesh local space only.
  14090. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14091. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14092. * ```javascript
  14093. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14094. * ```
  14095. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14096. * 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.
  14097. * @param x Rotation to add
  14098. * @param y Rotation to add
  14099. * @param z Rotation to add
  14100. * @returns the TransformNode.
  14101. */
  14102. addRotation(x: number, y: number, z: number): TransformNode;
  14103. /**
  14104. * @hidden
  14105. */
  14106. protected _getEffectiveParent(): Nullable<Node>;
  14107. /**
  14108. * Computes the world matrix of the node
  14109. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14110. * @returns the world matrix
  14111. */
  14112. computeWorldMatrix(force?: boolean): Matrix;
  14113. protected _afterComputeWorldMatrix(): void;
  14114. /**
  14115. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14116. * @param func callback function to add
  14117. *
  14118. * @returns the TransformNode.
  14119. */
  14120. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14121. /**
  14122. * Removes a registered callback function.
  14123. * @param func callback function to remove
  14124. * @returns the TransformNode.
  14125. */
  14126. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14127. /**
  14128. * Gets the position of the current mesh in camera space
  14129. * @param camera defines the camera to use
  14130. * @returns a position
  14131. */
  14132. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14133. /**
  14134. * Returns the distance from the mesh to the active camera
  14135. * @param camera defines the camera to use
  14136. * @returns the distance
  14137. */
  14138. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14139. /**
  14140. * Clone the current transform node
  14141. * @param name Name of the new clone
  14142. * @param newParent New parent for the clone
  14143. * @param doNotCloneChildren Do not clone children hierarchy
  14144. * @returns the new transform node
  14145. */
  14146. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14147. /**
  14148. * Serializes the objects information.
  14149. * @param currentSerializationObject defines the object to serialize in
  14150. * @returns the serialized object
  14151. */
  14152. serialize(currentSerializationObject?: any): any;
  14153. /**
  14154. * Returns a new TransformNode object parsed from the source provided.
  14155. * @param parsedTransformNode is the source.
  14156. * @param scene the scne the object belongs to
  14157. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14158. * @returns a new TransformNode object parsed from the source provided.
  14159. */
  14160. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14161. /**
  14162. * Get all child-transformNodes of this node
  14163. * @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
  14164. * @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
  14165. * @returns an array of TransformNode
  14166. */
  14167. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14168. /**
  14169. * Releases resources associated with this transform node.
  14170. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14171. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14172. */
  14173. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14174. /**
  14175. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14176. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14177. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14178. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14179. * @returns the current mesh
  14180. */
  14181. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14182. private _syncAbsoluteScalingAndRotation;
  14183. }
  14184. }
  14185. declare module BABYLON {
  14186. /**
  14187. * Defines the types of pose enabled controllers that are supported
  14188. */
  14189. export enum PoseEnabledControllerType {
  14190. /**
  14191. * HTC Vive
  14192. */
  14193. VIVE = 0,
  14194. /**
  14195. * Oculus Rift
  14196. */
  14197. OCULUS = 1,
  14198. /**
  14199. * Windows mixed reality
  14200. */
  14201. WINDOWS = 2,
  14202. /**
  14203. * Samsung gear VR
  14204. */
  14205. GEAR_VR = 3,
  14206. /**
  14207. * Google Daydream
  14208. */
  14209. DAYDREAM = 4,
  14210. /**
  14211. * Generic
  14212. */
  14213. GENERIC = 5
  14214. }
  14215. /**
  14216. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14217. */
  14218. export interface MutableGamepadButton {
  14219. /**
  14220. * Value of the button/trigger
  14221. */
  14222. value: number;
  14223. /**
  14224. * If the button/trigger is currently touched
  14225. */
  14226. touched: boolean;
  14227. /**
  14228. * If the button/trigger is currently pressed
  14229. */
  14230. pressed: boolean;
  14231. }
  14232. /**
  14233. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14234. * @hidden
  14235. */
  14236. export interface ExtendedGamepadButton extends GamepadButton {
  14237. /**
  14238. * If the button/trigger is currently pressed
  14239. */
  14240. readonly pressed: boolean;
  14241. /**
  14242. * If the button/trigger is currently touched
  14243. */
  14244. readonly touched: boolean;
  14245. /**
  14246. * Value of the button/trigger
  14247. */
  14248. readonly value: number;
  14249. }
  14250. /** @hidden */
  14251. export interface _GamePadFactory {
  14252. /**
  14253. * Returns wether or not the current gamepad can be created for this type of controller.
  14254. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14255. * @returns true if it can be created, otherwise false
  14256. */
  14257. canCreate(gamepadInfo: any): boolean;
  14258. /**
  14259. * Creates a new instance of the Gamepad.
  14260. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14261. * @returns the new gamepad instance
  14262. */
  14263. create(gamepadInfo: any): Gamepad;
  14264. }
  14265. /**
  14266. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14267. */
  14268. export class PoseEnabledControllerHelper {
  14269. /** @hidden */
  14270. static _ControllerFactories: _GamePadFactory[];
  14271. /** @hidden */
  14272. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14273. /**
  14274. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14275. * @param vrGamepad the gamepad to initialized
  14276. * @returns a vr controller of the type the gamepad identified as
  14277. */
  14278. static InitiateController(vrGamepad: any): Gamepad;
  14279. }
  14280. /**
  14281. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14282. */
  14283. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14284. /**
  14285. * If the controller is used in a webXR session
  14286. */
  14287. isXR: boolean;
  14288. private _deviceRoomPosition;
  14289. private _deviceRoomRotationQuaternion;
  14290. /**
  14291. * The device position in babylon space
  14292. */
  14293. devicePosition: Vector3;
  14294. /**
  14295. * The device rotation in babylon space
  14296. */
  14297. deviceRotationQuaternion: Quaternion;
  14298. /**
  14299. * The scale factor of the device in babylon space
  14300. */
  14301. deviceScaleFactor: number;
  14302. /**
  14303. * (Likely devicePosition should be used instead) The device position in its room space
  14304. */
  14305. position: Vector3;
  14306. /**
  14307. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14308. */
  14309. rotationQuaternion: Quaternion;
  14310. /**
  14311. * The type of controller (Eg. Windows mixed reality)
  14312. */
  14313. controllerType: PoseEnabledControllerType;
  14314. protected _calculatedPosition: Vector3;
  14315. private _calculatedRotation;
  14316. /**
  14317. * The raw pose from the device
  14318. */
  14319. rawPose: DevicePose;
  14320. private _trackPosition;
  14321. private _maxRotationDistFromHeadset;
  14322. private _draggedRoomRotation;
  14323. /**
  14324. * @hidden
  14325. */
  14326. _disableTrackPosition(fixedPosition: Vector3): void;
  14327. /**
  14328. * Internal, the mesh attached to the controller
  14329. * @hidden
  14330. */
  14331. _mesh: Nullable<AbstractMesh>;
  14332. private _poseControlledCamera;
  14333. private _leftHandSystemQuaternion;
  14334. /**
  14335. * Internal, matrix used to convert room space to babylon space
  14336. * @hidden
  14337. */
  14338. _deviceToWorld: Matrix;
  14339. /**
  14340. * Node to be used when casting a ray from the controller
  14341. * @hidden
  14342. */
  14343. _pointingPoseNode: Nullable<TransformNode>;
  14344. /**
  14345. * Name of the child mesh that can be used to cast a ray from the controller
  14346. */
  14347. static readonly POINTING_POSE: string;
  14348. /**
  14349. * Creates a new PoseEnabledController from a gamepad
  14350. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14351. */
  14352. constructor(browserGamepad: any);
  14353. private _workingMatrix;
  14354. /**
  14355. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14356. */
  14357. update(): void;
  14358. /**
  14359. * Updates only the pose device and mesh without doing any button event checking
  14360. */
  14361. protected _updatePoseAndMesh(): void;
  14362. /**
  14363. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14364. * @param poseData raw pose fromthe device
  14365. */
  14366. updateFromDevice(poseData: DevicePose): void;
  14367. /**
  14368. * @hidden
  14369. */
  14370. _meshAttachedObservable: Observable<AbstractMesh>;
  14371. /**
  14372. * Attaches a mesh to the controller
  14373. * @param mesh the mesh to be attached
  14374. */
  14375. attachToMesh(mesh: AbstractMesh): void;
  14376. /**
  14377. * Attaches the controllers mesh to a camera
  14378. * @param camera the camera the mesh should be attached to
  14379. */
  14380. attachToPoseControlledCamera(camera: TargetCamera): void;
  14381. /**
  14382. * Disposes of the controller
  14383. */
  14384. dispose(): void;
  14385. /**
  14386. * The mesh that is attached to the controller
  14387. */
  14388. readonly mesh: Nullable<AbstractMesh>;
  14389. /**
  14390. * Gets the ray of the controller in the direction the controller is pointing
  14391. * @param length the length the resulting ray should be
  14392. * @returns a ray in the direction the controller is pointing
  14393. */
  14394. getForwardRay(length?: number): Ray;
  14395. }
  14396. }
  14397. declare module BABYLON {
  14398. /**
  14399. * Defines the WebVRController object that represents controllers tracked in 3D space
  14400. */
  14401. export abstract class WebVRController extends PoseEnabledController {
  14402. /**
  14403. * Internal, the default controller model for the controller
  14404. */
  14405. protected _defaultModel: Nullable<AbstractMesh>;
  14406. /**
  14407. * Fired when the trigger state has changed
  14408. */
  14409. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14410. /**
  14411. * Fired when the main button state has changed
  14412. */
  14413. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14414. /**
  14415. * Fired when the secondary button state has changed
  14416. */
  14417. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14418. /**
  14419. * Fired when the pad state has changed
  14420. */
  14421. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14422. /**
  14423. * Fired when controllers stick values have changed
  14424. */
  14425. onPadValuesChangedObservable: Observable<StickValues>;
  14426. /**
  14427. * Array of button availible on the controller
  14428. */
  14429. protected _buttons: Array<MutableGamepadButton>;
  14430. private _onButtonStateChange;
  14431. /**
  14432. * Fired when a controller button's state has changed
  14433. * @param callback the callback containing the button that was modified
  14434. */
  14435. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14436. /**
  14437. * X and Y axis corresponding to the controllers joystick
  14438. */
  14439. pad: StickValues;
  14440. /**
  14441. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14442. */
  14443. hand: string;
  14444. /**
  14445. * The default controller model for the controller
  14446. */
  14447. readonly defaultModel: Nullable<AbstractMesh>;
  14448. /**
  14449. * Creates a new WebVRController from a gamepad
  14450. * @param vrGamepad the gamepad that the WebVRController should be created from
  14451. */
  14452. constructor(vrGamepad: any);
  14453. /**
  14454. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14455. */
  14456. update(): void;
  14457. /**
  14458. * Function to be called when a button is modified
  14459. */
  14460. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14461. /**
  14462. * Loads a mesh and attaches it to the controller
  14463. * @param scene the scene the mesh should be added to
  14464. * @param meshLoaded callback for when the mesh has been loaded
  14465. */
  14466. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14467. private _setButtonValue;
  14468. private _changes;
  14469. private _checkChanges;
  14470. /**
  14471. * Disposes of th webVRCOntroller
  14472. */
  14473. dispose(): void;
  14474. }
  14475. }
  14476. declare module BABYLON {
  14477. /**
  14478. * The HemisphericLight simulates the ambient environment light,
  14479. * so the passed direction is the light reflection direction, not the incoming direction.
  14480. */
  14481. export class HemisphericLight extends Light {
  14482. /**
  14483. * The groundColor is the light in the opposite direction to the one specified during creation.
  14484. * 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.
  14485. */
  14486. groundColor: Color3;
  14487. /**
  14488. * The light reflection direction, not the incoming direction.
  14489. */
  14490. direction: Vector3;
  14491. /**
  14492. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14493. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14494. * The HemisphericLight can't cast shadows.
  14495. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14496. * @param name The friendly name of the light
  14497. * @param direction The direction of the light reflection
  14498. * @param scene The scene the light belongs to
  14499. */
  14500. constructor(name: string, direction: Vector3, scene: Scene);
  14501. protected _buildUniformLayout(): void;
  14502. /**
  14503. * Returns the string "HemisphericLight".
  14504. * @return The class name
  14505. */
  14506. getClassName(): string;
  14507. /**
  14508. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14509. * Returns the updated direction.
  14510. * @param target The target the direction should point to
  14511. * @return The computed direction
  14512. */
  14513. setDirectionToTarget(target: Vector3): Vector3;
  14514. /**
  14515. * Returns the shadow generator associated to the light.
  14516. * @returns Always null for hemispheric lights because it does not support shadows.
  14517. */
  14518. getShadowGenerator(): Nullable<IShadowGenerator>;
  14519. /**
  14520. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14521. * @param effect The effect to update
  14522. * @param lightIndex The index of the light in the effect to update
  14523. * @returns The hemispheric light
  14524. */
  14525. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14526. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14527. /**
  14528. * Computes the world matrix of the node
  14529. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14530. * @param useWasUpdatedFlag defines a reserved property
  14531. * @returns the world matrix
  14532. */
  14533. computeWorldMatrix(): Matrix;
  14534. /**
  14535. * Returns the integer 3.
  14536. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14537. */
  14538. getTypeID(): number;
  14539. /**
  14540. * Prepares the list of defines specific to the light type.
  14541. * @param defines the list of defines
  14542. * @param lightIndex defines the index of the light for the effect
  14543. */
  14544. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14545. }
  14546. }
  14547. declare module BABYLON {
  14548. /** @hidden */
  14549. export var vrMultiviewToSingleviewPixelShader: {
  14550. name: string;
  14551. shader: string;
  14552. };
  14553. }
  14554. declare module BABYLON {
  14555. /**
  14556. * Renders to multiple views with a single draw call
  14557. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14558. */
  14559. export class MultiviewRenderTarget extends RenderTargetTexture {
  14560. /**
  14561. * Creates a multiview render target
  14562. * @param scene scene used with the render target
  14563. * @param size the size of the render target (used for each view)
  14564. */
  14565. constructor(scene: Scene, size?: number | {
  14566. width: number;
  14567. height: number;
  14568. } | {
  14569. ratio: number;
  14570. });
  14571. /**
  14572. * @hidden
  14573. * @param faceIndex the face index, if its a cube texture
  14574. */
  14575. _bindFrameBuffer(faceIndex?: number): void;
  14576. /**
  14577. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14578. * @returns the view count
  14579. */
  14580. getViewCount(): number;
  14581. }
  14582. }
  14583. declare module BABYLON {
  14584. /**
  14585. * Represents a camera frustum
  14586. */
  14587. export class Frustum {
  14588. /**
  14589. * Gets the planes representing the frustum
  14590. * @param transform matrix to be applied to the returned planes
  14591. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14592. */
  14593. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14594. /**
  14595. * Gets the near frustum plane transformed by the transform matrix
  14596. * @param transform transformation matrix to be applied to the resulting frustum plane
  14597. * @param frustumPlane the resuling frustum plane
  14598. */
  14599. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14600. /**
  14601. * Gets the far frustum plane transformed by the transform matrix
  14602. * @param transform transformation matrix to be applied to the resulting frustum plane
  14603. * @param frustumPlane the resuling frustum plane
  14604. */
  14605. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14606. /**
  14607. * Gets the left frustum plane transformed by the transform matrix
  14608. * @param transform transformation matrix to be applied to the resulting frustum plane
  14609. * @param frustumPlane the resuling frustum plane
  14610. */
  14611. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14612. /**
  14613. * Gets the right frustum plane transformed by the transform matrix
  14614. * @param transform transformation matrix to be applied to the resulting frustum plane
  14615. * @param frustumPlane the resuling frustum plane
  14616. */
  14617. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14618. /**
  14619. * Gets the top frustum plane transformed by the transform matrix
  14620. * @param transform transformation matrix to be applied to the resulting frustum plane
  14621. * @param frustumPlane the resuling frustum plane
  14622. */
  14623. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14624. /**
  14625. * Gets the bottom frustum plane transformed by the transform matrix
  14626. * @param transform transformation matrix to be applied to the resulting frustum plane
  14627. * @param frustumPlane the resuling frustum plane
  14628. */
  14629. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14630. /**
  14631. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14632. * @param transform transformation matrix to be applied to the resulting frustum planes
  14633. * @param frustumPlanes the resuling frustum planes
  14634. */
  14635. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14636. }
  14637. }
  14638. declare module BABYLON {
  14639. interface Engine {
  14640. /**
  14641. * Creates a new multiview render target
  14642. * @param width defines the width of the texture
  14643. * @param height defines the height of the texture
  14644. * @returns the created multiview texture
  14645. */
  14646. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14647. /**
  14648. * Binds a multiview framebuffer to be drawn to
  14649. * @param multiviewTexture texture to bind
  14650. */
  14651. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14652. }
  14653. interface Camera {
  14654. /**
  14655. * @hidden
  14656. * 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)
  14657. */
  14658. _useMultiviewToSingleView: boolean;
  14659. /**
  14660. * @hidden
  14661. * 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)
  14662. */
  14663. _multiviewTexture: Nullable<RenderTargetTexture>;
  14664. /**
  14665. * @hidden
  14666. * ensures the multiview texture of the camera exists and has the specified width/height
  14667. * @param width height to set on the multiview texture
  14668. * @param height width to set on the multiview texture
  14669. */
  14670. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14671. }
  14672. interface Scene {
  14673. /** @hidden */
  14674. _transformMatrixR: Matrix;
  14675. /** @hidden */
  14676. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14677. /** @hidden */
  14678. _createMultiviewUbo(): void;
  14679. /** @hidden */
  14680. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14681. /** @hidden */
  14682. _renderMultiviewToSingleView(camera: Camera): void;
  14683. }
  14684. }
  14685. declare module BABYLON {
  14686. /**
  14687. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14688. * This will not be used for webXR as it supports displaying texture arrays directly
  14689. */
  14690. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14691. /**
  14692. * Initializes a VRMultiviewToSingleview
  14693. * @param name name of the post process
  14694. * @param camera camera to be applied to
  14695. * @param scaleFactor scaling factor to the size of the output texture
  14696. */
  14697. constructor(name: string, camera: Camera, scaleFactor: number);
  14698. }
  14699. }
  14700. declare module BABYLON {
  14701. interface Engine {
  14702. /** @hidden */
  14703. _vrDisplay: any;
  14704. /** @hidden */
  14705. _vrSupported: boolean;
  14706. /** @hidden */
  14707. _oldSize: Size;
  14708. /** @hidden */
  14709. _oldHardwareScaleFactor: number;
  14710. /** @hidden */
  14711. _vrExclusivePointerMode: boolean;
  14712. /** @hidden */
  14713. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14714. /** @hidden */
  14715. _onVRDisplayPointerRestricted: () => void;
  14716. /** @hidden */
  14717. _onVRDisplayPointerUnrestricted: () => void;
  14718. /** @hidden */
  14719. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14720. /** @hidden */
  14721. _onVrDisplayDisconnect: Nullable<() => void>;
  14722. /** @hidden */
  14723. _onVrDisplayPresentChange: Nullable<() => void>;
  14724. /**
  14725. * Observable signaled when VR display mode changes
  14726. */
  14727. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14728. /**
  14729. * Observable signaled when VR request present is complete
  14730. */
  14731. onVRRequestPresentComplete: Observable<boolean>;
  14732. /**
  14733. * Observable signaled when VR request present starts
  14734. */
  14735. onVRRequestPresentStart: Observable<Engine>;
  14736. /**
  14737. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14738. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14739. */
  14740. isInVRExclusivePointerMode: boolean;
  14741. /**
  14742. * Gets a boolean indicating if a webVR device was detected
  14743. * @returns true if a webVR device was detected
  14744. */
  14745. isVRDevicePresent(): boolean;
  14746. /**
  14747. * Gets the current webVR device
  14748. * @returns the current webVR device (or null)
  14749. */
  14750. getVRDevice(): any;
  14751. /**
  14752. * Initializes a webVR display and starts listening to display change events
  14753. * The onVRDisplayChangedObservable will be notified upon these changes
  14754. * @returns A promise containing a VRDisplay and if vr is supported
  14755. */
  14756. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14757. /** @hidden */
  14758. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14759. /**
  14760. * Call this function to switch to webVR mode
  14761. * Will do nothing if webVR is not supported or if there is no webVR device
  14762. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14763. */
  14764. enableVR(): void;
  14765. /** @hidden */
  14766. _onVRFullScreenTriggered(): void;
  14767. }
  14768. }
  14769. declare module BABYLON {
  14770. /**
  14771. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14772. * IMPORTANT!! The data is right-hand data.
  14773. * @export
  14774. * @interface DevicePose
  14775. */
  14776. export interface DevicePose {
  14777. /**
  14778. * The position of the device, values in array are [x,y,z].
  14779. */
  14780. readonly position: Nullable<Float32Array>;
  14781. /**
  14782. * The linearVelocity of the device, values in array are [x,y,z].
  14783. */
  14784. readonly linearVelocity: Nullable<Float32Array>;
  14785. /**
  14786. * The linearAcceleration of the device, values in array are [x,y,z].
  14787. */
  14788. readonly linearAcceleration: Nullable<Float32Array>;
  14789. /**
  14790. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14791. */
  14792. readonly orientation: Nullable<Float32Array>;
  14793. /**
  14794. * The angularVelocity of the device, values in array are [x,y,z].
  14795. */
  14796. readonly angularVelocity: Nullable<Float32Array>;
  14797. /**
  14798. * The angularAcceleration of the device, values in array are [x,y,z].
  14799. */
  14800. readonly angularAcceleration: Nullable<Float32Array>;
  14801. }
  14802. /**
  14803. * Interface representing a pose controlled object in Babylon.
  14804. * A pose controlled object has both regular pose values as well as pose values
  14805. * from an external device such as a VR head mounted display
  14806. */
  14807. export interface PoseControlled {
  14808. /**
  14809. * The position of the object in babylon space.
  14810. */
  14811. position: Vector3;
  14812. /**
  14813. * The rotation quaternion of the object in babylon space.
  14814. */
  14815. rotationQuaternion: Quaternion;
  14816. /**
  14817. * The position of the device in babylon space.
  14818. */
  14819. devicePosition?: Vector3;
  14820. /**
  14821. * The rotation quaternion of the device in babylon space.
  14822. */
  14823. deviceRotationQuaternion: Quaternion;
  14824. /**
  14825. * The raw pose coming from the device.
  14826. */
  14827. rawPose: Nullable<DevicePose>;
  14828. /**
  14829. * The scale of the device to be used when translating from device space to babylon space.
  14830. */
  14831. deviceScaleFactor: number;
  14832. /**
  14833. * Updates the poseControlled values based on the input device pose.
  14834. * @param poseData the pose data to update the object with
  14835. */
  14836. updateFromDevice(poseData: DevicePose): void;
  14837. }
  14838. /**
  14839. * Set of options to customize the webVRCamera
  14840. */
  14841. export interface WebVROptions {
  14842. /**
  14843. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14844. */
  14845. trackPosition?: boolean;
  14846. /**
  14847. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14848. */
  14849. positionScale?: number;
  14850. /**
  14851. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14852. */
  14853. displayName?: string;
  14854. /**
  14855. * Should the native controller meshes be initialized. (default: true)
  14856. */
  14857. controllerMeshes?: boolean;
  14858. /**
  14859. * Creating a default HemiLight only on controllers. (default: true)
  14860. */
  14861. defaultLightingOnControllers?: boolean;
  14862. /**
  14863. * If you don't want to use the default VR button of the helper. (default: false)
  14864. */
  14865. useCustomVRButton?: boolean;
  14866. /**
  14867. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14868. */
  14869. customVRButton?: HTMLButtonElement;
  14870. /**
  14871. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14872. */
  14873. rayLength?: number;
  14874. /**
  14875. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14876. */
  14877. defaultHeight?: number;
  14878. /**
  14879. * If multiview should be used if availible (default: false)
  14880. */
  14881. useMultiview?: boolean;
  14882. }
  14883. /**
  14884. * This represents a WebVR camera.
  14885. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14886. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14887. */
  14888. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14889. private webVROptions;
  14890. /**
  14891. * @hidden
  14892. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14893. */
  14894. _vrDevice: any;
  14895. /**
  14896. * The rawPose of the vrDevice.
  14897. */
  14898. rawPose: Nullable<DevicePose>;
  14899. private _onVREnabled;
  14900. private _specsVersion;
  14901. private _attached;
  14902. private _frameData;
  14903. protected _descendants: Array<Node>;
  14904. private _deviceRoomPosition;
  14905. /** @hidden */
  14906. _deviceRoomRotationQuaternion: Quaternion;
  14907. private _standingMatrix;
  14908. /**
  14909. * Represents device position in babylon space.
  14910. */
  14911. devicePosition: Vector3;
  14912. /**
  14913. * Represents device rotation in babylon space.
  14914. */
  14915. deviceRotationQuaternion: Quaternion;
  14916. /**
  14917. * The scale of the device to be used when translating from device space to babylon space.
  14918. */
  14919. deviceScaleFactor: number;
  14920. private _deviceToWorld;
  14921. private _worldToDevice;
  14922. /**
  14923. * References to the webVR controllers for the vrDevice.
  14924. */
  14925. controllers: Array<WebVRController>;
  14926. /**
  14927. * Emits an event when a controller is attached.
  14928. */
  14929. onControllersAttachedObservable: Observable<WebVRController[]>;
  14930. /**
  14931. * Emits an event when a controller's mesh has been loaded;
  14932. */
  14933. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14934. /**
  14935. * Emits an event when the HMD's pose has been updated.
  14936. */
  14937. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14938. private _poseSet;
  14939. /**
  14940. * If the rig cameras be used as parent instead of this camera.
  14941. */
  14942. rigParenting: boolean;
  14943. private _lightOnControllers;
  14944. private _defaultHeight?;
  14945. /**
  14946. * Instantiates a WebVRFreeCamera.
  14947. * @param name The name of the WebVRFreeCamera
  14948. * @param position The starting anchor position for the camera
  14949. * @param scene The scene the camera belongs to
  14950. * @param webVROptions a set of customizable options for the webVRCamera
  14951. */
  14952. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14953. /**
  14954. * Gets the device distance from the ground in meters.
  14955. * @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.
  14956. */
  14957. deviceDistanceToRoomGround(): number;
  14958. /**
  14959. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14960. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14961. */
  14962. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14963. /**
  14964. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14965. * @returns A promise with a boolean set to if the standing matrix is supported.
  14966. */
  14967. useStandingMatrixAsync(): Promise<boolean>;
  14968. /**
  14969. * Disposes the camera
  14970. */
  14971. dispose(): void;
  14972. /**
  14973. * Gets a vrController by name.
  14974. * @param name The name of the controller to retreive
  14975. * @returns the controller matching the name specified or null if not found
  14976. */
  14977. getControllerByName(name: string): Nullable<WebVRController>;
  14978. private _leftController;
  14979. /**
  14980. * The controller corresponding to the users left hand.
  14981. */
  14982. readonly leftController: Nullable<WebVRController>;
  14983. private _rightController;
  14984. /**
  14985. * The controller corresponding to the users right hand.
  14986. */
  14987. readonly rightController: Nullable<WebVRController>;
  14988. /**
  14989. * Casts a ray forward from the vrCamera's gaze.
  14990. * @param length Length of the ray (default: 100)
  14991. * @returns the ray corresponding to the gaze
  14992. */
  14993. getForwardRay(length?: number): Ray;
  14994. /**
  14995. * @hidden
  14996. * Updates the camera based on device's frame data
  14997. */
  14998. _checkInputs(): void;
  14999. /**
  15000. * Updates the poseControlled values based on the input device pose.
  15001. * @param poseData Pose coming from the device
  15002. */
  15003. updateFromDevice(poseData: DevicePose): void;
  15004. private _htmlElementAttached;
  15005. private _detachIfAttached;
  15006. /**
  15007. * WebVR's attach control will start broadcasting frames to the device.
  15008. * Note that in certain browsers (chrome for example) this function must be called
  15009. * within a user-interaction callback. Example:
  15010. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15011. *
  15012. * @param element html element to attach the vrDevice to
  15013. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15014. */
  15015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15016. /**
  15017. * Detaches the camera from the html element and disables VR
  15018. *
  15019. * @param element html element to detach from
  15020. */
  15021. detachControl(element: HTMLElement): void;
  15022. /**
  15023. * @returns the name of this class
  15024. */
  15025. getClassName(): string;
  15026. /**
  15027. * Calls resetPose on the vrDisplay
  15028. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15029. */
  15030. resetToCurrentRotation(): void;
  15031. /**
  15032. * @hidden
  15033. * Updates the rig cameras (left and right eye)
  15034. */
  15035. _updateRigCameras(): void;
  15036. private _workingVector;
  15037. private _oneVector;
  15038. private _workingMatrix;
  15039. private updateCacheCalled;
  15040. private _correctPositionIfNotTrackPosition;
  15041. /**
  15042. * @hidden
  15043. * Updates the cached values of the camera
  15044. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15045. */
  15046. _updateCache(ignoreParentClass?: boolean): void;
  15047. /**
  15048. * @hidden
  15049. * Get current device position in babylon world
  15050. */
  15051. _computeDevicePosition(): void;
  15052. /**
  15053. * Updates the current device position and rotation in the babylon world
  15054. */
  15055. update(): void;
  15056. /**
  15057. * @hidden
  15058. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15059. * @returns an identity matrix
  15060. */
  15061. _getViewMatrix(): Matrix;
  15062. private _tmpMatrix;
  15063. /**
  15064. * This function is called by the two RIG cameras.
  15065. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15066. * @hidden
  15067. */
  15068. _getWebVRViewMatrix(): Matrix;
  15069. /** @hidden */
  15070. _getWebVRProjectionMatrix(): Matrix;
  15071. private _onGamepadConnectedObserver;
  15072. private _onGamepadDisconnectedObserver;
  15073. private _updateCacheWhenTrackingDisabledObserver;
  15074. /**
  15075. * Initializes the controllers and their meshes
  15076. */
  15077. initControllers(): void;
  15078. }
  15079. }
  15080. declare module BABYLON {
  15081. /**
  15082. * Size options for a post process
  15083. */
  15084. export type PostProcessOptions = {
  15085. width: number;
  15086. height: number;
  15087. };
  15088. /**
  15089. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15090. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15091. */
  15092. export class PostProcess {
  15093. /** Name of the PostProcess. */
  15094. name: string;
  15095. /**
  15096. * Gets or sets the unique id of the post process
  15097. */
  15098. uniqueId: number;
  15099. /**
  15100. * Width of the texture to apply the post process on
  15101. */
  15102. width: number;
  15103. /**
  15104. * Height of the texture to apply the post process on
  15105. */
  15106. height: number;
  15107. /**
  15108. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15109. * @hidden
  15110. */
  15111. _outputTexture: Nullable<InternalTexture>;
  15112. /**
  15113. * Sampling mode used by the shader
  15114. * See https://doc.babylonjs.com/classes/3.1/texture
  15115. */
  15116. renderTargetSamplingMode: number;
  15117. /**
  15118. * Clear color to use when screen clearing
  15119. */
  15120. clearColor: Color4;
  15121. /**
  15122. * If the buffer needs to be cleared before applying the post process. (default: true)
  15123. * Should be set to false if shader will overwrite all previous pixels.
  15124. */
  15125. autoClear: boolean;
  15126. /**
  15127. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15128. */
  15129. alphaMode: number;
  15130. /**
  15131. * Sets the setAlphaBlendConstants of the babylon engine
  15132. */
  15133. alphaConstants: Color4;
  15134. /**
  15135. * Animations to be used for the post processing
  15136. */
  15137. animations: Animation[];
  15138. /**
  15139. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15140. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15141. */
  15142. enablePixelPerfectMode: boolean;
  15143. /**
  15144. * Force the postprocess to be applied without taking in account viewport
  15145. */
  15146. forceFullscreenViewport: boolean;
  15147. /**
  15148. * List of inspectable custom properties (used by the Inspector)
  15149. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15150. */
  15151. inspectableCustomProperties: IInspectable[];
  15152. /**
  15153. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15154. *
  15155. * | Value | Type | Description |
  15156. * | ----- | ----------------------------------- | ----------- |
  15157. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15158. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15159. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15160. *
  15161. */
  15162. scaleMode: number;
  15163. /**
  15164. * Force textures to be a power of two (default: false)
  15165. */
  15166. alwaysForcePOT: boolean;
  15167. private _samples;
  15168. /**
  15169. * Number of sample textures (default: 1)
  15170. */
  15171. samples: number;
  15172. /**
  15173. * Modify the scale of the post process to be the same as the viewport (default: false)
  15174. */
  15175. adaptScaleToCurrentViewport: boolean;
  15176. private _camera;
  15177. private _scene;
  15178. private _engine;
  15179. private _options;
  15180. private _reusable;
  15181. private _textureType;
  15182. /**
  15183. * Smart array of input and output textures for the post process.
  15184. * @hidden
  15185. */
  15186. _textures: SmartArray<InternalTexture>;
  15187. /**
  15188. * The index in _textures that corresponds to the output texture.
  15189. * @hidden
  15190. */
  15191. _currentRenderTextureInd: number;
  15192. private _effect;
  15193. private _samplers;
  15194. private _fragmentUrl;
  15195. private _vertexUrl;
  15196. private _parameters;
  15197. private _scaleRatio;
  15198. protected _indexParameters: any;
  15199. private _shareOutputWithPostProcess;
  15200. private _texelSize;
  15201. private _forcedOutputTexture;
  15202. /**
  15203. * Returns the fragment url or shader name used in the post process.
  15204. * @returns the fragment url or name in the shader store.
  15205. */
  15206. getEffectName(): string;
  15207. /**
  15208. * An event triggered when the postprocess is activated.
  15209. */
  15210. onActivateObservable: Observable<Camera>;
  15211. private _onActivateObserver;
  15212. /**
  15213. * A function that is added to the onActivateObservable
  15214. */
  15215. onActivate: Nullable<(camera: Camera) => void>;
  15216. /**
  15217. * An event triggered when the postprocess changes its size.
  15218. */
  15219. onSizeChangedObservable: Observable<PostProcess>;
  15220. private _onSizeChangedObserver;
  15221. /**
  15222. * A function that is added to the onSizeChangedObservable
  15223. */
  15224. onSizeChanged: (postProcess: PostProcess) => void;
  15225. /**
  15226. * An event triggered when the postprocess applies its effect.
  15227. */
  15228. onApplyObservable: Observable<Effect>;
  15229. private _onApplyObserver;
  15230. /**
  15231. * A function that is added to the onApplyObservable
  15232. */
  15233. onApply: (effect: Effect) => void;
  15234. /**
  15235. * An event triggered before rendering the postprocess
  15236. */
  15237. onBeforeRenderObservable: Observable<Effect>;
  15238. private _onBeforeRenderObserver;
  15239. /**
  15240. * A function that is added to the onBeforeRenderObservable
  15241. */
  15242. onBeforeRender: (effect: Effect) => void;
  15243. /**
  15244. * An event triggered after rendering the postprocess
  15245. */
  15246. onAfterRenderObservable: Observable<Effect>;
  15247. private _onAfterRenderObserver;
  15248. /**
  15249. * A function that is added to the onAfterRenderObservable
  15250. */
  15251. onAfterRender: (efect: Effect) => void;
  15252. /**
  15253. * 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
  15254. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15255. */
  15256. inputTexture: InternalTexture;
  15257. /**
  15258. * Gets the camera which post process is applied to.
  15259. * @returns The camera the post process is applied to.
  15260. */
  15261. getCamera(): Camera;
  15262. /**
  15263. * Gets the texel size of the postprocess.
  15264. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15265. */
  15266. readonly texelSize: Vector2;
  15267. /**
  15268. * Creates a new instance PostProcess
  15269. * @param name The name of the PostProcess.
  15270. * @param fragmentUrl The url of the fragment shader to be used.
  15271. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15272. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15273. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15274. * @param camera The camera to apply the render pass to.
  15275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15276. * @param engine The engine which the post process will be applied. (default: current engine)
  15277. * @param reusable If the post process can be reused on the same frame. (default: false)
  15278. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15279. * @param textureType Type of textures used when performing the post process. (default: 0)
  15280. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15281. * @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
  15282. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15283. */
  15284. constructor(
  15285. /** Name of the PostProcess. */
  15286. 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);
  15287. /**
  15288. * Gets a string idenfifying the name of the class
  15289. * @returns "PostProcess" string
  15290. */
  15291. getClassName(): string;
  15292. /**
  15293. * Gets the engine which this post process belongs to.
  15294. * @returns The engine the post process was enabled with.
  15295. */
  15296. getEngine(): Engine;
  15297. /**
  15298. * The effect that is created when initializing the post process.
  15299. * @returns The created effect corresponding the the postprocess.
  15300. */
  15301. getEffect(): Effect;
  15302. /**
  15303. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15304. * @param postProcess The post process to share the output with.
  15305. * @returns This post process.
  15306. */
  15307. shareOutputWith(postProcess: PostProcess): PostProcess;
  15308. /**
  15309. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15310. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15311. */
  15312. useOwnOutput(): void;
  15313. /**
  15314. * Updates the effect with the current post process compile time values and recompiles the shader.
  15315. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15316. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15317. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15318. * @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
  15319. * @param onCompiled Called when the shader has been compiled.
  15320. * @param onError Called if there is an error when compiling a shader.
  15321. */
  15322. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15323. /**
  15324. * The post process is reusable if it can be used multiple times within one frame.
  15325. * @returns If the post process is reusable
  15326. */
  15327. isReusable(): boolean;
  15328. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15329. markTextureDirty(): void;
  15330. /**
  15331. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15332. * 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.
  15333. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15334. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15335. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15336. * @returns The target texture that was bound to be written to.
  15337. */
  15338. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15339. /**
  15340. * If the post process is supported.
  15341. */
  15342. readonly isSupported: boolean;
  15343. /**
  15344. * The aspect ratio of the output texture.
  15345. */
  15346. readonly aspectRatio: number;
  15347. /**
  15348. * Get a value indicating if the post-process is ready to be used
  15349. * @returns true if the post-process is ready (shader is compiled)
  15350. */
  15351. isReady(): boolean;
  15352. /**
  15353. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15354. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15355. */
  15356. apply(): Nullable<Effect>;
  15357. private _disposeTextures;
  15358. /**
  15359. * Disposes the post process.
  15360. * @param camera The camera to dispose the post process on.
  15361. */
  15362. dispose(camera?: Camera): void;
  15363. }
  15364. }
  15365. declare module BABYLON {
  15366. /** @hidden */
  15367. export var kernelBlurVaryingDeclaration: {
  15368. name: string;
  15369. shader: string;
  15370. };
  15371. }
  15372. declare module BABYLON {
  15373. /** @hidden */
  15374. export var kernelBlurFragment: {
  15375. name: string;
  15376. shader: string;
  15377. };
  15378. }
  15379. declare module BABYLON {
  15380. /** @hidden */
  15381. export var kernelBlurFragment2: {
  15382. name: string;
  15383. shader: string;
  15384. };
  15385. }
  15386. declare module BABYLON {
  15387. /** @hidden */
  15388. export var kernelBlurPixelShader: {
  15389. name: string;
  15390. shader: string;
  15391. };
  15392. }
  15393. declare module BABYLON {
  15394. /** @hidden */
  15395. export var kernelBlurVertex: {
  15396. name: string;
  15397. shader: string;
  15398. };
  15399. }
  15400. declare module BABYLON {
  15401. /** @hidden */
  15402. export var kernelBlurVertexShader: {
  15403. name: string;
  15404. shader: string;
  15405. };
  15406. }
  15407. declare module BABYLON {
  15408. /**
  15409. * The Blur Post Process which blurs an image based on a kernel and direction.
  15410. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15411. */
  15412. export class BlurPostProcess extends PostProcess {
  15413. /** The direction in which to blur the image. */
  15414. direction: Vector2;
  15415. private blockCompilation;
  15416. protected _kernel: number;
  15417. protected _idealKernel: number;
  15418. protected _packedFloat: boolean;
  15419. private _staticDefines;
  15420. /**
  15421. * Sets the length in pixels of the blur sample region
  15422. */
  15423. /**
  15424. * Gets the length in pixels of the blur sample region
  15425. */
  15426. kernel: number;
  15427. /**
  15428. * Sets wether or not the blur needs to unpack/repack floats
  15429. */
  15430. /**
  15431. * Gets wether or not the blur is unpacking/repacking floats
  15432. */
  15433. packedFloat: boolean;
  15434. /**
  15435. * Creates a new instance BlurPostProcess
  15436. * @param name The name of the effect.
  15437. * @param direction The direction in which to blur the image.
  15438. * @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.
  15439. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15440. * @param camera The camera to apply the render pass to.
  15441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15442. * @param engine The engine which the post process will be applied. (default: current engine)
  15443. * @param reusable If the post process can be reused on the same frame. (default: false)
  15444. * @param textureType Type of textures used when performing the post process. (default: 0)
  15445. * @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)
  15446. */
  15447. constructor(name: string,
  15448. /** The direction in which to blur the image. */
  15449. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15450. /**
  15451. * Updates the effect with the current post process compile time values and recompiles the shader.
  15452. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15453. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15454. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15455. * @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
  15456. * @param onCompiled Called when the shader has been compiled.
  15457. * @param onError Called if there is an error when compiling a shader.
  15458. */
  15459. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15460. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15461. /**
  15462. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15463. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15464. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15465. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15466. * The gaps between physical kernels are compensated for in the weighting of the samples
  15467. * @param idealKernel Ideal blur kernel.
  15468. * @return Nearest best kernel.
  15469. */
  15470. protected _nearestBestKernel(idealKernel: number): number;
  15471. /**
  15472. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15473. * @param x The point on the Gaussian distribution to sample.
  15474. * @return the value of the Gaussian function at x.
  15475. */
  15476. protected _gaussianWeight(x: number): number;
  15477. /**
  15478. * Generates a string that can be used as a floating point number in GLSL.
  15479. * @param x Value to print.
  15480. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15481. * @return GLSL float string.
  15482. */
  15483. protected _glslFloat(x: number, decimalFigures?: number): string;
  15484. }
  15485. }
  15486. declare module BABYLON {
  15487. /**
  15488. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15489. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15490. * You can then easily use it as a reflectionTexture on a flat surface.
  15491. * In case the surface is not a plane, please consider relying on reflection probes.
  15492. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15493. */
  15494. export class MirrorTexture extends RenderTargetTexture {
  15495. private scene;
  15496. /**
  15497. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15498. * 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.
  15499. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15500. */
  15501. mirrorPlane: Plane;
  15502. /**
  15503. * Define the blur ratio used to blur the reflection if needed.
  15504. */
  15505. blurRatio: number;
  15506. /**
  15507. * Define the adaptive blur kernel used to blur the reflection if needed.
  15508. * This will autocompute the closest best match for the `blurKernel`
  15509. */
  15510. adaptiveBlurKernel: number;
  15511. /**
  15512. * Define the blur kernel used to blur the reflection if needed.
  15513. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15514. */
  15515. blurKernel: number;
  15516. /**
  15517. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15518. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15519. */
  15520. blurKernelX: number;
  15521. /**
  15522. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15523. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15524. */
  15525. blurKernelY: number;
  15526. private _autoComputeBlurKernel;
  15527. protected _onRatioRescale(): void;
  15528. private _updateGammaSpace;
  15529. private _imageProcessingConfigChangeObserver;
  15530. private _transformMatrix;
  15531. private _mirrorMatrix;
  15532. private _savedViewMatrix;
  15533. private _blurX;
  15534. private _blurY;
  15535. private _adaptiveBlurKernel;
  15536. private _blurKernelX;
  15537. private _blurKernelY;
  15538. private _blurRatio;
  15539. /**
  15540. * Instantiates a Mirror Texture.
  15541. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15542. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15543. * You can then easily use it as a reflectionTexture on a flat surface.
  15544. * In case the surface is not a plane, please consider relying on reflection probes.
  15545. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15546. * @param name
  15547. * @param size
  15548. * @param scene
  15549. * @param generateMipMaps
  15550. * @param type
  15551. * @param samplingMode
  15552. * @param generateDepthBuffer
  15553. */
  15554. constructor(name: string, size: number | {
  15555. width: number;
  15556. height: number;
  15557. } | {
  15558. ratio: number;
  15559. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15560. private _preparePostProcesses;
  15561. /**
  15562. * Clone the mirror texture.
  15563. * @returns the cloned texture
  15564. */
  15565. clone(): MirrorTexture;
  15566. /**
  15567. * Serialize the texture to a JSON representation you could use in Parse later on
  15568. * @returns the serialized JSON representation
  15569. */
  15570. serialize(): any;
  15571. /**
  15572. * Dispose the texture and release its associated resources.
  15573. */
  15574. dispose(): void;
  15575. }
  15576. }
  15577. declare module BABYLON {
  15578. /**
  15579. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15580. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15581. */
  15582. export class Texture extends BaseTexture {
  15583. /**
  15584. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15585. */
  15586. static SerializeBuffers: boolean;
  15587. /** @hidden */
  15588. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15589. /** @hidden */
  15590. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15591. /** @hidden */
  15592. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15593. /** nearest is mag = nearest and min = nearest and mip = linear */
  15594. static readonly NEAREST_SAMPLINGMODE: number;
  15595. /** nearest is mag = nearest and min = nearest and mip = linear */
  15596. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15597. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15598. static readonly BILINEAR_SAMPLINGMODE: number;
  15599. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15600. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15601. /** Trilinear is mag = linear and min = linear and mip = linear */
  15602. static readonly TRILINEAR_SAMPLINGMODE: number;
  15603. /** Trilinear is mag = linear and min = linear and mip = linear */
  15604. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15605. /** mag = nearest and min = nearest and mip = nearest */
  15606. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15607. /** mag = nearest and min = linear and mip = nearest */
  15608. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15609. /** mag = nearest and min = linear and mip = linear */
  15610. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15611. /** mag = nearest and min = linear and mip = none */
  15612. static readonly NEAREST_LINEAR: number;
  15613. /** mag = nearest and min = nearest and mip = none */
  15614. static readonly NEAREST_NEAREST: number;
  15615. /** mag = linear and min = nearest and mip = nearest */
  15616. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15617. /** mag = linear and min = nearest and mip = linear */
  15618. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15619. /** mag = linear and min = linear and mip = none */
  15620. static readonly LINEAR_LINEAR: number;
  15621. /** mag = linear and min = nearest and mip = none */
  15622. static readonly LINEAR_NEAREST: number;
  15623. /** Explicit coordinates mode */
  15624. static readonly EXPLICIT_MODE: number;
  15625. /** Spherical coordinates mode */
  15626. static readonly SPHERICAL_MODE: number;
  15627. /** Planar coordinates mode */
  15628. static readonly PLANAR_MODE: number;
  15629. /** Cubic coordinates mode */
  15630. static readonly CUBIC_MODE: number;
  15631. /** Projection coordinates mode */
  15632. static readonly PROJECTION_MODE: number;
  15633. /** Inverse Cubic coordinates mode */
  15634. static readonly SKYBOX_MODE: number;
  15635. /** Inverse Cubic coordinates mode */
  15636. static readonly INVCUBIC_MODE: number;
  15637. /** Equirectangular coordinates mode */
  15638. static readonly EQUIRECTANGULAR_MODE: number;
  15639. /** Equirectangular Fixed coordinates mode */
  15640. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15641. /** Equirectangular Fixed Mirrored coordinates mode */
  15642. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15643. /** Texture is not repeating outside of 0..1 UVs */
  15644. static readonly CLAMP_ADDRESSMODE: number;
  15645. /** Texture is repeating outside of 0..1 UVs */
  15646. static readonly WRAP_ADDRESSMODE: number;
  15647. /** Texture is repeating and mirrored */
  15648. static readonly MIRROR_ADDRESSMODE: number;
  15649. /**
  15650. * 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
  15651. */
  15652. static UseSerializedUrlIfAny: boolean;
  15653. /**
  15654. * Define the url of the texture.
  15655. */
  15656. url: Nullable<string>;
  15657. /**
  15658. * Define an offset on the texture to offset the u coordinates of the UVs
  15659. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15660. */
  15661. uOffset: number;
  15662. /**
  15663. * Define an offset on the texture to offset the v coordinates of the UVs
  15664. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15665. */
  15666. vOffset: number;
  15667. /**
  15668. * Define an offset on the texture to scale the u coordinates of the UVs
  15669. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15670. */
  15671. uScale: number;
  15672. /**
  15673. * Define an offset on the texture to scale the v coordinates of the UVs
  15674. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15675. */
  15676. vScale: number;
  15677. /**
  15678. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15679. * @see http://doc.babylonjs.com/how_to/more_materials
  15680. */
  15681. uAng: number;
  15682. /**
  15683. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15684. * @see http://doc.babylonjs.com/how_to/more_materials
  15685. */
  15686. vAng: number;
  15687. /**
  15688. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15689. * @see http://doc.babylonjs.com/how_to/more_materials
  15690. */
  15691. wAng: number;
  15692. /**
  15693. * Defines the center of rotation (U)
  15694. */
  15695. uRotationCenter: number;
  15696. /**
  15697. * Defines the center of rotation (V)
  15698. */
  15699. vRotationCenter: number;
  15700. /**
  15701. * Defines the center of rotation (W)
  15702. */
  15703. wRotationCenter: number;
  15704. /**
  15705. * Are mip maps generated for this texture or not.
  15706. */
  15707. readonly noMipmap: boolean;
  15708. /**
  15709. * List of inspectable custom properties (used by the Inspector)
  15710. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15711. */
  15712. inspectableCustomProperties: Nullable<IInspectable[]>;
  15713. private _noMipmap;
  15714. /** @hidden */
  15715. _invertY: boolean;
  15716. private _rowGenerationMatrix;
  15717. private _cachedTextureMatrix;
  15718. private _projectionModeMatrix;
  15719. private _t0;
  15720. private _t1;
  15721. private _t2;
  15722. private _cachedUOffset;
  15723. private _cachedVOffset;
  15724. private _cachedUScale;
  15725. private _cachedVScale;
  15726. private _cachedUAng;
  15727. private _cachedVAng;
  15728. private _cachedWAng;
  15729. private _cachedProjectionMatrixId;
  15730. private _cachedCoordinatesMode;
  15731. /** @hidden */
  15732. protected _initialSamplingMode: number;
  15733. /** @hidden */
  15734. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15735. private _deleteBuffer;
  15736. protected _format: Nullable<number>;
  15737. private _delayedOnLoad;
  15738. private _delayedOnError;
  15739. private _mimeType?;
  15740. /**
  15741. * Observable triggered once the texture has been loaded.
  15742. */
  15743. onLoadObservable: Observable<Texture>;
  15744. protected _isBlocking: boolean;
  15745. /**
  15746. * Is the texture preventing material to render while loading.
  15747. * If false, a default texture will be used instead of the loading one during the preparation step.
  15748. */
  15749. isBlocking: boolean;
  15750. /**
  15751. * Get the current sampling mode associated with the texture.
  15752. */
  15753. readonly samplingMode: number;
  15754. /**
  15755. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15756. */
  15757. readonly invertY: boolean;
  15758. /**
  15759. * Instantiates a new texture.
  15760. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15761. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15762. * @param url defines the url of the picture to load as a texture
  15763. * @param scene defines the scene or engine the texture will belong to
  15764. * @param noMipmap defines if the texture will require mip maps or not
  15765. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15766. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15767. * @param onLoad defines a callback triggered when the texture has been loaded
  15768. * @param onError defines a callback triggered when an error occurred during the loading session
  15769. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15770. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15771. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15772. * @param mimeType defines an optional mime type information
  15773. */
  15774. 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);
  15775. /**
  15776. * Update the url (and optional buffer) of this texture if url was null during construction.
  15777. * @param url the url of the texture
  15778. * @param buffer the buffer of the texture (defaults to null)
  15779. * @param onLoad callback called when the texture is loaded (defaults to null)
  15780. */
  15781. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15782. /**
  15783. * Finish the loading sequence of a texture flagged as delayed load.
  15784. * @hidden
  15785. */
  15786. delayLoad(): void;
  15787. private _prepareRowForTextureGeneration;
  15788. /**
  15789. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15790. * @returns the transform matrix of the texture.
  15791. */
  15792. getTextureMatrix(): Matrix;
  15793. /**
  15794. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15795. * @returns The reflection texture transform
  15796. */
  15797. getReflectionTextureMatrix(): Matrix;
  15798. /**
  15799. * Clones the texture.
  15800. * @returns the cloned texture
  15801. */
  15802. clone(): Texture;
  15803. /**
  15804. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15805. * @returns The JSON representation of the texture
  15806. */
  15807. serialize(): any;
  15808. /**
  15809. * Get the current class name of the texture useful for serialization or dynamic coding.
  15810. * @returns "Texture"
  15811. */
  15812. getClassName(): string;
  15813. /**
  15814. * Dispose the texture and release its associated resources.
  15815. */
  15816. dispose(): void;
  15817. /**
  15818. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15819. * @param parsedTexture Define the JSON representation of the texture
  15820. * @param scene Define the scene the parsed texture should be instantiated in
  15821. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15822. * @returns The parsed texture if successful
  15823. */
  15824. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15825. /**
  15826. * Creates a texture from its base 64 representation.
  15827. * @param data Define the base64 payload without the data: prefix
  15828. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15829. * @param scene Define the scene the texture should belong to
  15830. * @param noMipmap Forces the texture to not create mip map information if true
  15831. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15832. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15833. * @param onLoad define a callback triggered when the texture has been loaded
  15834. * @param onError define a callback triggered when an error occurred during the loading session
  15835. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15836. * @returns the created texture
  15837. */
  15838. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15839. /**
  15840. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15841. * @param data Define the base64 payload without the data: prefix
  15842. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15843. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15844. * @param scene Define the scene the texture should belong to
  15845. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15846. * @param noMipmap Forces the texture to not create mip map information if true
  15847. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15848. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15849. * @param onLoad define a callback triggered when the texture has been loaded
  15850. * @param onError define a callback triggered when an error occurred during the loading session
  15851. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15852. * @returns the created texture
  15853. */
  15854. 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;
  15855. }
  15856. }
  15857. declare module BABYLON {
  15858. /**
  15859. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15860. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15861. */
  15862. export class PostProcessManager {
  15863. private _scene;
  15864. private _indexBuffer;
  15865. private _vertexBuffers;
  15866. /**
  15867. * Creates a new instance PostProcess
  15868. * @param scene The scene that the post process is associated with.
  15869. */
  15870. constructor(scene: Scene);
  15871. private _prepareBuffers;
  15872. private _buildIndexBuffer;
  15873. /**
  15874. * Rebuilds the vertex buffers of the manager.
  15875. * @hidden
  15876. */
  15877. _rebuild(): void;
  15878. /**
  15879. * Prepares a frame to be run through a post process.
  15880. * @param sourceTexture The input texture to the post procesess. (default: null)
  15881. * @param postProcesses An array of post processes to be run. (default: null)
  15882. * @returns True if the post processes were able to be run.
  15883. * @hidden
  15884. */
  15885. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15886. /**
  15887. * Manually render a set of post processes to a texture.
  15888. * @param postProcesses An array of post processes to be run.
  15889. * @param targetTexture The target texture to render to.
  15890. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15891. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15892. * @param lodLevel defines which lod of the texture to render to
  15893. */
  15894. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15895. /**
  15896. * Finalize the result of the output of the postprocesses.
  15897. * @param doNotPresent If true the result will not be displayed to the screen.
  15898. * @param targetTexture The target texture to render to.
  15899. * @param faceIndex The index of the face to bind the target texture to.
  15900. * @param postProcesses The array of post processes to render.
  15901. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15902. * @hidden
  15903. */
  15904. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15905. /**
  15906. * Disposes of the post process manager.
  15907. */
  15908. dispose(): void;
  15909. }
  15910. }
  15911. declare module BABYLON {
  15912. /** Interface used by value gradients (color, factor, ...) */
  15913. export interface IValueGradient {
  15914. /**
  15915. * Gets or sets the gradient value (between 0 and 1)
  15916. */
  15917. gradient: number;
  15918. }
  15919. /** Class used to store color4 gradient */
  15920. export class ColorGradient implements IValueGradient {
  15921. /**
  15922. * Gets or sets the gradient value (between 0 and 1)
  15923. */
  15924. gradient: number;
  15925. /**
  15926. * Gets or sets first associated color
  15927. */
  15928. color1: Color4;
  15929. /**
  15930. * Gets or sets second associated color
  15931. */
  15932. color2?: Color4;
  15933. /**
  15934. * Will get a color picked randomly between color1 and color2.
  15935. * If color2 is undefined then color1 will be used
  15936. * @param result defines the target Color4 to store the result in
  15937. */
  15938. getColorToRef(result: Color4): void;
  15939. }
  15940. /** Class used to store color 3 gradient */
  15941. export class Color3Gradient implements IValueGradient {
  15942. /**
  15943. * Gets or sets the gradient value (between 0 and 1)
  15944. */
  15945. gradient: number;
  15946. /**
  15947. * Gets or sets the associated color
  15948. */
  15949. color: Color3;
  15950. }
  15951. /** Class used to store factor gradient */
  15952. export class FactorGradient implements IValueGradient {
  15953. /**
  15954. * Gets or sets the gradient value (between 0 and 1)
  15955. */
  15956. gradient: number;
  15957. /**
  15958. * Gets or sets first associated factor
  15959. */
  15960. factor1: number;
  15961. /**
  15962. * Gets or sets second associated factor
  15963. */
  15964. factor2?: number;
  15965. /**
  15966. * Will get a number picked randomly between factor1 and factor2.
  15967. * If factor2 is undefined then factor1 will be used
  15968. * @returns the picked number
  15969. */
  15970. getFactor(): number;
  15971. }
  15972. /**
  15973. * Helper used to simplify some generic gradient tasks
  15974. */
  15975. export class GradientHelper {
  15976. /**
  15977. * Gets the current gradient from an array of IValueGradient
  15978. * @param ratio defines the current ratio to get
  15979. * @param gradients defines the array of IValueGradient
  15980. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15981. */
  15982. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15983. }
  15984. }
  15985. declare module BABYLON {
  15986. interface ThinEngine {
  15987. /**
  15988. * Creates a dynamic texture
  15989. * @param width defines the width of the texture
  15990. * @param height defines the height of the texture
  15991. * @param generateMipMaps defines if the engine should generate the mip levels
  15992. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  15993. * @returns the dynamic texture inside an InternalTexture
  15994. */
  15995. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  15996. /**
  15997. * Update the content of a dynamic texture
  15998. * @param texture defines the texture to update
  15999. * @param canvas defines the canvas containing the source
  16000. * @param invertY defines if data must be stored with Y axis inverted
  16001. * @param premulAlpha defines if alpha is stored as premultiplied
  16002. * @param format defines the format of the data
  16003. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16004. */
  16005. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16006. }
  16007. }
  16008. declare module BABYLON {
  16009. /**
  16010. * Helper class used to generate a canvas to manipulate images
  16011. */
  16012. export class CanvasGenerator {
  16013. /**
  16014. * Create a new canvas (or offscreen canvas depending on the context)
  16015. * @param width defines the expected width
  16016. * @param height defines the expected height
  16017. * @return a new canvas or offscreen canvas
  16018. */
  16019. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16020. }
  16021. }
  16022. declare module BABYLON {
  16023. /**
  16024. * A class extending Texture allowing drawing on a texture
  16025. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16026. */
  16027. export class DynamicTexture extends Texture {
  16028. private _generateMipMaps;
  16029. private _canvas;
  16030. private _context;
  16031. private _engine;
  16032. /**
  16033. * Creates a DynamicTexture
  16034. * @param name defines the name of the texture
  16035. * @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
  16036. * @param scene defines the scene where you want the texture
  16037. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16038. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16039. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16040. */
  16041. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16042. /**
  16043. * Get the current class name of the texture useful for serialization or dynamic coding.
  16044. * @returns "DynamicTexture"
  16045. */
  16046. getClassName(): string;
  16047. /**
  16048. * Gets the current state of canRescale
  16049. */
  16050. readonly canRescale: boolean;
  16051. private _recreate;
  16052. /**
  16053. * Scales the texture
  16054. * @param ratio the scale factor to apply to both width and height
  16055. */
  16056. scale(ratio: number): void;
  16057. /**
  16058. * Resizes the texture
  16059. * @param width the new width
  16060. * @param height the new height
  16061. */
  16062. scaleTo(width: number, height: number): void;
  16063. /**
  16064. * Gets the context of the canvas used by the texture
  16065. * @returns the canvas context of the dynamic texture
  16066. */
  16067. getContext(): CanvasRenderingContext2D;
  16068. /**
  16069. * Clears the texture
  16070. */
  16071. clear(): void;
  16072. /**
  16073. * Updates the texture
  16074. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16075. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16076. */
  16077. update(invertY?: boolean, premulAlpha?: boolean): void;
  16078. /**
  16079. * Draws text onto the texture
  16080. * @param text defines the text to be drawn
  16081. * @param x defines the placement of the text from the left
  16082. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16083. * @param font defines the font to be used with font-style, font-size, font-name
  16084. * @param color defines the color used for the text
  16085. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16086. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16087. * @param update defines whether texture is immediately update (default is true)
  16088. */
  16089. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16090. /**
  16091. * Clones the texture
  16092. * @returns the clone of the texture.
  16093. */
  16094. clone(): DynamicTexture;
  16095. /**
  16096. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16097. * @returns a serialized dynamic texture object
  16098. */
  16099. serialize(): any;
  16100. /** @hidden */
  16101. _rebuild(): void;
  16102. }
  16103. }
  16104. declare module BABYLON {
  16105. interface AbstractScene {
  16106. /**
  16107. * The list of procedural textures added to the scene
  16108. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16109. */
  16110. proceduralTextures: Array<ProceduralTexture>;
  16111. }
  16112. /**
  16113. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16114. * in a given scene.
  16115. */
  16116. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16117. /**
  16118. * The component name helpfull to identify the component in the list of scene components.
  16119. */
  16120. readonly name: string;
  16121. /**
  16122. * The scene the component belongs to.
  16123. */
  16124. scene: Scene;
  16125. /**
  16126. * Creates a new instance of the component for the given scene
  16127. * @param scene Defines the scene to register the component in
  16128. */
  16129. constructor(scene: Scene);
  16130. /**
  16131. * Registers the component in a given scene
  16132. */
  16133. register(): void;
  16134. /**
  16135. * Rebuilds the elements related to this component in case of
  16136. * context lost for instance.
  16137. */
  16138. rebuild(): void;
  16139. /**
  16140. * Disposes the component and the associated ressources.
  16141. */
  16142. dispose(): void;
  16143. private _beforeClear;
  16144. }
  16145. }
  16146. declare module BABYLON {
  16147. interface ThinEngine {
  16148. /**
  16149. * Creates a new render target cube texture
  16150. * @param size defines the size of the texture
  16151. * @param options defines the options used to create the texture
  16152. * @returns a new render target cube texture stored in an InternalTexture
  16153. */
  16154. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16155. }
  16156. }
  16157. declare module BABYLON {
  16158. /** @hidden */
  16159. export var proceduralVertexShader: {
  16160. name: string;
  16161. shader: string;
  16162. };
  16163. }
  16164. declare module BABYLON {
  16165. /**
  16166. * 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.
  16167. * This is the base class of any Procedural texture and contains most of the shareable code.
  16168. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16169. */
  16170. export class ProceduralTexture extends Texture {
  16171. isCube: boolean;
  16172. /**
  16173. * Define if the texture is enabled or not (disabled texture will not render)
  16174. */
  16175. isEnabled: boolean;
  16176. /**
  16177. * Define if the texture must be cleared before rendering (default is true)
  16178. */
  16179. autoClear: boolean;
  16180. /**
  16181. * Callback called when the texture is generated
  16182. */
  16183. onGenerated: () => void;
  16184. /**
  16185. * Event raised when the texture is generated
  16186. */
  16187. onGeneratedObservable: Observable<ProceduralTexture>;
  16188. /** @hidden */
  16189. _generateMipMaps: boolean;
  16190. /** @hidden **/
  16191. _effect: Effect;
  16192. /** @hidden */
  16193. _textures: {
  16194. [key: string]: Texture;
  16195. };
  16196. private _size;
  16197. private _currentRefreshId;
  16198. private _refreshRate;
  16199. private _vertexBuffers;
  16200. private _indexBuffer;
  16201. private _uniforms;
  16202. private _samplers;
  16203. private _fragment;
  16204. private _floats;
  16205. private _ints;
  16206. private _floatsArrays;
  16207. private _colors3;
  16208. private _colors4;
  16209. private _vectors2;
  16210. private _vectors3;
  16211. private _matrices;
  16212. private _fallbackTexture;
  16213. private _fallbackTextureUsed;
  16214. private _engine;
  16215. private _cachedDefines;
  16216. private _contentUpdateId;
  16217. private _contentData;
  16218. /**
  16219. * Instantiates a new procedural texture.
  16220. * 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.
  16221. * This is the base class of any Procedural texture and contains most of the shareable code.
  16222. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16223. * @param name Define the name of the texture
  16224. * @param size Define the size of the texture to create
  16225. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16226. * @param scene Define the scene the texture belongs to
  16227. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16228. * @param generateMipMaps Define if the texture should creates mip maps or not
  16229. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16230. */
  16231. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16232. /**
  16233. * The effect that is created when initializing the post process.
  16234. * @returns The created effect corresponding the the postprocess.
  16235. */
  16236. getEffect(): Effect;
  16237. /**
  16238. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16239. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16240. */
  16241. getContent(): Nullable<ArrayBufferView>;
  16242. private _createIndexBuffer;
  16243. /** @hidden */
  16244. _rebuild(): void;
  16245. /**
  16246. * Resets the texture in order to recreate its associated resources.
  16247. * This can be called in case of context loss
  16248. */
  16249. reset(): void;
  16250. protected _getDefines(): string;
  16251. /**
  16252. * Is the texture ready to be used ? (rendered at least once)
  16253. * @returns true if ready, otherwise, false.
  16254. */
  16255. isReady(): boolean;
  16256. /**
  16257. * Resets the refresh counter of the texture and start bak from scratch.
  16258. * Could be useful to regenerate the texture if it is setup to render only once.
  16259. */
  16260. resetRefreshCounter(): void;
  16261. /**
  16262. * Set the fragment shader to use in order to render the texture.
  16263. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16264. */
  16265. setFragment(fragment: any): void;
  16266. /**
  16267. * Define the refresh rate of the texture or the rendering frequency.
  16268. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16269. */
  16270. refreshRate: number;
  16271. /** @hidden */
  16272. _shouldRender(): boolean;
  16273. /**
  16274. * Get the size the texture is rendering at.
  16275. * @returns the size (texture is always squared)
  16276. */
  16277. getRenderSize(): number;
  16278. /**
  16279. * Resize the texture to new value.
  16280. * @param size Define the new size the texture should have
  16281. * @param generateMipMaps Define whether the new texture should create mip maps
  16282. */
  16283. resize(size: number, generateMipMaps: boolean): void;
  16284. private _checkUniform;
  16285. /**
  16286. * Set a texture in the shader program used to render.
  16287. * @param name Define the name of the uniform samplers as defined in the shader
  16288. * @param texture Define the texture to bind to this sampler
  16289. * @return the texture itself allowing "fluent" like uniform updates
  16290. */
  16291. setTexture(name: string, texture: Texture): ProceduralTexture;
  16292. /**
  16293. * Set a float in the shader.
  16294. * @param name Define the name of the uniform as defined in the shader
  16295. * @param value Define the value to give to the uniform
  16296. * @return the texture itself allowing "fluent" like uniform updates
  16297. */
  16298. setFloat(name: string, value: number): ProceduralTexture;
  16299. /**
  16300. * Set a int in the shader.
  16301. * @param name Define the name of the uniform as defined in the shader
  16302. * @param value Define the value to give to the uniform
  16303. * @return the texture itself allowing "fluent" like uniform updates
  16304. */
  16305. setInt(name: string, value: number): ProceduralTexture;
  16306. /**
  16307. * Set an array of floats in the shader.
  16308. * @param name Define the name of the uniform as defined in the shader
  16309. * @param value Define the value to give to the uniform
  16310. * @return the texture itself allowing "fluent" like uniform updates
  16311. */
  16312. setFloats(name: string, value: number[]): ProceduralTexture;
  16313. /**
  16314. * Set a vec3 in the shader from a Color3.
  16315. * @param name Define the name of the uniform as defined in the shader
  16316. * @param value Define the value to give to the uniform
  16317. * @return the texture itself allowing "fluent" like uniform updates
  16318. */
  16319. setColor3(name: string, value: Color3): ProceduralTexture;
  16320. /**
  16321. * Set a vec4 in the shader from a Color4.
  16322. * @param name Define the name of the uniform as defined in the shader
  16323. * @param value Define the value to give to the uniform
  16324. * @return the texture itself allowing "fluent" like uniform updates
  16325. */
  16326. setColor4(name: string, value: Color4): ProceduralTexture;
  16327. /**
  16328. * Set a vec2 in the shader from a Vector2.
  16329. * @param name Define the name of the uniform as defined in the shader
  16330. * @param value Define the value to give to the uniform
  16331. * @return the texture itself allowing "fluent" like uniform updates
  16332. */
  16333. setVector2(name: string, value: Vector2): ProceduralTexture;
  16334. /**
  16335. * Set a vec3 in the shader from a Vector3.
  16336. * @param name Define the name of the uniform as defined in the shader
  16337. * @param value Define the value to give to the uniform
  16338. * @return the texture itself allowing "fluent" like uniform updates
  16339. */
  16340. setVector3(name: string, value: Vector3): ProceduralTexture;
  16341. /**
  16342. * Set a mat4 in the shader from a MAtrix.
  16343. * @param name Define the name of the uniform as defined in the shader
  16344. * @param value Define the value to give to the uniform
  16345. * @return the texture itself allowing "fluent" like uniform updates
  16346. */
  16347. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16348. /**
  16349. * Render the texture to its associated render target.
  16350. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16351. */
  16352. render(useCameraPostProcess?: boolean): void;
  16353. /**
  16354. * Clone the texture.
  16355. * @returns the cloned texture
  16356. */
  16357. clone(): ProceduralTexture;
  16358. /**
  16359. * Dispose the texture and release its asoociated resources.
  16360. */
  16361. dispose(): void;
  16362. }
  16363. }
  16364. declare module BABYLON {
  16365. /**
  16366. * This represents the base class for particle system in Babylon.
  16367. * 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.
  16368. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16369. * @example https://doc.babylonjs.com/babylon101/particles
  16370. */
  16371. export class BaseParticleSystem {
  16372. /**
  16373. * Source color is added to the destination color without alpha affecting the result
  16374. */
  16375. static BLENDMODE_ONEONE: number;
  16376. /**
  16377. * Blend current color and particle color using particle’s alpha
  16378. */
  16379. static BLENDMODE_STANDARD: number;
  16380. /**
  16381. * Add current color and particle color multiplied by particle’s alpha
  16382. */
  16383. static BLENDMODE_ADD: number;
  16384. /**
  16385. * Multiply current color with particle color
  16386. */
  16387. static BLENDMODE_MULTIPLY: number;
  16388. /**
  16389. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16390. */
  16391. static BLENDMODE_MULTIPLYADD: number;
  16392. /**
  16393. * List of animations used by the particle system.
  16394. */
  16395. animations: Animation[];
  16396. /**
  16397. * The id of the Particle system.
  16398. */
  16399. id: string;
  16400. /**
  16401. * The friendly name of the Particle system.
  16402. */
  16403. name: string;
  16404. /**
  16405. * The rendering group used by the Particle system to chose when to render.
  16406. */
  16407. renderingGroupId: number;
  16408. /**
  16409. * The emitter represents the Mesh or position we are attaching the particle system to.
  16410. */
  16411. emitter: Nullable<AbstractMesh | Vector3>;
  16412. /**
  16413. * The maximum number of particles to emit per frame
  16414. */
  16415. emitRate: number;
  16416. /**
  16417. * If you want to launch only a few particles at once, that can be done, as well.
  16418. */
  16419. manualEmitCount: number;
  16420. /**
  16421. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16422. */
  16423. updateSpeed: number;
  16424. /**
  16425. * The amount of time the particle system is running (depends of the overall update speed).
  16426. */
  16427. targetStopDuration: number;
  16428. /**
  16429. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16430. */
  16431. disposeOnStop: boolean;
  16432. /**
  16433. * Minimum power of emitting particles.
  16434. */
  16435. minEmitPower: number;
  16436. /**
  16437. * Maximum power of emitting particles.
  16438. */
  16439. maxEmitPower: number;
  16440. /**
  16441. * Minimum life time of emitting particles.
  16442. */
  16443. minLifeTime: number;
  16444. /**
  16445. * Maximum life time of emitting particles.
  16446. */
  16447. maxLifeTime: number;
  16448. /**
  16449. * Minimum Size of emitting particles.
  16450. */
  16451. minSize: number;
  16452. /**
  16453. * Maximum Size of emitting particles.
  16454. */
  16455. maxSize: number;
  16456. /**
  16457. * Minimum scale of emitting particles on X axis.
  16458. */
  16459. minScaleX: number;
  16460. /**
  16461. * Maximum scale of emitting particles on X axis.
  16462. */
  16463. maxScaleX: number;
  16464. /**
  16465. * Minimum scale of emitting particles on Y axis.
  16466. */
  16467. minScaleY: number;
  16468. /**
  16469. * Maximum scale of emitting particles on Y axis.
  16470. */
  16471. maxScaleY: number;
  16472. /**
  16473. * Gets or sets the minimal initial rotation in radians.
  16474. */
  16475. minInitialRotation: number;
  16476. /**
  16477. * Gets or sets the maximal initial rotation in radians.
  16478. */
  16479. maxInitialRotation: number;
  16480. /**
  16481. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16482. */
  16483. minAngularSpeed: number;
  16484. /**
  16485. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16486. */
  16487. maxAngularSpeed: number;
  16488. /**
  16489. * The texture used to render each particle. (this can be a spritesheet)
  16490. */
  16491. particleTexture: Nullable<Texture>;
  16492. /**
  16493. * The layer mask we are rendering the particles through.
  16494. */
  16495. layerMask: number;
  16496. /**
  16497. * This can help using your own shader to render the particle system.
  16498. * The according effect will be created
  16499. */
  16500. customShader: any;
  16501. /**
  16502. * By default particle system starts as soon as they are created. This prevents the
  16503. * automatic start to happen and let you decide when to start emitting particles.
  16504. */
  16505. preventAutoStart: boolean;
  16506. private _noiseTexture;
  16507. /**
  16508. * Gets or sets a texture used to add random noise to particle positions
  16509. */
  16510. noiseTexture: Nullable<ProceduralTexture>;
  16511. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16512. noiseStrength: Vector3;
  16513. /**
  16514. * Callback triggered when the particle animation is ending.
  16515. */
  16516. onAnimationEnd: Nullable<() => void>;
  16517. /**
  16518. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16519. */
  16520. blendMode: number;
  16521. /**
  16522. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16523. * to override the particles.
  16524. */
  16525. forceDepthWrite: boolean;
  16526. /** 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 */
  16527. preWarmCycles: number;
  16528. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16529. preWarmStepOffset: number;
  16530. /**
  16531. * 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)
  16532. */
  16533. spriteCellChangeSpeed: number;
  16534. /**
  16535. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16536. */
  16537. startSpriteCellID: number;
  16538. /**
  16539. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16540. */
  16541. endSpriteCellID: number;
  16542. /**
  16543. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16544. */
  16545. spriteCellWidth: number;
  16546. /**
  16547. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16548. */
  16549. spriteCellHeight: number;
  16550. /**
  16551. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16552. */
  16553. spriteRandomStartCell: boolean;
  16554. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16555. translationPivot: Vector2;
  16556. /** @hidden */
  16557. protected _isAnimationSheetEnabled: boolean;
  16558. /**
  16559. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16560. */
  16561. beginAnimationOnStart: boolean;
  16562. /**
  16563. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16564. */
  16565. beginAnimationFrom: number;
  16566. /**
  16567. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16568. */
  16569. beginAnimationTo: number;
  16570. /**
  16571. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16572. */
  16573. beginAnimationLoop: boolean;
  16574. /**
  16575. * Gets or sets a world offset applied to all particles
  16576. */
  16577. worldOffset: Vector3;
  16578. /**
  16579. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16580. */
  16581. isAnimationSheetEnabled: boolean;
  16582. /**
  16583. * Get hosting scene
  16584. * @returns the scene
  16585. */
  16586. getScene(): Scene;
  16587. /**
  16588. * You can use gravity if you want to give an orientation to your particles.
  16589. */
  16590. gravity: Vector3;
  16591. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16592. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16593. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16594. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16595. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16596. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16597. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16598. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16599. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16600. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16601. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16602. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16603. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16604. /**
  16605. * Defines the delay in milliseconds before starting the system (0 by default)
  16606. */
  16607. startDelay: number;
  16608. /**
  16609. * Gets the current list of drag gradients.
  16610. * You must use addDragGradient and removeDragGradient to udpate this list
  16611. * @returns the list of drag gradients
  16612. */
  16613. getDragGradients(): Nullable<Array<FactorGradient>>;
  16614. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16615. limitVelocityDamping: number;
  16616. /**
  16617. * Gets the current list of limit velocity gradients.
  16618. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16619. * @returns the list of limit velocity gradients
  16620. */
  16621. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16622. /**
  16623. * Gets the current list of color gradients.
  16624. * You must use addColorGradient and removeColorGradient to udpate this list
  16625. * @returns the list of color gradients
  16626. */
  16627. getColorGradients(): Nullable<Array<ColorGradient>>;
  16628. /**
  16629. * Gets the current list of size gradients.
  16630. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16631. * @returns the list of size gradients
  16632. */
  16633. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16634. /**
  16635. * Gets the current list of color remap gradients.
  16636. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16637. * @returns the list of color remap gradients
  16638. */
  16639. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16640. /**
  16641. * Gets the current list of alpha remap gradients.
  16642. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16643. * @returns the list of alpha remap gradients
  16644. */
  16645. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16646. /**
  16647. * Gets the current list of life time gradients.
  16648. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16649. * @returns the list of life time gradients
  16650. */
  16651. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16652. /**
  16653. * Gets the current list of angular speed gradients.
  16654. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16655. * @returns the list of angular speed gradients
  16656. */
  16657. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16658. /**
  16659. * Gets the current list of velocity gradients.
  16660. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16661. * @returns the list of velocity gradients
  16662. */
  16663. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16664. /**
  16665. * Gets the current list of start size gradients.
  16666. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16667. * @returns the list of start size gradients
  16668. */
  16669. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16670. /**
  16671. * Gets the current list of emit rate gradients.
  16672. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16673. * @returns the list of emit rate gradients
  16674. */
  16675. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16676. /**
  16677. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16678. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16679. */
  16680. direction1: Vector3;
  16681. /**
  16682. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16683. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16684. */
  16685. direction2: Vector3;
  16686. /**
  16687. * 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.
  16688. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16689. */
  16690. minEmitBox: Vector3;
  16691. /**
  16692. * 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.
  16693. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16694. */
  16695. maxEmitBox: Vector3;
  16696. /**
  16697. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16698. */
  16699. color1: Color4;
  16700. /**
  16701. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16702. */
  16703. color2: Color4;
  16704. /**
  16705. * Color the particle will have at the end of its lifetime
  16706. */
  16707. colorDead: Color4;
  16708. /**
  16709. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16710. */
  16711. textureMask: Color4;
  16712. /**
  16713. * The particle emitter type defines the emitter used by the particle system.
  16714. * It can be for example box, sphere, or cone...
  16715. */
  16716. particleEmitterType: IParticleEmitterType;
  16717. /** @hidden */
  16718. _isSubEmitter: boolean;
  16719. /**
  16720. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16721. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16722. */
  16723. billboardMode: number;
  16724. protected _isBillboardBased: boolean;
  16725. /**
  16726. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16727. */
  16728. isBillboardBased: boolean;
  16729. /**
  16730. * The scene the particle system belongs to.
  16731. */
  16732. protected _scene: Scene;
  16733. /**
  16734. * Local cache of defines for image processing.
  16735. */
  16736. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16737. /**
  16738. * Default configuration related to image processing available in the standard Material.
  16739. */
  16740. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16741. /**
  16742. * Gets the image processing configuration used either in this material.
  16743. */
  16744. /**
  16745. * Sets the Default image processing configuration used either in the this material.
  16746. *
  16747. * If sets to null, the scene one is in use.
  16748. */
  16749. imageProcessingConfiguration: ImageProcessingConfiguration;
  16750. /**
  16751. * Attaches a new image processing configuration to the Standard Material.
  16752. * @param configuration
  16753. */
  16754. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16755. /** @hidden */
  16756. protected _reset(): void;
  16757. /** @hidden */
  16758. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16759. /**
  16760. * Instantiates a particle system.
  16761. * 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.
  16762. * @param name The name of the particle system
  16763. */
  16764. constructor(name: string);
  16765. /**
  16766. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16767. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16768. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16769. * @returns the emitter
  16770. */
  16771. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16772. /**
  16773. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16774. * @param radius The radius of the hemisphere to emit from
  16775. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16776. * @returns the emitter
  16777. */
  16778. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16779. /**
  16780. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16781. * @param radius The radius of the sphere to emit from
  16782. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16783. * @returns the emitter
  16784. */
  16785. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16786. /**
  16787. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16788. * @param radius The radius of the sphere to emit from
  16789. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16790. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16791. * @returns the emitter
  16792. */
  16793. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16794. /**
  16795. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16796. * @param radius The radius of the emission cylinder
  16797. * @param height The height of the emission cylinder
  16798. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16799. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16800. * @returns the emitter
  16801. */
  16802. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16803. /**
  16804. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16805. * @param radius The radius of the cylinder to emit from
  16806. * @param height The height of the emission cylinder
  16807. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16810. * @returns the emitter
  16811. */
  16812. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16813. /**
  16814. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16815. * @param radius The radius of the cone to emit from
  16816. * @param angle The base angle of the cone
  16817. * @returns the emitter
  16818. */
  16819. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16820. /**
  16821. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16822. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16823. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16824. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16825. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16826. * @returns the emitter
  16827. */
  16828. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16829. }
  16830. }
  16831. declare module BABYLON {
  16832. /**
  16833. * Type of sub emitter
  16834. */
  16835. export enum SubEmitterType {
  16836. /**
  16837. * Attached to the particle over it's lifetime
  16838. */
  16839. ATTACHED = 0,
  16840. /**
  16841. * Created when the particle dies
  16842. */
  16843. END = 1
  16844. }
  16845. /**
  16846. * Sub emitter class used to emit particles from an existing particle
  16847. */
  16848. export class SubEmitter {
  16849. /**
  16850. * the particle system to be used by the sub emitter
  16851. */
  16852. particleSystem: ParticleSystem;
  16853. /**
  16854. * Type of the submitter (Default: END)
  16855. */
  16856. type: SubEmitterType;
  16857. /**
  16858. * 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)
  16859. * Note: This only is supported when using an emitter of type Mesh
  16860. */
  16861. inheritDirection: boolean;
  16862. /**
  16863. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16864. */
  16865. inheritedVelocityAmount: number;
  16866. /**
  16867. * Creates a sub emitter
  16868. * @param particleSystem the particle system to be used by the sub emitter
  16869. */
  16870. constructor(
  16871. /**
  16872. * the particle system to be used by the sub emitter
  16873. */
  16874. particleSystem: ParticleSystem);
  16875. /**
  16876. * Clones the sub emitter
  16877. * @returns the cloned sub emitter
  16878. */
  16879. clone(): SubEmitter;
  16880. /**
  16881. * Serialize current object to a JSON object
  16882. * @returns the serialized object
  16883. */
  16884. serialize(): any;
  16885. /** @hidden */
  16886. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16887. /**
  16888. * Creates a new SubEmitter from a serialized JSON version
  16889. * @param serializationObject defines the JSON object to read from
  16890. * @param scene defines the hosting scene
  16891. * @param rootUrl defines the rootUrl for data loading
  16892. * @returns a new SubEmitter
  16893. */
  16894. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16895. /** Release associated resources */
  16896. dispose(): void;
  16897. }
  16898. }
  16899. declare module BABYLON {
  16900. /** @hidden */
  16901. export var clipPlaneFragmentDeclaration: {
  16902. name: string;
  16903. shader: string;
  16904. };
  16905. }
  16906. declare module BABYLON {
  16907. /** @hidden */
  16908. export var imageProcessingDeclaration: {
  16909. name: string;
  16910. shader: string;
  16911. };
  16912. }
  16913. declare module BABYLON {
  16914. /** @hidden */
  16915. export var imageProcessingFunctions: {
  16916. name: string;
  16917. shader: string;
  16918. };
  16919. }
  16920. declare module BABYLON {
  16921. /** @hidden */
  16922. export var clipPlaneFragment: {
  16923. name: string;
  16924. shader: string;
  16925. };
  16926. }
  16927. declare module BABYLON {
  16928. /** @hidden */
  16929. export var particlesPixelShader: {
  16930. name: string;
  16931. shader: string;
  16932. };
  16933. }
  16934. declare module BABYLON {
  16935. /** @hidden */
  16936. export var clipPlaneVertexDeclaration: {
  16937. name: string;
  16938. shader: string;
  16939. };
  16940. }
  16941. declare module BABYLON {
  16942. /** @hidden */
  16943. export var clipPlaneVertex: {
  16944. name: string;
  16945. shader: string;
  16946. };
  16947. }
  16948. declare module BABYLON {
  16949. /** @hidden */
  16950. export var particlesVertexShader: {
  16951. name: string;
  16952. shader: string;
  16953. };
  16954. }
  16955. declare module BABYLON {
  16956. /**
  16957. * This represents a particle system in Babylon.
  16958. * 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.
  16959. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16960. * @example https://doc.babylonjs.com/babylon101/particles
  16961. */
  16962. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16963. /**
  16964. * Billboard mode will only apply to Y axis
  16965. */
  16966. static readonly BILLBOARDMODE_Y: number;
  16967. /**
  16968. * Billboard mode will apply to all axes
  16969. */
  16970. static readonly BILLBOARDMODE_ALL: number;
  16971. /**
  16972. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16973. */
  16974. static readonly BILLBOARDMODE_STRETCHED: number;
  16975. /**
  16976. * This function can be defined to provide custom update for active particles.
  16977. * This function will be called instead of regular update (age, position, color, etc.).
  16978. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16979. */
  16980. updateFunction: (particles: Particle[]) => void;
  16981. private _emitterWorldMatrix;
  16982. /**
  16983. * This function can be defined to specify initial direction for every new particle.
  16984. * It by default use the emitterType defined function
  16985. */
  16986. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16987. /**
  16988. * This function can be defined to specify initial position for every new particle.
  16989. * It by default use the emitterType defined function
  16990. */
  16991. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16992. /**
  16993. * @hidden
  16994. */
  16995. _inheritedVelocityOffset: Vector3;
  16996. /**
  16997. * An event triggered when the system is disposed
  16998. */
  16999. onDisposeObservable: Observable<ParticleSystem>;
  17000. private _onDisposeObserver;
  17001. /**
  17002. * Sets a callback that will be triggered when the system is disposed
  17003. */
  17004. onDispose: () => void;
  17005. private _particles;
  17006. private _epsilon;
  17007. private _capacity;
  17008. private _stockParticles;
  17009. private _newPartsExcess;
  17010. private _vertexData;
  17011. private _vertexBuffer;
  17012. private _vertexBuffers;
  17013. private _spriteBuffer;
  17014. private _indexBuffer;
  17015. private _effect;
  17016. private _customEffect;
  17017. private _cachedDefines;
  17018. private _scaledColorStep;
  17019. private _colorDiff;
  17020. private _scaledDirection;
  17021. private _scaledGravity;
  17022. private _currentRenderId;
  17023. private _alive;
  17024. private _useInstancing;
  17025. private _started;
  17026. private _stopped;
  17027. private _actualFrame;
  17028. private _scaledUpdateSpeed;
  17029. private _vertexBufferSize;
  17030. /** @hidden */
  17031. _currentEmitRateGradient: Nullable<FactorGradient>;
  17032. /** @hidden */
  17033. _currentEmitRate1: number;
  17034. /** @hidden */
  17035. _currentEmitRate2: number;
  17036. /** @hidden */
  17037. _currentStartSizeGradient: Nullable<FactorGradient>;
  17038. /** @hidden */
  17039. _currentStartSize1: number;
  17040. /** @hidden */
  17041. _currentStartSize2: number;
  17042. private readonly _rawTextureWidth;
  17043. private _rampGradientsTexture;
  17044. private _useRampGradients;
  17045. /** Gets or sets a boolean indicating that ramp gradients must be used
  17046. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17047. */
  17048. useRampGradients: boolean;
  17049. /**
  17050. * 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.
  17051. * 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: [])
  17052. */
  17053. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17054. private _subEmitters;
  17055. /**
  17056. * @hidden
  17057. * If the particle systems emitter should be disposed when the particle system is disposed
  17058. */
  17059. _disposeEmitterOnDispose: boolean;
  17060. /**
  17061. * The current active Sub-systems, this property is used by the root particle system only.
  17062. */
  17063. activeSubSystems: Array<ParticleSystem>;
  17064. private _rootParticleSystem;
  17065. /**
  17066. * Gets the current list of active particles
  17067. */
  17068. readonly particles: Particle[];
  17069. /**
  17070. * Returns the string "ParticleSystem"
  17071. * @returns a string containing the class name
  17072. */
  17073. getClassName(): string;
  17074. /**
  17075. * Instantiates a particle system.
  17076. * 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.
  17077. * @param name The name of the particle system
  17078. * @param capacity The max number of particles alive at the same time
  17079. * @param scene The scene the particle system belongs to
  17080. * @param customEffect a custom effect used to change the way particles are rendered by default
  17081. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17082. * @param epsilon Offset used to render the particles
  17083. */
  17084. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17085. private _addFactorGradient;
  17086. private _removeFactorGradient;
  17087. /**
  17088. * Adds a new life time gradient
  17089. * @param gradient defines the gradient to use (between 0 and 1)
  17090. * @param factor defines the life time factor to affect to the specified gradient
  17091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17092. * @returns the current particle system
  17093. */
  17094. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17095. /**
  17096. * Remove a specific life time gradient
  17097. * @param gradient defines the gradient to remove
  17098. * @returns the current particle system
  17099. */
  17100. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17101. /**
  17102. * Adds a new size gradient
  17103. * @param gradient defines the gradient to use (between 0 and 1)
  17104. * @param factor defines the size factor to affect to the specified gradient
  17105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17106. * @returns the current particle system
  17107. */
  17108. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17109. /**
  17110. * Remove a specific size gradient
  17111. * @param gradient defines the gradient to remove
  17112. * @returns the current particle system
  17113. */
  17114. removeSizeGradient(gradient: number): IParticleSystem;
  17115. /**
  17116. * Adds a new color remap gradient
  17117. * @param gradient defines the gradient to use (between 0 and 1)
  17118. * @param min defines the color remap minimal range
  17119. * @param max defines the color remap maximal range
  17120. * @returns the current particle system
  17121. */
  17122. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17123. /**
  17124. * Remove a specific color remap gradient
  17125. * @param gradient defines the gradient to remove
  17126. * @returns the current particle system
  17127. */
  17128. removeColorRemapGradient(gradient: number): IParticleSystem;
  17129. /**
  17130. * Adds a new alpha remap gradient
  17131. * @param gradient defines the gradient to use (between 0 and 1)
  17132. * @param min defines the alpha remap minimal range
  17133. * @param max defines the alpha remap maximal range
  17134. * @returns the current particle system
  17135. */
  17136. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17137. /**
  17138. * Remove a specific alpha remap gradient
  17139. * @param gradient defines the gradient to remove
  17140. * @returns the current particle system
  17141. */
  17142. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17143. /**
  17144. * Adds a new angular speed gradient
  17145. * @param gradient defines the gradient to use (between 0 and 1)
  17146. * @param factor defines the angular speed to affect to the specified gradient
  17147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17148. * @returns the current particle system
  17149. */
  17150. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17151. /**
  17152. * Remove a specific angular speed gradient
  17153. * @param gradient defines the gradient to remove
  17154. * @returns the current particle system
  17155. */
  17156. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17157. /**
  17158. * Adds a new velocity gradient
  17159. * @param gradient defines the gradient to use (between 0 and 1)
  17160. * @param factor defines the velocity to affect to the specified gradient
  17161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17162. * @returns the current particle system
  17163. */
  17164. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17165. /**
  17166. * Remove a specific velocity gradient
  17167. * @param gradient defines the gradient to remove
  17168. * @returns the current particle system
  17169. */
  17170. removeVelocityGradient(gradient: number): IParticleSystem;
  17171. /**
  17172. * Adds a new limit velocity gradient
  17173. * @param gradient defines the gradient to use (between 0 and 1)
  17174. * @param factor defines the limit velocity value to affect to the specified gradient
  17175. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17176. * @returns the current particle system
  17177. */
  17178. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17179. /**
  17180. * Remove a specific limit velocity gradient
  17181. * @param gradient defines the gradient to remove
  17182. * @returns the current particle system
  17183. */
  17184. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17185. /**
  17186. * Adds a new drag gradient
  17187. * @param gradient defines the gradient to use (between 0 and 1)
  17188. * @param factor defines the drag value to affect to the specified gradient
  17189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17190. * @returns the current particle system
  17191. */
  17192. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17193. /**
  17194. * Remove a specific drag gradient
  17195. * @param gradient defines the gradient to remove
  17196. * @returns the current particle system
  17197. */
  17198. removeDragGradient(gradient: number): IParticleSystem;
  17199. /**
  17200. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17201. * @param gradient defines the gradient to use (between 0 and 1)
  17202. * @param factor defines the emit rate value to affect to the specified gradient
  17203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17204. * @returns the current particle system
  17205. */
  17206. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17207. /**
  17208. * Remove a specific emit rate gradient
  17209. * @param gradient defines the gradient to remove
  17210. * @returns the current particle system
  17211. */
  17212. removeEmitRateGradient(gradient: number): IParticleSystem;
  17213. /**
  17214. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17215. * @param gradient defines the gradient to use (between 0 and 1)
  17216. * @param factor defines the start size value to affect to the specified gradient
  17217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17218. * @returns the current particle system
  17219. */
  17220. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17221. /**
  17222. * Remove a specific start size gradient
  17223. * @param gradient defines the gradient to remove
  17224. * @returns the current particle system
  17225. */
  17226. removeStartSizeGradient(gradient: number): IParticleSystem;
  17227. private _createRampGradientTexture;
  17228. /**
  17229. * Gets the current list of ramp gradients.
  17230. * You must use addRampGradient and removeRampGradient to udpate this list
  17231. * @returns the list of ramp gradients
  17232. */
  17233. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17234. /**
  17235. * Adds a new ramp gradient used to remap particle colors
  17236. * @param gradient defines the gradient to use (between 0 and 1)
  17237. * @param color defines the color to affect to the specified gradient
  17238. * @returns the current particle system
  17239. */
  17240. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17241. /**
  17242. * Remove a specific ramp gradient
  17243. * @param gradient defines the gradient to remove
  17244. * @returns the current particle system
  17245. */
  17246. removeRampGradient(gradient: number): ParticleSystem;
  17247. /**
  17248. * Adds a new color gradient
  17249. * @param gradient defines the gradient to use (between 0 and 1)
  17250. * @param color1 defines the color to affect to the specified gradient
  17251. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17252. * @returns this particle system
  17253. */
  17254. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17255. /**
  17256. * Remove a specific color gradient
  17257. * @param gradient defines the gradient to remove
  17258. * @returns this particle system
  17259. */
  17260. removeColorGradient(gradient: number): IParticleSystem;
  17261. private _fetchR;
  17262. protected _reset(): void;
  17263. private _resetEffect;
  17264. private _createVertexBuffers;
  17265. private _createIndexBuffer;
  17266. /**
  17267. * Gets the maximum number of particles active at the same time.
  17268. * @returns The max number of active particles.
  17269. */
  17270. getCapacity(): number;
  17271. /**
  17272. * Gets whether there are still active particles in the system.
  17273. * @returns True if it is alive, otherwise false.
  17274. */
  17275. isAlive(): boolean;
  17276. /**
  17277. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17278. * @returns True if it has been started, otherwise false.
  17279. */
  17280. isStarted(): boolean;
  17281. private _prepareSubEmitterInternalArray;
  17282. /**
  17283. * Starts the particle system and begins to emit
  17284. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17285. */
  17286. start(delay?: number): void;
  17287. /**
  17288. * Stops the particle system.
  17289. * @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.
  17290. */
  17291. stop(stopSubEmitters?: boolean): void;
  17292. /**
  17293. * Remove all active particles
  17294. */
  17295. reset(): void;
  17296. /**
  17297. * @hidden (for internal use only)
  17298. */
  17299. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17300. /**
  17301. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17302. * Its lifetime will start back at 0.
  17303. */
  17304. recycleParticle: (particle: Particle) => void;
  17305. private _stopSubEmitters;
  17306. private _createParticle;
  17307. private _removeFromRoot;
  17308. private _emitFromParticle;
  17309. private _update;
  17310. /** @hidden */
  17311. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17312. /** @hidden */
  17313. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17314. /** @hidden */
  17315. private _getEffect;
  17316. /**
  17317. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17318. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17319. */
  17320. animate(preWarmOnly?: boolean): void;
  17321. private _appendParticleVertices;
  17322. /**
  17323. * Rebuilds the particle system.
  17324. */
  17325. rebuild(): void;
  17326. /**
  17327. * Is this system ready to be used/rendered
  17328. * @return true if the system is ready
  17329. */
  17330. isReady(): boolean;
  17331. private _render;
  17332. /**
  17333. * Renders the particle system in its current state.
  17334. * @returns the current number of particles
  17335. */
  17336. render(): number;
  17337. /**
  17338. * Disposes the particle system and free the associated resources
  17339. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17340. */
  17341. dispose(disposeTexture?: boolean): void;
  17342. /**
  17343. * Clones the particle system.
  17344. * @param name The name of the cloned object
  17345. * @param newEmitter The new emitter to use
  17346. * @returns the cloned particle system
  17347. */
  17348. clone(name: string, newEmitter: any): ParticleSystem;
  17349. /**
  17350. * Serializes the particle system to a JSON object.
  17351. * @returns the JSON object
  17352. */
  17353. serialize(): any;
  17354. /** @hidden */
  17355. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17356. /** @hidden */
  17357. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17358. /**
  17359. * Parses a JSON object to create a particle system.
  17360. * @param parsedParticleSystem The JSON object to parse
  17361. * @param scene The scene to create the particle system in
  17362. * @param rootUrl The root url to use to load external dependencies like texture
  17363. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17364. * @returns the Parsed particle system
  17365. */
  17366. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17367. }
  17368. }
  17369. declare module BABYLON {
  17370. /**
  17371. * A particle represents one of the element emitted by a particle system.
  17372. * This is mainly define by its coordinates, direction, velocity and age.
  17373. */
  17374. export class Particle {
  17375. /**
  17376. * The particle system the particle belongs to.
  17377. */
  17378. particleSystem: ParticleSystem;
  17379. private static _Count;
  17380. /**
  17381. * Unique ID of the particle
  17382. */
  17383. id: number;
  17384. /**
  17385. * The world position of the particle in the scene.
  17386. */
  17387. position: Vector3;
  17388. /**
  17389. * The world direction of the particle in the scene.
  17390. */
  17391. direction: Vector3;
  17392. /**
  17393. * The color of the particle.
  17394. */
  17395. color: Color4;
  17396. /**
  17397. * The color change of the particle per step.
  17398. */
  17399. colorStep: Color4;
  17400. /**
  17401. * Defines how long will the life of the particle be.
  17402. */
  17403. lifeTime: number;
  17404. /**
  17405. * The current age of the particle.
  17406. */
  17407. age: number;
  17408. /**
  17409. * The current size of the particle.
  17410. */
  17411. size: number;
  17412. /**
  17413. * The current scale of the particle.
  17414. */
  17415. scale: Vector2;
  17416. /**
  17417. * The current angle of the particle.
  17418. */
  17419. angle: number;
  17420. /**
  17421. * Defines how fast is the angle changing.
  17422. */
  17423. angularSpeed: number;
  17424. /**
  17425. * Defines the cell index used by the particle to be rendered from a sprite.
  17426. */
  17427. cellIndex: number;
  17428. /**
  17429. * The information required to support color remapping
  17430. */
  17431. remapData: Vector4;
  17432. /** @hidden */
  17433. _randomCellOffset?: number;
  17434. /** @hidden */
  17435. _initialDirection: Nullable<Vector3>;
  17436. /** @hidden */
  17437. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17438. /** @hidden */
  17439. _initialStartSpriteCellID: number;
  17440. /** @hidden */
  17441. _initialEndSpriteCellID: number;
  17442. /** @hidden */
  17443. _currentColorGradient: Nullable<ColorGradient>;
  17444. /** @hidden */
  17445. _currentColor1: Color4;
  17446. /** @hidden */
  17447. _currentColor2: Color4;
  17448. /** @hidden */
  17449. _currentSizeGradient: Nullable<FactorGradient>;
  17450. /** @hidden */
  17451. _currentSize1: number;
  17452. /** @hidden */
  17453. _currentSize2: number;
  17454. /** @hidden */
  17455. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17456. /** @hidden */
  17457. _currentAngularSpeed1: number;
  17458. /** @hidden */
  17459. _currentAngularSpeed2: number;
  17460. /** @hidden */
  17461. _currentVelocityGradient: Nullable<FactorGradient>;
  17462. /** @hidden */
  17463. _currentVelocity1: number;
  17464. /** @hidden */
  17465. _currentVelocity2: number;
  17466. /** @hidden */
  17467. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17468. /** @hidden */
  17469. _currentLimitVelocity1: number;
  17470. /** @hidden */
  17471. _currentLimitVelocity2: number;
  17472. /** @hidden */
  17473. _currentDragGradient: Nullable<FactorGradient>;
  17474. /** @hidden */
  17475. _currentDrag1: number;
  17476. /** @hidden */
  17477. _currentDrag2: number;
  17478. /** @hidden */
  17479. _randomNoiseCoordinates1: Vector3;
  17480. /** @hidden */
  17481. _randomNoiseCoordinates2: Vector3;
  17482. /**
  17483. * Creates a new instance Particle
  17484. * @param particleSystem the particle system the particle belongs to
  17485. */
  17486. constructor(
  17487. /**
  17488. * The particle system the particle belongs to.
  17489. */
  17490. particleSystem: ParticleSystem);
  17491. private updateCellInfoFromSystem;
  17492. /**
  17493. * Defines how the sprite cell index is updated for the particle
  17494. */
  17495. updateCellIndex(): void;
  17496. /** @hidden */
  17497. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17498. /** @hidden */
  17499. _inheritParticleInfoToSubEmitters(): void;
  17500. /** @hidden */
  17501. _reset(): void;
  17502. /**
  17503. * Copy the properties of particle to another one.
  17504. * @param other the particle to copy the information to.
  17505. */
  17506. copyTo(other: Particle): void;
  17507. }
  17508. }
  17509. declare module BABYLON {
  17510. /**
  17511. * Particle emitter represents a volume emitting particles.
  17512. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17513. */
  17514. export interface IParticleEmitterType {
  17515. /**
  17516. * Called by the particle System when the direction is computed for the created particle.
  17517. * @param worldMatrix is the world matrix of the particle system
  17518. * @param directionToUpdate is the direction vector to update with the result
  17519. * @param particle is the particle we are computed the direction for
  17520. */
  17521. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17522. /**
  17523. * Called by the particle System when the position is computed for the created particle.
  17524. * @param worldMatrix is the world matrix of the particle system
  17525. * @param positionToUpdate is the position vector to update with the result
  17526. * @param particle is the particle we are computed the position for
  17527. */
  17528. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17529. /**
  17530. * Clones the current emitter and returns a copy of it
  17531. * @returns the new emitter
  17532. */
  17533. clone(): IParticleEmitterType;
  17534. /**
  17535. * Called by the GPUParticleSystem to setup the update shader
  17536. * @param effect defines the update shader
  17537. */
  17538. applyToShader(effect: Effect): void;
  17539. /**
  17540. * Returns a string to use to update the GPU particles update shader
  17541. * @returns the effect defines string
  17542. */
  17543. getEffectDefines(): string;
  17544. /**
  17545. * Returns a string representing the class name
  17546. * @returns a string containing the class name
  17547. */
  17548. getClassName(): string;
  17549. /**
  17550. * Serializes the particle system to a JSON object.
  17551. * @returns the JSON object
  17552. */
  17553. serialize(): any;
  17554. /**
  17555. * Parse properties from a JSON object
  17556. * @param serializationObject defines the JSON object
  17557. */
  17558. parse(serializationObject: any): void;
  17559. }
  17560. }
  17561. declare module BABYLON {
  17562. /**
  17563. * Particle emitter emitting particles from the inside of a box.
  17564. * It emits the particles randomly between 2 given directions.
  17565. */
  17566. export class BoxParticleEmitter implements IParticleEmitterType {
  17567. /**
  17568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17569. */
  17570. direction1: Vector3;
  17571. /**
  17572. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17573. */
  17574. direction2: Vector3;
  17575. /**
  17576. * 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.
  17577. */
  17578. minEmitBox: Vector3;
  17579. /**
  17580. * 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.
  17581. */
  17582. maxEmitBox: Vector3;
  17583. /**
  17584. * Creates a new instance BoxParticleEmitter
  17585. */
  17586. constructor();
  17587. /**
  17588. * Called by the particle System when the direction is computed for the created particle.
  17589. * @param worldMatrix is the world matrix of the particle system
  17590. * @param directionToUpdate is the direction vector to update with the result
  17591. * @param particle is the particle we are computed the direction for
  17592. */
  17593. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17594. /**
  17595. * Called by the particle System when the position is computed for the created particle.
  17596. * @param worldMatrix is the world matrix of the particle system
  17597. * @param positionToUpdate is the position vector to update with the result
  17598. * @param particle is the particle we are computed the position for
  17599. */
  17600. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17601. /**
  17602. * Clones the current emitter and returns a copy of it
  17603. * @returns the new emitter
  17604. */
  17605. clone(): BoxParticleEmitter;
  17606. /**
  17607. * Called by the GPUParticleSystem to setup the update shader
  17608. * @param effect defines the update shader
  17609. */
  17610. applyToShader(effect: Effect): void;
  17611. /**
  17612. * Returns a string to use to update the GPU particles update shader
  17613. * @returns a string containng the defines string
  17614. */
  17615. getEffectDefines(): string;
  17616. /**
  17617. * Returns the string "BoxParticleEmitter"
  17618. * @returns a string containing the class name
  17619. */
  17620. getClassName(): string;
  17621. /**
  17622. * Serializes the particle system to a JSON object.
  17623. * @returns the JSON object
  17624. */
  17625. serialize(): any;
  17626. /**
  17627. * Parse properties from a JSON object
  17628. * @param serializationObject defines the JSON object
  17629. */
  17630. parse(serializationObject: any): void;
  17631. }
  17632. }
  17633. declare module BABYLON {
  17634. /**
  17635. * Particle emitter emitting particles from the inside of a cone.
  17636. * It emits the particles alongside the cone volume from the base to the particle.
  17637. * The emission direction might be randomized.
  17638. */
  17639. export class ConeParticleEmitter implements IParticleEmitterType {
  17640. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17641. directionRandomizer: number;
  17642. private _radius;
  17643. private _angle;
  17644. private _height;
  17645. /**
  17646. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17647. */
  17648. radiusRange: number;
  17649. /**
  17650. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17651. */
  17652. heightRange: number;
  17653. /**
  17654. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17655. */
  17656. emitFromSpawnPointOnly: boolean;
  17657. /**
  17658. * Gets or sets the radius of the emission cone
  17659. */
  17660. radius: number;
  17661. /**
  17662. * Gets or sets the angle of the emission cone
  17663. */
  17664. angle: number;
  17665. private _buildHeight;
  17666. /**
  17667. * Creates a new instance ConeParticleEmitter
  17668. * @param radius the radius of the emission cone (1 by default)
  17669. * @param angle the cone base angle (PI by default)
  17670. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17671. */
  17672. constructor(radius?: number, angle?: number,
  17673. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17674. directionRandomizer?: number);
  17675. /**
  17676. * Called by the particle System when the direction is computed for the created particle.
  17677. * @param worldMatrix is the world matrix of the particle system
  17678. * @param directionToUpdate is the direction vector to update with the result
  17679. * @param particle is the particle we are computed the direction for
  17680. */
  17681. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17682. /**
  17683. * Called by the particle System when the position is computed for the created particle.
  17684. * @param worldMatrix is the world matrix of the particle system
  17685. * @param positionToUpdate is the position vector to update with the result
  17686. * @param particle is the particle we are computed the position for
  17687. */
  17688. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17689. /**
  17690. * Clones the current emitter and returns a copy of it
  17691. * @returns the new emitter
  17692. */
  17693. clone(): ConeParticleEmitter;
  17694. /**
  17695. * Called by the GPUParticleSystem to setup the update shader
  17696. * @param effect defines the update shader
  17697. */
  17698. applyToShader(effect: Effect): void;
  17699. /**
  17700. * Returns a string to use to update the GPU particles update shader
  17701. * @returns a string containng the defines string
  17702. */
  17703. getEffectDefines(): string;
  17704. /**
  17705. * Returns the string "ConeParticleEmitter"
  17706. * @returns a string containing the class name
  17707. */
  17708. getClassName(): string;
  17709. /**
  17710. * Serializes the particle system to a JSON object.
  17711. * @returns the JSON object
  17712. */
  17713. serialize(): any;
  17714. /**
  17715. * Parse properties from a JSON object
  17716. * @param serializationObject defines the JSON object
  17717. */
  17718. parse(serializationObject: any): void;
  17719. }
  17720. }
  17721. declare module BABYLON {
  17722. /**
  17723. * Particle emitter emitting particles from the inside of a cylinder.
  17724. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17725. */
  17726. export class CylinderParticleEmitter implements IParticleEmitterType {
  17727. /**
  17728. * The radius of the emission cylinder.
  17729. */
  17730. radius: number;
  17731. /**
  17732. * The height of the emission cylinder.
  17733. */
  17734. height: number;
  17735. /**
  17736. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17737. */
  17738. radiusRange: number;
  17739. /**
  17740. * How much to randomize the particle direction [0-1].
  17741. */
  17742. directionRandomizer: number;
  17743. /**
  17744. * Creates a new instance CylinderParticleEmitter
  17745. * @param radius the radius of the emission cylinder (1 by default)
  17746. * @param height the height of the emission cylinder (1 by default)
  17747. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17748. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17749. */
  17750. constructor(
  17751. /**
  17752. * The radius of the emission cylinder.
  17753. */
  17754. radius?: number,
  17755. /**
  17756. * The height of the emission cylinder.
  17757. */
  17758. height?: number,
  17759. /**
  17760. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17761. */
  17762. radiusRange?: number,
  17763. /**
  17764. * How much to randomize the particle direction [0-1].
  17765. */
  17766. directionRandomizer?: number);
  17767. /**
  17768. * Called by the particle System when the direction is computed for the created particle.
  17769. * @param worldMatrix is the world matrix of the particle system
  17770. * @param directionToUpdate is the direction vector to update with the result
  17771. * @param particle is the particle we are computed the direction for
  17772. */
  17773. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17774. /**
  17775. * Called by the particle System when the position is computed for the created particle.
  17776. * @param worldMatrix is the world matrix of the particle system
  17777. * @param positionToUpdate is the position vector to update with the result
  17778. * @param particle is the particle we are computed the position for
  17779. */
  17780. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17781. /**
  17782. * Clones the current emitter and returns a copy of it
  17783. * @returns the new emitter
  17784. */
  17785. clone(): CylinderParticleEmitter;
  17786. /**
  17787. * Called by the GPUParticleSystem to setup the update shader
  17788. * @param effect defines the update shader
  17789. */
  17790. applyToShader(effect: Effect): void;
  17791. /**
  17792. * Returns a string to use to update the GPU particles update shader
  17793. * @returns a string containng the defines string
  17794. */
  17795. getEffectDefines(): string;
  17796. /**
  17797. * Returns the string "CylinderParticleEmitter"
  17798. * @returns a string containing the class name
  17799. */
  17800. getClassName(): string;
  17801. /**
  17802. * Serializes the particle system to a JSON object.
  17803. * @returns the JSON object
  17804. */
  17805. serialize(): any;
  17806. /**
  17807. * Parse properties from a JSON object
  17808. * @param serializationObject defines the JSON object
  17809. */
  17810. parse(serializationObject: any): void;
  17811. }
  17812. /**
  17813. * Particle emitter emitting particles from the inside of a cylinder.
  17814. * It emits the particles randomly between two vectors.
  17815. */
  17816. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17817. /**
  17818. * The min limit of the emission direction.
  17819. */
  17820. direction1: Vector3;
  17821. /**
  17822. * The max limit of the emission direction.
  17823. */
  17824. direction2: Vector3;
  17825. /**
  17826. * Creates a new instance CylinderDirectedParticleEmitter
  17827. * @param radius the radius of the emission cylinder (1 by default)
  17828. * @param height the height of the emission cylinder (1 by default)
  17829. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17830. * @param direction1 the min limit of the emission direction (up vector by default)
  17831. * @param direction2 the max limit of the emission direction (up vector by default)
  17832. */
  17833. constructor(radius?: number, height?: number, radiusRange?: number,
  17834. /**
  17835. * The min limit of the emission direction.
  17836. */
  17837. direction1?: Vector3,
  17838. /**
  17839. * The max limit of the emission direction.
  17840. */
  17841. direction2?: Vector3);
  17842. /**
  17843. * Called by the particle System when the direction is computed for the created particle.
  17844. * @param worldMatrix is the world matrix of the particle system
  17845. * @param directionToUpdate is the direction vector to update with the result
  17846. * @param particle is the particle we are computed the direction for
  17847. */
  17848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17849. /**
  17850. * Clones the current emitter and returns a copy of it
  17851. * @returns the new emitter
  17852. */
  17853. clone(): CylinderDirectedParticleEmitter;
  17854. /**
  17855. * Called by the GPUParticleSystem to setup the update shader
  17856. * @param effect defines the update shader
  17857. */
  17858. applyToShader(effect: Effect): void;
  17859. /**
  17860. * Returns a string to use to update the GPU particles update shader
  17861. * @returns a string containng the defines string
  17862. */
  17863. getEffectDefines(): string;
  17864. /**
  17865. * Returns the string "CylinderDirectedParticleEmitter"
  17866. * @returns a string containing the class name
  17867. */
  17868. getClassName(): string;
  17869. /**
  17870. * Serializes the particle system to a JSON object.
  17871. * @returns the JSON object
  17872. */
  17873. serialize(): any;
  17874. /**
  17875. * Parse properties from a JSON object
  17876. * @param serializationObject defines the JSON object
  17877. */
  17878. parse(serializationObject: any): void;
  17879. }
  17880. }
  17881. declare module BABYLON {
  17882. /**
  17883. * Particle emitter emitting particles from the inside of a hemisphere.
  17884. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17885. */
  17886. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17887. /**
  17888. * The radius of the emission hemisphere.
  17889. */
  17890. radius: number;
  17891. /**
  17892. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17893. */
  17894. radiusRange: number;
  17895. /**
  17896. * How much to randomize the particle direction [0-1].
  17897. */
  17898. directionRandomizer: number;
  17899. /**
  17900. * Creates a new instance HemisphericParticleEmitter
  17901. * @param radius the radius of the emission hemisphere (1 by default)
  17902. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17903. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17904. */
  17905. constructor(
  17906. /**
  17907. * The radius of the emission hemisphere.
  17908. */
  17909. radius?: number,
  17910. /**
  17911. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17912. */
  17913. radiusRange?: number,
  17914. /**
  17915. * How much to randomize the particle direction [0-1].
  17916. */
  17917. directionRandomizer?: number);
  17918. /**
  17919. * Called by the particle System when the direction is computed for the created particle.
  17920. * @param worldMatrix is the world matrix of the particle system
  17921. * @param directionToUpdate is the direction vector to update with the result
  17922. * @param particle is the particle we are computed the direction for
  17923. */
  17924. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17925. /**
  17926. * Called by the particle System when the position is computed for the created particle.
  17927. * @param worldMatrix is the world matrix of the particle system
  17928. * @param positionToUpdate is the position vector to update with the result
  17929. * @param particle is the particle we are computed the position for
  17930. */
  17931. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17932. /**
  17933. * Clones the current emitter and returns a copy of it
  17934. * @returns the new emitter
  17935. */
  17936. clone(): HemisphericParticleEmitter;
  17937. /**
  17938. * Called by the GPUParticleSystem to setup the update shader
  17939. * @param effect defines the update shader
  17940. */
  17941. applyToShader(effect: Effect): void;
  17942. /**
  17943. * Returns a string to use to update the GPU particles update shader
  17944. * @returns a string containng the defines string
  17945. */
  17946. getEffectDefines(): string;
  17947. /**
  17948. * Returns the string "HemisphericParticleEmitter"
  17949. * @returns a string containing the class name
  17950. */
  17951. getClassName(): string;
  17952. /**
  17953. * Serializes the particle system to a JSON object.
  17954. * @returns the JSON object
  17955. */
  17956. serialize(): any;
  17957. /**
  17958. * Parse properties from a JSON object
  17959. * @param serializationObject defines the JSON object
  17960. */
  17961. parse(serializationObject: any): void;
  17962. }
  17963. }
  17964. declare module BABYLON {
  17965. /**
  17966. * Particle emitter emitting particles from a point.
  17967. * It emits the particles randomly between 2 given directions.
  17968. */
  17969. export class PointParticleEmitter implements IParticleEmitterType {
  17970. /**
  17971. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17972. */
  17973. direction1: Vector3;
  17974. /**
  17975. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17976. */
  17977. direction2: Vector3;
  17978. /**
  17979. * Creates a new instance PointParticleEmitter
  17980. */
  17981. constructor();
  17982. /**
  17983. * Called by the particle System when the direction is computed for the created particle.
  17984. * @param worldMatrix is the world matrix of the particle system
  17985. * @param directionToUpdate is the direction vector to update with the result
  17986. * @param particle is the particle we are computed the direction for
  17987. */
  17988. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17989. /**
  17990. * Called by the particle System when the position is computed for the created particle.
  17991. * @param worldMatrix is the world matrix of the particle system
  17992. * @param positionToUpdate is the position vector to update with the result
  17993. * @param particle is the particle we are computed the position for
  17994. */
  17995. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17996. /**
  17997. * Clones the current emitter and returns a copy of it
  17998. * @returns the new emitter
  17999. */
  18000. clone(): PointParticleEmitter;
  18001. /**
  18002. * Called by the GPUParticleSystem to setup the update shader
  18003. * @param effect defines the update shader
  18004. */
  18005. applyToShader(effect: Effect): void;
  18006. /**
  18007. * Returns a string to use to update the GPU particles update shader
  18008. * @returns a string containng the defines string
  18009. */
  18010. getEffectDefines(): string;
  18011. /**
  18012. * Returns the string "PointParticleEmitter"
  18013. * @returns a string containing the class name
  18014. */
  18015. getClassName(): string;
  18016. /**
  18017. * Serializes the particle system to a JSON object.
  18018. * @returns the JSON object
  18019. */
  18020. serialize(): any;
  18021. /**
  18022. * Parse properties from a JSON object
  18023. * @param serializationObject defines the JSON object
  18024. */
  18025. parse(serializationObject: any): void;
  18026. }
  18027. }
  18028. declare module BABYLON {
  18029. /**
  18030. * Particle emitter emitting particles from the inside of a sphere.
  18031. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18032. */
  18033. export class SphereParticleEmitter implements IParticleEmitterType {
  18034. /**
  18035. * The radius of the emission sphere.
  18036. */
  18037. radius: number;
  18038. /**
  18039. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18040. */
  18041. radiusRange: number;
  18042. /**
  18043. * How much to randomize the particle direction [0-1].
  18044. */
  18045. directionRandomizer: number;
  18046. /**
  18047. * Creates a new instance SphereParticleEmitter
  18048. * @param radius the radius of the emission sphere (1 by default)
  18049. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18050. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18051. */
  18052. constructor(
  18053. /**
  18054. * The radius of the emission sphere.
  18055. */
  18056. radius?: number,
  18057. /**
  18058. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18059. */
  18060. radiusRange?: number,
  18061. /**
  18062. * How much to randomize the particle direction [0-1].
  18063. */
  18064. directionRandomizer?: number);
  18065. /**
  18066. * Called by the particle System when the direction is computed for the created particle.
  18067. * @param worldMatrix is the world matrix of the particle system
  18068. * @param directionToUpdate is the direction vector to update with the result
  18069. * @param particle is the particle we are computed the direction for
  18070. */
  18071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18072. /**
  18073. * Called by the particle System when the position is computed for the created particle.
  18074. * @param worldMatrix is the world matrix of the particle system
  18075. * @param positionToUpdate is the position vector to update with the result
  18076. * @param particle is the particle we are computed the position for
  18077. */
  18078. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18079. /**
  18080. * Clones the current emitter and returns a copy of it
  18081. * @returns the new emitter
  18082. */
  18083. clone(): SphereParticleEmitter;
  18084. /**
  18085. * Called by the GPUParticleSystem to setup the update shader
  18086. * @param effect defines the update shader
  18087. */
  18088. applyToShader(effect: Effect): void;
  18089. /**
  18090. * Returns a string to use to update the GPU particles update shader
  18091. * @returns a string containng the defines string
  18092. */
  18093. getEffectDefines(): string;
  18094. /**
  18095. * Returns the string "SphereParticleEmitter"
  18096. * @returns a string containing the class name
  18097. */
  18098. getClassName(): string;
  18099. /**
  18100. * Serializes the particle system to a JSON object.
  18101. * @returns the JSON object
  18102. */
  18103. serialize(): any;
  18104. /**
  18105. * Parse properties from a JSON object
  18106. * @param serializationObject defines the JSON object
  18107. */
  18108. parse(serializationObject: any): void;
  18109. }
  18110. /**
  18111. * Particle emitter emitting particles from the inside of a sphere.
  18112. * It emits the particles randomly between two vectors.
  18113. */
  18114. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18115. /**
  18116. * The min limit of the emission direction.
  18117. */
  18118. direction1: Vector3;
  18119. /**
  18120. * The max limit of the emission direction.
  18121. */
  18122. direction2: Vector3;
  18123. /**
  18124. * Creates a new instance SphereDirectedParticleEmitter
  18125. * @param radius the radius of the emission sphere (1 by default)
  18126. * @param direction1 the min limit of the emission direction (up vector by default)
  18127. * @param direction2 the max limit of the emission direction (up vector by default)
  18128. */
  18129. constructor(radius?: number,
  18130. /**
  18131. * The min limit of the emission direction.
  18132. */
  18133. direction1?: Vector3,
  18134. /**
  18135. * The max limit of the emission direction.
  18136. */
  18137. direction2?: Vector3);
  18138. /**
  18139. * Called by the particle System when the direction is computed for the created particle.
  18140. * @param worldMatrix is the world matrix of the particle system
  18141. * @param directionToUpdate is the direction vector to update with the result
  18142. * @param particle is the particle we are computed the direction for
  18143. */
  18144. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18145. /**
  18146. * Clones the current emitter and returns a copy of it
  18147. * @returns the new emitter
  18148. */
  18149. clone(): SphereDirectedParticleEmitter;
  18150. /**
  18151. * Called by the GPUParticleSystem to setup the update shader
  18152. * @param effect defines the update shader
  18153. */
  18154. applyToShader(effect: Effect): void;
  18155. /**
  18156. * Returns a string to use to update the GPU particles update shader
  18157. * @returns a string containng the defines string
  18158. */
  18159. getEffectDefines(): string;
  18160. /**
  18161. * Returns the string "SphereDirectedParticleEmitter"
  18162. * @returns a string containing the class name
  18163. */
  18164. getClassName(): string;
  18165. /**
  18166. * Serializes the particle system to a JSON object.
  18167. * @returns the JSON object
  18168. */
  18169. serialize(): any;
  18170. /**
  18171. * Parse properties from a JSON object
  18172. * @param serializationObject defines the JSON object
  18173. */
  18174. parse(serializationObject: any): void;
  18175. }
  18176. }
  18177. declare module BABYLON {
  18178. /**
  18179. * Interface representing a particle system in Babylon.js.
  18180. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18181. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18182. */
  18183. export interface IParticleSystem {
  18184. /**
  18185. * List of animations used by the particle system.
  18186. */
  18187. animations: Animation[];
  18188. /**
  18189. * The id of the Particle system.
  18190. */
  18191. id: string;
  18192. /**
  18193. * The name of the Particle system.
  18194. */
  18195. name: string;
  18196. /**
  18197. * The emitter represents the Mesh or position we are attaching the particle system to.
  18198. */
  18199. emitter: Nullable<AbstractMesh | Vector3>;
  18200. /**
  18201. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18202. */
  18203. isBillboardBased: boolean;
  18204. /**
  18205. * The rendering group used by the Particle system to chose when to render.
  18206. */
  18207. renderingGroupId: number;
  18208. /**
  18209. * The layer mask we are rendering the particles through.
  18210. */
  18211. layerMask: number;
  18212. /**
  18213. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18214. */
  18215. updateSpeed: number;
  18216. /**
  18217. * The amount of time the particle system is running (depends of the overall update speed).
  18218. */
  18219. targetStopDuration: number;
  18220. /**
  18221. * The texture used to render each particle. (this can be a spritesheet)
  18222. */
  18223. particleTexture: Nullable<Texture>;
  18224. /**
  18225. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18226. */
  18227. blendMode: number;
  18228. /**
  18229. * Minimum life time of emitting particles.
  18230. */
  18231. minLifeTime: number;
  18232. /**
  18233. * Maximum life time of emitting particles.
  18234. */
  18235. maxLifeTime: number;
  18236. /**
  18237. * Minimum Size of emitting particles.
  18238. */
  18239. minSize: number;
  18240. /**
  18241. * Maximum Size of emitting particles.
  18242. */
  18243. maxSize: number;
  18244. /**
  18245. * Minimum scale of emitting particles on X axis.
  18246. */
  18247. minScaleX: number;
  18248. /**
  18249. * Maximum scale of emitting particles on X axis.
  18250. */
  18251. maxScaleX: number;
  18252. /**
  18253. * Minimum scale of emitting particles on Y axis.
  18254. */
  18255. minScaleY: number;
  18256. /**
  18257. * Maximum scale of emitting particles on Y axis.
  18258. */
  18259. maxScaleY: number;
  18260. /**
  18261. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18262. */
  18263. color1: Color4;
  18264. /**
  18265. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18266. */
  18267. color2: Color4;
  18268. /**
  18269. * Color the particle will have at the end of its lifetime.
  18270. */
  18271. colorDead: Color4;
  18272. /**
  18273. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18274. */
  18275. emitRate: number;
  18276. /**
  18277. * You can use gravity if you want to give an orientation to your particles.
  18278. */
  18279. gravity: Vector3;
  18280. /**
  18281. * Minimum power of emitting particles.
  18282. */
  18283. minEmitPower: number;
  18284. /**
  18285. * Maximum power of emitting particles.
  18286. */
  18287. maxEmitPower: number;
  18288. /**
  18289. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18290. */
  18291. minAngularSpeed: number;
  18292. /**
  18293. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18294. */
  18295. maxAngularSpeed: number;
  18296. /**
  18297. * Gets or sets the minimal initial rotation in radians.
  18298. */
  18299. minInitialRotation: number;
  18300. /**
  18301. * Gets or sets the maximal initial rotation in radians.
  18302. */
  18303. maxInitialRotation: number;
  18304. /**
  18305. * The particle emitter type defines the emitter used by the particle system.
  18306. * It can be for example box, sphere, or cone...
  18307. */
  18308. particleEmitterType: Nullable<IParticleEmitterType>;
  18309. /**
  18310. * Defines the delay in milliseconds before starting the system (0 by default)
  18311. */
  18312. startDelay: number;
  18313. /**
  18314. * 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
  18315. */
  18316. preWarmCycles: number;
  18317. /**
  18318. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18319. */
  18320. preWarmStepOffset: number;
  18321. /**
  18322. * 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)
  18323. */
  18324. spriteCellChangeSpeed: number;
  18325. /**
  18326. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18327. */
  18328. startSpriteCellID: number;
  18329. /**
  18330. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18331. */
  18332. endSpriteCellID: number;
  18333. /**
  18334. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18335. */
  18336. spriteCellWidth: number;
  18337. /**
  18338. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18339. */
  18340. spriteCellHeight: number;
  18341. /**
  18342. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18343. */
  18344. spriteRandomStartCell: boolean;
  18345. /**
  18346. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18347. */
  18348. isAnimationSheetEnabled: boolean;
  18349. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18350. translationPivot: Vector2;
  18351. /**
  18352. * Gets or sets a texture used to add random noise to particle positions
  18353. */
  18354. noiseTexture: Nullable<BaseTexture>;
  18355. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18356. noiseStrength: Vector3;
  18357. /**
  18358. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18359. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18360. */
  18361. billboardMode: number;
  18362. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18363. limitVelocityDamping: number;
  18364. /**
  18365. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18366. */
  18367. beginAnimationOnStart: boolean;
  18368. /**
  18369. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18370. */
  18371. beginAnimationFrom: number;
  18372. /**
  18373. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18374. */
  18375. beginAnimationTo: number;
  18376. /**
  18377. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18378. */
  18379. beginAnimationLoop: boolean;
  18380. /**
  18381. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18382. */
  18383. disposeOnStop: boolean;
  18384. /**
  18385. * Gets the maximum number of particles active at the same time.
  18386. * @returns The max number of active particles.
  18387. */
  18388. getCapacity(): number;
  18389. /**
  18390. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18391. * @returns True if it has been started, otherwise false.
  18392. */
  18393. isStarted(): boolean;
  18394. /**
  18395. * Animates the particle system for this frame.
  18396. */
  18397. animate(): void;
  18398. /**
  18399. * Renders the particle system in its current state.
  18400. * @returns the current number of particles
  18401. */
  18402. render(): number;
  18403. /**
  18404. * Dispose the particle system and frees its associated resources.
  18405. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18406. */
  18407. dispose(disposeTexture?: boolean): void;
  18408. /**
  18409. * Clones the particle system.
  18410. * @param name The name of the cloned object
  18411. * @param newEmitter The new emitter to use
  18412. * @returns the cloned particle system
  18413. */
  18414. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18415. /**
  18416. * Serializes the particle system to a JSON object.
  18417. * @returns the JSON object
  18418. */
  18419. serialize(): any;
  18420. /**
  18421. * Rebuild the particle system
  18422. */
  18423. rebuild(): void;
  18424. /**
  18425. * Starts the particle system and begins to emit
  18426. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18427. */
  18428. start(delay?: number): void;
  18429. /**
  18430. * Stops the particle system.
  18431. */
  18432. stop(): void;
  18433. /**
  18434. * Remove all active particles
  18435. */
  18436. reset(): void;
  18437. /**
  18438. * Is this system ready to be used/rendered
  18439. * @return true if the system is ready
  18440. */
  18441. isReady(): boolean;
  18442. /**
  18443. * Adds a new color gradient
  18444. * @param gradient defines the gradient to use (between 0 and 1)
  18445. * @param color1 defines the color to affect to the specified gradient
  18446. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18447. * @returns the current particle system
  18448. */
  18449. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18450. /**
  18451. * Remove a specific color gradient
  18452. * @param gradient defines the gradient to remove
  18453. * @returns the current particle system
  18454. */
  18455. removeColorGradient(gradient: number): IParticleSystem;
  18456. /**
  18457. * Adds a new size gradient
  18458. * @param gradient defines the gradient to use (between 0 and 1)
  18459. * @param factor defines the size factor to affect to the specified gradient
  18460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18461. * @returns the current particle system
  18462. */
  18463. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18464. /**
  18465. * Remove a specific size gradient
  18466. * @param gradient defines the gradient to remove
  18467. * @returns the current particle system
  18468. */
  18469. removeSizeGradient(gradient: number): IParticleSystem;
  18470. /**
  18471. * Gets the current list of color gradients.
  18472. * You must use addColorGradient and removeColorGradient to udpate this list
  18473. * @returns the list of color gradients
  18474. */
  18475. getColorGradients(): Nullable<Array<ColorGradient>>;
  18476. /**
  18477. * Gets the current list of size gradients.
  18478. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18479. * @returns the list of size gradients
  18480. */
  18481. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18482. /**
  18483. * Gets the current list of angular speed gradients.
  18484. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18485. * @returns the list of angular speed gradients
  18486. */
  18487. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18488. /**
  18489. * Adds a new angular speed gradient
  18490. * @param gradient defines the gradient to use (between 0 and 1)
  18491. * @param factor defines the angular speed to affect to the specified gradient
  18492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18493. * @returns the current particle system
  18494. */
  18495. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18496. /**
  18497. * Remove a specific angular speed gradient
  18498. * @param gradient defines the gradient to remove
  18499. * @returns the current particle system
  18500. */
  18501. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18502. /**
  18503. * Gets the current list of velocity gradients.
  18504. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18505. * @returns the list of velocity gradients
  18506. */
  18507. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18508. /**
  18509. * Adds a new velocity gradient
  18510. * @param gradient defines the gradient to use (between 0 and 1)
  18511. * @param factor defines the velocity to affect to the specified gradient
  18512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18513. * @returns the current particle system
  18514. */
  18515. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18516. /**
  18517. * Remove a specific velocity gradient
  18518. * @param gradient defines the gradient to remove
  18519. * @returns the current particle system
  18520. */
  18521. removeVelocityGradient(gradient: number): IParticleSystem;
  18522. /**
  18523. * Gets the current list of limit velocity gradients.
  18524. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18525. * @returns the list of limit velocity gradients
  18526. */
  18527. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18528. /**
  18529. * Adds a new limit velocity gradient
  18530. * @param gradient defines the gradient to use (between 0 and 1)
  18531. * @param factor defines the limit velocity to affect to the specified gradient
  18532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18533. * @returns the current particle system
  18534. */
  18535. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18536. /**
  18537. * Remove a specific limit velocity gradient
  18538. * @param gradient defines the gradient to remove
  18539. * @returns the current particle system
  18540. */
  18541. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18542. /**
  18543. * Adds a new drag gradient
  18544. * @param gradient defines the gradient to use (between 0 and 1)
  18545. * @param factor defines the drag to affect to the specified gradient
  18546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18547. * @returns the current particle system
  18548. */
  18549. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18550. /**
  18551. * Remove a specific drag gradient
  18552. * @param gradient defines the gradient to remove
  18553. * @returns the current particle system
  18554. */
  18555. removeDragGradient(gradient: number): IParticleSystem;
  18556. /**
  18557. * Gets the current list of drag gradients.
  18558. * You must use addDragGradient and removeDragGradient to udpate this list
  18559. * @returns the list of drag gradients
  18560. */
  18561. getDragGradients(): Nullable<Array<FactorGradient>>;
  18562. /**
  18563. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18564. * @param gradient defines the gradient to use (between 0 and 1)
  18565. * @param factor defines the emit rate to affect to the specified gradient
  18566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18567. * @returns the current particle system
  18568. */
  18569. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18570. /**
  18571. * Remove a specific emit rate gradient
  18572. * @param gradient defines the gradient to remove
  18573. * @returns the current particle system
  18574. */
  18575. removeEmitRateGradient(gradient: number): IParticleSystem;
  18576. /**
  18577. * Gets the current list of emit rate gradients.
  18578. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18579. * @returns the list of emit rate gradients
  18580. */
  18581. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18582. /**
  18583. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18584. * @param gradient defines the gradient to use (between 0 and 1)
  18585. * @param factor defines the start size to affect to the specified gradient
  18586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18587. * @returns the current particle system
  18588. */
  18589. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18590. /**
  18591. * Remove a specific start size gradient
  18592. * @param gradient defines the gradient to remove
  18593. * @returns the current particle system
  18594. */
  18595. removeStartSizeGradient(gradient: number): IParticleSystem;
  18596. /**
  18597. * Gets the current list of start size gradients.
  18598. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18599. * @returns the list of start size gradients
  18600. */
  18601. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18602. /**
  18603. * Adds a new life time gradient
  18604. * @param gradient defines the gradient to use (between 0 and 1)
  18605. * @param factor defines the life time factor to affect to the specified gradient
  18606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18607. * @returns the current particle system
  18608. */
  18609. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18610. /**
  18611. * Remove a specific life time gradient
  18612. * @param gradient defines the gradient to remove
  18613. * @returns the current particle system
  18614. */
  18615. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18616. /**
  18617. * Gets the current list of life time gradients.
  18618. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18619. * @returns the list of life time gradients
  18620. */
  18621. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18622. /**
  18623. * Gets the current list of color gradients.
  18624. * You must use addColorGradient and removeColorGradient to udpate this list
  18625. * @returns the list of color gradients
  18626. */
  18627. getColorGradients(): Nullable<Array<ColorGradient>>;
  18628. /**
  18629. * Adds a new ramp gradient used to remap particle colors
  18630. * @param gradient defines the gradient to use (between 0 and 1)
  18631. * @param color defines the color to affect to the specified gradient
  18632. * @returns the current particle system
  18633. */
  18634. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18635. /**
  18636. * Gets the current list of ramp gradients.
  18637. * You must use addRampGradient and removeRampGradient to udpate this list
  18638. * @returns the list of ramp gradients
  18639. */
  18640. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18641. /** Gets or sets a boolean indicating that ramp gradients must be used
  18642. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18643. */
  18644. useRampGradients: boolean;
  18645. /**
  18646. * Adds a new color remap gradient
  18647. * @param gradient defines the gradient to use (between 0 and 1)
  18648. * @param min defines the color remap minimal range
  18649. * @param max defines the color remap maximal range
  18650. * @returns the current particle system
  18651. */
  18652. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18653. /**
  18654. * Gets the current list of color remap gradients.
  18655. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18656. * @returns the list of color remap gradients
  18657. */
  18658. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18659. /**
  18660. * Adds a new alpha remap gradient
  18661. * @param gradient defines the gradient to use (between 0 and 1)
  18662. * @param min defines the alpha remap minimal range
  18663. * @param max defines the alpha remap maximal range
  18664. * @returns the current particle system
  18665. */
  18666. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18667. /**
  18668. * Gets the current list of alpha remap gradients.
  18669. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18670. * @returns the list of alpha remap gradients
  18671. */
  18672. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18673. /**
  18674. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18677. * @returns the emitter
  18678. */
  18679. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18680. /**
  18681. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18682. * @param radius The radius of the hemisphere to emit from
  18683. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18684. * @returns the emitter
  18685. */
  18686. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18687. /**
  18688. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18689. * @param radius The radius of the sphere to emit from
  18690. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18691. * @returns the emitter
  18692. */
  18693. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18694. /**
  18695. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18696. * @param radius The radius of the sphere to emit from
  18697. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18698. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18699. * @returns the emitter
  18700. */
  18701. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18702. /**
  18703. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18704. * @param radius The radius of the emission cylinder
  18705. * @param height The height of the emission cylinder
  18706. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18707. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18708. * @returns the emitter
  18709. */
  18710. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18711. /**
  18712. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18713. * @param radius The radius of the cylinder to emit from
  18714. * @param height The height of the emission cylinder
  18715. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18718. * @returns the emitter
  18719. */
  18720. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18721. /**
  18722. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18723. * @param radius The radius of the cone to emit from
  18724. * @param angle The base angle of the cone
  18725. * @returns the emitter
  18726. */
  18727. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18728. /**
  18729. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18730. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18731. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18732. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18733. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18734. * @returns the emitter
  18735. */
  18736. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18737. /**
  18738. * Get hosting scene
  18739. * @returns the scene
  18740. */
  18741. getScene(): Scene;
  18742. }
  18743. }
  18744. declare module BABYLON {
  18745. /**
  18746. * Creates an instance based on a source mesh.
  18747. */
  18748. export class InstancedMesh extends AbstractMesh {
  18749. private _sourceMesh;
  18750. private _currentLOD;
  18751. /** @hidden */
  18752. _indexInSourceMeshInstanceArray: number;
  18753. constructor(name: string, source: Mesh);
  18754. /**
  18755. * Returns the string "InstancedMesh".
  18756. */
  18757. getClassName(): string;
  18758. /** Gets the list of lights affecting that mesh */
  18759. readonly lightSources: Light[];
  18760. _resyncLightSources(): void;
  18761. _resyncLighSource(light: Light): void;
  18762. _removeLightSource(light: Light, dispose: boolean): void;
  18763. /**
  18764. * If the source mesh receives shadows
  18765. */
  18766. readonly receiveShadows: boolean;
  18767. /**
  18768. * The material of the source mesh
  18769. */
  18770. readonly material: Nullable<Material>;
  18771. /**
  18772. * Visibility of the source mesh
  18773. */
  18774. readonly visibility: number;
  18775. /**
  18776. * Skeleton of the source mesh
  18777. */
  18778. readonly skeleton: Nullable<Skeleton>;
  18779. /**
  18780. * Rendering ground id of the source mesh
  18781. */
  18782. renderingGroupId: number;
  18783. /**
  18784. * Returns the total number of vertices (integer).
  18785. */
  18786. getTotalVertices(): number;
  18787. /**
  18788. * Returns a positive integer : the total number of indices in this mesh geometry.
  18789. * @returns the numner of indices or zero if the mesh has no geometry.
  18790. */
  18791. getTotalIndices(): number;
  18792. /**
  18793. * The source mesh of the instance
  18794. */
  18795. readonly sourceMesh: Mesh;
  18796. /**
  18797. * Is this node ready to be used/rendered
  18798. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18799. * @return {boolean} is it ready
  18800. */
  18801. isReady(completeCheck?: boolean): boolean;
  18802. /**
  18803. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18804. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18805. * @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.
  18806. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18807. */
  18808. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18809. /**
  18810. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18811. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18812. * The `data` are either a numeric array either a Float32Array.
  18813. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18814. * 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).
  18815. * Note that a new underlying VertexBuffer object is created each call.
  18816. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18817. *
  18818. * Possible `kind` values :
  18819. * - VertexBuffer.PositionKind
  18820. * - VertexBuffer.UVKind
  18821. * - VertexBuffer.UV2Kind
  18822. * - VertexBuffer.UV3Kind
  18823. * - VertexBuffer.UV4Kind
  18824. * - VertexBuffer.UV5Kind
  18825. * - VertexBuffer.UV6Kind
  18826. * - VertexBuffer.ColorKind
  18827. * - VertexBuffer.MatricesIndicesKind
  18828. * - VertexBuffer.MatricesIndicesExtraKind
  18829. * - VertexBuffer.MatricesWeightsKind
  18830. * - VertexBuffer.MatricesWeightsExtraKind
  18831. *
  18832. * Returns the Mesh.
  18833. */
  18834. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18835. /**
  18836. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18837. * If the mesh has no geometry, it is simply returned as it is.
  18838. * The `data` are either a numeric array either a Float32Array.
  18839. * No new underlying VertexBuffer object is created.
  18840. * 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.
  18841. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18842. *
  18843. * Possible `kind` values :
  18844. * - VertexBuffer.PositionKind
  18845. * - VertexBuffer.UVKind
  18846. * - VertexBuffer.UV2Kind
  18847. * - VertexBuffer.UV3Kind
  18848. * - VertexBuffer.UV4Kind
  18849. * - VertexBuffer.UV5Kind
  18850. * - VertexBuffer.UV6Kind
  18851. * - VertexBuffer.ColorKind
  18852. * - VertexBuffer.MatricesIndicesKind
  18853. * - VertexBuffer.MatricesIndicesExtraKind
  18854. * - VertexBuffer.MatricesWeightsKind
  18855. * - VertexBuffer.MatricesWeightsExtraKind
  18856. *
  18857. * Returns the Mesh.
  18858. */
  18859. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18860. /**
  18861. * Sets the mesh indices.
  18862. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18863. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18864. * This method creates a new index buffer each call.
  18865. * Returns the Mesh.
  18866. */
  18867. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18868. /**
  18869. * Boolean : True if the mesh owns the requested kind of data.
  18870. */
  18871. isVerticesDataPresent(kind: string): boolean;
  18872. /**
  18873. * Returns an array of indices (IndicesArray).
  18874. */
  18875. getIndices(): Nullable<IndicesArray>;
  18876. readonly _positions: Nullable<Vector3[]>;
  18877. /**
  18878. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18879. * This means the mesh underlying bounding box and sphere are recomputed.
  18880. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18881. * @returns the current mesh
  18882. */
  18883. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18884. /** @hidden */
  18885. _preActivate(): InstancedMesh;
  18886. /** @hidden */
  18887. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18888. /** @hidden */
  18889. _postActivate(): void;
  18890. getWorldMatrix(): Matrix;
  18891. readonly isAnInstance: boolean;
  18892. /**
  18893. * Returns the current associated LOD AbstractMesh.
  18894. */
  18895. getLOD(camera: Camera): AbstractMesh;
  18896. /** @hidden */
  18897. _syncSubMeshes(): InstancedMesh;
  18898. /** @hidden */
  18899. _generatePointsArray(): boolean;
  18900. /**
  18901. * Creates a new InstancedMesh from the current mesh.
  18902. * - name (string) : the cloned mesh name
  18903. * - newParent (optional Node) : the optional Node to parent the clone to.
  18904. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18905. *
  18906. * Returns the clone.
  18907. */
  18908. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18909. /**
  18910. * Disposes the InstancedMesh.
  18911. * Returns nothing.
  18912. */
  18913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18914. }
  18915. }
  18916. declare module BABYLON {
  18917. /**
  18918. * Defines the options associated with the creation of a shader material.
  18919. */
  18920. export interface IShaderMaterialOptions {
  18921. /**
  18922. * Does the material work in alpha blend mode
  18923. */
  18924. needAlphaBlending: boolean;
  18925. /**
  18926. * Does the material work in alpha test mode
  18927. */
  18928. needAlphaTesting: boolean;
  18929. /**
  18930. * The list of attribute names used in the shader
  18931. */
  18932. attributes: string[];
  18933. /**
  18934. * The list of unifrom names used in the shader
  18935. */
  18936. uniforms: string[];
  18937. /**
  18938. * The list of UBO names used in the shader
  18939. */
  18940. uniformBuffers: string[];
  18941. /**
  18942. * The list of sampler names used in the shader
  18943. */
  18944. samplers: string[];
  18945. /**
  18946. * The list of defines used in the shader
  18947. */
  18948. defines: string[];
  18949. }
  18950. /**
  18951. * 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.
  18952. *
  18953. * This returned material effects how the mesh will look based on the code in the shaders.
  18954. *
  18955. * @see http://doc.babylonjs.com/how_to/shader_material
  18956. */
  18957. export class ShaderMaterial extends Material {
  18958. private _shaderPath;
  18959. private _options;
  18960. private _textures;
  18961. private _textureArrays;
  18962. private _floats;
  18963. private _ints;
  18964. private _floatsArrays;
  18965. private _colors3;
  18966. private _colors3Arrays;
  18967. private _colors4;
  18968. private _colors4Arrays;
  18969. private _vectors2;
  18970. private _vectors3;
  18971. private _vectors4;
  18972. private _matrices;
  18973. private _matrices3x3;
  18974. private _matrices2x2;
  18975. private _vectors2Arrays;
  18976. private _vectors3Arrays;
  18977. private _vectors4Arrays;
  18978. private _cachedWorldViewMatrix;
  18979. private _cachedWorldViewProjectionMatrix;
  18980. private _renderId;
  18981. /**
  18982. * Instantiate a new shader material.
  18983. * 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.
  18984. * This returned material effects how the mesh will look based on the code in the shaders.
  18985. * @see http://doc.babylonjs.com/how_to/shader_material
  18986. * @param name Define the name of the material in the scene
  18987. * @param scene Define the scene the material belongs to
  18988. * @param shaderPath Defines the route to the shader code in one of three ways:
  18989. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18990. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18991. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18992. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18993. * @param options Define the options used to create the shader
  18994. */
  18995. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18996. /**
  18997. * Gets the options used to compile the shader.
  18998. * They can be modified to trigger a new compilation
  18999. */
  19000. readonly options: IShaderMaterialOptions;
  19001. /**
  19002. * Gets the current class name of the material e.g. "ShaderMaterial"
  19003. * Mainly use in serialization.
  19004. * @returns the class name
  19005. */
  19006. getClassName(): string;
  19007. /**
  19008. * Specifies if the material will require alpha blending
  19009. * @returns a boolean specifying if alpha blending is needed
  19010. */
  19011. needAlphaBlending(): boolean;
  19012. /**
  19013. * Specifies if this material should be rendered in alpha test mode
  19014. * @returns a boolean specifying if an alpha test is needed.
  19015. */
  19016. needAlphaTesting(): boolean;
  19017. private _checkUniform;
  19018. /**
  19019. * Set a texture in the shader.
  19020. * @param name Define the name of the uniform samplers as defined in the shader
  19021. * @param texture Define the texture to bind to this sampler
  19022. * @return the material itself allowing "fluent" like uniform updates
  19023. */
  19024. setTexture(name: string, texture: Texture): ShaderMaterial;
  19025. /**
  19026. * Set a texture array in the shader.
  19027. * @param name Define the name of the uniform sampler array as defined in the shader
  19028. * @param textures Define the list of textures to bind to this sampler
  19029. * @return the material itself allowing "fluent" like uniform updates
  19030. */
  19031. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19032. /**
  19033. * Set a float in the shader.
  19034. * @param name Define the name of the uniform as defined in the shader
  19035. * @param value Define the value to give to the uniform
  19036. * @return the material itself allowing "fluent" like uniform updates
  19037. */
  19038. setFloat(name: string, value: number): ShaderMaterial;
  19039. /**
  19040. * Set a int in the shader.
  19041. * @param name Define the name of the uniform as defined in the shader
  19042. * @param value Define the value to give to the uniform
  19043. * @return the material itself allowing "fluent" like uniform updates
  19044. */
  19045. setInt(name: string, value: number): ShaderMaterial;
  19046. /**
  19047. * Set an array of floats in the shader.
  19048. * @param name Define the name of the uniform as defined in the shader
  19049. * @param value Define the value to give to the uniform
  19050. * @return the material itself allowing "fluent" like uniform updates
  19051. */
  19052. setFloats(name: string, value: number[]): ShaderMaterial;
  19053. /**
  19054. * Set a vec3 in the shader from a Color3.
  19055. * @param name Define the name of the uniform as defined in the shader
  19056. * @param value Define the value to give to the uniform
  19057. * @return the material itself allowing "fluent" like uniform updates
  19058. */
  19059. setColor3(name: string, value: Color3): ShaderMaterial;
  19060. /**
  19061. * Set a vec3 array in the shader from a Color3 array.
  19062. * @param name Define the name of the uniform as defined in the shader
  19063. * @param value Define the value to give to the uniform
  19064. * @return the material itself allowing "fluent" like uniform updates
  19065. */
  19066. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19067. /**
  19068. * Set a vec4 in the shader from a Color4.
  19069. * @param name Define the name of the uniform as defined in the shader
  19070. * @param value Define the value to give to the uniform
  19071. * @return the material itself allowing "fluent" like uniform updates
  19072. */
  19073. setColor4(name: string, value: Color4): ShaderMaterial;
  19074. /**
  19075. * Set a vec4 array in the shader from a Color4 array.
  19076. * @param name Define the name of the uniform as defined in the shader
  19077. * @param value Define the value to give to the uniform
  19078. * @return the material itself allowing "fluent" like uniform updates
  19079. */
  19080. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19081. /**
  19082. * Set a vec2 in the shader from a Vector2.
  19083. * @param name Define the name of the uniform as defined in the shader
  19084. * @param value Define the value to give to the uniform
  19085. * @return the material itself allowing "fluent" like uniform updates
  19086. */
  19087. setVector2(name: string, value: Vector2): ShaderMaterial;
  19088. /**
  19089. * Set a vec3 in the shader from a Vector3.
  19090. * @param name Define the name of the uniform as defined in the shader
  19091. * @param value Define the value to give to the uniform
  19092. * @return the material itself allowing "fluent" like uniform updates
  19093. */
  19094. setVector3(name: string, value: Vector3): ShaderMaterial;
  19095. /**
  19096. * Set a vec4 in the shader from a Vector4.
  19097. * @param name Define the name of the uniform as defined in the shader
  19098. * @param value Define the value to give to the uniform
  19099. * @return the material itself allowing "fluent" like uniform updates
  19100. */
  19101. setVector4(name: string, value: Vector4): ShaderMaterial;
  19102. /**
  19103. * Set a mat4 in the shader from a Matrix.
  19104. * @param name Define the name of the uniform as defined in the shader
  19105. * @param value Define the value to give to the uniform
  19106. * @return the material itself allowing "fluent" like uniform updates
  19107. */
  19108. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19109. /**
  19110. * Set a mat3 in the shader from a Float32Array.
  19111. * @param name Define the name of the uniform as defined in the shader
  19112. * @param value Define the value to give to the uniform
  19113. * @return the material itself allowing "fluent" like uniform updates
  19114. */
  19115. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19116. /**
  19117. * Set a mat2 in the shader from a Float32Array.
  19118. * @param name Define the name of the uniform as defined in the shader
  19119. * @param value Define the value to give to the uniform
  19120. * @return the material itself allowing "fluent" like uniform updates
  19121. */
  19122. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19123. /**
  19124. * Set a vec2 array in the shader from a number array.
  19125. * @param name Define the name of the uniform as defined in the shader
  19126. * @param value Define the value to give to the uniform
  19127. * @return the material itself allowing "fluent" like uniform updates
  19128. */
  19129. setArray2(name: string, value: number[]): ShaderMaterial;
  19130. /**
  19131. * Set a vec3 array in the shader from a number array.
  19132. * @param name Define the name of the uniform as defined in the shader
  19133. * @param value Define the value to give to the uniform
  19134. * @return the material itself allowing "fluent" like uniform updates
  19135. */
  19136. setArray3(name: string, value: number[]): ShaderMaterial;
  19137. /**
  19138. * Set a vec4 array in the shader from a number array.
  19139. * @param name Define the name of the uniform as defined in the shader
  19140. * @param value Define the value to give to the uniform
  19141. * @return the material itself allowing "fluent" like uniform updates
  19142. */
  19143. setArray4(name: string, value: number[]): ShaderMaterial;
  19144. private _checkCache;
  19145. /**
  19146. * Specifies that the submesh is ready to be used
  19147. * @param mesh defines the mesh to check
  19148. * @param subMesh defines which submesh to check
  19149. * @param useInstances specifies that instances should be used
  19150. * @returns a boolean indicating that the submesh is ready or not
  19151. */
  19152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19153. /**
  19154. * Checks if the material is ready to render the requested mesh
  19155. * @param mesh Define the mesh to render
  19156. * @param useInstances Define whether or not the material is used with instances
  19157. * @returns true if ready, otherwise false
  19158. */
  19159. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19160. /**
  19161. * Binds the world matrix to the material
  19162. * @param world defines the world transformation matrix
  19163. */
  19164. bindOnlyWorldMatrix(world: Matrix): void;
  19165. /**
  19166. * Binds the material to the mesh
  19167. * @param world defines the world transformation matrix
  19168. * @param mesh defines the mesh to bind the material to
  19169. */
  19170. bind(world: Matrix, mesh?: Mesh): void;
  19171. /**
  19172. * Gets the active textures from the material
  19173. * @returns an array of textures
  19174. */
  19175. getActiveTextures(): BaseTexture[];
  19176. /**
  19177. * Specifies if the material uses a texture
  19178. * @param texture defines the texture to check against the material
  19179. * @returns a boolean specifying if the material uses the texture
  19180. */
  19181. hasTexture(texture: BaseTexture): boolean;
  19182. /**
  19183. * Makes a duplicate of the material, and gives it a new name
  19184. * @param name defines the new name for the duplicated material
  19185. * @returns the cloned material
  19186. */
  19187. clone(name: string): ShaderMaterial;
  19188. /**
  19189. * Disposes the material
  19190. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19191. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19192. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19193. */
  19194. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19195. /**
  19196. * Serializes this material in a JSON representation
  19197. * @returns the serialized material object
  19198. */
  19199. serialize(): any;
  19200. /**
  19201. * Creates a shader material from parsed shader material data
  19202. * @param source defines the JSON represnetation of the material
  19203. * @param scene defines the hosting scene
  19204. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19205. * @returns a new material
  19206. */
  19207. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19208. }
  19209. }
  19210. declare module BABYLON {
  19211. /** @hidden */
  19212. export var colorPixelShader: {
  19213. name: string;
  19214. shader: string;
  19215. };
  19216. }
  19217. declare module BABYLON {
  19218. /** @hidden */
  19219. export var colorVertexShader: {
  19220. name: string;
  19221. shader: string;
  19222. };
  19223. }
  19224. declare module BABYLON {
  19225. /**
  19226. * Line mesh
  19227. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19228. */
  19229. export class LinesMesh extends Mesh {
  19230. /**
  19231. * If vertex color should be applied to the mesh
  19232. */
  19233. readonly useVertexColor?: boolean | undefined;
  19234. /**
  19235. * If vertex alpha should be applied to the mesh
  19236. */
  19237. readonly useVertexAlpha?: boolean | undefined;
  19238. /**
  19239. * Color of the line (Default: White)
  19240. */
  19241. color: Color3;
  19242. /**
  19243. * Alpha of the line (Default: 1)
  19244. */
  19245. alpha: number;
  19246. /**
  19247. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19248. * This margin is expressed in world space coordinates, so its value may vary.
  19249. * Default value is 0.1
  19250. */
  19251. intersectionThreshold: number;
  19252. private _colorShader;
  19253. private color4;
  19254. /**
  19255. * Creates a new LinesMesh
  19256. * @param name defines the name
  19257. * @param scene defines the hosting scene
  19258. * @param parent defines the parent mesh if any
  19259. * @param source defines the optional source LinesMesh used to clone data from
  19260. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19261. * When false, achieved by calling a clone(), also passing False.
  19262. * This will make creation of children, recursive.
  19263. * @param useVertexColor defines if this LinesMesh supports vertex color
  19264. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19265. */
  19266. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19267. /**
  19268. * If vertex color should be applied to the mesh
  19269. */
  19270. useVertexColor?: boolean | undefined,
  19271. /**
  19272. * If vertex alpha should be applied to the mesh
  19273. */
  19274. useVertexAlpha?: boolean | undefined);
  19275. private _addClipPlaneDefine;
  19276. private _removeClipPlaneDefine;
  19277. isReady(): boolean;
  19278. /**
  19279. * Returns the string "LineMesh"
  19280. */
  19281. getClassName(): string;
  19282. /**
  19283. * @hidden
  19284. */
  19285. /**
  19286. * @hidden
  19287. */
  19288. material: Material;
  19289. /**
  19290. * @hidden
  19291. */
  19292. readonly checkCollisions: boolean;
  19293. /** @hidden */
  19294. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19295. /** @hidden */
  19296. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19297. /**
  19298. * Disposes of the line mesh
  19299. * @param doNotRecurse If children should be disposed
  19300. */
  19301. dispose(doNotRecurse?: boolean): void;
  19302. /**
  19303. * Returns a new LineMesh object cloned from the current one.
  19304. */
  19305. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19306. /**
  19307. * Creates a new InstancedLinesMesh object from the mesh model.
  19308. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19309. * @param name defines the name of the new instance
  19310. * @returns a new InstancedLinesMesh
  19311. */
  19312. createInstance(name: string): InstancedLinesMesh;
  19313. }
  19314. /**
  19315. * Creates an instance based on a source LinesMesh
  19316. */
  19317. export class InstancedLinesMesh extends InstancedMesh {
  19318. /**
  19319. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19320. * This margin is expressed in world space coordinates, so its value may vary.
  19321. * Initilized with the intersectionThreshold value of the source LinesMesh
  19322. */
  19323. intersectionThreshold: number;
  19324. constructor(name: string, source: LinesMesh);
  19325. /**
  19326. * Returns the string "InstancedLinesMesh".
  19327. */
  19328. getClassName(): string;
  19329. }
  19330. }
  19331. declare module BABYLON {
  19332. /** @hidden */
  19333. export var linePixelShader: {
  19334. name: string;
  19335. shader: string;
  19336. };
  19337. }
  19338. declare module BABYLON {
  19339. /** @hidden */
  19340. export var lineVertexShader: {
  19341. name: string;
  19342. shader: string;
  19343. };
  19344. }
  19345. declare module BABYLON {
  19346. interface AbstractMesh {
  19347. /**
  19348. * Gets the edgesRenderer associated with the mesh
  19349. */
  19350. edgesRenderer: Nullable<EdgesRenderer>;
  19351. }
  19352. interface LinesMesh {
  19353. /**
  19354. * Enables the edge rendering mode on the mesh.
  19355. * This mode makes the mesh edges visible
  19356. * @param epsilon defines the maximal distance between two angles to detect a face
  19357. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19358. * @returns the currentAbstractMesh
  19359. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19360. */
  19361. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19362. }
  19363. interface InstancedLinesMesh {
  19364. /**
  19365. * Enables the edge rendering mode on the mesh.
  19366. * This mode makes the mesh edges visible
  19367. * @param epsilon defines the maximal distance between two angles to detect a face
  19368. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19369. * @returns the current InstancedLinesMesh
  19370. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19371. */
  19372. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19373. }
  19374. /**
  19375. * Defines the minimum contract an Edges renderer should follow.
  19376. */
  19377. export interface IEdgesRenderer extends IDisposable {
  19378. /**
  19379. * Gets or sets a boolean indicating if the edgesRenderer is active
  19380. */
  19381. isEnabled: boolean;
  19382. /**
  19383. * Renders the edges of the attached mesh,
  19384. */
  19385. render(): void;
  19386. /**
  19387. * Checks wether or not the edges renderer is ready to render.
  19388. * @return true if ready, otherwise false.
  19389. */
  19390. isReady(): boolean;
  19391. }
  19392. /**
  19393. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19394. */
  19395. export class EdgesRenderer implements IEdgesRenderer {
  19396. /**
  19397. * Define the size of the edges with an orthographic camera
  19398. */
  19399. edgesWidthScalerForOrthographic: number;
  19400. /**
  19401. * Define the size of the edges with a perspective camera
  19402. */
  19403. edgesWidthScalerForPerspective: number;
  19404. protected _source: AbstractMesh;
  19405. protected _linesPositions: number[];
  19406. protected _linesNormals: number[];
  19407. protected _linesIndices: number[];
  19408. protected _epsilon: number;
  19409. protected _indicesCount: number;
  19410. protected _lineShader: ShaderMaterial;
  19411. protected _ib: DataBuffer;
  19412. protected _buffers: {
  19413. [key: string]: Nullable<VertexBuffer>;
  19414. };
  19415. protected _checkVerticesInsteadOfIndices: boolean;
  19416. private _meshRebuildObserver;
  19417. private _meshDisposeObserver;
  19418. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19419. isEnabled: boolean;
  19420. /**
  19421. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19422. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19423. * @param source Mesh used to create edges
  19424. * @param epsilon sum of angles in adjacency to check for edge
  19425. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19426. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19427. */
  19428. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19429. protected _prepareRessources(): void;
  19430. /** @hidden */
  19431. _rebuild(): void;
  19432. /**
  19433. * Releases the required resources for the edges renderer
  19434. */
  19435. dispose(): void;
  19436. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19437. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19438. /**
  19439. * Checks if the pair of p0 and p1 is en edge
  19440. * @param faceIndex
  19441. * @param edge
  19442. * @param faceNormals
  19443. * @param p0
  19444. * @param p1
  19445. * @private
  19446. */
  19447. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19448. /**
  19449. * push line into the position, normal and index buffer
  19450. * @protected
  19451. */
  19452. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19453. /**
  19454. * Generates lines edges from adjacencjes
  19455. * @private
  19456. */
  19457. _generateEdgesLines(): void;
  19458. /**
  19459. * Checks wether or not the edges renderer is ready to render.
  19460. * @return true if ready, otherwise false.
  19461. */
  19462. isReady(): boolean;
  19463. /**
  19464. * Renders the edges of the attached mesh,
  19465. */
  19466. render(): void;
  19467. }
  19468. /**
  19469. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19470. */
  19471. export class LineEdgesRenderer extends EdgesRenderer {
  19472. /**
  19473. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19474. * @param source LineMesh used to generate edges
  19475. * @param epsilon not important (specified angle for edge detection)
  19476. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19477. */
  19478. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19479. /**
  19480. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19481. */
  19482. _generateEdgesLines(): void;
  19483. }
  19484. }
  19485. declare module BABYLON {
  19486. /**
  19487. * This represents the object necessary to create a rendering group.
  19488. * This is exclusively used and created by the rendering manager.
  19489. * To modify the behavior, you use the available helpers in your scene or meshes.
  19490. * @hidden
  19491. */
  19492. export class RenderingGroup {
  19493. index: number;
  19494. private static _zeroVector;
  19495. private _scene;
  19496. private _opaqueSubMeshes;
  19497. private _transparentSubMeshes;
  19498. private _alphaTestSubMeshes;
  19499. private _depthOnlySubMeshes;
  19500. private _particleSystems;
  19501. private _spriteManagers;
  19502. private _opaqueSortCompareFn;
  19503. private _alphaTestSortCompareFn;
  19504. private _transparentSortCompareFn;
  19505. private _renderOpaque;
  19506. private _renderAlphaTest;
  19507. private _renderTransparent;
  19508. /** @hidden */
  19509. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19510. onBeforeTransparentRendering: () => void;
  19511. /**
  19512. * Set the opaque sort comparison function.
  19513. * If null the sub meshes will be render in the order they were created
  19514. */
  19515. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19516. /**
  19517. * Set the alpha test sort comparison function.
  19518. * If null the sub meshes will be render in the order they were created
  19519. */
  19520. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19521. /**
  19522. * Set the transparent sort comparison function.
  19523. * If null the sub meshes will be render in the order they were created
  19524. */
  19525. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19526. /**
  19527. * Creates a new rendering group.
  19528. * @param index The rendering group index
  19529. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19530. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19531. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19532. */
  19533. 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>);
  19534. /**
  19535. * Render all the sub meshes contained in the group.
  19536. * @param customRenderFunction Used to override the default render behaviour of the group.
  19537. * @returns true if rendered some submeshes.
  19538. */
  19539. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19540. /**
  19541. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19542. * @param subMeshes The submeshes to render
  19543. */
  19544. private renderOpaqueSorted;
  19545. /**
  19546. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19547. * @param subMeshes The submeshes to render
  19548. */
  19549. private renderAlphaTestSorted;
  19550. /**
  19551. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19552. * @param subMeshes The submeshes to render
  19553. */
  19554. private renderTransparentSorted;
  19555. /**
  19556. * Renders the submeshes in a specified order.
  19557. * @param subMeshes The submeshes to sort before render
  19558. * @param sortCompareFn The comparison function use to sort
  19559. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19560. * @param transparent Specifies to activate blending if true
  19561. */
  19562. private static renderSorted;
  19563. /**
  19564. * Renders the submeshes in the order they were dispatched (no sort applied).
  19565. * @param subMeshes The submeshes to render
  19566. */
  19567. private static renderUnsorted;
  19568. /**
  19569. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19570. * are rendered back to front if in the same alpha index.
  19571. *
  19572. * @param a The first submesh
  19573. * @param b The second submesh
  19574. * @returns The result of the comparison
  19575. */
  19576. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19577. /**
  19578. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19579. * are rendered back to front.
  19580. *
  19581. * @param a The first submesh
  19582. * @param b The second submesh
  19583. * @returns The result of the comparison
  19584. */
  19585. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19586. /**
  19587. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19588. * are rendered front to back (prevent overdraw).
  19589. *
  19590. * @param a The first submesh
  19591. * @param b The second submesh
  19592. * @returns The result of the comparison
  19593. */
  19594. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19595. /**
  19596. * Resets the different lists of submeshes to prepare a new frame.
  19597. */
  19598. prepare(): void;
  19599. dispose(): void;
  19600. /**
  19601. * Inserts the submesh in its correct queue depending on its material.
  19602. * @param subMesh The submesh to dispatch
  19603. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19604. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19605. */
  19606. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19607. dispatchSprites(spriteManager: ISpriteManager): void;
  19608. dispatchParticles(particleSystem: IParticleSystem): void;
  19609. private _renderParticles;
  19610. private _renderSprites;
  19611. }
  19612. }
  19613. declare module BABYLON {
  19614. /**
  19615. * Interface describing the different options available in the rendering manager
  19616. * regarding Auto Clear between groups.
  19617. */
  19618. export interface IRenderingManagerAutoClearSetup {
  19619. /**
  19620. * Defines whether or not autoclear is enable.
  19621. */
  19622. autoClear: boolean;
  19623. /**
  19624. * Defines whether or not to autoclear the depth buffer.
  19625. */
  19626. depth: boolean;
  19627. /**
  19628. * Defines whether or not to autoclear the stencil buffer.
  19629. */
  19630. stencil: boolean;
  19631. }
  19632. /**
  19633. * This class is used by the onRenderingGroupObservable
  19634. */
  19635. export class RenderingGroupInfo {
  19636. /**
  19637. * The Scene that being rendered
  19638. */
  19639. scene: Scene;
  19640. /**
  19641. * The camera currently used for the rendering pass
  19642. */
  19643. camera: Nullable<Camera>;
  19644. /**
  19645. * The ID of the renderingGroup being processed
  19646. */
  19647. renderingGroupId: number;
  19648. }
  19649. /**
  19650. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19651. * It is enable to manage the different groups as well as the different necessary sort functions.
  19652. * This should not be used directly aside of the few static configurations
  19653. */
  19654. export class RenderingManager {
  19655. /**
  19656. * The max id used for rendering groups (not included)
  19657. */
  19658. static MAX_RENDERINGGROUPS: number;
  19659. /**
  19660. * The min id used for rendering groups (included)
  19661. */
  19662. static MIN_RENDERINGGROUPS: number;
  19663. /**
  19664. * Used to globally prevent autoclearing scenes.
  19665. */
  19666. static AUTOCLEAR: boolean;
  19667. /**
  19668. * @hidden
  19669. */
  19670. _useSceneAutoClearSetup: boolean;
  19671. private _scene;
  19672. private _renderingGroups;
  19673. private _depthStencilBufferAlreadyCleaned;
  19674. private _autoClearDepthStencil;
  19675. private _customOpaqueSortCompareFn;
  19676. private _customAlphaTestSortCompareFn;
  19677. private _customTransparentSortCompareFn;
  19678. private _renderingGroupInfo;
  19679. /**
  19680. * Instantiates a new rendering group for a particular scene
  19681. * @param scene Defines the scene the groups belongs to
  19682. */
  19683. constructor(scene: Scene);
  19684. private _clearDepthStencilBuffer;
  19685. /**
  19686. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19687. * @hidden
  19688. */
  19689. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19690. /**
  19691. * Resets the different information of the group to prepare a new frame
  19692. * @hidden
  19693. */
  19694. reset(): void;
  19695. /**
  19696. * Dispose and release the group and its associated resources.
  19697. * @hidden
  19698. */
  19699. dispose(): void;
  19700. /**
  19701. * Clear the info related to rendering groups preventing retention points during dispose.
  19702. */
  19703. freeRenderingGroups(): void;
  19704. private _prepareRenderingGroup;
  19705. /**
  19706. * Add a sprite manager to the rendering manager in order to render it this frame.
  19707. * @param spriteManager Define the sprite manager to render
  19708. */
  19709. dispatchSprites(spriteManager: ISpriteManager): void;
  19710. /**
  19711. * Add a particle system to the rendering manager in order to render it this frame.
  19712. * @param particleSystem Define the particle system to render
  19713. */
  19714. dispatchParticles(particleSystem: IParticleSystem): void;
  19715. /**
  19716. * Add a submesh to the manager in order to render it this frame
  19717. * @param subMesh The submesh to dispatch
  19718. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19719. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19720. */
  19721. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19722. /**
  19723. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19724. * This allowed control for front to back rendering or reversly depending of the special needs.
  19725. *
  19726. * @param renderingGroupId The rendering group id corresponding to its index
  19727. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19728. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19729. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19730. */
  19731. 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;
  19732. /**
  19733. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19734. *
  19735. * @param renderingGroupId The rendering group id corresponding to its index
  19736. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19737. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19738. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19739. */
  19740. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19741. /**
  19742. * Gets the current auto clear configuration for one rendering group of the rendering
  19743. * manager.
  19744. * @param index the rendering group index to get the information for
  19745. * @returns The auto clear setup for the requested rendering group
  19746. */
  19747. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19748. }
  19749. }
  19750. declare module BABYLON {
  19751. /**
  19752. * This Helps creating a texture that will be created from a camera in your scene.
  19753. * It is basically a dynamic texture that could be used to create special effects for instance.
  19754. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19755. */
  19756. export class RenderTargetTexture extends Texture {
  19757. isCube: boolean;
  19758. /**
  19759. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19760. */
  19761. static readonly REFRESHRATE_RENDER_ONCE: number;
  19762. /**
  19763. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19764. */
  19765. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19766. /**
  19767. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19768. * the central point of your effect and can save a lot of performances.
  19769. */
  19770. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19771. /**
  19772. * Use this predicate to dynamically define the list of mesh you want to render.
  19773. * If set, the renderList property will be overwritten.
  19774. */
  19775. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19776. private _renderList;
  19777. /**
  19778. * Use this list to define the list of mesh you want to render.
  19779. */
  19780. renderList: Nullable<Array<AbstractMesh>>;
  19781. private _hookArray;
  19782. /**
  19783. * Define if particles should be rendered in your texture.
  19784. */
  19785. renderParticles: boolean;
  19786. /**
  19787. * Define if sprites should be rendered in your texture.
  19788. */
  19789. renderSprites: boolean;
  19790. /**
  19791. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19792. */
  19793. coordinatesMode: number;
  19794. /**
  19795. * Define the camera used to render the texture.
  19796. */
  19797. activeCamera: Nullable<Camera>;
  19798. /**
  19799. * Override the render function of the texture with your own one.
  19800. */
  19801. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19802. /**
  19803. * Define if camera post processes should be use while rendering the texture.
  19804. */
  19805. useCameraPostProcesses: boolean;
  19806. /**
  19807. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19808. */
  19809. ignoreCameraViewport: boolean;
  19810. private _postProcessManager;
  19811. private _postProcesses;
  19812. private _resizeObserver;
  19813. /**
  19814. * An event triggered when the texture is unbind.
  19815. */
  19816. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19817. /**
  19818. * An event triggered when the texture is unbind.
  19819. */
  19820. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19821. private _onAfterUnbindObserver;
  19822. /**
  19823. * Set a after unbind callback in the texture.
  19824. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19825. */
  19826. onAfterUnbind: () => void;
  19827. /**
  19828. * An event triggered before rendering the texture
  19829. */
  19830. onBeforeRenderObservable: Observable<number>;
  19831. private _onBeforeRenderObserver;
  19832. /**
  19833. * Set a before render callback in the texture.
  19834. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19835. */
  19836. onBeforeRender: (faceIndex: number) => void;
  19837. /**
  19838. * An event triggered after rendering the texture
  19839. */
  19840. onAfterRenderObservable: Observable<number>;
  19841. private _onAfterRenderObserver;
  19842. /**
  19843. * Set a after render callback in the texture.
  19844. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19845. */
  19846. onAfterRender: (faceIndex: number) => void;
  19847. /**
  19848. * An event triggered after the texture clear
  19849. */
  19850. onClearObservable: Observable<Engine>;
  19851. private _onClearObserver;
  19852. /**
  19853. * Set a clear callback in the texture.
  19854. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19855. */
  19856. onClear: (Engine: Engine) => void;
  19857. /**
  19858. * An event triggered when the texture is resized.
  19859. */
  19860. onResizeObservable: Observable<RenderTargetTexture>;
  19861. /**
  19862. * Define the clear color of the Render Target if it should be different from the scene.
  19863. */
  19864. clearColor: Color4;
  19865. protected _size: number | {
  19866. width: number;
  19867. height: number;
  19868. };
  19869. protected _initialSizeParameter: number | {
  19870. width: number;
  19871. height: number;
  19872. } | {
  19873. ratio: number;
  19874. };
  19875. protected _sizeRatio: Nullable<number>;
  19876. /** @hidden */
  19877. _generateMipMaps: boolean;
  19878. protected _renderingManager: RenderingManager;
  19879. /** @hidden */
  19880. _waitingRenderList: string[];
  19881. protected _doNotChangeAspectRatio: boolean;
  19882. protected _currentRefreshId: number;
  19883. protected _refreshRate: number;
  19884. protected _textureMatrix: Matrix;
  19885. protected _samples: number;
  19886. protected _renderTargetOptions: RenderTargetCreationOptions;
  19887. /**
  19888. * Gets render target creation options that were used.
  19889. */
  19890. readonly renderTargetOptions: RenderTargetCreationOptions;
  19891. protected _engine: Engine;
  19892. protected _onRatioRescale(): void;
  19893. /**
  19894. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19895. * It must define where the camera used to render the texture is set
  19896. */
  19897. boundingBoxPosition: Vector3;
  19898. private _boundingBoxSize;
  19899. /**
  19900. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19901. * When defined, the cubemap will switch to local mode
  19902. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19903. * @example https://www.babylonjs-playground.com/#RNASML
  19904. */
  19905. boundingBoxSize: Vector3;
  19906. /**
  19907. * In case the RTT has been created with a depth texture, get the associated
  19908. * depth texture.
  19909. * Otherwise, return null.
  19910. */
  19911. depthStencilTexture: Nullable<InternalTexture>;
  19912. /**
  19913. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19914. * or used a shadow, depth texture...
  19915. * @param name The friendly name of the texture
  19916. * @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)
  19917. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19918. * @param generateMipMaps True if mip maps need to be generated after render.
  19919. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19920. * @param type The type of the buffer in the RTT (int, half float, float...)
  19921. * @param isCube True if a cube texture needs to be created
  19922. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19923. * @param generateDepthBuffer True to generate a depth buffer
  19924. * @param generateStencilBuffer True to generate a stencil buffer
  19925. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19926. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19927. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19928. */
  19929. constructor(name: string, size: number | {
  19930. width: number;
  19931. height: number;
  19932. } | {
  19933. ratio: number;
  19934. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19935. /**
  19936. * Creates a depth stencil texture.
  19937. * This is only available in WebGL 2 or with the depth texture extension available.
  19938. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19939. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19940. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19941. */
  19942. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19943. private _processSizeParameter;
  19944. /**
  19945. * Define the number of samples to use in case of MSAA.
  19946. * It defaults to one meaning no MSAA has been enabled.
  19947. */
  19948. samples: number;
  19949. /**
  19950. * Resets the refresh counter of the texture and start bak from scratch.
  19951. * Could be useful to regenerate the texture if it is setup to render only once.
  19952. */
  19953. resetRefreshCounter(): void;
  19954. /**
  19955. * Define the refresh rate of the texture or the rendering frequency.
  19956. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19957. */
  19958. refreshRate: number;
  19959. /**
  19960. * Adds a post process to the render target rendering passes.
  19961. * @param postProcess define the post process to add
  19962. */
  19963. addPostProcess(postProcess: PostProcess): void;
  19964. /**
  19965. * Clear all the post processes attached to the render target
  19966. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19967. */
  19968. clearPostProcesses(dispose?: boolean): void;
  19969. /**
  19970. * Remove one of the post process from the list of attached post processes to the texture
  19971. * @param postProcess define the post process to remove from the list
  19972. */
  19973. removePostProcess(postProcess: PostProcess): void;
  19974. /** @hidden */
  19975. _shouldRender(): boolean;
  19976. /**
  19977. * Gets the actual render size of the texture.
  19978. * @returns the width of the render size
  19979. */
  19980. getRenderSize(): number;
  19981. /**
  19982. * Gets the actual render width of the texture.
  19983. * @returns the width of the render size
  19984. */
  19985. getRenderWidth(): number;
  19986. /**
  19987. * Gets the actual render height of the texture.
  19988. * @returns the height of the render size
  19989. */
  19990. getRenderHeight(): number;
  19991. /**
  19992. * Get if the texture can be rescaled or not.
  19993. */
  19994. readonly canRescale: boolean;
  19995. /**
  19996. * Resize the texture using a ratio.
  19997. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19998. */
  19999. scale(ratio: number): void;
  20000. /**
  20001. * Get the texture reflection matrix used to rotate/transform the reflection.
  20002. * @returns the reflection matrix
  20003. */
  20004. getReflectionTextureMatrix(): Matrix;
  20005. /**
  20006. * Resize the texture to a new desired size.
  20007. * Be carrefull as it will recreate all the data in the new texture.
  20008. * @param size Define the new size. It can be:
  20009. * - a number for squared texture,
  20010. * - an object containing { width: number, height: number }
  20011. * - or an object containing a ratio { ratio: number }
  20012. */
  20013. resize(size: number | {
  20014. width: number;
  20015. height: number;
  20016. } | {
  20017. ratio: number;
  20018. }): void;
  20019. /**
  20020. * Renders all the objects from the render list into the texture.
  20021. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20022. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20023. */
  20024. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20025. private _bestReflectionRenderTargetDimension;
  20026. /**
  20027. * @hidden
  20028. * @param faceIndex face index to bind to if this is a cubetexture
  20029. */
  20030. _bindFrameBuffer(faceIndex?: number): void;
  20031. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20032. private renderToTarget;
  20033. /**
  20034. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20035. * This allowed control for front to back rendering or reversly depending of the special needs.
  20036. *
  20037. * @param renderingGroupId The rendering group id corresponding to its index
  20038. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20039. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20040. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20041. */
  20042. 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;
  20043. /**
  20044. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20045. *
  20046. * @param renderingGroupId The rendering group id corresponding to its index
  20047. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20048. */
  20049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20050. /**
  20051. * Clones the texture.
  20052. * @returns the cloned texture
  20053. */
  20054. clone(): RenderTargetTexture;
  20055. /**
  20056. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20057. * @returns The JSON representation of the texture
  20058. */
  20059. serialize(): any;
  20060. /**
  20061. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20062. */
  20063. disposeFramebufferObjects(): void;
  20064. /**
  20065. * Dispose the texture and release its associated resources.
  20066. */
  20067. dispose(): void;
  20068. /** @hidden */
  20069. _rebuild(): void;
  20070. /**
  20071. * Clear the info related to rendering groups preventing retention point in material dispose.
  20072. */
  20073. freeRenderingGroups(): void;
  20074. /**
  20075. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20076. * @returns the view count
  20077. */
  20078. getViewCount(): number;
  20079. }
  20080. }
  20081. declare module BABYLON {
  20082. /**
  20083. * Base class for the main features of a material in Babylon.js
  20084. */
  20085. export class Material implements IAnimatable {
  20086. /**
  20087. * Returns the triangle fill mode
  20088. */
  20089. static readonly TriangleFillMode: number;
  20090. /**
  20091. * Returns the wireframe mode
  20092. */
  20093. static readonly WireFrameFillMode: number;
  20094. /**
  20095. * Returns the point fill mode
  20096. */
  20097. static readonly PointFillMode: number;
  20098. /**
  20099. * Returns the point list draw mode
  20100. */
  20101. static readonly PointListDrawMode: number;
  20102. /**
  20103. * Returns the line list draw mode
  20104. */
  20105. static readonly LineListDrawMode: number;
  20106. /**
  20107. * Returns the line loop draw mode
  20108. */
  20109. static readonly LineLoopDrawMode: number;
  20110. /**
  20111. * Returns the line strip draw mode
  20112. */
  20113. static readonly LineStripDrawMode: number;
  20114. /**
  20115. * Returns the triangle strip draw mode
  20116. */
  20117. static readonly TriangleStripDrawMode: number;
  20118. /**
  20119. * Returns the triangle fan draw mode
  20120. */
  20121. static readonly TriangleFanDrawMode: number;
  20122. /**
  20123. * Stores the clock-wise side orientation
  20124. */
  20125. static readonly ClockWiseSideOrientation: number;
  20126. /**
  20127. * Stores the counter clock-wise side orientation
  20128. */
  20129. static readonly CounterClockWiseSideOrientation: number;
  20130. /**
  20131. * The dirty texture flag value
  20132. */
  20133. static readonly TextureDirtyFlag: number;
  20134. /**
  20135. * The dirty light flag value
  20136. */
  20137. static readonly LightDirtyFlag: number;
  20138. /**
  20139. * The dirty fresnel flag value
  20140. */
  20141. static readonly FresnelDirtyFlag: number;
  20142. /**
  20143. * The dirty attribute flag value
  20144. */
  20145. static readonly AttributesDirtyFlag: number;
  20146. /**
  20147. * The dirty misc flag value
  20148. */
  20149. static readonly MiscDirtyFlag: number;
  20150. /**
  20151. * The all dirty flag value
  20152. */
  20153. static readonly AllDirtyFlag: number;
  20154. /**
  20155. * The ID of the material
  20156. */
  20157. id: string;
  20158. /**
  20159. * Gets or sets the unique id of the material
  20160. */
  20161. uniqueId: number;
  20162. /**
  20163. * The name of the material
  20164. */
  20165. name: string;
  20166. /**
  20167. * Gets or sets user defined metadata
  20168. */
  20169. metadata: any;
  20170. /**
  20171. * For internal use only. Please do not use.
  20172. */
  20173. reservedDataStore: any;
  20174. /**
  20175. * Specifies if the ready state should be checked on each call
  20176. */
  20177. checkReadyOnEveryCall: boolean;
  20178. /**
  20179. * Specifies if the ready state should be checked once
  20180. */
  20181. checkReadyOnlyOnce: boolean;
  20182. /**
  20183. * The state of the material
  20184. */
  20185. state: string;
  20186. /**
  20187. * The alpha value of the material
  20188. */
  20189. protected _alpha: number;
  20190. /**
  20191. * List of inspectable custom properties (used by the Inspector)
  20192. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20193. */
  20194. inspectableCustomProperties: IInspectable[];
  20195. /**
  20196. * Sets the alpha value of the material
  20197. */
  20198. /**
  20199. * Gets the alpha value of the material
  20200. */
  20201. alpha: number;
  20202. /**
  20203. * Specifies if back face culling is enabled
  20204. */
  20205. protected _backFaceCulling: boolean;
  20206. /**
  20207. * Sets the back-face culling state
  20208. */
  20209. /**
  20210. * Gets the back-face culling state
  20211. */
  20212. backFaceCulling: boolean;
  20213. /**
  20214. * Stores the value for side orientation
  20215. */
  20216. sideOrientation: number;
  20217. /**
  20218. * Callback triggered when the material is compiled
  20219. */
  20220. onCompiled: Nullable<(effect: Effect) => void>;
  20221. /**
  20222. * Callback triggered when an error occurs
  20223. */
  20224. onError: Nullable<(effect: Effect, errors: string) => void>;
  20225. /**
  20226. * Callback triggered to get the render target textures
  20227. */
  20228. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20229. /**
  20230. * Gets a boolean indicating that current material needs to register RTT
  20231. */
  20232. readonly hasRenderTargetTextures: boolean;
  20233. /**
  20234. * Specifies if the material should be serialized
  20235. */
  20236. doNotSerialize: boolean;
  20237. /**
  20238. * @hidden
  20239. */
  20240. _storeEffectOnSubMeshes: boolean;
  20241. /**
  20242. * Stores the animations for the material
  20243. */
  20244. animations: Nullable<Array<Animation>>;
  20245. /**
  20246. * An event triggered when the material is disposed
  20247. */
  20248. onDisposeObservable: Observable<Material>;
  20249. /**
  20250. * An observer which watches for dispose events
  20251. */
  20252. private _onDisposeObserver;
  20253. private _onUnBindObservable;
  20254. /**
  20255. * Called during a dispose event
  20256. */
  20257. onDispose: () => void;
  20258. private _onBindObservable;
  20259. /**
  20260. * An event triggered when the material is bound
  20261. */
  20262. readonly onBindObservable: Observable<AbstractMesh>;
  20263. /**
  20264. * An observer which watches for bind events
  20265. */
  20266. private _onBindObserver;
  20267. /**
  20268. * Called during a bind event
  20269. */
  20270. onBind: (Mesh: AbstractMesh) => void;
  20271. /**
  20272. * An event triggered when the material is unbound
  20273. */
  20274. readonly onUnBindObservable: Observable<Material>;
  20275. /**
  20276. * Stores the value of the alpha mode
  20277. */
  20278. private _alphaMode;
  20279. /**
  20280. * Sets the value of the alpha mode.
  20281. *
  20282. * | Value | Type | Description |
  20283. * | --- | --- | --- |
  20284. * | 0 | ALPHA_DISABLE | |
  20285. * | 1 | ALPHA_ADD | |
  20286. * | 2 | ALPHA_COMBINE | |
  20287. * | 3 | ALPHA_SUBTRACT | |
  20288. * | 4 | ALPHA_MULTIPLY | |
  20289. * | 5 | ALPHA_MAXIMIZED | |
  20290. * | 6 | ALPHA_ONEONE | |
  20291. * | 7 | ALPHA_PREMULTIPLIED | |
  20292. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20293. * | 9 | ALPHA_INTERPOLATE | |
  20294. * | 10 | ALPHA_SCREENMODE | |
  20295. *
  20296. */
  20297. /**
  20298. * Gets the value of the alpha mode
  20299. */
  20300. alphaMode: number;
  20301. /**
  20302. * Stores the state of the need depth pre-pass value
  20303. */
  20304. private _needDepthPrePass;
  20305. /**
  20306. * Sets the need depth pre-pass value
  20307. */
  20308. /**
  20309. * Gets the depth pre-pass value
  20310. */
  20311. needDepthPrePass: boolean;
  20312. /**
  20313. * Specifies if depth writing should be disabled
  20314. */
  20315. disableDepthWrite: boolean;
  20316. /**
  20317. * Specifies if depth writing should be forced
  20318. */
  20319. forceDepthWrite: boolean;
  20320. /**
  20321. * Specifies if there should be a separate pass for culling
  20322. */
  20323. separateCullingPass: boolean;
  20324. /**
  20325. * Stores the state specifing if fog should be enabled
  20326. */
  20327. private _fogEnabled;
  20328. /**
  20329. * Sets the state for enabling fog
  20330. */
  20331. /**
  20332. * Gets the value of the fog enabled state
  20333. */
  20334. fogEnabled: boolean;
  20335. /**
  20336. * Stores the size of points
  20337. */
  20338. pointSize: number;
  20339. /**
  20340. * Stores the z offset value
  20341. */
  20342. zOffset: number;
  20343. /**
  20344. * Gets a value specifying if wireframe mode is enabled
  20345. */
  20346. /**
  20347. * Sets the state of wireframe mode
  20348. */
  20349. wireframe: boolean;
  20350. /**
  20351. * Gets the value specifying if point clouds are enabled
  20352. */
  20353. /**
  20354. * Sets the state of point cloud mode
  20355. */
  20356. pointsCloud: boolean;
  20357. /**
  20358. * Gets the material fill mode
  20359. */
  20360. /**
  20361. * Sets the material fill mode
  20362. */
  20363. fillMode: number;
  20364. /**
  20365. * @hidden
  20366. * Stores the effects for the material
  20367. */
  20368. _effect: Nullable<Effect>;
  20369. /**
  20370. * @hidden
  20371. * Specifies if the material was previously ready
  20372. */
  20373. _wasPreviouslyReady: boolean;
  20374. /**
  20375. * Specifies if uniform buffers should be used
  20376. */
  20377. private _useUBO;
  20378. /**
  20379. * Stores a reference to the scene
  20380. */
  20381. private _scene;
  20382. /**
  20383. * Stores the fill mode state
  20384. */
  20385. private _fillMode;
  20386. /**
  20387. * Specifies if the depth write state should be cached
  20388. */
  20389. private _cachedDepthWriteState;
  20390. /**
  20391. * Stores the uniform buffer
  20392. */
  20393. protected _uniformBuffer: UniformBuffer;
  20394. /** @hidden */
  20395. _indexInSceneMaterialArray: number;
  20396. /** @hidden */
  20397. meshMap: Nullable<{
  20398. [id: string]: AbstractMesh | undefined;
  20399. }>;
  20400. /**
  20401. * Creates a material instance
  20402. * @param name defines the name of the material
  20403. * @param scene defines the scene to reference
  20404. * @param doNotAdd specifies if the material should be added to the scene
  20405. */
  20406. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20407. /**
  20408. * Returns a string representation of the current material
  20409. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20410. * @returns a string with material information
  20411. */
  20412. toString(fullDetails?: boolean): string;
  20413. /**
  20414. * Gets the class name of the material
  20415. * @returns a string with the class name of the material
  20416. */
  20417. getClassName(): string;
  20418. /**
  20419. * Specifies if updates for the material been locked
  20420. */
  20421. readonly isFrozen: boolean;
  20422. /**
  20423. * Locks updates for the material
  20424. */
  20425. freeze(): void;
  20426. /**
  20427. * Unlocks updates for the material
  20428. */
  20429. unfreeze(): void;
  20430. /**
  20431. * Specifies if the material is ready to be used
  20432. * @param mesh defines the mesh to check
  20433. * @param useInstances specifies if instances should be used
  20434. * @returns a boolean indicating if the material is ready to be used
  20435. */
  20436. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20437. /**
  20438. * Specifies that the submesh is ready to be used
  20439. * @param mesh defines the mesh to check
  20440. * @param subMesh defines which submesh to check
  20441. * @param useInstances specifies that instances should be used
  20442. * @returns a boolean indicating that the submesh is ready or not
  20443. */
  20444. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20445. /**
  20446. * Returns the material effect
  20447. * @returns the effect associated with the material
  20448. */
  20449. getEffect(): Nullable<Effect>;
  20450. /**
  20451. * Returns the current scene
  20452. * @returns a Scene
  20453. */
  20454. getScene(): Scene;
  20455. /**
  20456. * Specifies if the material will require alpha blending
  20457. * @returns a boolean specifying if alpha blending is needed
  20458. */
  20459. needAlphaBlending(): boolean;
  20460. /**
  20461. * Specifies if the mesh will require alpha blending
  20462. * @param mesh defines the mesh to check
  20463. * @returns a boolean specifying if alpha blending is needed for the mesh
  20464. */
  20465. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20466. /**
  20467. * Specifies if this material should be rendered in alpha test mode
  20468. * @returns a boolean specifying if an alpha test is needed.
  20469. */
  20470. needAlphaTesting(): boolean;
  20471. /**
  20472. * Gets the texture used for the alpha test
  20473. * @returns the texture to use for alpha testing
  20474. */
  20475. getAlphaTestTexture(): Nullable<BaseTexture>;
  20476. /**
  20477. * Marks the material to indicate that it needs to be re-calculated
  20478. */
  20479. markDirty(): void;
  20480. /** @hidden */
  20481. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20482. /**
  20483. * Binds the material to the mesh
  20484. * @param world defines the world transformation matrix
  20485. * @param mesh defines the mesh to bind the material to
  20486. */
  20487. bind(world: Matrix, mesh?: Mesh): void;
  20488. /**
  20489. * Binds the submesh to the material
  20490. * @param world defines the world transformation matrix
  20491. * @param mesh defines the mesh containing the submesh
  20492. * @param subMesh defines the submesh to bind the material to
  20493. */
  20494. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20495. /**
  20496. * Binds the world matrix to the material
  20497. * @param world defines the world transformation matrix
  20498. */
  20499. bindOnlyWorldMatrix(world: Matrix): void;
  20500. /**
  20501. * Binds the scene's uniform buffer to the effect.
  20502. * @param effect defines the effect to bind to the scene uniform buffer
  20503. * @param sceneUbo defines the uniform buffer storing scene data
  20504. */
  20505. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20506. /**
  20507. * Binds the view matrix to the effect
  20508. * @param effect defines the effect to bind the view matrix to
  20509. */
  20510. bindView(effect: Effect): void;
  20511. /**
  20512. * Binds the view projection matrix to the effect
  20513. * @param effect defines the effect to bind the view projection matrix to
  20514. */
  20515. bindViewProjection(effect: Effect): void;
  20516. /**
  20517. * Specifies if material alpha testing should be turned on for the mesh
  20518. * @param mesh defines the mesh to check
  20519. */
  20520. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20521. /**
  20522. * Processes to execute after binding the material to a mesh
  20523. * @param mesh defines the rendered mesh
  20524. */
  20525. protected _afterBind(mesh?: Mesh): void;
  20526. /**
  20527. * Unbinds the material from the mesh
  20528. */
  20529. unbind(): void;
  20530. /**
  20531. * Gets the active textures from the material
  20532. * @returns an array of textures
  20533. */
  20534. getActiveTextures(): BaseTexture[];
  20535. /**
  20536. * Specifies if the material uses a texture
  20537. * @param texture defines the texture to check against the material
  20538. * @returns a boolean specifying if the material uses the texture
  20539. */
  20540. hasTexture(texture: BaseTexture): boolean;
  20541. /**
  20542. * Makes a duplicate of the material, and gives it a new name
  20543. * @param name defines the new name for the duplicated material
  20544. * @returns the cloned material
  20545. */
  20546. clone(name: string): Nullable<Material>;
  20547. /**
  20548. * Gets the meshes bound to the material
  20549. * @returns an array of meshes bound to the material
  20550. */
  20551. getBindedMeshes(): AbstractMesh[];
  20552. /**
  20553. * Force shader compilation
  20554. * @param mesh defines the mesh associated with this material
  20555. * @param onCompiled defines a function to execute once the material is compiled
  20556. * @param options defines the options to configure the compilation
  20557. * @param onError defines a function to execute if the material fails compiling
  20558. */
  20559. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20560. clipPlane: boolean;
  20561. }>, onError?: (reason: string) => void): void;
  20562. /**
  20563. * Force shader compilation
  20564. * @param mesh defines the mesh that will use this material
  20565. * @param options defines additional options for compiling the shaders
  20566. * @returns a promise that resolves when the compilation completes
  20567. */
  20568. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20569. clipPlane: boolean;
  20570. }>): Promise<void>;
  20571. private static readonly _AllDirtyCallBack;
  20572. private static readonly _ImageProcessingDirtyCallBack;
  20573. private static readonly _TextureDirtyCallBack;
  20574. private static readonly _FresnelDirtyCallBack;
  20575. private static readonly _MiscDirtyCallBack;
  20576. private static readonly _LightsDirtyCallBack;
  20577. private static readonly _AttributeDirtyCallBack;
  20578. private static _FresnelAndMiscDirtyCallBack;
  20579. private static _TextureAndMiscDirtyCallBack;
  20580. private static readonly _DirtyCallbackArray;
  20581. private static readonly _RunDirtyCallBacks;
  20582. /**
  20583. * Marks a define in the material to indicate that it needs to be re-computed
  20584. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20585. */
  20586. markAsDirty(flag: number): void;
  20587. /**
  20588. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20589. * @param func defines a function which checks material defines against the submeshes
  20590. */
  20591. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20592. /**
  20593. * Indicates that we need to re-calculated for all submeshes
  20594. */
  20595. protected _markAllSubMeshesAsAllDirty(): void;
  20596. /**
  20597. * Indicates that image processing needs to be re-calculated for all submeshes
  20598. */
  20599. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20600. /**
  20601. * Indicates that textures need to be re-calculated for all submeshes
  20602. */
  20603. protected _markAllSubMeshesAsTexturesDirty(): void;
  20604. /**
  20605. * Indicates that fresnel needs to be re-calculated for all submeshes
  20606. */
  20607. protected _markAllSubMeshesAsFresnelDirty(): void;
  20608. /**
  20609. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20610. */
  20611. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20612. /**
  20613. * Indicates that lights need to be re-calculated for all submeshes
  20614. */
  20615. protected _markAllSubMeshesAsLightsDirty(): void;
  20616. /**
  20617. * Indicates that attributes need to be re-calculated for all submeshes
  20618. */
  20619. protected _markAllSubMeshesAsAttributesDirty(): void;
  20620. /**
  20621. * Indicates that misc needs to be re-calculated for all submeshes
  20622. */
  20623. protected _markAllSubMeshesAsMiscDirty(): void;
  20624. /**
  20625. * Indicates that textures and misc need to be re-calculated for all submeshes
  20626. */
  20627. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20628. /**
  20629. * Disposes the material
  20630. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20631. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20632. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20633. */
  20634. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20635. /** @hidden */
  20636. private releaseVertexArrayObject;
  20637. /**
  20638. * Serializes this material
  20639. * @returns the serialized material object
  20640. */
  20641. serialize(): any;
  20642. /**
  20643. * Creates a material from parsed material data
  20644. * @param parsedMaterial defines parsed material data
  20645. * @param scene defines the hosting scene
  20646. * @param rootUrl defines the root URL to use to load textures
  20647. * @returns a new material
  20648. */
  20649. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20650. }
  20651. }
  20652. declare module BABYLON {
  20653. /**
  20654. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20655. * separate meshes. This can be use to improve performances.
  20656. * @see http://doc.babylonjs.com/how_to/multi_materials
  20657. */
  20658. export class MultiMaterial extends Material {
  20659. private _subMaterials;
  20660. /**
  20661. * Gets or Sets the list of Materials used within the multi material.
  20662. * They need to be ordered according to the submeshes order in the associated mesh
  20663. */
  20664. subMaterials: Nullable<Material>[];
  20665. /**
  20666. * Function used to align with Node.getChildren()
  20667. * @returns the list of Materials used within the multi material
  20668. */
  20669. getChildren(): Nullable<Material>[];
  20670. /**
  20671. * Instantiates a new Multi Material
  20672. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20673. * separate meshes. This can be use to improve performances.
  20674. * @see http://doc.babylonjs.com/how_to/multi_materials
  20675. * @param name Define the name in the scene
  20676. * @param scene Define the scene the material belongs to
  20677. */
  20678. constructor(name: string, scene: Scene);
  20679. private _hookArray;
  20680. /**
  20681. * Get one of the submaterial by its index in the submaterials array
  20682. * @param index The index to look the sub material at
  20683. * @returns The Material if the index has been defined
  20684. */
  20685. getSubMaterial(index: number): Nullable<Material>;
  20686. /**
  20687. * Get the list of active textures for the whole sub materials list.
  20688. * @returns All the textures that will be used during the rendering
  20689. */
  20690. getActiveTextures(): BaseTexture[];
  20691. /**
  20692. * Gets the current class name of the material e.g. "MultiMaterial"
  20693. * Mainly use in serialization.
  20694. * @returns the class name
  20695. */
  20696. getClassName(): string;
  20697. /**
  20698. * Checks if the material is ready to render the requested sub mesh
  20699. * @param mesh Define the mesh the submesh belongs to
  20700. * @param subMesh Define the sub mesh to look readyness for
  20701. * @param useInstances Define whether or not the material is used with instances
  20702. * @returns true if ready, otherwise false
  20703. */
  20704. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20705. /**
  20706. * Clones the current material and its related sub materials
  20707. * @param name Define the name of the newly cloned material
  20708. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20709. * @returns the cloned material
  20710. */
  20711. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20712. /**
  20713. * Serializes the materials into a JSON representation.
  20714. * @returns the JSON representation
  20715. */
  20716. serialize(): any;
  20717. /**
  20718. * Dispose the material and release its associated resources
  20719. * @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)
  20720. * @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)
  20721. * @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)
  20722. */
  20723. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20724. /**
  20725. * Creates a MultiMaterial from parsed MultiMaterial data.
  20726. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20727. * @param scene defines the hosting scene
  20728. * @returns a new MultiMaterial
  20729. */
  20730. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20731. }
  20732. }
  20733. declare module BABYLON {
  20734. /**
  20735. * Base class for submeshes
  20736. */
  20737. export class BaseSubMesh {
  20738. /** @hidden */
  20739. _materialDefines: Nullable<MaterialDefines>;
  20740. /** @hidden */
  20741. _materialEffect: Nullable<Effect>;
  20742. /**
  20743. * Gets associated effect
  20744. */
  20745. readonly effect: Nullable<Effect>;
  20746. /**
  20747. * Sets associated effect (effect used to render this submesh)
  20748. * @param effect defines the effect to associate with
  20749. * @param defines defines the set of defines used to compile this effect
  20750. */
  20751. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20752. }
  20753. /**
  20754. * Defines a subdivision inside a mesh
  20755. */
  20756. export class SubMesh extends BaseSubMesh implements ICullable {
  20757. /** the material index to use */
  20758. materialIndex: number;
  20759. /** vertex index start */
  20760. verticesStart: number;
  20761. /** vertices count */
  20762. verticesCount: number;
  20763. /** index start */
  20764. indexStart: number;
  20765. /** indices count */
  20766. indexCount: number;
  20767. /** @hidden */
  20768. _linesIndexCount: number;
  20769. private _mesh;
  20770. private _renderingMesh;
  20771. private _boundingInfo;
  20772. private _linesIndexBuffer;
  20773. /** @hidden */
  20774. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20775. /** @hidden */
  20776. _trianglePlanes: Plane[];
  20777. /** @hidden */
  20778. _lastColliderTransformMatrix: Nullable<Matrix>;
  20779. /** @hidden */
  20780. _renderId: number;
  20781. /** @hidden */
  20782. _alphaIndex: number;
  20783. /** @hidden */
  20784. _distanceToCamera: number;
  20785. /** @hidden */
  20786. _id: number;
  20787. private _currentMaterial;
  20788. /**
  20789. * Add a new submesh to a mesh
  20790. * @param materialIndex defines the material index to use
  20791. * @param verticesStart defines vertex index start
  20792. * @param verticesCount defines vertices count
  20793. * @param indexStart defines index start
  20794. * @param indexCount defines indices count
  20795. * @param mesh defines the parent mesh
  20796. * @param renderingMesh defines an optional rendering mesh
  20797. * @param createBoundingBox defines if bounding box should be created for this submesh
  20798. * @returns the new submesh
  20799. */
  20800. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20801. /**
  20802. * Creates a new submesh
  20803. * @param materialIndex defines the material index to use
  20804. * @param verticesStart defines vertex index start
  20805. * @param verticesCount defines vertices count
  20806. * @param indexStart defines index start
  20807. * @param indexCount defines indices count
  20808. * @param mesh defines the parent mesh
  20809. * @param renderingMesh defines an optional rendering mesh
  20810. * @param createBoundingBox defines if bounding box should be created for this submesh
  20811. */
  20812. constructor(
  20813. /** the material index to use */
  20814. materialIndex: number,
  20815. /** vertex index start */
  20816. verticesStart: number,
  20817. /** vertices count */
  20818. verticesCount: number,
  20819. /** index start */
  20820. indexStart: number,
  20821. /** indices count */
  20822. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20823. /**
  20824. * Returns true if this submesh covers the entire parent mesh
  20825. * @ignorenaming
  20826. */
  20827. readonly IsGlobal: boolean;
  20828. /**
  20829. * Returns the submesh BoudingInfo object
  20830. * @returns current bounding info (or mesh's one if the submesh is global)
  20831. */
  20832. getBoundingInfo(): BoundingInfo;
  20833. /**
  20834. * Sets the submesh BoundingInfo
  20835. * @param boundingInfo defines the new bounding info to use
  20836. * @returns the SubMesh
  20837. */
  20838. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20839. /**
  20840. * Returns the mesh of the current submesh
  20841. * @return the parent mesh
  20842. */
  20843. getMesh(): AbstractMesh;
  20844. /**
  20845. * Returns the rendering mesh of the submesh
  20846. * @returns the rendering mesh (could be different from parent mesh)
  20847. */
  20848. getRenderingMesh(): Mesh;
  20849. /**
  20850. * Returns the submesh material
  20851. * @returns null or the current material
  20852. */
  20853. getMaterial(): Nullable<Material>;
  20854. /**
  20855. * Sets a new updated BoundingInfo object to the submesh
  20856. * @param data defines an optional position array to use to determine the bounding info
  20857. * @returns the SubMesh
  20858. */
  20859. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20860. /** @hidden */
  20861. _checkCollision(collider: Collider): boolean;
  20862. /**
  20863. * Updates the submesh BoundingInfo
  20864. * @param world defines the world matrix to use to update the bounding info
  20865. * @returns the submesh
  20866. */
  20867. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20868. /**
  20869. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20870. * @param frustumPlanes defines the frustum planes
  20871. * @returns true if the submesh is intersecting with the frustum
  20872. */
  20873. isInFrustum(frustumPlanes: Plane[]): boolean;
  20874. /**
  20875. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20876. * @param frustumPlanes defines the frustum planes
  20877. * @returns true if the submesh is inside the frustum
  20878. */
  20879. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20880. /**
  20881. * Renders the submesh
  20882. * @param enableAlphaMode defines if alpha needs to be used
  20883. * @returns the submesh
  20884. */
  20885. render(enableAlphaMode: boolean): SubMesh;
  20886. /**
  20887. * @hidden
  20888. */
  20889. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20890. /**
  20891. * Checks if the submesh intersects with a ray
  20892. * @param ray defines the ray to test
  20893. * @returns true is the passed ray intersects the submesh bounding box
  20894. */
  20895. canIntersects(ray: Ray): boolean;
  20896. /**
  20897. * Intersects current submesh with a ray
  20898. * @param ray defines the ray to test
  20899. * @param positions defines mesh's positions array
  20900. * @param indices defines mesh's indices array
  20901. * @param fastCheck defines if only bounding info should be used
  20902. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20903. * @returns intersection info or null if no intersection
  20904. */
  20905. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20906. /** @hidden */
  20907. private _intersectLines;
  20908. /** @hidden */
  20909. private _intersectUnIndexedLines;
  20910. /** @hidden */
  20911. private _intersectTriangles;
  20912. /** @hidden */
  20913. private _intersectUnIndexedTriangles;
  20914. /** @hidden */
  20915. _rebuild(): void;
  20916. /**
  20917. * Creates a new submesh from the passed mesh
  20918. * @param newMesh defines the new hosting mesh
  20919. * @param newRenderingMesh defines an optional rendering mesh
  20920. * @returns the new submesh
  20921. */
  20922. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20923. /**
  20924. * Release associated resources
  20925. */
  20926. dispose(): void;
  20927. /**
  20928. * Gets the class name
  20929. * @returns the string "SubMesh".
  20930. */
  20931. getClassName(): string;
  20932. /**
  20933. * Creates a new submesh from indices data
  20934. * @param materialIndex the index of the main mesh material
  20935. * @param startIndex the index where to start the copy in the mesh indices array
  20936. * @param indexCount the number of indices to copy then from the startIndex
  20937. * @param mesh the main mesh to create the submesh from
  20938. * @param renderingMesh the optional rendering mesh
  20939. * @returns a new submesh
  20940. */
  20941. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20942. }
  20943. }
  20944. declare module BABYLON {
  20945. /**
  20946. * Class used to represent data loading progression
  20947. */
  20948. export class SceneLoaderFlags {
  20949. private static _ForceFullSceneLoadingForIncremental;
  20950. private static _ShowLoadingScreen;
  20951. private static _CleanBoneMatrixWeights;
  20952. private static _loggingLevel;
  20953. /**
  20954. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20955. */
  20956. static ForceFullSceneLoadingForIncremental: boolean;
  20957. /**
  20958. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20959. */
  20960. static ShowLoadingScreen: boolean;
  20961. /**
  20962. * Defines the current logging level (while loading the scene)
  20963. * @ignorenaming
  20964. */
  20965. static loggingLevel: number;
  20966. /**
  20967. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20968. */
  20969. static CleanBoneMatrixWeights: boolean;
  20970. }
  20971. }
  20972. declare module BABYLON {
  20973. /**
  20974. * Class used to store geometry data (vertex buffers + index buffer)
  20975. */
  20976. export class Geometry implements IGetSetVerticesData {
  20977. /**
  20978. * Gets or sets the ID of the geometry
  20979. */
  20980. id: string;
  20981. /**
  20982. * Gets or sets the unique ID of the geometry
  20983. */
  20984. uniqueId: number;
  20985. /**
  20986. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20987. */
  20988. delayLoadState: number;
  20989. /**
  20990. * Gets the file containing the data to load when running in delay load state
  20991. */
  20992. delayLoadingFile: Nullable<string>;
  20993. /**
  20994. * Callback called when the geometry is updated
  20995. */
  20996. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20997. private _scene;
  20998. private _engine;
  20999. private _meshes;
  21000. private _totalVertices;
  21001. /** @hidden */
  21002. _indices: IndicesArray;
  21003. /** @hidden */
  21004. _vertexBuffers: {
  21005. [key: string]: VertexBuffer;
  21006. };
  21007. private _isDisposed;
  21008. private _extend;
  21009. private _boundingBias;
  21010. /** @hidden */
  21011. _delayInfo: Array<string>;
  21012. private _indexBuffer;
  21013. private _indexBufferIsUpdatable;
  21014. /** @hidden */
  21015. _boundingInfo: Nullable<BoundingInfo>;
  21016. /** @hidden */
  21017. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21018. /** @hidden */
  21019. _softwareSkinningFrameId: number;
  21020. private _vertexArrayObjects;
  21021. private _updatable;
  21022. /** @hidden */
  21023. _positions: Nullable<Vector3[]>;
  21024. /**
  21025. * 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
  21026. */
  21027. /**
  21028. * 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
  21029. */
  21030. boundingBias: Vector2;
  21031. /**
  21032. * Static function used to attach a new empty geometry to a mesh
  21033. * @param mesh defines the mesh to attach the geometry to
  21034. * @returns the new Geometry
  21035. */
  21036. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21037. /**
  21038. * Creates a new geometry
  21039. * @param id defines the unique ID
  21040. * @param scene defines the hosting scene
  21041. * @param vertexData defines the VertexData used to get geometry data
  21042. * @param updatable defines if geometry must be updatable (false by default)
  21043. * @param mesh defines the mesh that will be associated with the geometry
  21044. */
  21045. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21046. /**
  21047. * Gets the current extend of the geometry
  21048. */
  21049. readonly extend: {
  21050. minimum: Vector3;
  21051. maximum: Vector3;
  21052. };
  21053. /**
  21054. * Gets the hosting scene
  21055. * @returns the hosting Scene
  21056. */
  21057. getScene(): Scene;
  21058. /**
  21059. * Gets the hosting engine
  21060. * @returns the hosting Engine
  21061. */
  21062. getEngine(): Engine;
  21063. /**
  21064. * Defines if the geometry is ready to use
  21065. * @returns true if the geometry is ready to be used
  21066. */
  21067. isReady(): boolean;
  21068. /**
  21069. * Gets a value indicating that the geometry should not be serialized
  21070. */
  21071. readonly doNotSerialize: boolean;
  21072. /** @hidden */
  21073. _rebuild(): void;
  21074. /**
  21075. * Affects all geometry data in one call
  21076. * @param vertexData defines the geometry data
  21077. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21078. */
  21079. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21080. /**
  21081. * Set specific vertex data
  21082. * @param kind defines the data kind (Position, normal, etc...)
  21083. * @param data defines the vertex data to use
  21084. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21085. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21086. */
  21087. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21088. /**
  21089. * Removes a specific vertex data
  21090. * @param kind defines the data kind (Position, normal, etc...)
  21091. */
  21092. removeVerticesData(kind: string): void;
  21093. /**
  21094. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21095. * @param buffer defines the vertex buffer to use
  21096. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21097. */
  21098. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21099. /**
  21100. * Update a specific vertex buffer
  21101. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21102. * It will do nothing if the buffer is not updatable
  21103. * @param kind defines the data kind (Position, normal, etc...)
  21104. * @param data defines the data to use
  21105. * @param offset defines the offset in the target buffer where to store the data
  21106. * @param useBytes set to true if the offset is in bytes
  21107. */
  21108. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21109. /**
  21110. * Update a specific vertex buffer
  21111. * This function will create a new buffer if the current one is not updatable
  21112. * @param kind defines the data kind (Position, normal, etc...)
  21113. * @param data defines the data to use
  21114. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21115. */
  21116. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21117. private _updateBoundingInfo;
  21118. /** @hidden */
  21119. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21120. /**
  21121. * Gets total number of vertices
  21122. * @returns the total number of vertices
  21123. */
  21124. getTotalVertices(): number;
  21125. /**
  21126. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21127. * @param kind defines the data kind (Position, normal, etc...)
  21128. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21129. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21130. * @returns a float array containing vertex data
  21131. */
  21132. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21133. /**
  21134. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21135. * @param kind defines the data kind (Position, normal, etc...)
  21136. * @returns true if the vertex buffer with the specified kind is updatable
  21137. */
  21138. isVertexBufferUpdatable(kind: string): boolean;
  21139. /**
  21140. * Gets a specific vertex buffer
  21141. * @param kind defines the data kind (Position, normal, etc...)
  21142. * @returns a VertexBuffer
  21143. */
  21144. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21145. /**
  21146. * Returns all vertex buffers
  21147. * @return an object holding all vertex buffers indexed by kind
  21148. */
  21149. getVertexBuffers(): Nullable<{
  21150. [key: string]: VertexBuffer;
  21151. }>;
  21152. /**
  21153. * Gets a boolean indicating if specific vertex buffer is present
  21154. * @param kind defines the data kind (Position, normal, etc...)
  21155. * @returns true if data is present
  21156. */
  21157. isVerticesDataPresent(kind: string): boolean;
  21158. /**
  21159. * Gets a list of all attached data kinds (Position, normal, etc...)
  21160. * @returns a list of string containing all kinds
  21161. */
  21162. getVerticesDataKinds(): string[];
  21163. /**
  21164. * Update index buffer
  21165. * @param indices defines the indices to store in the index buffer
  21166. * @param offset defines the offset in the target buffer where to store the data
  21167. * @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)
  21168. */
  21169. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21170. /**
  21171. * Creates a new index buffer
  21172. * @param indices defines the indices to store in the index buffer
  21173. * @param totalVertices defines the total number of vertices (could be null)
  21174. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21175. */
  21176. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21177. /**
  21178. * Return the total number of indices
  21179. * @returns the total number of indices
  21180. */
  21181. getTotalIndices(): number;
  21182. /**
  21183. * Gets the index buffer array
  21184. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21185. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21186. * @returns the index buffer array
  21187. */
  21188. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21189. /**
  21190. * Gets the index buffer
  21191. * @return the index buffer
  21192. */
  21193. getIndexBuffer(): Nullable<DataBuffer>;
  21194. /** @hidden */
  21195. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21196. /**
  21197. * Release the associated resources for a specific mesh
  21198. * @param mesh defines the source mesh
  21199. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21200. */
  21201. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21202. /**
  21203. * Apply current geometry to a given mesh
  21204. * @param mesh defines the mesh to apply geometry to
  21205. */
  21206. applyToMesh(mesh: Mesh): void;
  21207. private _updateExtend;
  21208. private _applyToMesh;
  21209. private notifyUpdate;
  21210. /**
  21211. * Load the geometry if it was flagged as delay loaded
  21212. * @param scene defines the hosting scene
  21213. * @param onLoaded defines a callback called when the geometry is loaded
  21214. */
  21215. load(scene: Scene, onLoaded?: () => void): void;
  21216. private _queueLoad;
  21217. /**
  21218. * Invert the geometry to move from a right handed system to a left handed one.
  21219. */
  21220. toLeftHanded(): void;
  21221. /** @hidden */
  21222. _resetPointsArrayCache(): void;
  21223. /** @hidden */
  21224. _generatePointsArray(): boolean;
  21225. /**
  21226. * Gets a value indicating if the geometry is disposed
  21227. * @returns true if the geometry was disposed
  21228. */
  21229. isDisposed(): boolean;
  21230. private _disposeVertexArrayObjects;
  21231. /**
  21232. * Free all associated resources
  21233. */
  21234. dispose(): void;
  21235. /**
  21236. * Clone the current geometry into a new geometry
  21237. * @param id defines the unique ID of the new geometry
  21238. * @returns a new geometry object
  21239. */
  21240. copy(id: string): Geometry;
  21241. /**
  21242. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21243. * @return a JSON representation of the current geometry data (without the vertices data)
  21244. */
  21245. serialize(): any;
  21246. private toNumberArray;
  21247. /**
  21248. * Serialize all vertices data into a JSON oject
  21249. * @returns a JSON representation of the current geometry data
  21250. */
  21251. serializeVerticeData(): any;
  21252. /**
  21253. * Extracts a clone of a mesh geometry
  21254. * @param mesh defines the source mesh
  21255. * @param id defines the unique ID of the new geometry object
  21256. * @returns the new geometry object
  21257. */
  21258. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21259. /**
  21260. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21261. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21262. * Be aware Math.random() could cause collisions, but:
  21263. * "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"
  21264. * @returns a string containing a new GUID
  21265. */
  21266. static RandomId(): string;
  21267. /** @hidden */
  21268. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21269. private static _CleanMatricesWeights;
  21270. /**
  21271. * Create a new geometry from persisted data (Using .babylon file format)
  21272. * @param parsedVertexData defines the persisted data
  21273. * @param scene defines the hosting scene
  21274. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21275. * @returns the new geometry object
  21276. */
  21277. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21278. }
  21279. }
  21280. declare module BABYLON {
  21281. /**
  21282. * Define an interface for all classes that will get and set the data on vertices
  21283. */
  21284. export interface IGetSetVerticesData {
  21285. /**
  21286. * Gets a boolean indicating if specific vertex data is present
  21287. * @param kind defines the vertex data kind to use
  21288. * @returns true is data kind is present
  21289. */
  21290. isVerticesDataPresent(kind: string): boolean;
  21291. /**
  21292. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21293. * @param kind defines the data kind (Position, normal, etc...)
  21294. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21295. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21296. * @returns a float array containing vertex data
  21297. */
  21298. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21299. /**
  21300. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21301. * @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.
  21302. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21303. * @returns the indices array or an empty array if the mesh has no geometry
  21304. */
  21305. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21306. /**
  21307. * Set specific vertex data
  21308. * @param kind defines the data kind (Position, normal, etc...)
  21309. * @param data defines the vertex data to use
  21310. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21311. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21312. */
  21313. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21314. /**
  21315. * Update a specific associated vertex buffer
  21316. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21317. * - VertexBuffer.PositionKind
  21318. * - VertexBuffer.UVKind
  21319. * - VertexBuffer.UV2Kind
  21320. * - VertexBuffer.UV3Kind
  21321. * - VertexBuffer.UV4Kind
  21322. * - VertexBuffer.UV5Kind
  21323. * - VertexBuffer.UV6Kind
  21324. * - VertexBuffer.ColorKind
  21325. * - VertexBuffer.MatricesIndicesKind
  21326. * - VertexBuffer.MatricesIndicesExtraKind
  21327. * - VertexBuffer.MatricesWeightsKind
  21328. * - VertexBuffer.MatricesWeightsExtraKind
  21329. * @param data defines the data source
  21330. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21331. * @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)
  21332. */
  21333. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21334. /**
  21335. * Creates a new index buffer
  21336. * @param indices defines the indices to store in the index buffer
  21337. * @param totalVertices defines the total number of vertices (could be null)
  21338. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21339. */
  21340. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21341. }
  21342. /**
  21343. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21344. */
  21345. export class VertexData {
  21346. /**
  21347. * Mesh side orientation : usually the external or front surface
  21348. */
  21349. static readonly FRONTSIDE: number;
  21350. /**
  21351. * Mesh side orientation : usually the internal or back surface
  21352. */
  21353. static readonly BACKSIDE: number;
  21354. /**
  21355. * Mesh side orientation : both internal and external or front and back surfaces
  21356. */
  21357. static readonly DOUBLESIDE: number;
  21358. /**
  21359. * Mesh side orientation : by default, `FRONTSIDE`
  21360. */
  21361. static readonly DEFAULTSIDE: number;
  21362. /**
  21363. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21364. */
  21365. positions: Nullable<FloatArray>;
  21366. /**
  21367. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21368. */
  21369. normals: Nullable<FloatArray>;
  21370. /**
  21371. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21372. */
  21373. tangents: Nullable<FloatArray>;
  21374. /**
  21375. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21376. */
  21377. uvs: Nullable<FloatArray>;
  21378. /**
  21379. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21380. */
  21381. uvs2: Nullable<FloatArray>;
  21382. /**
  21383. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21384. */
  21385. uvs3: Nullable<FloatArray>;
  21386. /**
  21387. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21388. */
  21389. uvs4: Nullable<FloatArray>;
  21390. /**
  21391. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21392. */
  21393. uvs5: Nullable<FloatArray>;
  21394. /**
  21395. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21396. */
  21397. uvs6: Nullable<FloatArray>;
  21398. /**
  21399. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21400. */
  21401. colors: Nullable<FloatArray>;
  21402. /**
  21403. * 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).
  21404. */
  21405. matricesIndices: Nullable<FloatArray>;
  21406. /**
  21407. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21408. */
  21409. matricesWeights: Nullable<FloatArray>;
  21410. /**
  21411. * An array extending the number of possible indices
  21412. */
  21413. matricesIndicesExtra: Nullable<FloatArray>;
  21414. /**
  21415. * An array extending the number of possible weights when the number of indices is extended
  21416. */
  21417. matricesWeightsExtra: Nullable<FloatArray>;
  21418. /**
  21419. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21420. */
  21421. indices: Nullable<IndicesArray>;
  21422. /**
  21423. * Uses the passed data array to set the set the values for the specified kind of data
  21424. * @param data a linear array of floating numbers
  21425. * @param kind the type of data that is being set, eg positions, colors etc
  21426. */
  21427. set(data: FloatArray, kind: string): void;
  21428. /**
  21429. * Associates the vertexData to the passed Mesh.
  21430. * Sets it as updatable or not (default `false`)
  21431. * @param mesh the mesh the vertexData is applied to
  21432. * @param updatable when used and having the value true allows new data to update the vertexData
  21433. * @returns the VertexData
  21434. */
  21435. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21436. /**
  21437. * Associates the vertexData to the passed Geometry.
  21438. * Sets it as updatable or not (default `false`)
  21439. * @param geometry the geometry the vertexData is applied to
  21440. * @param updatable when used and having the value true allows new data to update the vertexData
  21441. * @returns VertexData
  21442. */
  21443. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21444. /**
  21445. * Updates the associated mesh
  21446. * @param mesh the mesh to be updated
  21447. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21448. * @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
  21449. * @returns VertexData
  21450. */
  21451. updateMesh(mesh: Mesh): VertexData;
  21452. /**
  21453. * Updates the associated geometry
  21454. * @param geometry the geometry to be updated
  21455. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21456. * @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
  21457. * @returns VertexData.
  21458. */
  21459. updateGeometry(geometry: Geometry): VertexData;
  21460. private _applyTo;
  21461. private _update;
  21462. /**
  21463. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21464. * @param matrix the transforming matrix
  21465. * @returns the VertexData
  21466. */
  21467. transform(matrix: Matrix): VertexData;
  21468. /**
  21469. * Merges the passed VertexData into the current one
  21470. * @param other the VertexData to be merged into the current one
  21471. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21472. * @returns the modified VertexData
  21473. */
  21474. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21475. private _mergeElement;
  21476. private _validate;
  21477. /**
  21478. * Serializes the VertexData
  21479. * @returns a serialized object
  21480. */
  21481. serialize(): any;
  21482. /**
  21483. * Extracts the vertexData from a mesh
  21484. * @param mesh the mesh from which to extract the VertexData
  21485. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21486. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21487. * @returns the object VertexData associated to the passed mesh
  21488. */
  21489. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21490. /**
  21491. * Extracts the vertexData from the geometry
  21492. * @param geometry the geometry from which to extract the VertexData
  21493. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21494. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21495. * @returns the object VertexData associated to the passed mesh
  21496. */
  21497. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21498. private static _ExtractFrom;
  21499. /**
  21500. * Creates the VertexData for a Ribbon
  21501. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21502. * * pathArray array of paths, each of which an array of successive Vector3
  21503. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21504. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21505. * * 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
  21506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21507. * * 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)
  21508. * * 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)
  21509. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21510. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21511. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21512. * @returns the VertexData of the ribbon
  21513. */
  21514. static CreateRibbon(options: {
  21515. pathArray: Vector3[][];
  21516. closeArray?: boolean;
  21517. closePath?: boolean;
  21518. offset?: number;
  21519. sideOrientation?: number;
  21520. frontUVs?: Vector4;
  21521. backUVs?: Vector4;
  21522. invertUV?: boolean;
  21523. uvs?: Vector2[];
  21524. colors?: Color4[];
  21525. }): VertexData;
  21526. /**
  21527. * Creates the VertexData for a box
  21528. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21529. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21530. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21531. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21532. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21533. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21534. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21535. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21536. * * 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)
  21537. * * 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)
  21538. * @returns the VertexData of the box
  21539. */
  21540. static CreateBox(options: {
  21541. size?: number;
  21542. width?: number;
  21543. height?: number;
  21544. depth?: number;
  21545. faceUV?: Vector4[];
  21546. faceColors?: Color4[];
  21547. sideOrientation?: number;
  21548. frontUVs?: Vector4;
  21549. backUVs?: Vector4;
  21550. }): VertexData;
  21551. /**
  21552. * Creates the VertexData for a tiled box
  21553. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21554. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21555. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21556. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21557. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21558. * @returns the VertexData of the box
  21559. */
  21560. static CreateTiledBox(options: {
  21561. pattern?: number;
  21562. width?: number;
  21563. height?: number;
  21564. depth?: number;
  21565. tileSize?: number;
  21566. tileWidth?: number;
  21567. tileHeight?: number;
  21568. alignHorizontal?: number;
  21569. alignVertical?: number;
  21570. faceUV?: Vector4[];
  21571. faceColors?: Color4[];
  21572. sideOrientation?: number;
  21573. }): VertexData;
  21574. /**
  21575. * Creates the VertexData for a tiled plane
  21576. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21577. * * pattern a limited pattern arrangement depending on the number
  21578. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21579. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21580. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21581. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21582. * * 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)
  21583. * * 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)
  21584. * @returns the VertexData of the tiled plane
  21585. */
  21586. static CreateTiledPlane(options: {
  21587. pattern?: number;
  21588. tileSize?: number;
  21589. tileWidth?: number;
  21590. tileHeight?: number;
  21591. size?: number;
  21592. width?: number;
  21593. height?: number;
  21594. alignHorizontal?: number;
  21595. alignVertical?: number;
  21596. sideOrientation?: number;
  21597. frontUVs?: Vector4;
  21598. backUVs?: Vector4;
  21599. }): VertexData;
  21600. /**
  21601. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21602. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21603. * * segments sets the number of horizontal strips optional, default 32
  21604. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21605. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21606. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21607. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21608. * * 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
  21609. * * 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
  21610. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21611. * * 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)
  21612. * * 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)
  21613. * @returns the VertexData of the ellipsoid
  21614. */
  21615. static CreateSphere(options: {
  21616. segments?: number;
  21617. diameter?: number;
  21618. diameterX?: number;
  21619. diameterY?: number;
  21620. diameterZ?: number;
  21621. arc?: number;
  21622. slice?: number;
  21623. sideOrientation?: number;
  21624. frontUVs?: Vector4;
  21625. backUVs?: Vector4;
  21626. }): VertexData;
  21627. /**
  21628. * Creates the VertexData for a cylinder, cone or prism
  21629. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21630. * * height sets the height (y direction) of the cylinder, optional, default 2
  21631. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21632. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21633. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21634. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21635. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21636. * * 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
  21637. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21638. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21639. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21640. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21641. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21642. * * 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)
  21643. * * 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)
  21644. * @returns the VertexData of the cylinder, cone or prism
  21645. */
  21646. static CreateCylinder(options: {
  21647. height?: number;
  21648. diameterTop?: number;
  21649. diameterBottom?: number;
  21650. diameter?: number;
  21651. tessellation?: number;
  21652. subdivisions?: number;
  21653. arc?: number;
  21654. faceColors?: Color4[];
  21655. faceUV?: Vector4[];
  21656. hasRings?: boolean;
  21657. enclose?: boolean;
  21658. sideOrientation?: number;
  21659. frontUVs?: Vector4;
  21660. backUVs?: Vector4;
  21661. }): VertexData;
  21662. /**
  21663. * Creates the VertexData for a torus
  21664. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21665. * * diameter the diameter of the torus, optional default 1
  21666. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21667. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21668. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21669. * * 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)
  21670. * * 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)
  21671. * @returns the VertexData of the torus
  21672. */
  21673. static CreateTorus(options: {
  21674. diameter?: number;
  21675. thickness?: number;
  21676. tessellation?: number;
  21677. sideOrientation?: number;
  21678. frontUVs?: Vector4;
  21679. backUVs?: Vector4;
  21680. }): VertexData;
  21681. /**
  21682. * Creates the VertexData of the LineSystem
  21683. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21684. * - lines an array of lines, each line being an array of successive Vector3
  21685. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21686. * @returns the VertexData of the LineSystem
  21687. */
  21688. static CreateLineSystem(options: {
  21689. lines: Vector3[][];
  21690. colors?: Nullable<Color4[][]>;
  21691. }): VertexData;
  21692. /**
  21693. * Create the VertexData for a DashedLines
  21694. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21695. * - points an array successive Vector3
  21696. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21697. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21698. * - dashNb the intended total number of dashes, optional, default 200
  21699. * @returns the VertexData for the DashedLines
  21700. */
  21701. static CreateDashedLines(options: {
  21702. points: Vector3[];
  21703. dashSize?: number;
  21704. gapSize?: number;
  21705. dashNb?: number;
  21706. }): VertexData;
  21707. /**
  21708. * Creates the VertexData for a Ground
  21709. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21710. * - width the width (x direction) of the ground, optional, default 1
  21711. * - height the height (z direction) of the ground, optional, default 1
  21712. * - subdivisions the number of subdivisions per side, optional, default 1
  21713. * @returns the VertexData of the Ground
  21714. */
  21715. static CreateGround(options: {
  21716. width?: number;
  21717. height?: number;
  21718. subdivisions?: number;
  21719. subdivisionsX?: number;
  21720. subdivisionsY?: number;
  21721. }): VertexData;
  21722. /**
  21723. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21724. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21725. * * xmin the ground minimum X coordinate, optional, default -1
  21726. * * zmin the ground minimum Z coordinate, optional, default -1
  21727. * * xmax the ground maximum X coordinate, optional, default 1
  21728. * * zmax the ground maximum Z coordinate, optional, default 1
  21729. * * 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}
  21730. * * 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}
  21731. * @returns the VertexData of the TiledGround
  21732. */
  21733. static CreateTiledGround(options: {
  21734. xmin: number;
  21735. zmin: number;
  21736. xmax: number;
  21737. zmax: number;
  21738. subdivisions?: {
  21739. w: number;
  21740. h: number;
  21741. };
  21742. precision?: {
  21743. w: number;
  21744. h: number;
  21745. };
  21746. }): VertexData;
  21747. /**
  21748. * Creates the VertexData of the Ground designed from a heightmap
  21749. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21750. * * width the width (x direction) of the ground
  21751. * * height the height (z direction) of the ground
  21752. * * subdivisions the number of subdivisions per side
  21753. * * minHeight the minimum altitude on the ground, optional, default 0
  21754. * * maxHeight the maximum altitude on the ground, optional default 1
  21755. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21756. * * buffer the array holding the image color data
  21757. * * bufferWidth the width of image
  21758. * * bufferHeight the height of image
  21759. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21760. * @returns the VertexData of the Ground designed from a heightmap
  21761. */
  21762. static CreateGroundFromHeightMap(options: {
  21763. width: number;
  21764. height: number;
  21765. subdivisions: number;
  21766. minHeight: number;
  21767. maxHeight: number;
  21768. colorFilter: Color3;
  21769. buffer: Uint8Array;
  21770. bufferWidth: number;
  21771. bufferHeight: number;
  21772. alphaFilter: number;
  21773. }): VertexData;
  21774. /**
  21775. * Creates the VertexData for a Plane
  21776. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21777. * * size sets the width and height of the plane to the value of size, optional default 1
  21778. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21779. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21780. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21781. * * 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)
  21782. * * 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)
  21783. * @returns the VertexData of the box
  21784. */
  21785. static CreatePlane(options: {
  21786. size?: number;
  21787. width?: number;
  21788. height?: number;
  21789. sideOrientation?: number;
  21790. frontUVs?: Vector4;
  21791. backUVs?: Vector4;
  21792. }): VertexData;
  21793. /**
  21794. * Creates the VertexData of the Disc or regular Polygon
  21795. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21796. * * radius the radius of the disc, optional default 0.5
  21797. * * tessellation the number of polygon sides, optional, default 64
  21798. * * 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
  21799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21800. * * 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)
  21801. * * 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)
  21802. * @returns the VertexData of the box
  21803. */
  21804. static CreateDisc(options: {
  21805. radius?: number;
  21806. tessellation?: number;
  21807. arc?: number;
  21808. sideOrientation?: number;
  21809. frontUVs?: Vector4;
  21810. backUVs?: Vector4;
  21811. }): VertexData;
  21812. /**
  21813. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21814. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21815. * @param polygon a mesh built from polygonTriangulation.build()
  21816. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21817. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21818. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21819. * @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)
  21820. * @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)
  21821. * @returns the VertexData of the Polygon
  21822. */
  21823. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21824. /**
  21825. * Creates the VertexData of the IcoSphere
  21826. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21827. * * radius the radius of the IcoSphere, optional default 1
  21828. * * radiusX allows stretching in the x direction, optional, default radius
  21829. * * radiusY allows stretching in the y direction, optional, default radius
  21830. * * radiusZ allows stretching in the z direction, optional, default radius
  21831. * * flat when true creates a flat shaded mesh, optional, default true
  21832. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21833. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21834. * * 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)
  21835. * * 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)
  21836. * @returns the VertexData of the IcoSphere
  21837. */
  21838. static CreateIcoSphere(options: {
  21839. radius?: number;
  21840. radiusX?: number;
  21841. radiusY?: number;
  21842. radiusZ?: number;
  21843. flat?: boolean;
  21844. subdivisions?: number;
  21845. sideOrientation?: number;
  21846. frontUVs?: Vector4;
  21847. backUVs?: Vector4;
  21848. }): VertexData;
  21849. /**
  21850. * Creates the VertexData for a Polyhedron
  21851. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21852. * * type provided types are:
  21853. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21854. * * 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)
  21855. * * size the size of the IcoSphere, optional default 1
  21856. * * sizeX allows stretching in the x direction, optional, default size
  21857. * * sizeY allows stretching in the y direction, optional, default size
  21858. * * sizeZ allows stretching in the z direction, optional, default size
  21859. * * 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
  21860. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21861. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21862. * * flat when true creates a flat shaded mesh, optional, default true
  21863. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21864. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21865. * * 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)
  21866. * * 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)
  21867. * @returns the VertexData of the Polyhedron
  21868. */
  21869. static CreatePolyhedron(options: {
  21870. type?: number;
  21871. size?: number;
  21872. sizeX?: number;
  21873. sizeY?: number;
  21874. sizeZ?: number;
  21875. custom?: any;
  21876. faceUV?: Vector4[];
  21877. faceColors?: Color4[];
  21878. flat?: boolean;
  21879. sideOrientation?: number;
  21880. frontUVs?: Vector4;
  21881. backUVs?: Vector4;
  21882. }): VertexData;
  21883. /**
  21884. * Creates the VertexData for a TorusKnot
  21885. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21886. * * radius the radius of the torus knot, optional, default 2
  21887. * * tube the thickness of the tube, optional, default 0.5
  21888. * * radialSegments the number of sides on each tube segments, optional, default 32
  21889. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21890. * * p the number of windings around the z axis, optional, default 2
  21891. * * q the number of windings around the x axis, optional, default 3
  21892. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21893. * * 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)
  21894. * * 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)
  21895. * @returns the VertexData of the Torus Knot
  21896. */
  21897. static CreateTorusKnot(options: {
  21898. radius?: number;
  21899. tube?: number;
  21900. radialSegments?: number;
  21901. tubularSegments?: number;
  21902. p?: number;
  21903. q?: number;
  21904. sideOrientation?: number;
  21905. frontUVs?: Vector4;
  21906. backUVs?: Vector4;
  21907. }): VertexData;
  21908. /**
  21909. * Compute normals for given positions and indices
  21910. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21911. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21912. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21913. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21914. * * facetNormals : optional array of facet normals (vector3)
  21915. * * facetPositions : optional array of facet positions (vector3)
  21916. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21917. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21918. * * bInfo : optional bounding info, required for facetPartitioning computation
  21919. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21920. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21921. * * useRightHandedSystem: optional boolean to for right handed system computation
  21922. * * depthSort : optional boolean to enable the facet depth sort computation
  21923. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21924. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21925. */
  21926. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21927. facetNormals?: any;
  21928. facetPositions?: any;
  21929. facetPartitioning?: any;
  21930. ratio?: number;
  21931. bInfo?: any;
  21932. bbSize?: Vector3;
  21933. subDiv?: any;
  21934. useRightHandedSystem?: boolean;
  21935. depthSort?: boolean;
  21936. distanceTo?: Vector3;
  21937. depthSortedFacets?: any;
  21938. }): void;
  21939. /** @hidden */
  21940. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21941. /**
  21942. * Applies VertexData created from the imported parameters to the geometry
  21943. * @param parsedVertexData the parsed data from an imported file
  21944. * @param geometry the geometry to apply the VertexData to
  21945. */
  21946. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21947. }
  21948. }
  21949. declare module BABYLON {
  21950. /**
  21951. * Defines a target to use with MorphTargetManager
  21952. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21953. */
  21954. export class MorphTarget implements IAnimatable {
  21955. /** defines the name of the target */
  21956. name: string;
  21957. /**
  21958. * Gets or sets the list of animations
  21959. */
  21960. animations: Animation[];
  21961. private _scene;
  21962. private _positions;
  21963. private _normals;
  21964. private _tangents;
  21965. private _uvs;
  21966. private _influence;
  21967. /**
  21968. * Observable raised when the influence changes
  21969. */
  21970. onInfluenceChanged: Observable<boolean>;
  21971. /** @hidden */
  21972. _onDataLayoutChanged: Observable<void>;
  21973. /**
  21974. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21975. */
  21976. influence: number;
  21977. /**
  21978. * Gets or sets the id of the morph Target
  21979. */
  21980. id: string;
  21981. private _animationPropertiesOverride;
  21982. /**
  21983. * Gets or sets the animation properties override
  21984. */
  21985. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21986. /**
  21987. * Creates a new MorphTarget
  21988. * @param name defines the name of the target
  21989. * @param influence defines the influence to use
  21990. * @param scene defines the scene the morphtarget belongs to
  21991. */
  21992. constructor(
  21993. /** defines the name of the target */
  21994. name: string, influence?: number, scene?: Nullable<Scene>);
  21995. /**
  21996. * Gets a boolean defining if the target contains position data
  21997. */
  21998. readonly hasPositions: boolean;
  21999. /**
  22000. * Gets a boolean defining if the target contains normal data
  22001. */
  22002. readonly hasNormals: boolean;
  22003. /**
  22004. * Gets a boolean defining if the target contains tangent data
  22005. */
  22006. readonly hasTangents: boolean;
  22007. /**
  22008. * Gets a boolean defining if the target contains texture coordinates data
  22009. */
  22010. readonly hasUVs: boolean;
  22011. /**
  22012. * Affects position data to this target
  22013. * @param data defines the position data to use
  22014. */
  22015. setPositions(data: Nullable<FloatArray>): void;
  22016. /**
  22017. * Gets the position data stored in this target
  22018. * @returns a FloatArray containing the position data (or null if not present)
  22019. */
  22020. getPositions(): Nullable<FloatArray>;
  22021. /**
  22022. * Affects normal data to this target
  22023. * @param data defines the normal data to use
  22024. */
  22025. setNormals(data: Nullable<FloatArray>): void;
  22026. /**
  22027. * Gets the normal data stored in this target
  22028. * @returns a FloatArray containing the normal data (or null if not present)
  22029. */
  22030. getNormals(): Nullable<FloatArray>;
  22031. /**
  22032. * Affects tangent data to this target
  22033. * @param data defines the tangent data to use
  22034. */
  22035. setTangents(data: Nullable<FloatArray>): void;
  22036. /**
  22037. * Gets the tangent data stored in this target
  22038. * @returns a FloatArray containing the tangent data (or null if not present)
  22039. */
  22040. getTangents(): Nullable<FloatArray>;
  22041. /**
  22042. * Affects texture coordinates data to this target
  22043. * @param data defines the texture coordinates data to use
  22044. */
  22045. setUVs(data: Nullable<FloatArray>): void;
  22046. /**
  22047. * Gets the texture coordinates data stored in this target
  22048. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22049. */
  22050. getUVs(): Nullable<FloatArray>;
  22051. /**
  22052. * Serializes the current target into a Serialization object
  22053. * @returns the serialized object
  22054. */
  22055. serialize(): any;
  22056. /**
  22057. * Returns the string "MorphTarget"
  22058. * @returns "MorphTarget"
  22059. */
  22060. getClassName(): string;
  22061. /**
  22062. * Creates a new target from serialized data
  22063. * @param serializationObject defines the serialized data to use
  22064. * @returns a new MorphTarget
  22065. */
  22066. static Parse(serializationObject: any): MorphTarget;
  22067. /**
  22068. * Creates a MorphTarget from mesh data
  22069. * @param mesh defines the source mesh
  22070. * @param name defines the name to use for the new target
  22071. * @param influence defines the influence to attach to the target
  22072. * @returns a new MorphTarget
  22073. */
  22074. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22075. }
  22076. }
  22077. declare module BABYLON {
  22078. /**
  22079. * This class is used to deform meshes using morphing between different targets
  22080. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22081. */
  22082. export class MorphTargetManager {
  22083. private _targets;
  22084. private _targetInfluenceChangedObservers;
  22085. private _targetDataLayoutChangedObservers;
  22086. private _activeTargets;
  22087. private _scene;
  22088. private _influences;
  22089. private _supportsNormals;
  22090. private _supportsTangents;
  22091. private _supportsUVs;
  22092. private _vertexCount;
  22093. private _uniqueId;
  22094. private _tempInfluences;
  22095. /**
  22096. * Gets or sets a boolean indicating if normals must be morphed
  22097. */
  22098. enableNormalMorphing: boolean;
  22099. /**
  22100. * Gets or sets a boolean indicating if tangents must be morphed
  22101. */
  22102. enableTangentMorphing: boolean;
  22103. /**
  22104. * Gets or sets a boolean indicating if UV must be morphed
  22105. */
  22106. enableUVMorphing: boolean;
  22107. /**
  22108. * Creates a new MorphTargetManager
  22109. * @param scene defines the current scene
  22110. */
  22111. constructor(scene?: Nullable<Scene>);
  22112. /**
  22113. * Gets the unique ID of this manager
  22114. */
  22115. readonly uniqueId: number;
  22116. /**
  22117. * Gets the number of vertices handled by this manager
  22118. */
  22119. readonly vertexCount: number;
  22120. /**
  22121. * Gets a boolean indicating if this manager supports morphing of normals
  22122. */
  22123. readonly supportsNormals: boolean;
  22124. /**
  22125. * Gets a boolean indicating if this manager supports morphing of tangents
  22126. */
  22127. readonly supportsTangents: boolean;
  22128. /**
  22129. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22130. */
  22131. readonly supportsUVs: boolean;
  22132. /**
  22133. * Gets the number of targets stored in this manager
  22134. */
  22135. readonly numTargets: number;
  22136. /**
  22137. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22138. */
  22139. readonly numInfluencers: number;
  22140. /**
  22141. * Gets the list of influences (one per target)
  22142. */
  22143. readonly influences: Float32Array;
  22144. /**
  22145. * Gets the active target at specified index. An active target is a target with an influence > 0
  22146. * @param index defines the index to check
  22147. * @returns the requested target
  22148. */
  22149. getActiveTarget(index: number): MorphTarget;
  22150. /**
  22151. * Gets the target at specified index
  22152. * @param index defines the index to check
  22153. * @returns the requested target
  22154. */
  22155. getTarget(index: number): MorphTarget;
  22156. /**
  22157. * Add a new target to this manager
  22158. * @param target defines the target to add
  22159. */
  22160. addTarget(target: MorphTarget): void;
  22161. /**
  22162. * Removes a target from the manager
  22163. * @param target defines the target to remove
  22164. */
  22165. removeTarget(target: MorphTarget): void;
  22166. /**
  22167. * Serializes the current manager into a Serialization object
  22168. * @returns the serialized object
  22169. */
  22170. serialize(): any;
  22171. private _syncActiveTargets;
  22172. /**
  22173. * Syncrhonize the targets with all the meshes using this morph target manager
  22174. */
  22175. synchronize(): void;
  22176. /**
  22177. * Creates a new MorphTargetManager from serialized data
  22178. * @param serializationObject defines the serialized data
  22179. * @param scene defines the hosting scene
  22180. * @returns the new MorphTargetManager
  22181. */
  22182. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22183. }
  22184. }
  22185. declare module BABYLON {
  22186. /**
  22187. * Class used to represent a specific level of detail of a mesh
  22188. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22189. */
  22190. export class MeshLODLevel {
  22191. /** Defines the distance where this level should start being displayed */
  22192. distance: number;
  22193. /** Defines the mesh to use to render this level */
  22194. mesh: Nullable<Mesh>;
  22195. /**
  22196. * Creates a new LOD level
  22197. * @param distance defines the distance where this level should star being displayed
  22198. * @param mesh defines the mesh to use to render this level
  22199. */
  22200. constructor(
  22201. /** Defines the distance where this level should start being displayed */
  22202. distance: number,
  22203. /** Defines the mesh to use to render this level */
  22204. mesh: Nullable<Mesh>);
  22205. }
  22206. }
  22207. declare module BABYLON {
  22208. /**
  22209. * Mesh representing the gorund
  22210. */
  22211. export class GroundMesh extends Mesh {
  22212. /** If octree should be generated */
  22213. generateOctree: boolean;
  22214. private _heightQuads;
  22215. /** @hidden */
  22216. _subdivisionsX: number;
  22217. /** @hidden */
  22218. _subdivisionsY: number;
  22219. /** @hidden */
  22220. _width: number;
  22221. /** @hidden */
  22222. _height: number;
  22223. /** @hidden */
  22224. _minX: number;
  22225. /** @hidden */
  22226. _maxX: number;
  22227. /** @hidden */
  22228. _minZ: number;
  22229. /** @hidden */
  22230. _maxZ: number;
  22231. constructor(name: string, scene: Scene);
  22232. /**
  22233. * "GroundMesh"
  22234. * @returns "GroundMesh"
  22235. */
  22236. getClassName(): string;
  22237. /**
  22238. * The minimum of x and y subdivisions
  22239. */
  22240. readonly subdivisions: number;
  22241. /**
  22242. * X subdivisions
  22243. */
  22244. readonly subdivisionsX: number;
  22245. /**
  22246. * Y subdivisions
  22247. */
  22248. readonly subdivisionsY: number;
  22249. /**
  22250. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22251. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22252. * @param chunksCount the number of subdivisions for x and y
  22253. * @param octreeBlocksSize (Default: 32)
  22254. */
  22255. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22256. /**
  22257. * Returns a height (y) value in the Worl system :
  22258. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22259. * @param x x coordinate
  22260. * @param z z coordinate
  22261. * @returns the ground y position if (x, z) are outside the ground surface.
  22262. */
  22263. getHeightAtCoordinates(x: number, z: number): number;
  22264. /**
  22265. * Returns a normalized vector (Vector3) orthogonal to the ground
  22266. * at the ground coordinates (x, z) expressed in the World system.
  22267. * @param x x coordinate
  22268. * @param z z coordinate
  22269. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22270. */
  22271. getNormalAtCoordinates(x: number, z: number): Vector3;
  22272. /**
  22273. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22274. * at the ground coordinates (x, z) expressed in the World system.
  22275. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22276. * @param x x coordinate
  22277. * @param z z coordinate
  22278. * @param ref vector to store the result
  22279. * @returns the GroundMesh.
  22280. */
  22281. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22282. /**
  22283. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22284. * if the ground has been updated.
  22285. * This can be used in the render loop.
  22286. * @returns the GroundMesh.
  22287. */
  22288. updateCoordinateHeights(): GroundMesh;
  22289. private _getFacetAt;
  22290. private _initHeightQuads;
  22291. private _computeHeightQuads;
  22292. /**
  22293. * Serializes this ground mesh
  22294. * @param serializationObject object to write serialization to
  22295. */
  22296. serialize(serializationObject: any): void;
  22297. /**
  22298. * Parses a serialized ground mesh
  22299. * @param parsedMesh the serialized mesh
  22300. * @param scene the scene to create the ground mesh in
  22301. * @returns the created ground mesh
  22302. */
  22303. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22304. }
  22305. }
  22306. declare module BABYLON {
  22307. /**
  22308. * Interface for Physics-Joint data
  22309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22310. */
  22311. export interface PhysicsJointData {
  22312. /**
  22313. * The main pivot of the joint
  22314. */
  22315. mainPivot?: Vector3;
  22316. /**
  22317. * The connected pivot of the joint
  22318. */
  22319. connectedPivot?: Vector3;
  22320. /**
  22321. * The main axis of the joint
  22322. */
  22323. mainAxis?: Vector3;
  22324. /**
  22325. * The connected axis of the joint
  22326. */
  22327. connectedAxis?: Vector3;
  22328. /**
  22329. * The collision of the joint
  22330. */
  22331. collision?: boolean;
  22332. /**
  22333. * Native Oimo/Cannon/Energy data
  22334. */
  22335. nativeParams?: any;
  22336. }
  22337. /**
  22338. * This is a holder class for the physics joint created by the physics plugin
  22339. * It holds a set of functions to control the underlying joint
  22340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22341. */
  22342. export class PhysicsJoint {
  22343. /**
  22344. * The type of the physics joint
  22345. */
  22346. type: number;
  22347. /**
  22348. * The data for the physics joint
  22349. */
  22350. jointData: PhysicsJointData;
  22351. private _physicsJoint;
  22352. protected _physicsPlugin: IPhysicsEnginePlugin;
  22353. /**
  22354. * Initializes the physics joint
  22355. * @param type The type of the physics joint
  22356. * @param jointData The data for the physics joint
  22357. */
  22358. constructor(
  22359. /**
  22360. * The type of the physics joint
  22361. */
  22362. type: number,
  22363. /**
  22364. * The data for the physics joint
  22365. */
  22366. jointData: PhysicsJointData);
  22367. /**
  22368. * Gets the physics joint
  22369. */
  22370. /**
  22371. * Sets the physics joint
  22372. */
  22373. physicsJoint: any;
  22374. /**
  22375. * Sets the physics plugin
  22376. */
  22377. physicsPlugin: IPhysicsEnginePlugin;
  22378. /**
  22379. * Execute a function that is physics-plugin specific.
  22380. * @param {Function} func the function that will be executed.
  22381. * It accepts two parameters: the physics world and the physics joint
  22382. */
  22383. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22384. /**
  22385. * Distance-Joint type
  22386. */
  22387. static DistanceJoint: number;
  22388. /**
  22389. * Hinge-Joint type
  22390. */
  22391. static HingeJoint: number;
  22392. /**
  22393. * Ball-and-Socket joint type
  22394. */
  22395. static BallAndSocketJoint: number;
  22396. /**
  22397. * Wheel-Joint type
  22398. */
  22399. static WheelJoint: number;
  22400. /**
  22401. * Slider-Joint type
  22402. */
  22403. static SliderJoint: number;
  22404. /**
  22405. * Prismatic-Joint type
  22406. */
  22407. static PrismaticJoint: number;
  22408. /**
  22409. * Universal-Joint type
  22410. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22411. */
  22412. static UniversalJoint: number;
  22413. /**
  22414. * Hinge-Joint 2 type
  22415. */
  22416. static Hinge2Joint: number;
  22417. /**
  22418. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22419. */
  22420. static PointToPointJoint: number;
  22421. /**
  22422. * Spring-Joint type
  22423. */
  22424. static SpringJoint: number;
  22425. /**
  22426. * Lock-Joint type
  22427. */
  22428. static LockJoint: number;
  22429. }
  22430. /**
  22431. * A class representing a physics distance joint
  22432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22433. */
  22434. export class DistanceJoint extends PhysicsJoint {
  22435. /**
  22436. *
  22437. * @param jointData The data for the Distance-Joint
  22438. */
  22439. constructor(jointData: DistanceJointData);
  22440. /**
  22441. * Update the predefined distance.
  22442. * @param maxDistance The maximum preferred distance
  22443. * @param minDistance The minimum preferred distance
  22444. */
  22445. updateDistance(maxDistance: number, minDistance?: number): void;
  22446. }
  22447. /**
  22448. * Represents a Motor-Enabled Joint
  22449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22450. */
  22451. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22452. /**
  22453. * Initializes the Motor-Enabled Joint
  22454. * @param type The type of the joint
  22455. * @param jointData The physica joint data for the joint
  22456. */
  22457. constructor(type: number, jointData: PhysicsJointData);
  22458. /**
  22459. * Set the motor values.
  22460. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22461. * @param force the force to apply
  22462. * @param maxForce max force for this motor.
  22463. */
  22464. setMotor(force?: number, maxForce?: number): void;
  22465. /**
  22466. * Set the motor's limits.
  22467. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22468. * @param upperLimit The upper limit of the motor
  22469. * @param lowerLimit The lower limit of the motor
  22470. */
  22471. setLimit(upperLimit: number, lowerLimit?: number): void;
  22472. }
  22473. /**
  22474. * This class represents a single physics Hinge-Joint
  22475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22476. */
  22477. export class HingeJoint extends MotorEnabledJoint {
  22478. /**
  22479. * Initializes the Hinge-Joint
  22480. * @param jointData The joint data for the Hinge-Joint
  22481. */
  22482. constructor(jointData: PhysicsJointData);
  22483. /**
  22484. * Set the motor values.
  22485. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22486. * @param {number} force the force to apply
  22487. * @param {number} maxForce max force for this motor.
  22488. */
  22489. setMotor(force?: number, maxForce?: number): void;
  22490. /**
  22491. * Set the motor's limits.
  22492. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22493. * @param upperLimit The upper limit of the motor
  22494. * @param lowerLimit The lower limit of the motor
  22495. */
  22496. setLimit(upperLimit: number, lowerLimit?: number): void;
  22497. }
  22498. /**
  22499. * This class represents a dual hinge physics joint (same as wheel joint)
  22500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22501. */
  22502. export class Hinge2Joint extends MotorEnabledJoint {
  22503. /**
  22504. * Initializes the Hinge2-Joint
  22505. * @param jointData The joint data for the Hinge2-Joint
  22506. */
  22507. constructor(jointData: PhysicsJointData);
  22508. /**
  22509. * Set the motor values.
  22510. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22511. * @param {number} targetSpeed the speed the motor is to reach
  22512. * @param {number} maxForce max force for this motor.
  22513. * @param {motorIndex} the motor's index, 0 or 1.
  22514. */
  22515. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22516. /**
  22517. * Set the motor limits.
  22518. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22519. * @param {number} upperLimit the upper limit
  22520. * @param {number} lowerLimit lower limit
  22521. * @param {motorIndex} the motor's index, 0 or 1.
  22522. */
  22523. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22524. }
  22525. /**
  22526. * Interface for a motor enabled joint
  22527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22528. */
  22529. export interface IMotorEnabledJoint {
  22530. /**
  22531. * Physics joint
  22532. */
  22533. physicsJoint: any;
  22534. /**
  22535. * Sets the motor of the motor-enabled joint
  22536. * @param force The force of the motor
  22537. * @param maxForce The maximum force of the motor
  22538. * @param motorIndex The index of the motor
  22539. */
  22540. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22541. /**
  22542. * Sets the limit of the motor
  22543. * @param upperLimit The upper limit of the motor
  22544. * @param lowerLimit The lower limit of the motor
  22545. * @param motorIndex The index of the motor
  22546. */
  22547. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22548. }
  22549. /**
  22550. * Joint data for a Distance-Joint
  22551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22552. */
  22553. export interface DistanceJointData extends PhysicsJointData {
  22554. /**
  22555. * Max distance the 2 joint objects can be apart
  22556. */
  22557. maxDistance: number;
  22558. }
  22559. /**
  22560. * Joint data from a spring joint
  22561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22562. */
  22563. export interface SpringJointData extends PhysicsJointData {
  22564. /**
  22565. * Length of the spring
  22566. */
  22567. length: number;
  22568. /**
  22569. * Stiffness of the spring
  22570. */
  22571. stiffness: number;
  22572. /**
  22573. * Damping of the spring
  22574. */
  22575. damping: number;
  22576. /** this callback will be called when applying the force to the impostors. */
  22577. forceApplicationCallback: () => void;
  22578. }
  22579. }
  22580. declare module BABYLON {
  22581. /**
  22582. * Holds the data for the raycast result
  22583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22584. */
  22585. export class PhysicsRaycastResult {
  22586. private _hasHit;
  22587. private _hitDistance;
  22588. private _hitNormalWorld;
  22589. private _hitPointWorld;
  22590. private _rayFromWorld;
  22591. private _rayToWorld;
  22592. /**
  22593. * Gets if there was a hit
  22594. */
  22595. readonly hasHit: boolean;
  22596. /**
  22597. * Gets the distance from the hit
  22598. */
  22599. readonly hitDistance: number;
  22600. /**
  22601. * Gets the hit normal/direction in the world
  22602. */
  22603. readonly hitNormalWorld: Vector3;
  22604. /**
  22605. * Gets the hit point in the world
  22606. */
  22607. readonly hitPointWorld: Vector3;
  22608. /**
  22609. * Gets the ray "start point" of the ray in the world
  22610. */
  22611. readonly rayFromWorld: Vector3;
  22612. /**
  22613. * Gets the ray "end point" of the ray in the world
  22614. */
  22615. readonly rayToWorld: Vector3;
  22616. /**
  22617. * Sets the hit data (normal & point in world space)
  22618. * @param hitNormalWorld defines the normal in world space
  22619. * @param hitPointWorld defines the point in world space
  22620. */
  22621. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22622. /**
  22623. * Sets the distance from the start point to the hit point
  22624. * @param distance
  22625. */
  22626. setHitDistance(distance: number): void;
  22627. /**
  22628. * Calculates the distance manually
  22629. */
  22630. calculateHitDistance(): void;
  22631. /**
  22632. * Resets all the values to default
  22633. * @param from The from point on world space
  22634. * @param to The to point on world space
  22635. */
  22636. reset(from?: Vector3, to?: Vector3): void;
  22637. }
  22638. /**
  22639. * Interface for the size containing width and height
  22640. */
  22641. interface IXYZ {
  22642. /**
  22643. * X
  22644. */
  22645. x: number;
  22646. /**
  22647. * Y
  22648. */
  22649. y: number;
  22650. /**
  22651. * Z
  22652. */
  22653. z: number;
  22654. }
  22655. }
  22656. declare module BABYLON {
  22657. /**
  22658. * Interface used to describe a physics joint
  22659. */
  22660. export interface PhysicsImpostorJoint {
  22661. /** Defines the main impostor to which the joint is linked */
  22662. mainImpostor: PhysicsImpostor;
  22663. /** Defines the impostor that is connected to the main impostor using this joint */
  22664. connectedImpostor: PhysicsImpostor;
  22665. /** Defines the joint itself */
  22666. joint: PhysicsJoint;
  22667. }
  22668. /** @hidden */
  22669. export interface IPhysicsEnginePlugin {
  22670. world: any;
  22671. name: string;
  22672. setGravity(gravity: Vector3): void;
  22673. setTimeStep(timeStep: number): void;
  22674. getTimeStep(): number;
  22675. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22676. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22677. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22678. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22679. removePhysicsBody(impostor: PhysicsImpostor): void;
  22680. generateJoint(joint: PhysicsImpostorJoint): void;
  22681. removeJoint(joint: PhysicsImpostorJoint): void;
  22682. isSupported(): boolean;
  22683. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22684. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22685. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22686. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22687. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22688. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22689. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22690. getBodyMass(impostor: PhysicsImpostor): number;
  22691. getBodyFriction(impostor: PhysicsImpostor): number;
  22692. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22693. getBodyRestitution(impostor: PhysicsImpostor): number;
  22694. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22695. getBodyPressure?(impostor: PhysicsImpostor): number;
  22696. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22697. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22698. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22699. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22700. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22701. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22702. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22703. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22704. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22705. sleepBody(impostor: PhysicsImpostor): void;
  22706. wakeUpBody(impostor: PhysicsImpostor): void;
  22707. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22708. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22709. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22710. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22711. getRadius(impostor: PhysicsImpostor): number;
  22712. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22713. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22714. dispose(): void;
  22715. }
  22716. /**
  22717. * Interface used to define a physics engine
  22718. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22719. */
  22720. export interface IPhysicsEngine {
  22721. /**
  22722. * Gets the gravity vector used by the simulation
  22723. */
  22724. gravity: Vector3;
  22725. /**
  22726. * Sets the gravity vector used by the simulation
  22727. * @param gravity defines the gravity vector to use
  22728. */
  22729. setGravity(gravity: Vector3): void;
  22730. /**
  22731. * Set the time step of the physics engine.
  22732. * Default is 1/60.
  22733. * To slow it down, enter 1/600 for example.
  22734. * To speed it up, 1/30
  22735. * @param newTimeStep the new timestep to apply to this world.
  22736. */
  22737. setTimeStep(newTimeStep: number): void;
  22738. /**
  22739. * Get the time step of the physics engine.
  22740. * @returns the current time step
  22741. */
  22742. getTimeStep(): number;
  22743. /**
  22744. * Release all resources
  22745. */
  22746. dispose(): void;
  22747. /**
  22748. * Gets the name of the current physics plugin
  22749. * @returns the name of the plugin
  22750. */
  22751. getPhysicsPluginName(): string;
  22752. /**
  22753. * Adding a new impostor for the impostor tracking.
  22754. * This will be done by the impostor itself.
  22755. * @param impostor the impostor to add
  22756. */
  22757. addImpostor(impostor: PhysicsImpostor): void;
  22758. /**
  22759. * Remove an impostor from the engine.
  22760. * This impostor and its mesh will not longer be updated by the physics engine.
  22761. * @param impostor the impostor to remove
  22762. */
  22763. removeImpostor(impostor: PhysicsImpostor): void;
  22764. /**
  22765. * Add a joint to the physics engine
  22766. * @param mainImpostor defines the main impostor to which the joint is added.
  22767. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22768. * @param joint defines the joint that will connect both impostors.
  22769. */
  22770. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22771. /**
  22772. * Removes a joint from the simulation
  22773. * @param mainImpostor defines the impostor used with the joint
  22774. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22775. * @param joint defines the joint to remove
  22776. */
  22777. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22778. /**
  22779. * Gets the current plugin used to run the simulation
  22780. * @returns current plugin
  22781. */
  22782. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22783. /**
  22784. * Gets the list of physic impostors
  22785. * @returns an array of PhysicsImpostor
  22786. */
  22787. getImpostors(): Array<PhysicsImpostor>;
  22788. /**
  22789. * Gets the impostor for a physics enabled object
  22790. * @param object defines the object impersonated by the impostor
  22791. * @returns the PhysicsImpostor or null if not found
  22792. */
  22793. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22794. /**
  22795. * Gets the impostor for a physics body object
  22796. * @param body defines physics body used by the impostor
  22797. * @returns the PhysicsImpostor or null if not found
  22798. */
  22799. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22800. /**
  22801. * Does a raycast in the physics world
  22802. * @param from when should the ray start?
  22803. * @param to when should the ray end?
  22804. * @returns PhysicsRaycastResult
  22805. */
  22806. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22807. /**
  22808. * Called by the scene. No need to call it.
  22809. * @param delta defines the timespam between frames
  22810. */
  22811. _step(delta: number): void;
  22812. }
  22813. }
  22814. declare module BABYLON {
  22815. /**
  22816. * The interface for the physics imposter parameters
  22817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22818. */
  22819. export interface PhysicsImpostorParameters {
  22820. /**
  22821. * The mass of the physics imposter
  22822. */
  22823. mass: number;
  22824. /**
  22825. * The friction of the physics imposter
  22826. */
  22827. friction?: number;
  22828. /**
  22829. * The coefficient of restitution of the physics imposter
  22830. */
  22831. restitution?: number;
  22832. /**
  22833. * The native options of the physics imposter
  22834. */
  22835. nativeOptions?: any;
  22836. /**
  22837. * Specifies if the parent should be ignored
  22838. */
  22839. ignoreParent?: boolean;
  22840. /**
  22841. * Specifies if bi-directional transformations should be disabled
  22842. */
  22843. disableBidirectionalTransformation?: boolean;
  22844. /**
  22845. * The pressure inside the physics imposter, soft object only
  22846. */
  22847. pressure?: number;
  22848. /**
  22849. * The stiffness the physics imposter, soft object only
  22850. */
  22851. stiffness?: number;
  22852. /**
  22853. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22854. */
  22855. velocityIterations?: number;
  22856. /**
  22857. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22858. */
  22859. positionIterations?: number;
  22860. /**
  22861. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22862. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22863. * Add to fix multiple points
  22864. */
  22865. fixedPoints?: number;
  22866. /**
  22867. * The collision margin around a soft object
  22868. */
  22869. margin?: number;
  22870. /**
  22871. * The collision margin around a soft object
  22872. */
  22873. damping?: number;
  22874. /**
  22875. * The path for a rope based on an extrusion
  22876. */
  22877. path?: any;
  22878. /**
  22879. * The shape of an extrusion used for a rope based on an extrusion
  22880. */
  22881. shape?: any;
  22882. }
  22883. /**
  22884. * Interface for a physics-enabled object
  22885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22886. */
  22887. export interface IPhysicsEnabledObject {
  22888. /**
  22889. * The position of the physics-enabled object
  22890. */
  22891. position: Vector3;
  22892. /**
  22893. * The rotation of the physics-enabled object
  22894. */
  22895. rotationQuaternion: Nullable<Quaternion>;
  22896. /**
  22897. * The scale of the physics-enabled object
  22898. */
  22899. scaling: Vector3;
  22900. /**
  22901. * The rotation of the physics-enabled object
  22902. */
  22903. rotation?: Vector3;
  22904. /**
  22905. * The parent of the physics-enabled object
  22906. */
  22907. parent?: any;
  22908. /**
  22909. * The bounding info of the physics-enabled object
  22910. * @returns The bounding info of the physics-enabled object
  22911. */
  22912. getBoundingInfo(): BoundingInfo;
  22913. /**
  22914. * Computes the world matrix
  22915. * @param force Specifies if the world matrix should be computed by force
  22916. * @returns A world matrix
  22917. */
  22918. computeWorldMatrix(force: boolean): Matrix;
  22919. /**
  22920. * Gets the world matrix
  22921. * @returns A world matrix
  22922. */
  22923. getWorldMatrix?(): Matrix;
  22924. /**
  22925. * Gets the child meshes
  22926. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22927. * @returns An array of abstract meshes
  22928. */
  22929. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22930. /**
  22931. * Gets the vertex data
  22932. * @param kind The type of vertex data
  22933. * @returns A nullable array of numbers, or a float32 array
  22934. */
  22935. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22936. /**
  22937. * Gets the indices from the mesh
  22938. * @returns A nullable array of index arrays
  22939. */
  22940. getIndices?(): Nullable<IndicesArray>;
  22941. /**
  22942. * Gets the scene from the mesh
  22943. * @returns the indices array or null
  22944. */
  22945. getScene?(): Scene;
  22946. /**
  22947. * Gets the absolute position from the mesh
  22948. * @returns the absolute position
  22949. */
  22950. getAbsolutePosition(): Vector3;
  22951. /**
  22952. * Gets the absolute pivot point from the mesh
  22953. * @returns the absolute pivot point
  22954. */
  22955. getAbsolutePivotPoint(): Vector3;
  22956. /**
  22957. * Rotates the mesh
  22958. * @param axis The axis of rotation
  22959. * @param amount The amount of rotation
  22960. * @param space The space of the rotation
  22961. * @returns The rotation transform node
  22962. */
  22963. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22964. /**
  22965. * Translates the mesh
  22966. * @param axis The axis of translation
  22967. * @param distance The distance of translation
  22968. * @param space The space of the translation
  22969. * @returns The transform node
  22970. */
  22971. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22972. /**
  22973. * Sets the absolute position of the mesh
  22974. * @param absolutePosition The absolute position of the mesh
  22975. * @returns The transform node
  22976. */
  22977. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22978. /**
  22979. * Gets the class name of the mesh
  22980. * @returns The class name
  22981. */
  22982. getClassName(): string;
  22983. }
  22984. /**
  22985. * Represents a physics imposter
  22986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22987. */
  22988. export class PhysicsImpostor {
  22989. /**
  22990. * The physics-enabled object used as the physics imposter
  22991. */
  22992. object: IPhysicsEnabledObject;
  22993. /**
  22994. * The type of the physics imposter
  22995. */
  22996. type: number;
  22997. private _options;
  22998. private _scene?;
  22999. /**
  23000. * The default object size of the imposter
  23001. */
  23002. static DEFAULT_OBJECT_SIZE: Vector3;
  23003. /**
  23004. * The identity quaternion of the imposter
  23005. */
  23006. static IDENTITY_QUATERNION: Quaternion;
  23007. /** @hidden */
  23008. _pluginData: any;
  23009. private _physicsEngine;
  23010. private _physicsBody;
  23011. private _bodyUpdateRequired;
  23012. private _onBeforePhysicsStepCallbacks;
  23013. private _onAfterPhysicsStepCallbacks;
  23014. /** @hidden */
  23015. _onPhysicsCollideCallbacks: Array<{
  23016. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23017. otherImpostors: Array<PhysicsImpostor>;
  23018. }>;
  23019. private _deltaPosition;
  23020. private _deltaRotation;
  23021. private _deltaRotationConjugated;
  23022. /** @hidden */
  23023. _isFromLine: boolean;
  23024. private _parent;
  23025. private _isDisposed;
  23026. private static _tmpVecs;
  23027. private static _tmpQuat;
  23028. /**
  23029. * Specifies if the physics imposter is disposed
  23030. */
  23031. readonly isDisposed: boolean;
  23032. /**
  23033. * Gets the mass of the physics imposter
  23034. */
  23035. mass: number;
  23036. /**
  23037. * Gets the coefficient of friction
  23038. */
  23039. /**
  23040. * Sets the coefficient of friction
  23041. */
  23042. friction: number;
  23043. /**
  23044. * Gets the coefficient of restitution
  23045. */
  23046. /**
  23047. * Sets the coefficient of restitution
  23048. */
  23049. restitution: number;
  23050. /**
  23051. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23052. */
  23053. /**
  23054. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23055. */
  23056. pressure: number;
  23057. /**
  23058. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23059. */
  23060. /**
  23061. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23062. */
  23063. stiffness: number;
  23064. /**
  23065. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23066. */
  23067. /**
  23068. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23069. */
  23070. velocityIterations: number;
  23071. /**
  23072. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23073. */
  23074. /**
  23075. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23076. */
  23077. positionIterations: number;
  23078. /**
  23079. * The unique id of the physics imposter
  23080. * set by the physics engine when adding this impostor to the array
  23081. */
  23082. uniqueId: number;
  23083. /**
  23084. * @hidden
  23085. */
  23086. soft: boolean;
  23087. /**
  23088. * @hidden
  23089. */
  23090. segments: number;
  23091. private _joints;
  23092. /**
  23093. * Initializes the physics imposter
  23094. * @param object The physics-enabled object used as the physics imposter
  23095. * @param type The type of the physics imposter
  23096. * @param _options The options for the physics imposter
  23097. * @param _scene The Babylon scene
  23098. */
  23099. constructor(
  23100. /**
  23101. * The physics-enabled object used as the physics imposter
  23102. */
  23103. object: IPhysicsEnabledObject,
  23104. /**
  23105. * The type of the physics imposter
  23106. */
  23107. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23108. /**
  23109. * This function will completly initialize this impostor.
  23110. * It will create a new body - but only if this mesh has no parent.
  23111. * If it has, this impostor will not be used other than to define the impostor
  23112. * of the child mesh.
  23113. * @hidden
  23114. */
  23115. _init(): void;
  23116. private _getPhysicsParent;
  23117. /**
  23118. * Should a new body be generated.
  23119. * @returns boolean specifying if body initialization is required
  23120. */
  23121. isBodyInitRequired(): boolean;
  23122. /**
  23123. * Sets the updated scaling
  23124. * @param updated Specifies if the scaling is updated
  23125. */
  23126. setScalingUpdated(): void;
  23127. /**
  23128. * Force a regeneration of this or the parent's impostor's body.
  23129. * Use under cautious - This will remove all joints already implemented.
  23130. */
  23131. forceUpdate(): void;
  23132. /**
  23133. * Gets the body that holds this impostor. Either its own, or its parent.
  23134. */
  23135. /**
  23136. * Set the physics body. Used mainly by the physics engine/plugin
  23137. */
  23138. physicsBody: any;
  23139. /**
  23140. * Get the parent of the physics imposter
  23141. * @returns Physics imposter or null
  23142. */
  23143. /**
  23144. * Sets the parent of the physics imposter
  23145. */
  23146. parent: Nullable<PhysicsImpostor>;
  23147. /**
  23148. * Resets the update flags
  23149. */
  23150. resetUpdateFlags(): void;
  23151. /**
  23152. * Gets the object extend size
  23153. * @returns the object extend size
  23154. */
  23155. getObjectExtendSize(): Vector3;
  23156. /**
  23157. * Gets the object center
  23158. * @returns The object center
  23159. */
  23160. getObjectCenter(): Vector3;
  23161. /**
  23162. * Get a specific parametes from the options parameter
  23163. * @param paramName The object parameter name
  23164. * @returns The object parameter
  23165. */
  23166. getParam(paramName: string): any;
  23167. /**
  23168. * Sets a specific parameter in the options given to the physics plugin
  23169. * @param paramName The parameter name
  23170. * @param value The value of the parameter
  23171. */
  23172. setParam(paramName: string, value: number): void;
  23173. /**
  23174. * Specifically change the body's mass option. Won't recreate the physics body object
  23175. * @param mass The mass of the physics imposter
  23176. */
  23177. setMass(mass: number): void;
  23178. /**
  23179. * Gets the linear velocity
  23180. * @returns linear velocity or null
  23181. */
  23182. getLinearVelocity(): Nullable<Vector3>;
  23183. /**
  23184. * Sets the linear velocity
  23185. * @param velocity linear velocity or null
  23186. */
  23187. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23188. /**
  23189. * Gets the angular velocity
  23190. * @returns angular velocity or null
  23191. */
  23192. getAngularVelocity(): Nullable<Vector3>;
  23193. /**
  23194. * Sets the angular velocity
  23195. * @param velocity The velocity or null
  23196. */
  23197. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23198. /**
  23199. * Execute a function with the physics plugin native code
  23200. * Provide a function the will have two variables - the world object and the physics body object
  23201. * @param func The function to execute with the physics plugin native code
  23202. */
  23203. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23204. /**
  23205. * Register a function that will be executed before the physics world is stepping forward
  23206. * @param func The function to execute before the physics world is stepped forward
  23207. */
  23208. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23209. /**
  23210. * Unregister a function that will be executed before the physics world is stepping forward
  23211. * @param func The function to execute before the physics world is stepped forward
  23212. */
  23213. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23214. /**
  23215. * Register a function that will be executed after the physics step
  23216. * @param func The function to execute after physics step
  23217. */
  23218. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23219. /**
  23220. * Unregisters a function that will be executed after the physics step
  23221. * @param func The function to execute after physics step
  23222. */
  23223. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23224. /**
  23225. * register a function that will be executed when this impostor collides against a different body
  23226. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23227. * @param func Callback that is executed on collision
  23228. */
  23229. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23230. /**
  23231. * Unregisters the physics imposter on contact
  23232. * @param collideAgainst The physics object to collide against
  23233. * @param func Callback to execute on collision
  23234. */
  23235. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23236. private _tmpQuat;
  23237. private _tmpQuat2;
  23238. /**
  23239. * Get the parent rotation
  23240. * @returns The parent rotation
  23241. */
  23242. getParentsRotation(): Quaternion;
  23243. /**
  23244. * this function is executed by the physics engine.
  23245. */
  23246. beforeStep: () => void;
  23247. /**
  23248. * this function is executed by the physics engine
  23249. */
  23250. afterStep: () => void;
  23251. /**
  23252. * Legacy collision detection event support
  23253. */
  23254. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23255. /**
  23256. * event and body object due to cannon's event-based architecture.
  23257. */
  23258. onCollide: (e: {
  23259. body: any;
  23260. }) => void;
  23261. /**
  23262. * Apply a force
  23263. * @param force The force to apply
  23264. * @param contactPoint The contact point for the force
  23265. * @returns The physics imposter
  23266. */
  23267. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23268. /**
  23269. * Apply an impulse
  23270. * @param force The impulse force
  23271. * @param contactPoint The contact point for the impulse force
  23272. * @returns The physics imposter
  23273. */
  23274. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23275. /**
  23276. * A help function to create a joint
  23277. * @param otherImpostor A physics imposter used to create a joint
  23278. * @param jointType The type of joint
  23279. * @param jointData The data for the joint
  23280. * @returns The physics imposter
  23281. */
  23282. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23283. /**
  23284. * Add a joint to this impostor with a different impostor
  23285. * @param otherImpostor A physics imposter used to add a joint
  23286. * @param joint The joint to add
  23287. * @returns The physics imposter
  23288. */
  23289. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23290. /**
  23291. * Add an anchor to a cloth impostor
  23292. * @param otherImpostor rigid impostor to anchor to
  23293. * @param width ratio across width from 0 to 1
  23294. * @param height ratio up height from 0 to 1
  23295. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23296. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23297. * @returns impostor the soft imposter
  23298. */
  23299. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23300. /**
  23301. * Add a hook to a rope impostor
  23302. * @param otherImpostor rigid impostor to anchor to
  23303. * @param length ratio across rope from 0 to 1
  23304. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23305. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23306. * @returns impostor the rope imposter
  23307. */
  23308. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23309. /**
  23310. * Will keep this body still, in a sleep mode.
  23311. * @returns the physics imposter
  23312. */
  23313. sleep(): PhysicsImpostor;
  23314. /**
  23315. * Wake the body up.
  23316. * @returns The physics imposter
  23317. */
  23318. wakeUp(): PhysicsImpostor;
  23319. /**
  23320. * Clones the physics imposter
  23321. * @param newObject The physics imposter clones to this physics-enabled object
  23322. * @returns A nullable physics imposter
  23323. */
  23324. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23325. /**
  23326. * Disposes the physics imposter
  23327. */
  23328. dispose(): void;
  23329. /**
  23330. * Sets the delta position
  23331. * @param position The delta position amount
  23332. */
  23333. setDeltaPosition(position: Vector3): void;
  23334. /**
  23335. * Sets the delta rotation
  23336. * @param rotation The delta rotation amount
  23337. */
  23338. setDeltaRotation(rotation: Quaternion): void;
  23339. /**
  23340. * Gets the box size of the physics imposter and stores the result in the input parameter
  23341. * @param result Stores the box size
  23342. * @returns The physics imposter
  23343. */
  23344. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23345. /**
  23346. * Gets the radius of the physics imposter
  23347. * @returns Radius of the physics imposter
  23348. */
  23349. getRadius(): number;
  23350. /**
  23351. * Sync a bone with this impostor
  23352. * @param bone The bone to sync to the impostor.
  23353. * @param boneMesh The mesh that the bone is influencing.
  23354. * @param jointPivot The pivot of the joint / bone in local space.
  23355. * @param distToJoint Optional distance from the impostor to the joint.
  23356. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23357. */
  23358. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23359. /**
  23360. * Sync impostor to a bone
  23361. * @param bone The bone that the impostor will be synced to.
  23362. * @param boneMesh The mesh that the bone is influencing.
  23363. * @param jointPivot The pivot of the joint / bone in local space.
  23364. * @param distToJoint Optional distance from the impostor to the joint.
  23365. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23366. * @param boneAxis Optional vector3 axis the bone is aligned with
  23367. */
  23368. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23369. /**
  23370. * No-Imposter type
  23371. */
  23372. static NoImpostor: number;
  23373. /**
  23374. * Sphere-Imposter type
  23375. */
  23376. static SphereImpostor: number;
  23377. /**
  23378. * Box-Imposter type
  23379. */
  23380. static BoxImpostor: number;
  23381. /**
  23382. * Plane-Imposter type
  23383. */
  23384. static PlaneImpostor: number;
  23385. /**
  23386. * Mesh-imposter type
  23387. */
  23388. static MeshImpostor: number;
  23389. /**
  23390. * Capsule-Impostor type (Ammo.js plugin only)
  23391. */
  23392. static CapsuleImpostor: number;
  23393. /**
  23394. * Cylinder-Imposter type
  23395. */
  23396. static CylinderImpostor: number;
  23397. /**
  23398. * Particle-Imposter type
  23399. */
  23400. static ParticleImpostor: number;
  23401. /**
  23402. * Heightmap-Imposter type
  23403. */
  23404. static HeightmapImpostor: number;
  23405. /**
  23406. * ConvexHull-Impostor type (Ammo.js plugin only)
  23407. */
  23408. static ConvexHullImpostor: number;
  23409. /**
  23410. * Rope-Imposter type
  23411. */
  23412. static RopeImpostor: number;
  23413. /**
  23414. * Cloth-Imposter type
  23415. */
  23416. static ClothImpostor: number;
  23417. /**
  23418. * Softbody-Imposter type
  23419. */
  23420. static SoftbodyImpostor: number;
  23421. }
  23422. }
  23423. declare module BABYLON {
  23424. /**
  23425. * @hidden
  23426. **/
  23427. export class _CreationDataStorage {
  23428. closePath?: boolean;
  23429. closeArray?: boolean;
  23430. idx: number[];
  23431. dashSize: number;
  23432. gapSize: number;
  23433. path3D: Path3D;
  23434. pathArray: Vector3[][];
  23435. arc: number;
  23436. radius: number;
  23437. cap: number;
  23438. tessellation: number;
  23439. }
  23440. /**
  23441. * @hidden
  23442. **/
  23443. class _InstanceDataStorage {
  23444. visibleInstances: any;
  23445. batchCache: _InstancesBatch;
  23446. instancesBufferSize: number;
  23447. instancesBuffer: Nullable<Buffer>;
  23448. instancesData: Float32Array;
  23449. overridenInstanceCount: number;
  23450. isFrozen: boolean;
  23451. previousBatch: Nullable<_InstancesBatch>;
  23452. hardwareInstancedRendering: boolean;
  23453. sideOrientation: number;
  23454. }
  23455. /**
  23456. * @hidden
  23457. **/
  23458. export class _InstancesBatch {
  23459. mustReturn: boolean;
  23460. visibleInstances: Nullable<InstancedMesh[]>[];
  23461. renderSelf: boolean[];
  23462. hardwareInstancedRendering: boolean[];
  23463. }
  23464. /**
  23465. * Class used to represent renderable models
  23466. */
  23467. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23468. /**
  23469. * Mesh side orientation : usually the external or front surface
  23470. */
  23471. static readonly FRONTSIDE: number;
  23472. /**
  23473. * Mesh side orientation : usually the internal or back surface
  23474. */
  23475. static readonly BACKSIDE: number;
  23476. /**
  23477. * Mesh side orientation : both internal and external or front and back surfaces
  23478. */
  23479. static readonly DOUBLESIDE: number;
  23480. /**
  23481. * Mesh side orientation : by default, `FRONTSIDE`
  23482. */
  23483. static readonly DEFAULTSIDE: number;
  23484. /**
  23485. * Mesh cap setting : no cap
  23486. */
  23487. static readonly NO_CAP: number;
  23488. /**
  23489. * Mesh cap setting : one cap at the beginning of the mesh
  23490. */
  23491. static readonly CAP_START: number;
  23492. /**
  23493. * Mesh cap setting : one cap at the end of the mesh
  23494. */
  23495. static readonly CAP_END: number;
  23496. /**
  23497. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23498. */
  23499. static readonly CAP_ALL: number;
  23500. /**
  23501. * Mesh pattern setting : no flip or rotate
  23502. */
  23503. static readonly NO_FLIP: number;
  23504. /**
  23505. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23506. */
  23507. static readonly FLIP_TILE: number;
  23508. /**
  23509. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23510. */
  23511. static readonly ROTATE_TILE: number;
  23512. /**
  23513. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23514. */
  23515. static readonly FLIP_ROW: number;
  23516. /**
  23517. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23518. */
  23519. static readonly ROTATE_ROW: number;
  23520. /**
  23521. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23522. */
  23523. static readonly FLIP_N_ROTATE_TILE: number;
  23524. /**
  23525. * Mesh pattern setting : rotate pattern and rotate
  23526. */
  23527. static readonly FLIP_N_ROTATE_ROW: number;
  23528. /**
  23529. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23530. */
  23531. static readonly CENTER: number;
  23532. /**
  23533. * Mesh tile positioning : part tiles on left
  23534. */
  23535. static readonly LEFT: number;
  23536. /**
  23537. * Mesh tile positioning : part tiles on right
  23538. */
  23539. static readonly RIGHT: number;
  23540. /**
  23541. * Mesh tile positioning : part tiles on top
  23542. */
  23543. static readonly TOP: number;
  23544. /**
  23545. * Mesh tile positioning : part tiles on bottom
  23546. */
  23547. static readonly BOTTOM: number;
  23548. /**
  23549. * Gets the default side orientation.
  23550. * @param orientation the orientation to value to attempt to get
  23551. * @returns the default orientation
  23552. * @hidden
  23553. */
  23554. static _GetDefaultSideOrientation(orientation?: number): number;
  23555. private _internalMeshDataInfo;
  23556. /**
  23557. * An event triggered before rendering the mesh
  23558. */
  23559. readonly onBeforeRenderObservable: Observable<Mesh>;
  23560. /**
  23561. * An event triggered before binding the mesh
  23562. */
  23563. readonly onBeforeBindObservable: Observable<Mesh>;
  23564. /**
  23565. * An event triggered after rendering the mesh
  23566. */
  23567. readonly onAfterRenderObservable: Observable<Mesh>;
  23568. /**
  23569. * An event triggered before drawing the mesh
  23570. */
  23571. readonly onBeforeDrawObservable: Observable<Mesh>;
  23572. private _onBeforeDrawObserver;
  23573. /**
  23574. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23575. */
  23576. onBeforeDraw: () => void;
  23577. readonly hasInstances: boolean;
  23578. /**
  23579. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23580. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23581. */
  23582. delayLoadState: number;
  23583. /**
  23584. * Gets the list of instances created from this mesh
  23585. * it is not supposed to be modified manually.
  23586. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23587. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23588. */
  23589. instances: InstancedMesh[];
  23590. /**
  23591. * Gets the file containing delay loading data for this mesh
  23592. */
  23593. delayLoadingFile: string;
  23594. /** @hidden */
  23595. _binaryInfo: any;
  23596. /**
  23597. * User defined function used to change how LOD level selection is done
  23598. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23599. */
  23600. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23601. /**
  23602. * Gets or sets the morph target manager
  23603. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23604. */
  23605. morphTargetManager: Nullable<MorphTargetManager>;
  23606. /** @hidden */
  23607. _creationDataStorage: Nullable<_CreationDataStorage>;
  23608. /** @hidden */
  23609. _geometry: Nullable<Geometry>;
  23610. /** @hidden */
  23611. _delayInfo: Array<string>;
  23612. /** @hidden */
  23613. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23614. /** @hidden */
  23615. _instanceDataStorage: _InstanceDataStorage;
  23616. private _effectiveMaterial;
  23617. /** @hidden */
  23618. _shouldGenerateFlatShading: boolean;
  23619. /** @hidden */
  23620. _originalBuilderSideOrientation: number;
  23621. /**
  23622. * Use this property to change the original side orientation defined at construction time
  23623. */
  23624. overrideMaterialSideOrientation: Nullable<number>;
  23625. /**
  23626. * Gets the source mesh (the one used to clone this one from)
  23627. */
  23628. readonly source: Nullable<Mesh>;
  23629. /**
  23630. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23631. */
  23632. isUnIndexed: boolean;
  23633. /**
  23634. * @constructor
  23635. * @param name The value used by scene.getMeshByName() to do a lookup.
  23636. * @param scene The scene to add this mesh to.
  23637. * @param parent The parent of this mesh, if it has one
  23638. * @param source An optional Mesh from which geometry is shared, cloned.
  23639. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23640. * When false, achieved by calling a clone(), also passing False.
  23641. * This will make creation of children, recursive.
  23642. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23643. */
  23644. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23645. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23646. /**
  23647. * Gets the class name
  23648. * @returns the string "Mesh".
  23649. */
  23650. getClassName(): string;
  23651. /** @hidden */
  23652. readonly _isMesh: boolean;
  23653. /**
  23654. * Returns a description of this mesh
  23655. * @param fullDetails define if full details about this mesh must be used
  23656. * @returns a descriptive string representing this mesh
  23657. */
  23658. toString(fullDetails?: boolean): string;
  23659. /** @hidden */
  23660. _unBindEffect(): void;
  23661. /**
  23662. * Gets a boolean indicating if this mesh has LOD
  23663. */
  23664. readonly hasLODLevels: boolean;
  23665. /**
  23666. * Gets the list of MeshLODLevel associated with the current mesh
  23667. * @returns an array of MeshLODLevel
  23668. */
  23669. getLODLevels(): MeshLODLevel[];
  23670. private _sortLODLevels;
  23671. /**
  23672. * Add a mesh as LOD level triggered at the given distance.
  23673. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23674. * @param distance The distance from the center of the object to show this level
  23675. * @param mesh The mesh to be added as LOD level (can be null)
  23676. * @return This mesh (for chaining)
  23677. */
  23678. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23679. /**
  23680. * Returns the LOD level mesh at the passed distance or null if not found.
  23681. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23682. * @param distance The distance from the center of the object to show this level
  23683. * @returns a Mesh or `null`
  23684. */
  23685. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23686. /**
  23687. * Remove a mesh from the LOD array
  23688. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23689. * @param mesh defines the mesh to be removed
  23690. * @return This mesh (for chaining)
  23691. */
  23692. removeLODLevel(mesh: Mesh): Mesh;
  23693. /**
  23694. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23695. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23696. * @param camera defines the camera to use to compute distance
  23697. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23698. * @return This mesh (for chaining)
  23699. */
  23700. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23701. /**
  23702. * Gets the mesh internal Geometry object
  23703. */
  23704. readonly geometry: Nullable<Geometry>;
  23705. /**
  23706. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23707. * @returns the total number of vertices
  23708. */
  23709. getTotalVertices(): number;
  23710. /**
  23711. * Returns the content of an associated vertex buffer
  23712. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23713. * - VertexBuffer.PositionKind
  23714. * - VertexBuffer.UVKind
  23715. * - VertexBuffer.UV2Kind
  23716. * - VertexBuffer.UV3Kind
  23717. * - VertexBuffer.UV4Kind
  23718. * - VertexBuffer.UV5Kind
  23719. * - VertexBuffer.UV6Kind
  23720. * - VertexBuffer.ColorKind
  23721. * - VertexBuffer.MatricesIndicesKind
  23722. * - VertexBuffer.MatricesIndicesExtraKind
  23723. * - VertexBuffer.MatricesWeightsKind
  23724. * - VertexBuffer.MatricesWeightsExtraKind
  23725. * @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
  23726. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23727. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23728. */
  23729. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23730. /**
  23731. * Returns the mesh VertexBuffer object from the requested `kind`
  23732. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23733. * - VertexBuffer.PositionKind
  23734. * - VertexBuffer.NormalKind
  23735. * - VertexBuffer.UVKind
  23736. * - VertexBuffer.UV2Kind
  23737. * - VertexBuffer.UV3Kind
  23738. * - VertexBuffer.UV4Kind
  23739. * - VertexBuffer.UV5Kind
  23740. * - VertexBuffer.UV6Kind
  23741. * - VertexBuffer.ColorKind
  23742. * - VertexBuffer.MatricesIndicesKind
  23743. * - VertexBuffer.MatricesIndicesExtraKind
  23744. * - VertexBuffer.MatricesWeightsKind
  23745. * - VertexBuffer.MatricesWeightsExtraKind
  23746. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23747. */
  23748. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23749. /**
  23750. * Tests if a specific vertex buffer is associated with this mesh
  23751. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23752. * - VertexBuffer.PositionKind
  23753. * - VertexBuffer.NormalKind
  23754. * - VertexBuffer.UVKind
  23755. * - VertexBuffer.UV2Kind
  23756. * - VertexBuffer.UV3Kind
  23757. * - VertexBuffer.UV4Kind
  23758. * - VertexBuffer.UV5Kind
  23759. * - VertexBuffer.UV6Kind
  23760. * - VertexBuffer.ColorKind
  23761. * - VertexBuffer.MatricesIndicesKind
  23762. * - VertexBuffer.MatricesIndicesExtraKind
  23763. * - VertexBuffer.MatricesWeightsKind
  23764. * - VertexBuffer.MatricesWeightsExtraKind
  23765. * @returns a boolean
  23766. */
  23767. isVerticesDataPresent(kind: string): boolean;
  23768. /**
  23769. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23770. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23771. * - VertexBuffer.PositionKind
  23772. * - VertexBuffer.UVKind
  23773. * - VertexBuffer.UV2Kind
  23774. * - VertexBuffer.UV3Kind
  23775. * - VertexBuffer.UV4Kind
  23776. * - VertexBuffer.UV5Kind
  23777. * - VertexBuffer.UV6Kind
  23778. * - VertexBuffer.ColorKind
  23779. * - VertexBuffer.MatricesIndicesKind
  23780. * - VertexBuffer.MatricesIndicesExtraKind
  23781. * - VertexBuffer.MatricesWeightsKind
  23782. * - VertexBuffer.MatricesWeightsExtraKind
  23783. * @returns a boolean
  23784. */
  23785. isVertexBufferUpdatable(kind: string): boolean;
  23786. /**
  23787. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23788. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23789. * - VertexBuffer.PositionKind
  23790. * - VertexBuffer.NormalKind
  23791. * - VertexBuffer.UVKind
  23792. * - VertexBuffer.UV2Kind
  23793. * - VertexBuffer.UV3Kind
  23794. * - VertexBuffer.UV4Kind
  23795. * - VertexBuffer.UV5Kind
  23796. * - VertexBuffer.UV6Kind
  23797. * - VertexBuffer.ColorKind
  23798. * - VertexBuffer.MatricesIndicesKind
  23799. * - VertexBuffer.MatricesIndicesExtraKind
  23800. * - VertexBuffer.MatricesWeightsKind
  23801. * - VertexBuffer.MatricesWeightsExtraKind
  23802. * @returns an array of strings
  23803. */
  23804. getVerticesDataKinds(): string[];
  23805. /**
  23806. * Returns a positive integer : the total number of indices in this mesh geometry.
  23807. * @returns the numner of indices or zero if the mesh has no geometry.
  23808. */
  23809. getTotalIndices(): number;
  23810. /**
  23811. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23812. * @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.
  23813. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23814. * @returns the indices array or an empty array if the mesh has no geometry
  23815. */
  23816. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23817. readonly isBlocked: boolean;
  23818. /**
  23819. * Determine if the current mesh is ready to be rendered
  23820. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23821. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23822. * @returns true if all associated assets are ready (material, textures, shaders)
  23823. */
  23824. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23825. /**
  23826. * 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.
  23827. */
  23828. readonly areNormalsFrozen: boolean;
  23829. /**
  23830. * 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.
  23831. * @returns the current mesh
  23832. */
  23833. freezeNormals(): Mesh;
  23834. /**
  23835. * 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
  23836. * @returns the current mesh
  23837. */
  23838. unfreezeNormals(): Mesh;
  23839. /**
  23840. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23841. */
  23842. overridenInstanceCount: number;
  23843. /** @hidden */
  23844. _preActivate(): Mesh;
  23845. /** @hidden */
  23846. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23847. /** @hidden */
  23848. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23849. /**
  23850. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23851. * This means the mesh underlying bounding box and sphere are recomputed.
  23852. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23853. * @returns the current mesh
  23854. */
  23855. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23856. /** @hidden */
  23857. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23858. /**
  23859. * This function will subdivide the mesh into multiple submeshes
  23860. * @param count defines the expected number of submeshes
  23861. */
  23862. subdivide(count: number): void;
  23863. /**
  23864. * Copy a FloatArray into a specific associated vertex buffer
  23865. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23866. * - VertexBuffer.PositionKind
  23867. * - VertexBuffer.UVKind
  23868. * - VertexBuffer.UV2Kind
  23869. * - VertexBuffer.UV3Kind
  23870. * - VertexBuffer.UV4Kind
  23871. * - VertexBuffer.UV5Kind
  23872. * - VertexBuffer.UV6Kind
  23873. * - VertexBuffer.ColorKind
  23874. * - VertexBuffer.MatricesIndicesKind
  23875. * - VertexBuffer.MatricesIndicesExtraKind
  23876. * - VertexBuffer.MatricesWeightsKind
  23877. * - VertexBuffer.MatricesWeightsExtraKind
  23878. * @param data defines the data source
  23879. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23880. * @param stride defines the data stride size (can be null)
  23881. * @returns the current mesh
  23882. */
  23883. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23884. /**
  23885. * Flags an associated vertex buffer as updatable
  23886. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23887. * - VertexBuffer.PositionKind
  23888. * - VertexBuffer.UVKind
  23889. * - VertexBuffer.UV2Kind
  23890. * - VertexBuffer.UV3Kind
  23891. * - VertexBuffer.UV4Kind
  23892. * - VertexBuffer.UV5Kind
  23893. * - VertexBuffer.UV6Kind
  23894. * - VertexBuffer.ColorKind
  23895. * - VertexBuffer.MatricesIndicesKind
  23896. * - VertexBuffer.MatricesIndicesExtraKind
  23897. * - VertexBuffer.MatricesWeightsKind
  23898. * - VertexBuffer.MatricesWeightsExtraKind
  23899. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23900. */
  23901. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23902. /**
  23903. * Sets the mesh global Vertex Buffer
  23904. * @param buffer defines the buffer to use
  23905. * @returns the current mesh
  23906. */
  23907. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23908. /**
  23909. * Update a specific associated vertex buffer
  23910. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23911. * - VertexBuffer.PositionKind
  23912. * - VertexBuffer.UVKind
  23913. * - VertexBuffer.UV2Kind
  23914. * - VertexBuffer.UV3Kind
  23915. * - VertexBuffer.UV4Kind
  23916. * - VertexBuffer.UV5Kind
  23917. * - VertexBuffer.UV6Kind
  23918. * - VertexBuffer.ColorKind
  23919. * - VertexBuffer.MatricesIndicesKind
  23920. * - VertexBuffer.MatricesIndicesExtraKind
  23921. * - VertexBuffer.MatricesWeightsKind
  23922. * - VertexBuffer.MatricesWeightsExtraKind
  23923. * @param data defines the data source
  23924. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23925. * @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)
  23926. * @returns the current mesh
  23927. */
  23928. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23929. /**
  23930. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23931. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23932. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23933. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23934. * @returns the current mesh
  23935. */
  23936. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23937. /**
  23938. * Creates a un-shared specific occurence of the geometry for the mesh.
  23939. * @returns the current mesh
  23940. */
  23941. makeGeometryUnique(): Mesh;
  23942. /**
  23943. * Set the index buffer of this mesh
  23944. * @param indices defines the source data
  23945. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23946. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23947. * @returns the current mesh
  23948. */
  23949. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23950. /**
  23951. * Update the current index buffer
  23952. * @param indices defines the source data
  23953. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23954. * @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)
  23955. * @returns the current mesh
  23956. */
  23957. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23958. /**
  23959. * Invert the geometry to move from a right handed system to a left handed one.
  23960. * @returns the current mesh
  23961. */
  23962. toLeftHanded(): Mesh;
  23963. /** @hidden */
  23964. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23965. /** @hidden */
  23966. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23967. /**
  23968. * Registers for this mesh a javascript function called just before the rendering process
  23969. * @param func defines the function to call before rendering this mesh
  23970. * @returns the current mesh
  23971. */
  23972. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23973. /**
  23974. * Disposes a previously registered javascript function called before the rendering
  23975. * @param func defines the function to remove
  23976. * @returns the current mesh
  23977. */
  23978. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23979. /**
  23980. * Registers for this mesh a javascript function called just after the rendering is complete
  23981. * @param func defines the function to call after rendering this mesh
  23982. * @returns the current mesh
  23983. */
  23984. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23985. /**
  23986. * Disposes a previously registered javascript function called after the rendering.
  23987. * @param func defines the function to remove
  23988. * @returns the current mesh
  23989. */
  23990. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23991. /** @hidden */
  23992. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23993. /** @hidden */
  23994. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23995. /** @hidden */
  23996. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23997. /** @hidden */
  23998. _rebuild(): void;
  23999. /** @hidden */
  24000. _freeze(): void;
  24001. /** @hidden */
  24002. _unFreeze(): void;
  24003. /**
  24004. * 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
  24005. * @param subMesh defines the subMesh to render
  24006. * @param enableAlphaMode defines if alpha mode can be changed
  24007. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24008. * @returns the current mesh
  24009. */
  24010. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24011. private _onBeforeDraw;
  24012. /**
  24013. * Renormalize the mesh and patch it up if there are no weights
  24014. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24015. * However in the case of zero weights then we set just a single influence to 1.
  24016. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24017. */
  24018. cleanMatrixWeights(): void;
  24019. private normalizeSkinFourWeights;
  24020. private normalizeSkinWeightsAndExtra;
  24021. /**
  24022. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24023. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24024. * the user know there was an issue with importing the mesh
  24025. * @returns a validation object with skinned, valid and report string
  24026. */
  24027. validateSkinning(): {
  24028. skinned: boolean;
  24029. valid: boolean;
  24030. report: string;
  24031. };
  24032. /** @hidden */
  24033. _checkDelayState(): Mesh;
  24034. private _queueLoad;
  24035. /**
  24036. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24037. * A mesh is in the frustum if its bounding box intersects the frustum
  24038. * @param frustumPlanes defines the frustum to test
  24039. * @returns true if the mesh is in the frustum planes
  24040. */
  24041. isInFrustum(frustumPlanes: Plane[]): boolean;
  24042. /**
  24043. * Sets the mesh material by the material or multiMaterial `id` property
  24044. * @param id is a string identifying the material or the multiMaterial
  24045. * @returns the current mesh
  24046. */
  24047. setMaterialByID(id: string): Mesh;
  24048. /**
  24049. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24050. * @returns an array of IAnimatable
  24051. */
  24052. getAnimatables(): IAnimatable[];
  24053. /**
  24054. * Modifies the mesh geometry according to the passed transformation matrix.
  24055. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24056. * The mesh normals are modified using the same transformation.
  24057. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24058. * @param transform defines the transform matrix to use
  24059. * @see http://doc.babylonjs.com/resources/baking_transformations
  24060. * @returns the current mesh
  24061. */
  24062. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24063. /**
  24064. * Modifies the mesh geometry according to its own current World Matrix.
  24065. * The mesh World Matrix is then reset.
  24066. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24067. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24068. * @see http://doc.babylonjs.com/resources/baking_transformations
  24069. * @returns the current mesh
  24070. */
  24071. bakeCurrentTransformIntoVertices(): Mesh;
  24072. /** @hidden */
  24073. readonly _positions: Nullable<Vector3[]>;
  24074. /** @hidden */
  24075. _resetPointsArrayCache(): Mesh;
  24076. /** @hidden */
  24077. _generatePointsArray(): boolean;
  24078. /**
  24079. * Returns a new Mesh object generated from the current mesh properties.
  24080. * This method must not get confused with createInstance()
  24081. * @param name is a string, the name given to the new mesh
  24082. * @param newParent can be any Node object (default `null`)
  24083. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24084. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24085. * @returns a new mesh
  24086. */
  24087. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24088. /**
  24089. * Releases resources associated with this mesh.
  24090. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24091. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24092. */
  24093. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24094. /**
  24095. * Modifies the mesh geometry according to a displacement map.
  24096. * 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.
  24097. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24098. * @param url is a string, the URL from the image file is to be downloaded.
  24099. * @param minHeight is the lower limit of the displacement.
  24100. * @param maxHeight is the upper limit of the displacement.
  24101. * @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.
  24102. * @param uvOffset is an optional vector2 used to offset UV.
  24103. * @param uvScale is an optional vector2 used to scale UV.
  24104. * @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.
  24105. * @returns the Mesh.
  24106. */
  24107. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24108. /**
  24109. * Modifies the mesh geometry according to a displacementMap buffer.
  24110. * 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.
  24111. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24112. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24113. * @param heightMapWidth is the width of the buffer image.
  24114. * @param heightMapHeight is the height of the buffer image.
  24115. * @param minHeight is the lower limit of the displacement.
  24116. * @param maxHeight is the upper limit of the displacement.
  24117. * @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.
  24118. * @param uvOffset is an optional vector2 used to offset UV.
  24119. * @param uvScale is an optional vector2 used to scale UV.
  24120. * @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.
  24121. * @returns the Mesh.
  24122. */
  24123. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24124. /**
  24125. * Modify the mesh to get a flat shading rendering.
  24126. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24127. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24128. * @returns current mesh
  24129. */
  24130. convertToFlatShadedMesh(): Mesh;
  24131. /**
  24132. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24133. * In other words, more vertices, no more indices and a single bigger VBO.
  24134. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24135. * @returns current mesh
  24136. */
  24137. convertToUnIndexedMesh(): Mesh;
  24138. /**
  24139. * Inverses facet orientations.
  24140. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24141. * @param flipNormals will also inverts the normals
  24142. * @returns current mesh
  24143. */
  24144. flipFaces(flipNormals?: boolean): Mesh;
  24145. /**
  24146. * Increase the number of facets and hence vertices in a mesh
  24147. * Vertex normals are interpolated from existing vertex normals
  24148. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24149. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24150. */
  24151. increaseVertices(numberPerEdge: number): void;
  24152. /**
  24153. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24154. * This will undo any application of covertToFlatShadedMesh
  24155. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24156. */
  24157. forceSharedVertices(): void;
  24158. /** @hidden */
  24159. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24160. /** @hidden */
  24161. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24162. /**
  24163. * Creates a new InstancedMesh object from the mesh model.
  24164. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24165. * @param name defines the name of the new instance
  24166. * @returns a new InstancedMesh
  24167. */
  24168. createInstance(name: string): InstancedMesh;
  24169. /**
  24170. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24171. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24172. * @returns the current mesh
  24173. */
  24174. synchronizeInstances(): Mesh;
  24175. /**
  24176. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24177. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24178. * This should be used together with the simplification to avoid disappearing triangles.
  24179. * @param successCallback an optional success callback to be called after the optimization finished.
  24180. * @returns the current mesh
  24181. */
  24182. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24183. /**
  24184. * Serialize current mesh
  24185. * @param serializationObject defines the object which will receive the serialization data
  24186. */
  24187. serialize(serializationObject: any): void;
  24188. /** @hidden */
  24189. _syncGeometryWithMorphTargetManager(): void;
  24190. /** @hidden */
  24191. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24192. /**
  24193. * Returns a new Mesh object parsed from the source provided.
  24194. * @param parsedMesh is the source
  24195. * @param scene defines the hosting scene
  24196. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24197. * @returns a new Mesh
  24198. */
  24199. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24200. /**
  24201. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24202. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24203. * @param name defines the name of the mesh to create
  24204. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24205. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24206. * @param closePath creates a seam between the first and the last points of each path of the path array
  24207. * @param offset is taken in account only if the `pathArray` is containing a single path
  24208. * @param scene defines the hosting scene
  24209. * @param updatable defines if the mesh must be flagged as updatable
  24210. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24211. * @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)
  24212. * @returns a new Mesh
  24213. */
  24214. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24215. /**
  24216. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24217. * @param name defines the name of the mesh to create
  24218. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24219. * @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
  24220. * @param scene defines the hosting scene
  24221. * @param updatable defines if the mesh must be flagged as updatable
  24222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24223. * @returns a new Mesh
  24224. */
  24225. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24226. /**
  24227. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24228. * @param name defines the name of the mesh to create
  24229. * @param size sets the size (float) of each box side (default 1)
  24230. * @param scene defines the hosting scene
  24231. * @param updatable defines if the mesh must be flagged as updatable
  24232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24233. * @returns a new Mesh
  24234. */
  24235. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24236. /**
  24237. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24238. * @param name defines the name of the mesh to create
  24239. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24240. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24241. * @param scene defines the hosting scene
  24242. * @param updatable defines if the mesh must be flagged as updatable
  24243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24244. * @returns a new Mesh
  24245. */
  24246. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24247. /**
  24248. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24249. * @param name defines the name of the mesh to create
  24250. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24251. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24252. * @param scene defines the hosting scene
  24253. * @returns a new Mesh
  24254. */
  24255. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24256. /**
  24257. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24258. * @param name defines the name of the mesh to create
  24259. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24260. * @param diameterTop set the top cap diameter (floats, default 1)
  24261. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24262. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24263. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24264. * @param scene defines the hosting scene
  24265. * @param updatable defines if the mesh must be flagged as updatable
  24266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24267. * @returns a new Mesh
  24268. */
  24269. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24270. /**
  24271. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24272. * @param name defines the name of the mesh to create
  24273. * @param diameter sets the diameter size (float) of the torus (default 1)
  24274. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24275. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24276. * @param scene defines the hosting scene
  24277. * @param updatable defines if the mesh must be flagged as updatable
  24278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24279. * @returns a new Mesh
  24280. */
  24281. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24282. /**
  24283. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24284. * @param name defines the name of the mesh to create
  24285. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24286. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24287. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24288. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24289. * @param p the number of windings on X axis (positive integers, default 2)
  24290. * @param q the number of windings on Y axis (positive integers, default 3)
  24291. * @param scene defines the hosting scene
  24292. * @param updatable defines if the mesh must be flagged as updatable
  24293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24294. * @returns a new Mesh
  24295. */
  24296. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24297. /**
  24298. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24299. * @param name defines the name of the mesh to create
  24300. * @param points is an array successive Vector3
  24301. * @param scene defines the hosting scene
  24302. * @param updatable defines if the mesh must be flagged as updatable
  24303. * @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).
  24304. * @returns a new Mesh
  24305. */
  24306. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24307. /**
  24308. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24309. * @param name defines the name of the mesh to create
  24310. * @param points is an array successive Vector3
  24311. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24312. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24313. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24314. * @param scene defines the hosting scene
  24315. * @param updatable defines if the mesh must be flagged as updatable
  24316. * @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)
  24317. * @returns a new Mesh
  24318. */
  24319. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24320. /**
  24321. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24322. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24323. * 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.
  24324. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24325. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24326. * Remember you can only change the shape positions, not their number when updating a polygon.
  24327. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24328. * @param name defines the name of the mesh to create
  24329. * @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
  24330. * @param scene defines the hosting scene
  24331. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24332. * @param updatable defines if the mesh must be flagged as updatable
  24333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24334. * @param earcutInjection can be used to inject your own earcut reference
  24335. * @returns a new Mesh
  24336. */
  24337. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24338. /**
  24339. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24340. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24341. * @param name defines the name of the mesh to create
  24342. * @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
  24343. * @param depth defines the height of extrusion
  24344. * @param scene defines the hosting scene
  24345. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24346. * @param updatable defines if the mesh must be flagged as updatable
  24347. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24348. * @param earcutInjection can be used to inject your own earcut reference
  24349. * @returns a new Mesh
  24350. */
  24351. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24352. /**
  24353. * Creates an extruded shape mesh.
  24354. * 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
  24355. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24356. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24357. * @param name defines the name of the mesh to create
  24358. * @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
  24359. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24360. * @param scale is the value to scale the shape
  24361. * @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
  24362. * @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
  24363. * @param scene defines the hosting scene
  24364. * @param updatable defines if the mesh must be flagged as updatable
  24365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24366. * @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)
  24367. * @returns a new Mesh
  24368. */
  24369. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24370. /**
  24371. * Creates an custom extruded shape mesh.
  24372. * The custom extrusion is a parametric shape.
  24373. * It has no predefined shape. Its final shape will depend on the input parameters.
  24374. * Please consider using the same method from the MeshBuilder class instead
  24375. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24376. * @param name defines the name of the mesh to create
  24377. * @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
  24378. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24379. * @param scaleFunction is a custom Javascript function called on each path point
  24380. * @param rotationFunction is a custom Javascript function called on each path point
  24381. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24382. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24383. * @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
  24384. * @param scene defines the hosting scene
  24385. * @param updatable defines if the mesh must be flagged as updatable
  24386. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24387. * @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)
  24388. * @returns a new Mesh
  24389. */
  24390. 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;
  24391. /**
  24392. * Creates lathe mesh.
  24393. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24394. * Please consider using the same method from the MeshBuilder class instead
  24395. * @param name defines the name of the mesh to create
  24396. * @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
  24397. * @param radius is the radius value of the lathe
  24398. * @param tessellation is the side number of the lathe.
  24399. * @param scene defines the hosting scene
  24400. * @param updatable defines if the mesh must be flagged as updatable
  24401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24402. * @returns a new Mesh
  24403. */
  24404. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24405. /**
  24406. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24407. * @param name defines the name of the mesh to create
  24408. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24409. * @param scene defines the hosting scene
  24410. * @param updatable defines if the mesh must be flagged as updatable
  24411. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24412. * @returns a new Mesh
  24413. */
  24414. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24415. /**
  24416. * Creates a ground mesh.
  24417. * Please consider using the same method from the MeshBuilder class instead
  24418. * @param name defines the name of the mesh to create
  24419. * @param width set the width of the ground
  24420. * @param height set the height of the ground
  24421. * @param subdivisions sets the number of subdivisions per side
  24422. * @param scene defines the hosting scene
  24423. * @param updatable defines if the mesh must be flagged as updatable
  24424. * @returns a new Mesh
  24425. */
  24426. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24427. /**
  24428. * Creates a tiled ground mesh.
  24429. * Please consider using the same method from the MeshBuilder class instead
  24430. * @param name defines the name of the mesh to create
  24431. * @param xmin set the ground minimum X coordinate
  24432. * @param zmin set the ground minimum Y coordinate
  24433. * @param xmax set the ground maximum X coordinate
  24434. * @param zmax set the ground maximum Z coordinate
  24435. * @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
  24436. * @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
  24437. * @param scene defines the hosting scene
  24438. * @param updatable defines if the mesh must be flagged as updatable
  24439. * @returns a new Mesh
  24440. */
  24441. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24442. w: number;
  24443. h: number;
  24444. }, precision: {
  24445. w: number;
  24446. h: number;
  24447. }, scene: Scene, updatable?: boolean): Mesh;
  24448. /**
  24449. * Creates a ground mesh from a height map.
  24450. * Please consider using the same method from the MeshBuilder class instead
  24451. * @see http://doc.babylonjs.com/babylon101/height_map
  24452. * @param name defines the name of the mesh to create
  24453. * @param url sets the URL of the height map image resource
  24454. * @param width set the ground width size
  24455. * @param height set the ground height size
  24456. * @param subdivisions sets the number of subdivision per side
  24457. * @param minHeight is the minimum altitude on the ground
  24458. * @param maxHeight is the maximum altitude on the ground
  24459. * @param scene defines the hosting scene
  24460. * @param updatable defines if the mesh must be flagged as updatable
  24461. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24462. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24463. * @returns a new Mesh
  24464. */
  24465. 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;
  24466. /**
  24467. * Creates a tube mesh.
  24468. * The tube is a parametric shape.
  24469. * It has no predefined shape. Its final shape will depend on the input parameters.
  24470. * Please consider using the same method from the MeshBuilder class instead
  24471. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24472. * @param name defines the name of the mesh to create
  24473. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24474. * @param radius sets the tube radius size
  24475. * @param tessellation is the number of sides on the tubular surface
  24476. * @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
  24477. * @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
  24478. * @param scene defines the hosting scene
  24479. * @param updatable defines if the mesh must be flagged as updatable
  24480. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24481. * @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)
  24482. * @returns a new Mesh
  24483. */
  24484. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24485. (i: number, distance: number): number;
  24486. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24487. /**
  24488. * Creates a polyhedron mesh.
  24489. * Please consider using the same method from the MeshBuilder class instead.
  24490. * * 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
  24491. * * The parameter `size` (positive float, default 1) sets the polygon size
  24492. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24493. * * 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`
  24494. * * 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
  24495. * * 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)`)
  24496. * * 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
  24497. * * 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
  24498. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24499. * * 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
  24500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24501. * @param name defines the name of the mesh to create
  24502. * @param options defines the options used to create the mesh
  24503. * @param scene defines the hosting scene
  24504. * @returns a new Mesh
  24505. */
  24506. static CreatePolyhedron(name: string, options: {
  24507. type?: number;
  24508. size?: number;
  24509. sizeX?: number;
  24510. sizeY?: number;
  24511. sizeZ?: number;
  24512. custom?: any;
  24513. faceUV?: Vector4[];
  24514. faceColors?: Color4[];
  24515. updatable?: boolean;
  24516. sideOrientation?: number;
  24517. }, scene: Scene): Mesh;
  24518. /**
  24519. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24520. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24521. * * 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`)
  24522. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24523. * * 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
  24524. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24525. * * 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
  24526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24527. * @param name defines the name of the mesh
  24528. * @param options defines the options used to create the mesh
  24529. * @param scene defines the hosting scene
  24530. * @returns a new Mesh
  24531. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24532. */
  24533. static CreateIcoSphere(name: string, options: {
  24534. radius?: number;
  24535. flat?: boolean;
  24536. subdivisions?: number;
  24537. sideOrientation?: number;
  24538. updatable?: boolean;
  24539. }, scene: Scene): Mesh;
  24540. /**
  24541. * Creates a decal mesh.
  24542. * Please consider using the same method from the MeshBuilder class instead.
  24543. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24544. * @param name defines the name of the mesh
  24545. * @param sourceMesh defines the mesh receiving the decal
  24546. * @param position sets the position of the decal in world coordinates
  24547. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24548. * @param size sets the decal scaling
  24549. * @param angle sets the angle to rotate the decal
  24550. * @returns a new Mesh
  24551. */
  24552. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24553. /**
  24554. * Prepare internal position array for software CPU skinning
  24555. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24556. */
  24557. setPositionsForCPUSkinning(): Float32Array;
  24558. /**
  24559. * Prepare internal normal array for software CPU skinning
  24560. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24561. */
  24562. setNormalsForCPUSkinning(): Float32Array;
  24563. /**
  24564. * Updates the vertex buffer by applying transformation from the bones
  24565. * @param skeleton defines the skeleton to apply to current mesh
  24566. * @returns the current mesh
  24567. */
  24568. applySkeleton(skeleton: Skeleton): Mesh;
  24569. /**
  24570. * 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
  24571. * @param meshes defines the list of meshes to scan
  24572. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24573. */
  24574. static MinMax(meshes: AbstractMesh[]): {
  24575. min: Vector3;
  24576. max: Vector3;
  24577. };
  24578. /**
  24579. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24580. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24581. * @returns a vector3
  24582. */
  24583. static Center(meshesOrMinMaxVector: {
  24584. min: Vector3;
  24585. max: Vector3;
  24586. } | AbstractMesh[]): Vector3;
  24587. /**
  24588. * Merge the array of meshes into a single mesh for performance reasons.
  24589. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24590. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24591. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24592. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24593. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24594. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24595. * @returns a new mesh
  24596. */
  24597. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24598. /** @hidden */
  24599. addInstance(instance: InstancedMesh): void;
  24600. /** @hidden */
  24601. removeInstance(instance: InstancedMesh): void;
  24602. }
  24603. }
  24604. declare module BABYLON {
  24605. /**
  24606. * This is the base class of all the camera used in the application.
  24607. * @see http://doc.babylonjs.com/features/cameras
  24608. */
  24609. export class Camera extends Node {
  24610. /** @hidden */
  24611. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24612. /**
  24613. * This is the default projection mode used by the cameras.
  24614. * It helps recreating a feeling of perspective and better appreciate depth.
  24615. * This is the best way to simulate real life cameras.
  24616. */
  24617. static readonly PERSPECTIVE_CAMERA: number;
  24618. /**
  24619. * This helps creating camera with an orthographic mode.
  24620. * 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.
  24621. */
  24622. static readonly ORTHOGRAPHIC_CAMERA: number;
  24623. /**
  24624. * This is the default FOV mode for perspective cameras.
  24625. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24626. */
  24627. static readonly FOVMODE_VERTICAL_FIXED: number;
  24628. /**
  24629. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24630. */
  24631. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24632. /**
  24633. * This specifies ther is no need for a camera rig.
  24634. * Basically only one eye is rendered corresponding to the camera.
  24635. */
  24636. static readonly RIG_MODE_NONE: number;
  24637. /**
  24638. * Simulates a camera Rig with one blue eye and one red eye.
  24639. * This can be use with 3d blue and red glasses.
  24640. */
  24641. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24642. /**
  24643. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24644. */
  24645. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24646. /**
  24647. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24648. */
  24649. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24650. /**
  24651. * Defines that both eyes of the camera will be rendered over under each other.
  24652. */
  24653. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24654. /**
  24655. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24656. */
  24657. static readonly RIG_MODE_VR: number;
  24658. /**
  24659. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24660. */
  24661. static readonly RIG_MODE_WEBVR: number;
  24662. /**
  24663. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24664. */
  24665. static readonly RIG_MODE_CUSTOM: number;
  24666. /**
  24667. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24668. */
  24669. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24670. /**
  24671. * Define the input manager associated with the camera.
  24672. */
  24673. inputs: CameraInputsManager<Camera>;
  24674. /** @hidden */
  24675. _position: Vector3;
  24676. /**
  24677. * Define the current local position of the camera in the scene
  24678. */
  24679. position: Vector3;
  24680. /**
  24681. * The vector the camera should consider as up.
  24682. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24683. */
  24684. upVector: Vector3;
  24685. /**
  24686. * Define the current limit on the left side for an orthographic camera
  24687. * In scene unit
  24688. */
  24689. orthoLeft: Nullable<number>;
  24690. /**
  24691. * Define the current limit on the right side for an orthographic camera
  24692. * In scene unit
  24693. */
  24694. orthoRight: Nullable<number>;
  24695. /**
  24696. * Define the current limit on the bottom side for an orthographic camera
  24697. * In scene unit
  24698. */
  24699. orthoBottom: Nullable<number>;
  24700. /**
  24701. * Define the current limit on the top side for an orthographic camera
  24702. * In scene unit
  24703. */
  24704. orthoTop: Nullable<number>;
  24705. /**
  24706. * Field Of View is set in Radians. (default is 0.8)
  24707. */
  24708. fov: number;
  24709. /**
  24710. * Define the minimum distance the camera can see from.
  24711. * This is important to note that the depth buffer are not infinite and the closer it starts
  24712. * the more your scene might encounter depth fighting issue.
  24713. */
  24714. minZ: number;
  24715. /**
  24716. * Define the maximum distance the camera can see to.
  24717. * This is important to note that the depth buffer are not infinite and the further it end
  24718. * the more your scene might encounter depth fighting issue.
  24719. */
  24720. maxZ: number;
  24721. /**
  24722. * Define the default inertia of the camera.
  24723. * This helps giving a smooth feeling to the camera movement.
  24724. */
  24725. inertia: number;
  24726. /**
  24727. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24728. */
  24729. mode: number;
  24730. /**
  24731. * Define wether the camera is intermediate.
  24732. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24733. */
  24734. isIntermediate: boolean;
  24735. /**
  24736. * Define the viewport of the camera.
  24737. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24738. */
  24739. viewport: Viewport;
  24740. /**
  24741. * Restricts the camera to viewing objects with the same layerMask.
  24742. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24743. */
  24744. layerMask: number;
  24745. /**
  24746. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24747. */
  24748. fovMode: number;
  24749. /**
  24750. * Rig mode of the camera.
  24751. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24752. * This is normally controlled byt the camera themselves as internal use.
  24753. */
  24754. cameraRigMode: number;
  24755. /**
  24756. * Defines the distance between both "eyes" in case of a RIG
  24757. */
  24758. interaxialDistance: number;
  24759. /**
  24760. * Defines if stereoscopic rendering is done side by side or over under.
  24761. */
  24762. isStereoscopicSideBySide: boolean;
  24763. /**
  24764. * 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
  24765. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24766. * else in the scene. (Eg. security camera)
  24767. *
  24768. * 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)
  24769. */
  24770. customRenderTargets: RenderTargetTexture[];
  24771. /**
  24772. * When set, the camera will render to this render target instead of the default canvas
  24773. *
  24774. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24775. */
  24776. outputRenderTarget: Nullable<RenderTargetTexture>;
  24777. /**
  24778. * Observable triggered when the camera view matrix has changed.
  24779. */
  24780. onViewMatrixChangedObservable: Observable<Camera>;
  24781. /**
  24782. * Observable triggered when the camera Projection matrix has changed.
  24783. */
  24784. onProjectionMatrixChangedObservable: Observable<Camera>;
  24785. /**
  24786. * Observable triggered when the inputs have been processed.
  24787. */
  24788. onAfterCheckInputsObservable: Observable<Camera>;
  24789. /**
  24790. * Observable triggered when reset has been called and applied to the camera.
  24791. */
  24792. onRestoreStateObservable: Observable<Camera>;
  24793. /** @hidden */
  24794. _cameraRigParams: any;
  24795. /** @hidden */
  24796. _rigCameras: Camera[];
  24797. /** @hidden */
  24798. _rigPostProcess: Nullable<PostProcess>;
  24799. protected _webvrViewMatrix: Matrix;
  24800. /** @hidden */
  24801. _skipRendering: boolean;
  24802. /** @hidden */
  24803. _projectionMatrix: Matrix;
  24804. /** @hidden */
  24805. _postProcesses: Nullable<PostProcess>[];
  24806. /** @hidden */
  24807. _activeMeshes: SmartArray<AbstractMesh>;
  24808. protected _globalPosition: Vector3;
  24809. /** @hidden */
  24810. _computedViewMatrix: Matrix;
  24811. private _doNotComputeProjectionMatrix;
  24812. private _transformMatrix;
  24813. private _frustumPlanes;
  24814. private _refreshFrustumPlanes;
  24815. private _storedFov;
  24816. private _stateStored;
  24817. /**
  24818. * Instantiates a new camera object.
  24819. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24820. * @see http://doc.babylonjs.com/features/cameras
  24821. * @param name Defines the name of the camera in the scene
  24822. * @param position Defines the position of the camera
  24823. * @param scene Defines the scene the camera belongs too
  24824. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24825. */
  24826. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24827. /**
  24828. * Store current camera state (fov, position, etc..)
  24829. * @returns the camera
  24830. */
  24831. storeState(): Camera;
  24832. /**
  24833. * Restores the camera state values if it has been stored. You must call storeState() first
  24834. */
  24835. protected _restoreStateValues(): boolean;
  24836. /**
  24837. * Restored camera state. You must call storeState() first.
  24838. * @returns true if restored and false otherwise
  24839. */
  24840. restoreState(): boolean;
  24841. /**
  24842. * Gets the class name of the camera.
  24843. * @returns the class name
  24844. */
  24845. getClassName(): string;
  24846. /** @hidden */
  24847. readonly _isCamera: boolean;
  24848. /**
  24849. * Gets a string representation of the camera useful for debug purpose.
  24850. * @param fullDetails Defines that a more verboe level of logging is required
  24851. * @returns the string representation
  24852. */
  24853. toString(fullDetails?: boolean): string;
  24854. /**
  24855. * Gets the current world space position of the camera.
  24856. */
  24857. readonly globalPosition: Vector3;
  24858. /**
  24859. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24860. * @returns the active meshe list
  24861. */
  24862. getActiveMeshes(): SmartArray<AbstractMesh>;
  24863. /**
  24864. * Check wether a mesh is part of the current active mesh list of the camera
  24865. * @param mesh Defines the mesh to check
  24866. * @returns true if active, false otherwise
  24867. */
  24868. isActiveMesh(mesh: Mesh): boolean;
  24869. /**
  24870. * Is this camera ready to be used/rendered
  24871. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24872. * @return true if the camera is ready
  24873. */
  24874. isReady(completeCheck?: boolean): boolean;
  24875. /** @hidden */
  24876. _initCache(): void;
  24877. /** @hidden */
  24878. _updateCache(ignoreParentClass?: boolean): void;
  24879. /** @hidden */
  24880. _isSynchronized(): boolean;
  24881. /** @hidden */
  24882. _isSynchronizedViewMatrix(): boolean;
  24883. /** @hidden */
  24884. _isSynchronizedProjectionMatrix(): boolean;
  24885. /**
  24886. * Attach the input controls to a specific dom element to get the input from.
  24887. * @param element Defines the element the controls should be listened from
  24888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24889. */
  24890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24891. /**
  24892. * Detach the current controls from the specified dom element.
  24893. * @param element Defines the element to stop listening the inputs from
  24894. */
  24895. detachControl(element: HTMLElement): void;
  24896. /**
  24897. * Update the camera state according to the different inputs gathered during the frame.
  24898. */
  24899. update(): void;
  24900. /** @hidden */
  24901. _checkInputs(): void;
  24902. /** @hidden */
  24903. readonly rigCameras: Camera[];
  24904. /**
  24905. * Gets the post process used by the rig cameras
  24906. */
  24907. readonly rigPostProcess: Nullable<PostProcess>;
  24908. /**
  24909. * Internal, gets the first post proces.
  24910. * @returns the first post process to be run on this camera.
  24911. */
  24912. _getFirstPostProcess(): Nullable<PostProcess>;
  24913. private _cascadePostProcessesToRigCams;
  24914. /**
  24915. * Attach a post process to the camera.
  24916. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24917. * @param postProcess The post process to attach to the camera
  24918. * @param insertAt The position of the post process in case several of them are in use in the scene
  24919. * @returns the position the post process has been inserted at
  24920. */
  24921. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24922. /**
  24923. * Detach a post process to the camera.
  24924. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24925. * @param postProcess The post process to detach from the camera
  24926. */
  24927. detachPostProcess(postProcess: PostProcess): void;
  24928. /**
  24929. * Gets the current world matrix of the camera
  24930. */
  24931. getWorldMatrix(): Matrix;
  24932. /** @hidden */
  24933. _getViewMatrix(): Matrix;
  24934. /**
  24935. * Gets the current view matrix of the camera.
  24936. * @param force forces the camera to recompute the matrix without looking at the cached state
  24937. * @returns the view matrix
  24938. */
  24939. getViewMatrix(force?: boolean): Matrix;
  24940. /**
  24941. * Freeze the projection matrix.
  24942. * It will prevent the cache check of the camera projection compute and can speed up perf
  24943. * if no parameter of the camera are meant to change
  24944. * @param projection Defines manually a projection if necessary
  24945. */
  24946. freezeProjectionMatrix(projection?: Matrix): void;
  24947. /**
  24948. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24949. */
  24950. unfreezeProjectionMatrix(): void;
  24951. /**
  24952. * Gets the current projection matrix of the camera.
  24953. * @param force forces the camera to recompute the matrix without looking at the cached state
  24954. * @returns the projection matrix
  24955. */
  24956. getProjectionMatrix(force?: boolean): Matrix;
  24957. /**
  24958. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24959. * @returns a Matrix
  24960. */
  24961. getTransformationMatrix(): Matrix;
  24962. private _updateFrustumPlanes;
  24963. /**
  24964. * Checks if a cullable object (mesh...) is in the camera frustum
  24965. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24966. * @param target The object to check
  24967. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24968. * @returns true if the object is in frustum otherwise false
  24969. */
  24970. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24971. /**
  24972. * Checks if a cullable object (mesh...) is in the camera frustum
  24973. * Unlike isInFrustum this cheks the full bounding box
  24974. * @param target The object to check
  24975. * @returns true if the object is in frustum otherwise false
  24976. */
  24977. isCompletelyInFrustum(target: ICullable): boolean;
  24978. /**
  24979. * Gets a ray in the forward direction from the camera.
  24980. * @param length Defines the length of the ray to create
  24981. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24982. * @param origin Defines the start point of the ray which defaults to the camera position
  24983. * @returns the forward ray
  24984. */
  24985. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24986. /**
  24987. * Releases resources associated with this node.
  24988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24990. */
  24991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24992. /** @hidden */
  24993. _isLeftCamera: boolean;
  24994. /**
  24995. * Gets the left camera of a rig setup in case of Rigged Camera
  24996. */
  24997. readonly isLeftCamera: boolean;
  24998. /** @hidden */
  24999. _isRightCamera: boolean;
  25000. /**
  25001. * Gets the right camera of a rig setup in case of Rigged Camera
  25002. */
  25003. readonly isRightCamera: boolean;
  25004. /**
  25005. * Gets the left camera of a rig setup in case of Rigged Camera
  25006. */
  25007. readonly leftCamera: Nullable<FreeCamera>;
  25008. /**
  25009. * Gets the right camera of a rig setup in case of Rigged Camera
  25010. */
  25011. readonly rightCamera: Nullable<FreeCamera>;
  25012. /**
  25013. * Gets the left camera target of a rig setup in case of Rigged Camera
  25014. * @returns the target position
  25015. */
  25016. getLeftTarget(): Nullable<Vector3>;
  25017. /**
  25018. * Gets the right camera target of a rig setup in case of Rigged Camera
  25019. * @returns the target position
  25020. */
  25021. getRightTarget(): Nullable<Vector3>;
  25022. /**
  25023. * @hidden
  25024. */
  25025. setCameraRigMode(mode: number, rigParams: any): void;
  25026. /** @hidden */
  25027. static _setStereoscopicRigMode(camera: Camera): void;
  25028. /** @hidden */
  25029. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25030. /** @hidden */
  25031. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25032. /** @hidden */
  25033. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25034. /** @hidden */
  25035. _getVRProjectionMatrix(): Matrix;
  25036. protected _updateCameraRotationMatrix(): void;
  25037. protected _updateWebVRCameraRotationMatrix(): void;
  25038. /**
  25039. * This function MUST be overwritten by the different WebVR cameras available.
  25040. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25041. * @hidden
  25042. */
  25043. _getWebVRProjectionMatrix(): Matrix;
  25044. /**
  25045. * This function MUST be overwritten by the different WebVR cameras available.
  25046. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25047. * @hidden
  25048. */
  25049. _getWebVRViewMatrix(): Matrix;
  25050. /** @hidden */
  25051. setCameraRigParameter(name: string, value: any): void;
  25052. /**
  25053. * needs to be overridden by children so sub has required properties to be copied
  25054. * @hidden
  25055. */
  25056. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25057. /**
  25058. * May need to be overridden by children
  25059. * @hidden
  25060. */
  25061. _updateRigCameras(): void;
  25062. /** @hidden */
  25063. _setupInputs(): void;
  25064. /**
  25065. * Serialiaze the camera setup to a json represention
  25066. * @returns the JSON representation
  25067. */
  25068. serialize(): any;
  25069. /**
  25070. * Clones the current camera.
  25071. * @param name The cloned camera name
  25072. * @returns the cloned camera
  25073. */
  25074. clone(name: string): Camera;
  25075. /**
  25076. * Gets the direction of the camera relative to a given local axis.
  25077. * @param localAxis Defines the reference axis to provide a relative direction.
  25078. * @return the direction
  25079. */
  25080. getDirection(localAxis: Vector3): Vector3;
  25081. /**
  25082. * Returns the current camera absolute rotation
  25083. */
  25084. readonly absoluteRotation: Quaternion;
  25085. /**
  25086. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25087. * @param localAxis Defines the reference axis to provide a relative direction.
  25088. * @param result Defines the vector to store the result in
  25089. */
  25090. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25091. /**
  25092. * Gets a camera constructor for a given camera type
  25093. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25094. * @param name The name of the camera the result will be able to instantiate
  25095. * @param scene The scene the result will construct the camera in
  25096. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25097. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25098. * @returns a factory method to construc the camera
  25099. */
  25100. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25101. /**
  25102. * Compute the world matrix of the camera.
  25103. * @returns the camera workd matrix
  25104. */
  25105. computeWorldMatrix(): Matrix;
  25106. /**
  25107. * Parse a JSON and creates the camera from the parsed information
  25108. * @param parsedCamera The JSON to parse
  25109. * @param scene The scene to instantiate the camera in
  25110. * @returns the newly constructed camera
  25111. */
  25112. static Parse(parsedCamera: any, scene: Scene): Camera;
  25113. }
  25114. }
  25115. declare module BABYLON {
  25116. /**
  25117. * Class containing static functions to help procedurally build meshes
  25118. */
  25119. export class DiscBuilder {
  25120. /**
  25121. * Creates a plane polygonal mesh. By default, this is a disc
  25122. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25123. * * 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
  25124. * * 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
  25125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25126. * * 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
  25127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25128. * @param name defines the name of the mesh
  25129. * @param options defines the options used to create the mesh
  25130. * @param scene defines the hosting scene
  25131. * @returns the plane polygonal mesh
  25132. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25133. */
  25134. static CreateDisc(name: string, options: {
  25135. radius?: number;
  25136. tessellation?: number;
  25137. arc?: number;
  25138. updatable?: boolean;
  25139. sideOrientation?: number;
  25140. frontUVs?: Vector4;
  25141. backUVs?: Vector4;
  25142. }, scene?: Nullable<Scene>): Mesh;
  25143. }
  25144. }
  25145. declare module BABYLON {
  25146. /**
  25147. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25148. *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.
  25149. * The SPS is also a particle system. It provides some methods to manage the particles.
  25150. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25151. *
  25152. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25153. */
  25154. export class SolidParticleSystem implements IDisposable {
  25155. /**
  25156. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25157. * Example : var p = SPS.particles[i];
  25158. */
  25159. particles: SolidParticle[];
  25160. /**
  25161. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25162. */
  25163. nbParticles: number;
  25164. /**
  25165. * If the particles must ever face the camera (default false). Useful for planar particles.
  25166. */
  25167. billboard: boolean;
  25168. /**
  25169. * Recompute normals when adding a shape
  25170. */
  25171. recomputeNormals: boolean;
  25172. /**
  25173. * This a counter ofr your own usage. It's not set by any SPS functions.
  25174. */
  25175. counter: number;
  25176. /**
  25177. * The SPS name. This name is also given to the underlying mesh.
  25178. */
  25179. name: string;
  25180. /**
  25181. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25182. */
  25183. mesh: Mesh;
  25184. /**
  25185. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25186. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25187. */
  25188. vars: any;
  25189. /**
  25190. * This array is populated when the SPS is set as 'pickable'.
  25191. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25192. * Each element of this array is an object `{idx: int, faceId: int}`.
  25193. * `idx` is the picked particle index in the `SPS.particles` array
  25194. * `faceId` is the picked face index counted within this particle.
  25195. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25196. */
  25197. pickedParticles: {
  25198. idx: number;
  25199. faceId: number;
  25200. }[];
  25201. /**
  25202. * This array is populated when `enableDepthSort` is set to true.
  25203. * Each element of this array is an instance of the class DepthSortedParticle.
  25204. */
  25205. depthSortedParticles: DepthSortedParticle[];
  25206. /**
  25207. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25208. * @hidden
  25209. */
  25210. _bSphereOnly: boolean;
  25211. /**
  25212. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25213. * @hidden
  25214. */
  25215. _bSphereRadiusFactor: number;
  25216. private _scene;
  25217. private _positions;
  25218. private _indices;
  25219. private _normals;
  25220. private _colors;
  25221. private _uvs;
  25222. private _indices32;
  25223. private _positions32;
  25224. private _normals32;
  25225. private _fixedNormal32;
  25226. private _colors32;
  25227. private _uvs32;
  25228. private _index;
  25229. private _updatable;
  25230. private _pickable;
  25231. private _isVisibilityBoxLocked;
  25232. private _alwaysVisible;
  25233. private _depthSort;
  25234. private _expandable;
  25235. private _shapeCounter;
  25236. private _copy;
  25237. private _color;
  25238. private _computeParticleColor;
  25239. private _computeParticleTexture;
  25240. private _computeParticleRotation;
  25241. private _computeParticleVertex;
  25242. private _computeBoundingBox;
  25243. private _depthSortParticles;
  25244. private _camera;
  25245. private _mustUnrotateFixedNormals;
  25246. private _particlesIntersect;
  25247. private _needs32Bits;
  25248. /**
  25249. * Creates a SPS (Solid Particle System) object.
  25250. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25251. * @param scene (Scene) is the scene in which the SPS is added.
  25252. * @param options defines the options of the sps e.g.
  25253. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25254. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25255. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25256. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25257. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25258. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25259. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25260. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25261. */
  25262. constructor(name: string, scene: Scene, options?: {
  25263. updatable?: boolean;
  25264. isPickable?: boolean;
  25265. enableDepthSort?: boolean;
  25266. particleIntersection?: boolean;
  25267. boundingSphereOnly?: boolean;
  25268. bSphereRadiusFactor?: number;
  25269. expandable?: boolean;
  25270. });
  25271. /**
  25272. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25273. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25274. * @returns the created mesh
  25275. */
  25276. buildMesh(): Mesh;
  25277. /**
  25278. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25279. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25280. * Thus the particles generated from `digest()` have their property `position` set yet.
  25281. * @param mesh ( Mesh ) is the mesh to be digested
  25282. * @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
  25283. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25284. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25285. * @returns the current SPS
  25286. */
  25287. digest(mesh: Mesh, options?: {
  25288. facetNb?: number;
  25289. number?: number;
  25290. delta?: number;
  25291. }): SolidParticleSystem;
  25292. private _unrotateFixedNormals;
  25293. private _resetCopy;
  25294. private _meshBuilder;
  25295. private _posToShape;
  25296. private _uvsToShapeUV;
  25297. private _addParticle;
  25298. /**
  25299. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25300. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25301. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25302. * @param nb (positive integer) the number of particles to be created from this model
  25303. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25304. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25305. * @returns the number of shapes in the system
  25306. */
  25307. addShape(mesh: Mesh, nb: number, options?: {
  25308. positionFunction?: any;
  25309. vertexFunction?: any;
  25310. }): number;
  25311. private _rebuildParticle;
  25312. /**
  25313. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25314. * @returns the SPS.
  25315. */
  25316. rebuildMesh(): SolidParticleSystem;
  25317. /**
  25318. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25319. * This method calls `updateParticle()` for each particle of the SPS.
  25320. * For an animated SPS, it is usually called within the render loop.
  25321. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25322. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25323. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25324. * @returns the SPS.
  25325. */
  25326. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25327. /**
  25328. * Disposes the SPS.
  25329. */
  25330. dispose(): void;
  25331. /**
  25332. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25333. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25334. * @returns the SPS.
  25335. */
  25336. refreshVisibleSize(): SolidParticleSystem;
  25337. /**
  25338. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25339. * @param size the size (float) of the visibility box
  25340. * note : this doesn't lock the SPS mesh bounding box.
  25341. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25342. */
  25343. setVisibilityBox(size: number): void;
  25344. /**
  25345. * Gets whether the SPS as always visible or not
  25346. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25347. */
  25348. /**
  25349. * Sets the SPS as always visible or not
  25350. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25351. */
  25352. isAlwaysVisible: boolean;
  25353. /**
  25354. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25355. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25356. */
  25357. /**
  25358. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25359. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25360. */
  25361. isVisibilityBoxLocked: boolean;
  25362. /**
  25363. * Tells to `setParticles()` to compute the particle rotations or not.
  25364. * Default value : true. The SPS is faster when it's set to false.
  25365. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25366. */
  25367. /**
  25368. * Gets if `setParticles()` computes the particle rotations or not.
  25369. * Default value : true. The SPS is faster when it's set to false.
  25370. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25371. */
  25372. computeParticleRotation: boolean;
  25373. /**
  25374. * Tells to `setParticles()` to compute the particle colors or not.
  25375. * Default value : true. The SPS is faster when it's set to false.
  25376. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25377. */
  25378. /**
  25379. * Gets if `setParticles()` computes the particle colors or not.
  25380. * Default value : true. The SPS is faster when it's set to false.
  25381. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25382. */
  25383. computeParticleColor: boolean;
  25384. /**
  25385. * Gets if `setParticles()` computes the particle textures or not.
  25386. * Default value : true. The SPS is faster when it's set to false.
  25387. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25388. */
  25389. computeParticleTexture: boolean;
  25390. /**
  25391. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25392. * Default value : false. The SPS is faster when it's set to false.
  25393. * Note : the particle custom vertex positions aren't stored values.
  25394. */
  25395. /**
  25396. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25397. * Default value : false. The SPS is faster when it's set to false.
  25398. * Note : the particle custom vertex positions aren't stored values.
  25399. */
  25400. computeParticleVertex: boolean;
  25401. /**
  25402. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25403. */
  25404. /**
  25405. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25406. */
  25407. computeBoundingBox: boolean;
  25408. /**
  25409. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25410. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25411. * Default : `true`
  25412. */
  25413. /**
  25414. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25415. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25416. * Default : `true`
  25417. */
  25418. depthSortParticles: boolean;
  25419. /**
  25420. * Gets if the SPS is created as expandable at construction time.
  25421. * Default : `false`
  25422. */
  25423. readonly expandable: boolean;
  25424. /**
  25425. * This function does nothing. It may be overwritten to set all the particle first values.
  25426. * The SPS doesn't call this function, you may have to call it by your own.
  25427. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25428. */
  25429. initParticles(): void;
  25430. /**
  25431. * This function does nothing. It may be overwritten to recycle a particle.
  25432. * The SPS doesn't call this function, you may have to call it by your own.
  25433. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25434. * @param particle The particle to recycle
  25435. * @returns the recycled particle
  25436. */
  25437. recycleParticle(particle: SolidParticle): SolidParticle;
  25438. /**
  25439. * Updates a particle : this function should be overwritten by the user.
  25440. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25441. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25442. * @example : just set a particle position or velocity and recycle conditions
  25443. * @param particle The particle to update
  25444. * @returns the updated particle
  25445. */
  25446. updateParticle(particle: SolidParticle): SolidParticle;
  25447. /**
  25448. * Updates a vertex of a particle : it can be overwritten by the user.
  25449. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25450. * @param particle the current particle
  25451. * @param vertex the current index of the current particle
  25452. * @param pt the index of the current vertex in the particle shape
  25453. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25454. * @example : just set a vertex particle position
  25455. * @returns the updated vertex
  25456. */
  25457. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25458. /**
  25459. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25460. * This does nothing and may be overwritten by the user.
  25461. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25462. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25463. * @param update the boolean update value actually passed to setParticles()
  25464. */
  25465. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25466. /**
  25467. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25468. * This will be passed three parameters.
  25469. * This does nothing and may be overwritten by the user.
  25470. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25471. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25472. * @param update the boolean update value actually passed to setParticles()
  25473. */
  25474. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25475. }
  25476. }
  25477. declare module BABYLON {
  25478. /**
  25479. * Represents one particle of a solid particle system.
  25480. */
  25481. export class SolidParticle {
  25482. /**
  25483. * particle global index
  25484. */
  25485. idx: number;
  25486. /**
  25487. * The color of the particle
  25488. */
  25489. color: Nullable<Color4>;
  25490. /**
  25491. * The world space position of the particle.
  25492. */
  25493. position: Vector3;
  25494. /**
  25495. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25496. */
  25497. rotation: Vector3;
  25498. /**
  25499. * The world space rotation quaternion of the particle.
  25500. */
  25501. rotationQuaternion: Nullable<Quaternion>;
  25502. /**
  25503. * The scaling of the particle.
  25504. */
  25505. scaling: Vector3;
  25506. /**
  25507. * The uvs of the particle.
  25508. */
  25509. uvs: Vector4;
  25510. /**
  25511. * The current speed of the particle.
  25512. */
  25513. velocity: Vector3;
  25514. /**
  25515. * The pivot point in the particle local space.
  25516. */
  25517. pivot: Vector3;
  25518. /**
  25519. * Must the particle be translated from its pivot point in its local space ?
  25520. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25521. * Default : false
  25522. */
  25523. translateFromPivot: boolean;
  25524. /**
  25525. * Is the particle active or not ?
  25526. */
  25527. alive: boolean;
  25528. /**
  25529. * Is the particle visible or not ?
  25530. */
  25531. isVisible: boolean;
  25532. /**
  25533. * Index of this particle in the global "positions" array (Internal use)
  25534. * @hidden
  25535. */
  25536. _pos: number;
  25537. /**
  25538. * @hidden Index of this particle in the global "indices" array (Internal use)
  25539. */
  25540. _ind: number;
  25541. /**
  25542. * @hidden ModelShape of this particle (Internal use)
  25543. */
  25544. _model: ModelShape;
  25545. /**
  25546. * ModelShape id of this particle
  25547. */
  25548. shapeId: number;
  25549. /**
  25550. * Index of the particle in its shape id
  25551. */
  25552. idxInShape: number;
  25553. /**
  25554. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25555. */
  25556. _modelBoundingInfo: BoundingInfo;
  25557. /**
  25558. * @hidden Particle BoundingInfo object (Internal use)
  25559. */
  25560. _boundingInfo: BoundingInfo;
  25561. /**
  25562. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25563. */
  25564. _sps: SolidParticleSystem;
  25565. /**
  25566. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25567. */
  25568. _stillInvisible: boolean;
  25569. /**
  25570. * @hidden Last computed particle rotation matrix
  25571. */
  25572. _rotationMatrix: number[];
  25573. /**
  25574. * Parent particle Id, if any.
  25575. * Default null.
  25576. */
  25577. parentId: Nullable<number>;
  25578. /**
  25579. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25580. * The possible values are :
  25581. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25582. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25583. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25584. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25585. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25586. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25587. * */
  25588. cullingStrategy: number;
  25589. /**
  25590. * @hidden Internal global position in the SPS.
  25591. */
  25592. _globalPosition: Vector3;
  25593. /**
  25594. * Creates a Solid Particle object.
  25595. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25596. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25597. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25598. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25599. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25600. * @param shapeId (integer) is the model shape identifier in the SPS.
  25601. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25602. * @param sps defines the sps it is associated to
  25603. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25604. */
  25605. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25606. /**
  25607. * Legacy support, changed scale to scaling
  25608. */
  25609. /**
  25610. * Legacy support, changed scale to scaling
  25611. */
  25612. scale: Vector3;
  25613. /**
  25614. * Legacy support, changed quaternion to rotationQuaternion
  25615. */
  25616. /**
  25617. * Legacy support, changed quaternion to rotationQuaternion
  25618. */
  25619. quaternion: Nullable<Quaternion>;
  25620. /**
  25621. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25622. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25623. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25624. * @returns true if it intersects
  25625. */
  25626. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25627. /**
  25628. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25629. * A particle is in the frustum if its bounding box intersects the frustum
  25630. * @param frustumPlanes defines the frustum to test
  25631. * @returns true if the particle is in the frustum planes
  25632. */
  25633. isInFrustum(frustumPlanes: Plane[]): boolean;
  25634. /**
  25635. * get the rotation matrix of the particle
  25636. * @hidden
  25637. */
  25638. getRotationMatrix(m: Matrix): void;
  25639. }
  25640. /**
  25641. * Represents the shape of the model used by one particle of a solid particle system.
  25642. * SPS internal tool, don't use it manually.
  25643. */
  25644. export class ModelShape {
  25645. /**
  25646. * The shape id
  25647. * @hidden
  25648. */
  25649. shapeID: number;
  25650. /**
  25651. * flat array of model positions (internal use)
  25652. * @hidden
  25653. */
  25654. _shape: Vector3[];
  25655. /**
  25656. * flat array of model UVs (internal use)
  25657. * @hidden
  25658. */
  25659. _shapeUV: number[];
  25660. /**
  25661. * length of the shape in the model indices array (internal use)
  25662. * @hidden
  25663. */
  25664. _indicesLength: number;
  25665. /**
  25666. * Custom position function (internal use)
  25667. * @hidden
  25668. */
  25669. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25670. /**
  25671. * Custom vertex function (internal use)
  25672. * @hidden
  25673. */
  25674. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25675. /**
  25676. * 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.
  25677. * SPS internal tool, don't use it manually.
  25678. * @hidden
  25679. */
  25680. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25681. }
  25682. /**
  25683. * Represents a Depth Sorted Particle in the solid particle system.
  25684. */
  25685. export class DepthSortedParticle {
  25686. /**
  25687. * Index of the particle in the "indices" array
  25688. */
  25689. ind: number;
  25690. /**
  25691. * Length of the particle shape in the "indices" array
  25692. */
  25693. indicesLength: number;
  25694. /**
  25695. * Squared distance from the particle to the camera
  25696. */
  25697. sqDistance: number;
  25698. }
  25699. }
  25700. declare module BABYLON {
  25701. /**
  25702. * @hidden
  25703. */
  25704. export class _MeshCollisionData {
  25705. _checkCollisions: boolean;
  25706. _collisionMask: number;
  25707. _collisionGroup: number;
  25708. _collider: Nullable<Collider>;
  25709. _oldPositionForCollisions: Vector3;
  25710. _diffPositionForCollisions: Vector3;
  25711. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25712. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25713. }
  25714. }
  25715. declare module BABYLON {
  25716. /** @hidden */
  25717. class _FacetDataStorage {
  25718. facetPositions: Vector3[];
  25719. facetNormals: Vector3[];
  25720. facetPartitioning: number[][];
  25721. facetNb: number;
  25722. partitioningSubdivisions: number;
  25723. partitioningBBoxRatio: number;
  25724. facetDataEnabled: boolean;
  25725. facetParameters: any;
  25726. bbSize: Vector3;
  25727. subDiv: {
  25728. max: number;
  25729. X: number;
  25730. Y: number;
  25731. Z: number;
  25732. };
  25733. facetDepthSort: boolean;
  25734. facetDepthSortEnabled: boolean;
  25735. depthSortedIndices: IndicesArray;
  25736. depthSortedFacets: {
  25737. ind: number;
  25738. sqDistance: number;
  25739. }[];
  25740. facetDepthSortFunction: (f1: {
  25741. ind: number;
  25742. sqDistance: number;
  25743. }, f2: {
  25744. ind: number;
  25745. sqDistance: number;
  25746. }) => number;
  25747. facetDepthSortFrom: Vector3;
  25748. facetDepthSortOrigin: Vector3;
  25749. invertedMatrix: Matrix;
  25750. }
  25751. /**
  25752. * @hidden
  25753. **/
  25754. class _InternalAbstractMeshDataInfo {
  25755. _hasVertexAlpha: boolean;
  25756. _useVertexColors: boolean;
  25757. _numBoneInfluencers: number;
  25758. _applyFog: boolean;
  25759. _receiveShadows: boolean;
  25760. _facetData: _FacetDataStorage;
  25761. _visibility: number;
  25762. _skeleton: Nullable<Skeleton>;
  25763. _layerMask: number;
  25764. _computeBonesUsingShaders: boolean;
  25765. _isActive: boolean;
  25766. _onlyForInstances: boolean;
  25767. _isActiveIntermediate: boolean;
  25768. _onlyForInstancesIntermediate: boolean;
  25769. _actAsRegularMesh: boolean;
  25770. }
  25771. /**
  25772. * Class used to store all common mesh properties
  25773. */
  25774. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25775. /** No occlusion */
  25776. static OCCLUSION_TYPE_NONE: number;
  25777. /** Occlusion set to optimisitic */
  25778. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25779. /** Occlusion set to strict */
  25780. static OCCLUSION_TYPE_STRICT: number;
  25781. /** Use an accurante occlusion algorithm */
  25782. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25783. /** Use a conservative occlusion algorithm */
  25784. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25785. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25786. * Test order :
  25787. * Is the bounding sphere outside the frustum ?
  25788. * If not, are the bounding box vertices outside the frustum ?
  25789. * It not, then the cullable object is in the frustum.
  25790. */
  25791. static readonly CULLINGSTRATEGY_STANDARD: number;
  25792. /** Culling strategy : Bounding Sphere Only.
  25793. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25794. * It's also less accurate than the standard because some not visible objects can still be selected.
  25795. * Test : is the bounding sphere outside the frustum ?
  25796. * If not, then the cullable object is in the frustum.
  25797. */
  25798. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25799. /** Culling strategy : Optimistic Inclusion.
  25800. * This in an inclusion test first, then the standard exclusion test.
  25801. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25802. * 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.
  25803. * Anyway, it's as accurate as the standard strategy.
  25804. * Test :
  25805. * Is the cullable object bounding sphere center in the frustum ?
  25806. * If not, apply the default culling strategy.
  25807. */
  25808. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25809. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25810. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25811. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25812. * 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.
  25813. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25814. * Test :
  25815. * Is the cullable object bounding sphere center in the frustum ?
  25816. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25817. */
  25818. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25819. /**
  25820. * No billboard
  25821. */
  25822. static readonly BILLBOARDMODE_NONE: number;
  25823. /** Billboard on X axis */
  25824. static readonly BILLBOARDMODE_X: number;
  25825. /** Billboard on Y axis */
  25826. static readonly BILLBOARDMODE_Y: number;
  25827. /** Billboard on Z axis */
  25828. static readonly BILLBOARDMODE_Z: number;
  25829. /** Billboard on all axes */
  25830. static readonly BILLBOARDMODE_ALL: number;
  25831. /** Billboard on using position instead of orientation */
  25832. static readonly BILLBOARDMODE_USE_POSITION: number;
  25833. /** @hidden */
  25834. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25835. /**
  25836. * The culling strategy to use to check whether the mesh must be rendered or not.
  25837. * This value can be changed at any time and will be used on the next render mesh selection.
  25838. * The possible values are :
  25839. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25840. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25841. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25842. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25843. * Please read each static variable documentation to get details about the culling process.
  25844. * */
  25845. cullingStrategy: number;
  25846. /**
  25847. * Gets the number of facets in the mesh
  25848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25849. */
  25850. readonly facetNb: number;
  25851. /**
  25852. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25854. */
  25855. partitioningSubdivisions: number;
  25856. /**
  25857. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25858. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25860. */
  25861. partitioningBBoxRatio: number;
  25862. /**
  25863. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25864. * Works only for updatable meshes.
  25865. * Doesn't work with multi-materials
  25866. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25867. */
  25868. mustDepthSortFacets: boolean;
  25869. /**
  25870. * The location (Vector3) where the facet depth sort must be computed from.
  25871. * By default, the active camera position.
  25872. * Used only when facet depth sort is enabled
  25873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25874. */
  25875. facetDepthSortFrom: Vector3;
  25876. /**
  25877. * gets a boolean indicating if facetData is enabled
  25878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25879. */
  25880. readonly isFacetDataEnabled: boolean;
  25881. /** @hidden */
  25882. _updateNonUniformScalingState(value: boolean): boolean;
  25883. /**
  25884. * An event triggered when this mesh collides with another one
  25885. */
  25886. onCollideObservable: Observable<AbstractMesh>;
  25887. /** Set a function to call when this mesh collides with another one */
  25888. onCollide: () => void;
  25889. /**
  25890. * An event triggered when the collision's position changes
  25891. */
  25892. onCollisionPositionChangeObservable: Observable<Vector3>;
  25893. /** Set a function to call when the collision's position changes */
  25894. onCollisionPositionChange: () => void;
  25895. /**
  25896. * An event triggered when material is changed
  25897. */
  25898. onMaterialChangedObservable: Observable<AbstractMesh>;
  25899. /**
  25900. * Gets or sets the orientation for POV movement & rotation
  25901. */
  25902. definedFacingForward: boolean;
  25903. /** @hidden */
  25904. _occlusionQuery: Nullable<WebGLQuery>;
  25905. /** @hidden */
  25906. _renderingGroup: Nullable<RenderingGroup>;
  25907. /**
  25908. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25909. */
  25910. /**
  25911. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25912. */
  25913. visibility: number;
  25914. /** Gets or sets the alpha index used to sort transparent meshes
  25915. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25916. */
  25917. alphaIndex: number;
  25918. /**
  25919. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25920. */
  25921. isVisible: boolean;
  25922. /**
  25923. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25924. */
  25925. isPickable: boolean;
  25926. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25927. showSubMeshesBoundingBox: boolean;
  25928. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25929. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25930. */
  25931. isBlocker: boolean;
  25932. /**
  25933. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25934. */
  25935. enablePointerMoveEvents: boolean;
  25936. /**
  25937. * Specifies the rendering group id for this mesh (0 by default)
  25938. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25939. */
  25940. renderingGroupId: number;
  25941. private _material;
  25942. /** Gets or sets current material */
  25943. material: Nullable<Material>;
  25944. /**
  25945. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25946. * @see http://doc.babylonjs.com/babylon101/shadows
  25947. */
  25948. receiveShadows: boolean;
  25949. /** Defines color to use when rendering outline */
  25950. outlineColor: Color3;
  25951. /** Define width to use when rendering outline */
  25952. outlineWidth: number;
  25953. /** Defines color to use when rendering overlay */
  25954. overlayColor: Color3;
  25955. /** Defines alpha to use when rendering overlay */
  25956. overlayAlpha: number;
  25957. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25958. hasVertexAlpha: boolean;
  25959. /** 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) */
  25960. useVertexColors: boolean;
  25961. /**
  25962. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25963. */
  25964. computeBonesUsingShaders: boolean;
  25965. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25966. numBoneInfluencers: number;
  25967. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25968. applyFog: boolean;
  25969. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25970. useOctreeForRenderingSelection: boolean;
  25971. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25972. useOctreeForPicking: boolean;
  25973. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25974. useOctreeForCollisions: boolean;
  25975. /**
  25976. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25977. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25978. */
  25979. layerMask: number;
  25980. /**
  25981. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25982. */
  25983. alwaysSelectAsActiveMesh: boolean;
  25984. /**
  25985. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25986. */
  25987. doNotSyncBoundingInfo: boolean;
  25988. /**
  25989. * Gets or sets the current action manager
  25990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25991. */
  25992. actionManager: Nullable<AbstractActionManager>;
  25993. private _meshCollisionData;
  25994. /**
  25995. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25996. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25997. */
  25998. ellipsoid: Vector3;
  25999. /**
  26000. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26001. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26002. */
  26003. ellipsoidOffset: Vector3;
  26004. /**
  26005. * Gets or sets a collision mask used to mask collisions (default is -1).
  26006. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26007. */
  26008. collisionMask: number;
  26009. /**
  26010. * Gets or sets the current collision group mask (-1 by default).
  26011. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26012. */
  26013. collisionGroup: number;
  26014. /**
  26015. * Defines edge width used when edgesRenderer is enabled
  26016. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26017. */
  26018. edgesWidth: number;
  26019. /**
  26020. * Defines edge color used when edgesRenderer is enabled
  26021. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26022. */
  26023. edgesColor: Color4;
  26024. /** @hidden */
  26025. _edgesRenderer: Nullable<IEdgesRenderer>;
  26026. /** @hidden */
  26027. _masterMesh: Nullable<AbstractMesh>;
  26028. /** @hidden */
  26029. _boundingInfo: Nullable<BoundingInfo>;
  26030. /** @hidden */
  26031. _renderId: number;
  26032. /**
  26033. * Gets or sets the list of subMeshes
  26034. * @see http://doc.babylonjs.com/how_to/multi_materials
  26035. */
  26036. subMeshes: SubMesh[];
  26037. /** @hidden */
  26038. _intersectionsInProgress: AbstractMesh[];
  26039. /** @hidden */
  26040. _unIndexed: boolean;
  26041. /** @hidden */
  26042. _lightSources: Light[];
  26043. /** Gets the list of lights affecting that mesh */
  26044. readonly lightSources: Light[];
  26045. /** @hidden */
  26046. readonly _positions: Nullable<Vector3[]>;
  26047. /** @hidden */
  26048. _waitingData: {
  26049. lods: Nullable<any>;
  26050. actions: Nullable<any>;
  26051. freezeWorldMatrix: Nullable<boolean>;
  26052. };
  26053. /** @hidden */
  26054. _bonesTransformMatrices: Nullable<Float32Array>;
  26055. /** @hidden */
  26056. _transformMatrixTexture: Nullable<RawTexture>;
  26057. /**
  26058. * Gets or sets a skeleton to apply skining transformations
  26059. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26060. */
  26061. skeleton: Nullable<Skeleton>;
  26062. /**
  26063. * An event triggered when the mesh is rebuilt.
  26064. */
  26065. onRebuildObservable: Observable<AbstractMesh>;
  26066. /**
  26067. * Creates a new AbstractMesh
  26068. * @param name defines the name of the mesh
  26069. * @param scene defines the hosting scene
  26070. */
  26071. constructor(name: string, scene?: Nullable<Scene>);
  26072. /**
  26073. * Returns the string "AbstractMesh"
  26074. * @returns "AbstractMesh"
  26075. */
  26076. getClassName(): string;
  26077. /**
  26078. * Gets a string representation of the current mesh
  26079. * @param fullDetails defines a boolean indicating if full details must be included
  26080. * @returns a string representation of the current mesh
  26081. */
  26082. toString(fullDetails?: boolean): string;
  26083. /**
  26084. * @hidden
  26085. */
  26086. protected _getEffectiveParent(): Nullable<Node>;
  26087. /** @hidden */
  26088. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26089. /** @hidden */
  26090. _rebuild(): void;
  26091. /** @hidden */
  26092. _resyncLightSources(): void;
  26093. /** @hidden */
  26094. _resyncLighSource(light: Light): void;
  26095. /** @hidden */
  26096. _unBindEffect(): void;
  26097. /** @hidden */
  26098. _removeLightSource(light: Light, dispose: boolean): void;
  26099. private _markSubMeshesAsDirty;
  26100. /** @hidden */
  26101. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26102. /** @hidden */
  26103. _markSubMeshesAsAttributesDirty(): void;
  26104. /** @hidden */
  26105. _markSubMeshesAsMiscDirty(): void;
  26106. /**
  26107. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26108. */
  26109. scaling: Vector3;
  26110. /**
  26111. * Returns true if the mesh is blocked. Implemented by child classes
  26112. */
  26113. readonly isBlocked: boolean;
  26114. /**
  26115. * Returns the mesh itself by default. Implemented by child classes
  26116. * @param camera defines the camera to use to pick the right LOD level
  26117. * @returns the currentAbstractMesh
  26118. */
  26119. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26120. /**
  26121. * Returns 0 by default. Implemented by child classes
  26122. * @returns an integer
  26123. */
  26124. getTotalVertices(): number;
  26125. /**
  26126. * Returns a positive integer : the total number of indices in this mesh geometry.
  26127. * @returns the numner of indices or zero if the mesh has no geometry.
  26128. */
  26129. getTotalIndices(): number;
  26130. /**
  26131. * Returns null by default. Implemented by child classes
  26132. * @returns null
  26133. */
  26134. getIndices(): Nullable<IndicesArray>;
  26135. /**
  26136. * Returns the array of the requested vertex data kind. Implemented by child classes
  26137. * @param kind defines the vertex data kind to use
  26138. * @returns null
  26139. */
  26140. getVerticesData(kind: string): Nullable<FloatArray>;
  26141. /**
  26142. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26143. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26144. * Note that a new underlying VertexBuffer object is created each call.
  26145. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26146. * @param kind defines vertex data kind:
  26147. * * VertexBuffer.PositionKind
  26148. * * VertexBuffer.UVKind
  26149. * * VertexBuffer.UV2Kind
  26150. * * VertexBuffer.UV3Kind
  26151. * * VertexBuffer.UV4Kind
  26152. * * VertexBuffer.UV5Kind
  26153. * * VertexBuffer.UV6Kind
  26154. * * VertexBuffer.ColorKind
  26155. * * VertexBuffer.MatricesIndicesKind
  26156. * * VertexBuffer.MatricesIndicesExtraKind
  26157. * * VertexBuffer.MatricesWeightsKind
  26158. * * VertexBuffer.MatricesWeightsExtraKind
  26159. * @param data defines the data source
  26160. * @param updatable defines if the data must be flagged as updatable (or static)
  26161. * @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
  26162. * @returns the current mesh
  26163. */
  26164. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26165. /**
  26166. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26167. * If the mesh has no geometry, it is simply returned as it is.
  26168. * @param kind defines vertex data kind:
  26169. * * VertexBuffer.PositionKind
  26170. * * VertexBuffer.UVKind
  26171. * * VertexBuffer.UV2Kind
  26172. * * VertexBuffer.UV3Kind
  26173. * * VertexBuffer.UV4Kind
  26174. * * VertexBuffer.UV5Kind
  26175. * * VertexBuffer.UV6Kind
  26176. * * VertexBuffer.ColorKind
  26177. * * VertexBuffer.MatricesIndicesKind
  26178. * * VertexBuffer.MatricesIndicesExtraKind
  26179. * * VertexBuffer.MatricesWeightsKind
  26180. * * VertexBuffer.MatricesWeightsExtraKind
  26181. * @param data defines the data source
  26182. * @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
  26183. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26184. * @returns the current mesh
  26185. */
  26186. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26187. /**
  26188. * Sets the mesh indices,
  26189. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26190. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26191. * @param totalVertices Defines the total number of vertices
  26192. * @returns the current mesh
  26193. */
  26194. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26195. /**
  26196. * Gets a boolean indicating if specific vertex data is present
  26197. * @param kind defines the vertex data kind to use
  26198. * @returns true is data kind is present
  26199. */
  26200. isVerticesDataPresent(kind: string): boolean;
  26201. /**
  26202. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26203. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26204. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26205. * @returns a BoundingInfo
  26206. */
  26207. getBoundingInfo(): BoundingInfo;
  26208. /**
  26209. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26210. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26211. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26212. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26213. * @returns the current mesh
  26214. */
  26215. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26216. /**
  26217. * Overwrite the current bounding info
  26218. * @param boundingInfo defines the new bounding info
  26219. * @returns the current mesh
  26220. */
  26221. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26222. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26223. readonly useBones: boolean;
  26224. /** @hidden */
  26225. _preActivate(): void;
  26226. /** @hidden */
  26227. _preActivateForIntermediateRendering(renderId: number): void;
  26228. /** @hidden */
  26229. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26230. /** @hidden */
  26231. _postActivate(): void;
  26232. /** @hidden */
  26233. _freeze(): void;
  26234. /** @hidden */
  26235. _unFreeze(): void;
  26236. /**
  26237. * Gets the current world matrix
  26238. * @returns a Matrix
  26239. */
  26240. getWorldMatrix(): Matrix;
  26241. /** @hidden */
  26242. _getWorldMatrixDeterminant(): number;
  26243. /**
  26244. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26245. */
  26246. readonly isAnInstance: boolean;
  26247. /**
  26248. * Gets a boolean indicating if this mesh has instances
  26249. */
  26250. readonly hasInstances: boolean;
  26251. /**
  26252. * Perform relative position change from the point of view of behind the front of the mesh.
  26253. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26254. * Supports definition of mesh facing forward or backward
  26255. * @param amountRight defines the distance on the right axis
  26256. * @param amountUp defines the distance on the up axis
  26257. * @param amountForward defines the distance on the forward axis
  26258. * @returns the current mesh
  26259. */
  26260. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26261. /**
  26262. * Calculate relative position change from the point of view of behind the front of the mesh.
  26263. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26264. * Supports definition of mesh facing forward or backward
  26265. * @param amountRight defines the distance on the right axis
  26266. * @param amountUp defines the distance on the up axis
  26267. * @param amountForward defines the distance on the forward axis
  26268. * @returns the new displacement vector
  26269. */
  26270. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26271. /**
  26272. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26273. * Supports definition of mesh facing forward or backward
  26274. * @param flipBack defines the flip
  26275. * @param twirlClockwise defines the twirl
  26276. * @param tiltRight defines the tilt
  26277. * @returns the current mesh
  26278. */
  26279. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26280. /**
  26281. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26282. * Supports definition of mesh facing forward or backward.
  26283. * @param flipBack defines the flip
  26284. * @param twirlClockwise defines the twirl
  26285. * @param tiltRight defines the tilt
  26286. * @returns the new rotation vector
  26287. */
  26288. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26289. /**
  26290. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26291. * This means the mesh underlying bounding box and sphere are recomputed.
  26292. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26293. * @returns the current mesh
  26294. */
  26295. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26296. /** @hidden */
  26297. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26298. /** @hidden */
  26299. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26300. /** @hidden */
  26301. _updateBoundingInfo(): AbstractMesh;
  26302. /** @hidden */
  26303. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26304. /** @hidden */
  26305. protected _afterComputeWorldMatrix(): void;
  26306. /** @hidden */
  26307. readonly _effectiveMesh: AbstractMesh;
  26308. /**
  26309. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26310. * A mesh is in the frustum if its bounding box intersects the frustum
  26311. * @param frustumPlanes defines the frustum to test
  26312. * @returns true if the mesh is in the frustum planes
  26313. */
  26314. isInFrustum(frustumPlanes: Plane[]): boolean;
  26315. /**
  26316. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26317. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26318. * @param frustumPlanes defines the frustum to test
  26319. * @returns true if the mesh is completely in the frustum planes
  26320. */
  26321. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26322. /**
  26323. * True if the mesh intersects another mesh or a SolidParticle object
  26324. * @param mesh defines a target mesh or SolidParticle to test
  26325. * @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)
  26326. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26327. * @returns true if there is an intersection
  26328. */
  26329. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26330. /**
  26331. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26332. * @param point defines the point to test
  26333. * @returns true if there is an intersection
  26334. */
  26335. intersectsPoint(point: Vector3): boolean;
  26336. /**
  26337. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26338. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26339. */
  26340. checkCollisions: boolean;
  26341. /**
  26342. * Gets Collider object used to compute collisions (not physics)
  26343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26344. */
  26345. readonly collider: Nullable<Collider>;
  26346. /**
  26347. * Move the mesh using collision engine
  26348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26349. * @param displacement defines the requested displacement vector
  26350. * @returns the current mesh
  26351. */
  26352. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26353. private _onCollisionPositionChange;
  26354. /** @hidden */
  26355. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26356. /** @hidden */
  26357. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26358. /** @hidden */
  26359. _checkCollision(collider: Collider): AbstractMesh;
  26360. /** @hidden */
  26361. _generatePointsArray(): boolean;
  26362. /**
  26363. * Checks if the passed Ray intersects with the mesh
  26364. * @param ray defines the ray to use
  26365. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26366. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26367. * @returns the picking info
  26368. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26369. */
  26370. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26371. /**
  26372. * Clones the current mesh
  26373. * @param name defines the mesh name
  26374. * @param newParent defines the new mesh parent
  26375. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26376. * @returns the new mesh
  26377. */
  26378. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26379. /**
  26380. * Disposes all the submeshes of the current meshnp
  26381. * @returns the current mesh
  26382. */
  26383. releaseSubMeshes(): AbstractMesh;
  26384. /**
  26385. * Releases resources associated with this abstract mesh.
  26386. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26387. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26388. */
  26389. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26390. /**
  26391. * Adds the passed mesh as a child to the current mesh
  26392. * @param mesh defines the child mesh
  26393. * @returns the current mesh
  26394. */
  26395. addChild(mesh: AbstractMesh): AbstractMesh;
  26396. /**
  26397. * Removes the passed mesh from the current mesh children list
  26398. * @param mesh defines the child mesh
  26399. * @returns the current mesh
  26400. */
  26401. removeChild(mesh: AbstractMesh): AbstractMesh;
  26402. /** @hidden */
  26403. private _initFacetData;
  26404. /**
  26405. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26406. * This method can be called within the render loop.
  26407. * 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
  26408. * @returns the current mesh
  26409. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26410. */
  26411. updateFacetData(): AbstractMesh;
  26412. /**
  26413. * Returns the facetLocalNormals array.
  26414. * The normals are expressed in the mesh local spac
  26415. * @returns an array of Vector3
  26416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26417. */
  26418. getFacetLocalNormals(): Vector3[];
  26419. /**
  26420. * Returns the facetLocalPositions array.
  26421. * The facet positions are expressed in the mesh local space
  26422. * @returns an array of Vector3
  26423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26424. */
  26425. getFacetLocalPositions(): Vector3[];
  26426. /**
  26427. * Returns the facetLocalPartioning array
  26428. * @returns an array of array of numbers
  26429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26430. */
  26431. getFacetLocalPartitioning(): number[][];
  26432. /**
  26433. * Returns the i-th facet position in the world system.
  26434. * This method allocates a new Vector3 per call
  26435. * @param i defines the facet index
  26436. * @returns a new Vector3
  26437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26438. */
  26439. getFacetPosition(i: number): Vector3;
  26440. /**
  26441. * Sets the reference Vector3 with the i-th facet position in the world system
  26442. * @param i defines the facet index
  26443. * @param ref defines the target vector
  26444. * @returns the current mesh
  26445. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26446. */
  26447. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26448. /**
  26449. * Returns the i-th facet normal in the world system.
  26450. * This method allocates a new Vector3 per call
  26451. * @param i defines the facet index
  26452. * @returns a new Vector3
  26453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26454. */
  26455. getFacetNormal(i: number): Vector3;
  26456. /**
  26457. * Sets the reference Vector3 with the i-th facet normal in the world system
  26458. * @param i defines the facet index
  26459. * @param ref defines the target vector
  26460. * @returns the current mesh
  26461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26462. */
  26463. getFacetNormalToRef(i: number, ref: Vector3): this;
  26464. /**
  26465. * 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)
  26466. * @param x defines x coordinate
  26467. * @param y defines y coordinate
  26468. * @param z defines z coordinate
  26469. * @returns the array of facet indexes
  26470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26471. */
  26472. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26473. /**
  26474. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26475. * @param projected sets as the (x,y,z) world projection on the facet
  26476. * @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
  26477. * @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
  26478. * @param x defines x coordinate
  26479. * @param y defines y coordinate
  26480. * @param z defines z coordinate
  26481. * @returns the face index if found (or null instead)
  26482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26483. */
  26484. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26485. /**
  26486. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26487. * @param projected sets as the (x,y,z) local projection on the facet
  26488. * @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
  26489. * @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
  26490. * @param x defines x coordinate
  26491. * @param y defines y coordinate
  26492. * @param z defines z coordinate
  26493. * @returns the face index if found (or null instead)
  26494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26495. */
  26496. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26497. /**
  26498. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26499. * @returns the parameters
  26500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26501. */
  26502. getFacetDataParameters(): any;
  26503. /**
  26504. * Disables the feature FacetData and frees the related memory
  26505. * @returns the current mesh
  26506. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26507. */
  26508. disableFacetData(): AbstractMesh;
  26509. /**
  26510. * Updates the AbstractMesh indices array
  26511. * @param indices defines the data source
  26512. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26513. * @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)
  26514. * @returns the current mesh
  26515. */
  26516. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26517. /**
  26518. * Creates new normals data for the mesh
  26519. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26520. * @returns the current mesh
  26521. */
  26522. createNormals(updatable: boolean): AbstractMesh;
  26523. /**
  26524. * Align the mesh with a normal
  26525. * @param normal defines the normal to use
  26526. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26527. * @returns the current mesh
  26528. */
  26529. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26530. /** @hidden */
  26531. _checkOcclusionQuery(): boolean;
  26532. /**
  26533. * Disables the mesh edge rendering mode
  26534. * @returns the currentAbstractMesh
  26535. */
  26536. disableEdgesRendering(): AbstractMesh;
  26537. /**
  26538. * Enables the edge rendering mode on the mesh.
  26539. * This mode makes the mesh edges visible
  26540. * @param epsilon defines the maximal distance between two angles to detect a face
  26541. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26542. * @returns the currentAbstractMesh
  26543. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26544. */
  26545. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26546. }
  26547. }
  26548. declare module BABYLON {
  26549. /**
  26550. * Interface used to define ActionEvent
  26551. */
  26552. export interface IActionEvent {
  26553. /** The mesh or sprite that triggered the action */
  26554. source: any;
  26555. /** The X mouse cursor position at the time of the event */
  26556. pointerX: number;
  26557. /** The Y mouse cursor position at the time of the event */
  26558. pointerY: number;
  26559. /** The mesh that is currently pointed at (can be null) */
  26560. meshUnderPointer: Nullable<AbstractMesh>;
  26561. /** the original (browser) event that triggered the ActionEvent */
  26562. sourceEvent?: any;
  26563. /** additional data for the event */
  26564. additionalData?: any;
  26565. }
  26566. /**
  26567. * ActionEvent is the event being sent when an action is triggered.
  26568. */
  26569. export class ActionEvent implements IActionEvent {
  26570. /** The mesh or sprite that triggered the action */
  26571. source: any;
  26572. /** The X mouse cursor position at the time of the event */
  26573. pointerX: number;
  26574. /** The Y mouse cursor position at the time of the event */
  26575. pointerY: number;
  26576. /** The mesh that is currently pointed at (can be null) */
  26577. meshUnderPointer: Nullable<AbstractMesh>;
  26578. /** the original (browser) event that triggered the ActionEvent */
  26579. sourceEvent?: any;
  26580. /** additional data for the event */
  26581. additionalData?: any;
  26582. /**
  26583. * Creates a new ActionEvent
  26584. * @param source The mesh or sprite that triggered the action
  26585. * @param pointerX The X mouse cursor position at the time of the event
  26586. * @param pointerY The Y mouse cursor position at the time of the event
  26587. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26588. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26589. * @param additionalData additional data for the event
  26590. */
  26591. constructor(
  26592. /** The mesh or sprite that triggered the action */
  26593. source: any,
  26594. /** The X mouse cursor position at the time of the event */
  26595. pointerX: number,
  26596. /** The Y mouse cursor position at the time of the event */
  26597. pointerY: number,
  26598. /** The mesh that is currently pointed at (can be null) */
  26599. meshUnderPointer: Nullable<AbstractMesh>,
  26600. /** the original (browser) event that triggered the ActionEvent */
  26601. sourceEvent?: any,
  26602. /** additional data for the event */
  26603. additionalData?: any);
  26604. /**
  26605. * Helper function to auto-create an ActionEvent from a source mesh.
  26606. * @param source The source mesh that triggered the event
  26607. * @param evt The original (browser) event
  26608. * @param additionalData additional data for the event
  26609. * @returns the new ActionEvent
  26610. */
  26611. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26612. /**
  26613. * Helper function to auto-create an ActionEvent from a source sprite
  26614. * @param source The source sprite that triggered the event
  26615. * @param scene Scene associated with the sprite
  26616. * @param evt The original (browser) event
  26617. * @param additionalData additional data for the event
  26618. * @returns the new ActionEvent
  26619. */
  26620. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26621. /**
  26622. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26623. * @param scene the scene where the event occurred
  26624. * @param evt The original (browser) event
  26625. * @returns the new ActionEvent
  26626. */
  26627. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26628. /**
  26629. * Helper function to auto-create an ActionEvent from a primitive
  26630. * @param prim defines the target primitive
  26631. * @param pointerPos defines the pointer position
  26632. * @param evt The original (browser) event
  26633. * @param additionalData additional data for the event
  26634. * @returns the new ActionEvent
  26635. */
  26636. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26637. }
  26638. }
  26639. declare module BABYLON {
  26640. /**
  26641. * Abstract class used to decouple action Manager from scene and meshes.
  26642. * Do not instantiate.
  26643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26644. */
  26645. export abstract class AbstractActionManager implements IDisposable {
  26646. /** Gets the list of active triggers */
  26647. static Triggers: {
  26648. [key: string]: number;
  26649. };
  26650. /** Gets the cursor to use when hovering items */
  26651. hoverCursor: string;
  26652. /** Gets the list of actions */
  26653. actions: IAction[];
  26654. /**
  26655. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26656. */
  26657. isRecursive: boolean;
  26658. /**
  26659. * Releases all associated resources
  26660. */
  26661. abstract dispose(): void;
  26662. /**
  26663. * Does this action manager has pointer triggers
  26664. */
  26665. abstract readonly hasPointerTriggers: boolean;
  26666. /**
  26667. * Does this action manager has pick triggers
  26668. */
  26669. abstract readonly hasPickTriggers: boolean;
  26670. /**
  26671. * Process a specific trigger
  26672. * @param trigger defines the trigger to process
  26673. * @param evt defines the event details to be processed
  26674. */
  26675. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26676. /**
  26677. * Does this action manager handles actions of any of the given triggers
  26678. * @param triggers defines the triggers to be tested
  26679. * @return a boolean indicating whether one (or more) of the triggers is handled
  26680. */
  26681. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26682. /**
  26683. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26684. * speed.
  26685. * @param triggerA defines the trigger to be tested
  26686. * @param triggerB defines the trigger to be tested
  26687. * @return a boolean indicating whether one (or more) of the triggers is handled
  26688. */
  26689. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26690. /**
  26691. * Does this action manager handles actions of a given trigger
  26692. * @param trigger defines the trigger to be tested
  26693. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26694. * @return whether the trigger is handled
  26695. */
  26696. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26697. /**
  26698. * Serialize this manager to a JSON object
  26699. * @param name defines the property name to store this manager
  26700. * @returns a JSON representation of this manager
  26701. */
  26702. abstract serialize(name: string): any;
  26703. /**
  26704. * Registers an action to this action manager
  26705. * @param action defines the action to be registered
  26706. * @return the action amended (prepared) after registration
  26707. */
  26708. abstract registerAction(action: IAction): Nullable<IAction>;
  26709. /**
  26710. * Unregisters an action to this action manager
  26711. * @param action defines the action to be unregistered
  26712. * @return a boolean indicating whether the action has been unregistered
  26713. */
  26714. abstract unregisterAction(action: IAction): Boolean;
  26715. /**
  26716. * Does exist one action manager with at least one trigger
  26717. **/
  26718. static readonly HasTriggers: boolean;
  26719. /**
  26720. * Does exist one action manager with at least one pick trigger
  26721. **/
  26722. static readonly HasPickTriggers: boolean;
  26723. /**
  26724. * Does exist one action manager that handles actions of a given trigger
  26725. * @param trigger defines the trigger to be tested
  26726. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26727. **/
  26728. static HasSpecificTrigger(trigger: number): boolean;
  26729. }
  26730. }
  26731. declare module BABYLON {
  26732. /**
  26733. * Defines how a node can be built from a string name.
  26734. */
  26735. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26736. /**
  26737. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26738. */
  26739. export class Node implements IBehaviorAware<Node> {
  26740. /** @hidden */
  26741. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26742. private static _NodeConstructors;
  26743. /**
  26744. * Add a new node constructor
  26745. * @param type defines the type name of the node to construct
  26746. * @param constructorFunc defines the constructor function
  26747. */
  26748. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26749. /**
  26750. * Returns a node constructor based on type name
  26751. * @param type defines the type name
  26752. * @param name defines the new node name
  26753. * @param scene defines the hosting scene
  26754. * @param options defines optional options to transmit to constructors
  26755. * @returns the new constructor or null
  26756. */
  26757. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26758. /**
  26759. * Gets or sets the name of the node
  26760. */
  26761. name: string;
  26762. /**
  26763. * Gets or sets the id of the node
  26764. */
  26765. id: string;
  26766. /**
  26767. * Gets or sets the unique id of the node
  26768. */
  26769. uniqueId: number;
  26770. /**
  26771. * Gets or sets a string used to store user defined state for the node
  26772. */
  26773. state: string;
  26774. /**
  26775. * Gets or sets an object used to store user defined information for the node
  26776. */
  26777. metadata: any;
  26778. /**
  26779. * For internal use only. Please do not use.
  26780. */
  26781. reservedDataStore: any;
  26782. /**
  26783. * List of inspectable custom properties (used by the Inspector)
  26784. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26785. */
  26786. inspectableCustomProperties: IInspectable[];
  26787. private _doNotSerialize;
  26788. /**
  26789. * Gets or sets a boolean used to define if the node must be serialized
  26790. */
  26791. doNotSerialize: boolean;
  26792. /** @hidden */
  26793. _isDisposed: boolean;
  26794. /**
  26795. * Gets a list of Animations associated with the node
  26796. */
  26797. animations: Animation[];
  26798. protected _ranges: {
  26799. [name: string]: Nullable<AnimationRange>;
  26800. };
  26801. /**
  26802. * Callback raised when the node is ready to be used
  26803. */
  26804. onReady: Nullable<(node: Node) => void>;
  26805. private _isEnabled;
  26806. private _isParentEnabled;
  26807. private _isReady;
  26808. /** @hidden */
  26809. _currentRenderId: number;
  26810. private _parentUpdateId;
  26811. /** @hidden */
  26812. _childUpdateId: number;
  26813. /** @hidden */
  26814. _waitingParentId: Nullable<string>;
  26815. /** @hidden */
  26816. _scene: Scene;
  26817. /** @hidden */
  26818. _cache: any;
  26819. private _parentNode;
  26820. private _children;
  26821. /** @hidden */
  26822. _worldMatrix: Matrix;
  26823. /** @hidden */
  26824. _worldMatrixDeterminant: number;
  26825. /** @hidden */
  26826. _worldMatrixDeterminantIsDirty: boolean;
  26827. /** @hidden */
  26828. private _sceneRootNodesIndex;
  26829. /**
  26830. * Gets a boolean indicating if the node has been disposed
  26831. * @returns true if the node was disposed
  26832. */
  26833. isDisposed(): boolean;
  26834. /**
  26835. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26836. * @see https://doc.babylonjs.com/how_to/parenting
  26837. */
  26838. parent: Nullable<Node>;
  26839. private addToSceneRootNodes;
  26840. private removeFromSceneRootNodes;
  26841. private _animationPropertiesOverride;
  26842. /**
  26843. * Gets or sets the animation properties override
  26844. */
  26845. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26846. /**
  26847. * Gets a string idenfifying the name of the class
  26848. * @returns "Node" string
  26849. */
  26850. getClassName(): string;
  26851. /** @hidden */
  26852. readonly _isNode: boolean;
  26853. /**
  26854. * An event triggered when the mesh is disposed
  26855. */
  26856. onDisposeObservable: Observable<Node>;
  26857. private _onDisposeObserver;
  26858. /**
  26859. * Sets a callback that will be raised when the node will be disposed
  26860. */
  26861. onDispose: () => void;
  26862. /**
  26863. * Creates a new Node
  26864. * @param name the name and id to be given to this node
  26865. * @param scene the scene this node will be added to
  26866. * @param addToRootNodes the node will be added to scene.rootNodes
  26867. */
  26868. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26869. /**
  26870. * Gets the scene of the node
  26871. * @returns a scene
  26872. */
  26873. getScene(): Scene;
  26874. /**
  26875. * Gets the engine of the node
  26876. * @returns a Engine
  26877. */
  26878. getEngine(): Engine;
  26879. private _behaviors;
  26880. /**
  26881. * Attach a behavior to the node
  26882. * @see http://doc.babylonjs.com/features/behaviour
  26883. * @param behavior defines the behavior to attach
  26884. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26885. * @returns the current Node
  26886. */
  26887. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26888. /**
  26889. * Remove an attached behavior
  26890. * @see http://doc.babylonjs.com/features/behaviour
  26891. * @param behavior defines the behavior to attach
  26892. * @returns the current Node
  26893. */
  26894. removeBehavior(behavior: Behavior<Node>): Node;
  26895. /**
  26896. * Gets the list of attached behaviors
  26897. * @see http://doc.babylonjs.com/features/behaviour
  26898. */
  26899. readonly behaviors: Behavior<Node>[];
  26900. /**
  26901. * Gets an attached behavior by name
  26902. * @param name defines the name of the behavior to look for
  26903. * @see http://doc.babylonjs.com/features/behaviour
  26904. * @returns null if behavior was not found else the requested behavior
  26905. */
  26906. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26907. /**
  26908. * Returns the latest update of the World matrix
  26909. * @returns a Matrix
  26910. */
  26911. getWorldMatrix(): Matrix;
  26912. /** @hidden */
  26913. _getWorldMatrixDeterminant(): number;
  26914. /**
  26915. * Returns directly the latest state of the mesh World matrix.
  26916. * A Matrix is returned.
  26917. */
  26918. readonly worldMatrixFromCache: Matrix;
  26919. /** @hidden */
  26920. _initCache(): void;
  26921. /** @hidden */
  26922. updateCache(force?: boolean): void;
  26923. /** @hidden */
  26924. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26925. /** @hidden */
  26926. _updateCache(ignoreParentClass?: boolean): void;
  26927. /** @hidden */
  26928. _isSynchronized(): boolean;
  26929. /** @hidden */
  26930. _markSyncedWithParent(): void;
  26931. /** @hidden */
  26932. isSynchronizedWithParent(): boolean;
  26933. /** @hidden */
  26934. isSynchronized(): boolean;
  26935. /**
  26936. * Is this node ready to be used/rendered
  26937. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26938. * @return true if the node is ready
  26939. */
  26940. isReady(completeCheck?: boolean): boolean;
  26941. /**
  26942. * Is this node enabled?
  26943. * 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
  26944. * @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
  26945. * @return whether this node (and its parent) is enabled
  26946. */
  26947. isEnabled(checkAncestors?: boolean): boolean;
  26948. /** @hidden */
  26949. protected _syncParentEnabledState(): void;
  26950. /**
  26951. * Set the enabled state of this node
  26952. * @param value defines the new enabled state
  26953. */
  26954. setEnabled(value: boolean): void;
  26955. /**
  26956. * Is this node a descendant of the given node?
  26957. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26958. * @param ancestor defines the parent node to inspect
  26959. * @returns a boolean indicating if this node is a descendant of the given node
  26960. */
  26961. isDescendantOf(ancestor: Node): boolean;
  26962. /** @hidden */
  26963. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26964. /**
  26965. * Will return all nodes that have this node as ascendant
  26966. * @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
  26967. * @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
  26968. * @return all children nodes of all types
  26969. */
  26970. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26971. /**
  26972. * Get all child-meshes of this node
  26973. * @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)
  26974. * @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
  26975. * @returns an array of AbstractMesh
  26976. */
  26977. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26978. /**
  26979. * Get all direct children of this node
  26980. * @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
  26981. * @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)
  26982. * @returns an array of Node
  26983. */
  26984. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26985. /** @hidden */
  26986. _setReady(state: boolean): void;
  26987. /**
  26988. * Get an animation by name
  26989. * @param name defines the name of the animation to look for
  26990. * @returns null if not found else the requested animation
  26991. */
  26992. getAnimationByName(name: string): Nullable<Animation>;
  26993. /**
  26994. * Creates an animation range for this node
  26995. * @param name defines the name of the range
  26996. * @param from defines the starting key
  26997. * @param to defines the end key
  26998. */
  26999. createAnimationRange(name: string, from: number, to: number): void;
  27000. /**
  27001. * Delete a specific animation range
  27002. * @param name defines the name of the range to delete
  27003. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27004. */
  27005. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27006. /**
  27007. * Get an animation range by name
  27008. * @param name defines the name of the animation range to look for
  27009. * @returns null if not found else the requested animation range
  27010. */
  27011. getAnimationRange(name: string): Nullable<AnimationRange>;
  27012. /**
  27013. * Gets the list of all animation ranges defined on this node
  27014. * @returns an array
  27015. */
  27016. getAnimationRanges(): Nullable<AnimationRange>[];
  27017. /**
  27018. * Will start the animation sequence
  27019. * @param name defines the range frames for animation sequence
  27020. * @param loop defines if the animation should loop (false by default)
  27021. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27022. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27023. * @returns the object created for this animation. If range does not exist, it will return null
  27024. */
  27025. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27026. /**
  27027. * Serialize animation ranges into a JSON compatible object
  27028. * @returns serialization object
  27029. */
  27030. serializeAnimationRanges(): any;
  27031. /**
  27032. * Computes the world matrix of the node
  27033. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27034. * @returns the world matrix
  27035. */
  27036. computeWorldMatrix(force?: boolean): Matrix;
  27037. /**
  27038. * Releases resources associated with this node.
  27039. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27040. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27041. */
  27042. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27043. /**
  27044. * Parse animation range data from a serialization object and store them into a given node
  27045. * @param node defines where to store the animation ranges
  27046. * @param parsedNode defines the serialization object to read data from
  27047. * @param scene defines the hosting scene
  27048. */
  27049. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27050. /**
  27051. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27052. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27053. * @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
  27054. * @returns the new bounding vectors
  27055. */
  27056. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27057. min: Vector3;
  27058. max: Vector3;
  27059. };
  27060. }
  27061. }
  27062. declare module BABYLON {
  27063. /**
  27064. * @hidden
  27065. */
  27066. export class _IAnimationState {
  27067. key: number;
  27068. repeatCount: number;
  27069. workValue?: any;
  27070. loopMode?: number;
  27071. offsetValue?: any;
  27072. highLimitValue?: any;
  27073. }
  27074. /**
  27075. * Class used to store any kind of animation
  27076. */
  27077. export class Animation {
  27078. /**Name of the animation */
  27079. name: string;
  27080. /**Property to animate */
  27081. targetProperty: string;
  27082. /**The frames per second of the animation */
  27083. framePerSecond: number;
  27084. /**The data type of the animation */
  27085. dataType: number;
  27086. /**The loop mode of the animation */
  27087. loopMode?: number | undefined;
  27088. /**Specifies if blending should be enabled */
  27089. enableBlending?: boolean | undefined;
  27090. /**
  27091. * Use matrix interpolation instead of using direct key value when animating matrices
  27092. */
  27093. static AllowMatricesInterpolation: boolean;
  27094. /**
  27095. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27096. */
  27097. static AllowMatrixDecomposeForInterpolation: boolean;
  27098. /**
  27099. * Stores the key frames of the animation
  27100. */
  27101. private _keys;
  27102. /**
  27103. * Stores the easing function of the animation
  27104. */
  27105. private _easingFunction;
  27106. /**
  27107. * @hidden Internal use only
  27108. */
  27109. _runtimeAnimations: RuntimeAnimation[];
  27110. /**
  27111. * The set of event that will be linked to this animation
  27112. */
  27113. private _events;
  27114. /**
  27115. * Stores an array of target property paths
  27116. */
  27117. targetPropertyPath: string[];
  27118. /**
  27119. * Stores the blending speed of the animation
  27120. */
  27121. blendingSpeed: number;
  27122. /**
  27123. * Stores the animation ranges for the animation
  27124. */
  27125. private _ranges;
  27126. /**
  27127. * @hidden Internal use
  27128. */
  27129. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27130. /**
  27131. * Sets up an animation
  27132. * @param property The property to animate
  27133. * @param animationType The animation type to apply
  27134. * @param framePerSecond The frames per second of the animation
  27135. * @param easingFunction The easing function used in the animation
  27136. * @returns The created animation
  27137. */
  27138. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27139. /**
  27140. * Create and start an animation on a node
  27141. * @param name defines the name of the global animation that will be run on all nodes
  27142. * @param node defines the root node where the animation will take place
  27143. * @param targetProperty defines property to animate
  27144. * @param framePerSecond defines the number of frame per second yo use
  27145. * @param totalFrame defines the number of frames in total
  27146. * @param from defines the initial value
  27147. * @param to defines the final value
  27148. * @param loopMode defines which loop mode you want to use (off by default)
  27149. * @param easingFunction defines the easing function to use (linear by default)
  27150. * @param onAnimationEnd defines the callback to call when animation end
  27151. * @returns the animatable created for this animation
  27152. */
  27153. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27154. /**
  27155. * Create and start an animation on a node and its descendants
  27156. * @param name defines the name of the global animation that will be run on all nodes
  27157. * @param node defines the root node where the animation will take place
  27158. * @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
  27159. * @param targetProperty defines property to animate
  27160. * @param framePerSecond defines the number of frame per second to use
  27161. * @param totalFrame defines the number of frames in total
  27162. * @param from defines the initial value
  27163. * @param to defines the final value
  27164. * @param loopMode defines which loop mode you want to use (off by default)
  27165. * @param easingFunction defines the easing function to use (linear by default)
  27166. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27167. * @returns the list of animatables created for all nodes
  27168. * @example https://www.babylonjs-playground.com/#MH0VLI
  27169. */
  27170. 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[]>;
  27171. /**
  27172. * Creates a new animation, merges it with the existing animations and starts it
  27173. * @param name Name of the animation
  27174. * @param node Node which contains the scene that begins the animations
  27175. * @param targetProperty Specifies which property to animate
  27176. * @param framePerSecond The frames per second of the animation
  27177. * @param totalFrame The total number of frames
  27178. * @param from The frame at the beginning of the animation
  27179. * @param to The frame at the end of the animation
  27180. * @param loopMode Specifies the loop mode of the animation
  27181. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27182. * @param onAnimationEnd Callback to run once the animation is complete
  27183. * @returns Nullable animation
  27184. */
  27185. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27186. /**
  27187. * Transition property of an host to the target Value
  27188. * @param property The property to transition
  27189. * @param targetValue The target Value of the property
  27190. * @param host The object where the property to animate belongs
  27191. * @param scene Scene used to run the animation
  27192. * @param frameRate Framerate (in frame/s) to use
  27193. * @param transition The transition type we want to use
  27194. * @param duration The duration of the animation, in milliseconds
  27195. * @param onAnimationEnd Callback trigger at the end of the animation
  27196. * @returns Nullable animation
  27197. */
  27198. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27199. /**
  27200. * Return the array of runtime animations currently using this animation
  27201. */
  27202. readonly runtimeAnimations: RuntimeAnimation[];
  27203. /**
  27204. * Specifies if any of the runtime animations are currently running
  27205. */
  27206. readonly hasRunningRuntimeAnimations: boolean;
  27207. /**
  27208. * Initializes the animation
  27209. * @param name Name of the animation
  27210. * @param targetProperty Property to animate
  27211. * @param framePerSecond The frames per second of the animation
  27212. * @param dataType The data type of the animation
  27213. * @param loopMode The loop mode of the animation
  27214. * @param enableBlending Specifies if blending should be enabled
  27215. */
  27216. constructor(
  27217. /**Name of the animation */
  27218. name: string,
  27219. /**Property to animate */
  27220. targetProperty: string,
  27221. /**The frames per second of the animation */
  27222. framePerSecond: number,
  27223. /**The data type of the animation */
  27224. dataType: number,
  27225. /**The loop mode of the animation */
  27226. loopMode?: number | undefined,
  27227. /**Specifies if blending should be enabled */
  27228. enableBlending?: boolean | undefined);
  27229. /**
  27230. * Converts the animation to a string
  27231. * @param fullDetails support for multiple levels of logging within scene loading
  27232. * @returns String form of the animation
  27233. */
  27234. toString(fullDetails?: boolean): string;
  27235. /**
  27236. * Add an event to this animation
  27237. * @param event Event to add
  27238. */
  27239. addEvent(event: AnimationEvent): void;
  27240. /**
  27241. * Remove all events found at the given frame
  27242. * @param frame The frame to remove events from
  27243. */
  27244. removeEvents(frame: number): void;
  27245. /**
  27246. * Retrieves all the events from the animation
  27247. * @returns Events from the animation
  27248. */
  27249. getEvents(): AnimationEvent[];
  27250. /**
  27251. * Creates an animation range
  27252. * @param name Name of the animation range
  27253. * @param from Starting frame of the animation range
  27254. * @param to Ending frame of the animation
  27255. */
  27256. createRange(name: string, from: number, to: number): void;
  27257. /**
  27258. * Deletes an animation range by name
  27259. * @param name Name of the animation range to delete
  27260. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27261. */
  27262. deleteRange(name: string, deleteFrames?: boolean): void;
  27263. /**
  27264. * Gets the animation range by name, or null if not defined
  27265. * @param name Name of the animation range
  27266. * @returns Nullable animation range
  27267. */
  27268. getRange(name: string): Nullable<AnimationRange>;
  27269. /**
  27270. * Gets the key frames from the animation
  27271. * @returns The key frames of the animation
  27272. */
  27273. getKeys(): Array<IAnimationKey>;
  27274. /**
  27275. * Gets the highest frame rate of the animation
  27276. * @returns Highest frame rate of the animation
  27277. */
  27278. getHighestFrame(): number;
  27279. /**
  27280. * Gets the easing function of the animation
  27281. * @returns Easing function of the animation
  27282. */
  27283. getEasingFunction(): IEasingFunction;
  27284. /**
  27285. * Sets the easing function of the animation
  27286. * @param easingFunction A custom mathematical formula for animation
  27287. */
  27288. setEasingFunction(easingFunction: EasingFunction): void;
  27289. /**
  27290. * Interpolates a scalar linearly
  27291. * @param startValue Start value of the animation curve
  27292. * @param endValue End value of the animation curve
  27293. * @param gradient Scalar amount to interpolate
  27294. * @returns Interpolated scalar value
  27295. */
  27296. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27297. /**
  27298. * Interpolates a scalar cubically
  27299. * @param startValue Start value of the animation curve
  27300. * @param outTangent End tangent of the animation
  27301. * @param endValue End value of the animation curve
  27302. * @param inTangent Start tangent of the animation curve
  27303. * @param gradient Scalar amount to interpolate
  27304. * @returns Interpolated scalar value
  27305. */
  27306. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27307. /**
  27308. * Interpolates a quaternion using a spherical linear interpolation
  27309. * @param startValue Start value of the animation curve
  27310. * @param endValue End value of the animation curve
  27311. * @param gradient Scalar amount to interpolate
  27312. * @returns Interpolated quaternion value
  27313. */
  27314. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27315. /**
  27316. * Interpolates a quaternion cubically
  27317. * @param startValue Start value of the animation curve
  27318. * @param outTangent End tangent of the animation curve
  27319. * @param endValue End value of the animation curve
  27320. * @param inTangent Start tangent of the animation curve
  27321. * @param gradient Scalar amount to interpolate
  27322. * @returns Interpolated quaternion value
  27323. */
  27324. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27325. /**
  27326. * Interpolates a Vector3 linearl
  27327. * @param startValue Start value of the animation curve
  27328. * @param endValue End value of the animation curve
  27329. * @param gradient Scalar amount to interpolate
  27330. * @returns Interpolated scalar value
  27331. */
  27332. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27333. /**
  27334. * Interpolates a Vector3 cubically
  27335. * @param startValue Start value of the animation curve
  27336. * @param outTangent End tangent of the animation
  27337. * @param endValue End value of the animation curve
  27338. * @param inTangent Start tangent of the animation curve
  27339. * @param gradient Scalar amount to interpolate
  27340. * @returns InterpolatedVector3 value
  27341. */
  27342. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27343. /**
  27344. * Interpolates a Vector2 linearly
  27345. * @param startValue Start value of the animation curve
  27346. * @param endValue End value of the animation curve
  27347. * @param gradient Scalar amount to interpolate
  27348. * @returns Interpolated Vector2 value
  27349. */
  27350. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27351. /**
  27352. * Interpolates a Vector2 cubically
  27353. * @param startValue Start value of the animation curve
  27354. * @param outTangent End tangent of the animation
  27355. * @param endValue End value of the animation curve
  27356. * @param inTangent Start tangent of the animation curve
  27357. * @param gradient Scalar amount to interpolate
  27358. * @returns Interpolated Vector2 value
  27359. */
  27360. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27361. /**
  27362. * Interpolates a size linearly
  27363. * @param startValue Start value of the animation curve
  27364. * @param endValue End value of the animation curve
  27365. * @param gradient Scalar amount to interpolate
  27366. * @returns Interpolated Size value
  27367. */
  27368. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27369. /**
  27370. * Interpolates a Color3 linearly
  27371. * @param startValue Start value of the animation curve
  27372. * @param endValue End value of the animation curve
  27373. * @param gradient Scalar amount to interpolate
  27374. * @returns Interpolated Color3 value
  27375. */
  27376. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27377. /**
  27378. * @hidden Internal use only
  27379. */
  27380. _getKeyValue(value: any): any;
  27381. /**
  27382. * @hidden Internal use only
  27383. */
  27384. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27385. /**
  27386. * Defines the function to use to interpolate matrices
  27387. * @param startValue defines the start matrix
  27388. * @param endValue defines the end matrix
  27389. * @param gradient defines the gradient between both matrices
  27390. * @param result defines an optional target matrix where to store the interpolation
  27391. * @returns the interpolated matrix
  27392. */
  27393. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27394. /**
  27395. * Makes a copy of the animation
  27396. * @returns Cloned animation
  27397. */
  27398. clone(): Animation;
  27399. /**
  27400. * Sets the key frames of the animation
  27401. * @param values The animation key frames to set
  27402. */
  27403. setKeys(values: Array<IAnimationKey>): void;
  27404. /**
  27405. * Serializes the animation to an object
  27406. * @returns Serialized object
  27407. */
  27408. serialize(): any;
  27409. /**
  27410. * Float animation type
  27411. */
  27412. private static _ANIMATIONTYPE_FLOAT;
  27413. /**
  27414. * Vector3 animation type
  27415. */
  27416. private static _ANIMATIONTYPE_VECTOR3;
  27417. /**
  27418. * Quaternion animation type
  27419. */
  27420. private static _ANIMATIONTYPE_QUATERNION;
  27421. /**
  27422. * Matrix animation type
  27423. */
  27424. private static _ANIMATIONTYPE_MATRIX;
  27425. /**
  27426. * Color3 animation type
  27427. */
  27428. private static _ANIMATIONTYPE_COLOR3;
  27429. /**
  27430. * Vector2 animation type
  27431. */
  27432. private static _ANIMATIONTYPE_VECTOR2;
  27433. /**
  27434. * Size animation type
  27435. */
  27436. private static _ANIMATIONTYPE_SIZE;
  27437. /**
  27438. * Relative Loop Mode
  27439. */
  27440. private static _ANIMATIONLOOPMODE_RELATIVE;
  27441. /**
  27442. * Cycle Loop Mode
  27443. */
  27444. private static _ANIMATIONLOOPMODE_CYCLE;
  27445. /**
  27446. * Constant Loop Mode
  27447. */
  27448. private static _ANIMATIONLOOPMODE_CONSTANT;
  27449. /**
  27450. * Get the float animation type
  27451. */
  27452. static readonly ANIMATIONTYPE_FLOAT: number;
  27453. /**
  27454. * Get the Vector3 animation type
  27455. */
  27456. static readonly ANIMATIONTYPE_VECTOR3: number;
  27457. /**
  27458. * Get the Vector2 animation type
  27459. */
  27460. static readonly ANIMATIONTYPE_VECTOR2: number;
  27461. /**
  27462. * Get the Size animation type
  27463. */
  27464. static readonly ANIMATIONTYPE_SIZE: number;
  27465. /**
  27466. * Get the Quaternion animation type
  27467. */
  27468. static readonly ANIMATIONTYPE_QUATERNION: number;
  27469. /**
  27470. * Get the Matrix animation type
  27471. */
  27472. static readonly ANIMATIONTYPE_MATRIX: number;
  27473. /**
  27474. * Get the Color3 animation type
  27475. */
  27476. static readonly ANIMATIONTYPE_COLOR3: number;
  27477. /**
  27478. * Get the Relative Loop Mode
  27479. */
  27480. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27481. /**
  27482. * Get the Cycle Loop Mode
  27483. */
  27484. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27485. /**
  27486. * Get the Constant Loop Mode
  27487. */
  27488. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27489. /** @hidden */
  27490. static _UniversalLerp(left: any, right: any, amount: number): any;
  27491. /**
  27492. * Parses an animation object and creates an animation
  27493. * @param parsedAnimation Parsed animation object
  27494. * @returns Animation object
  27495. */
  27496. static Parse(parsedAnimation: any): Animation;
  27497. /**
  27498. * Appends the serialized animations from the source animations
  27499. * @param source Source containing the animations
  27500. * @param destination Target to store the animations
  27501. */
  27502. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27503. }
  27504. }
  27505. declare module BABYLON {
  27506. /**
  27507. * Interface containing an array of animations
  27508. */
  27509. export interface IAnimatable {
  27510. /**
  27511. * Array of animations
  27512. */
  27513. animations: Nullable<Array<Animation>>;
  27514. }
  27515. }
  27516. declare module BABYLON {
  27517. /**
  27518. * This represents all the required information to add a fresnel effect on a material:
  27519. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27520. */
  27521. export class FresnelParameters {
  27522. private _isEnabled;
  27523. /**
  27524. * Define if the fresnel effect is enable or not.
  27525. */
  27526. isEnabled: boolean;
  27527. /**
  27528. * Define the color used on edges (grazing angle)
  27529. */
  27530. leftColor: Color3;
  27531. /**
  27532. * Define the color used on center
  27533. */
  27534. rightColor: Color3;
  27535. /**
  27536. * Define bias applied to computed fresnel term
  27537. */
  27538. bias: number;
  27539. /**
  27540. * Defined the power exponent applied to fresnel term
  27541. */
  27542. power: number;
  27543. /**
  27544. * Clones the current fresnel and its valuues
  27545. * @returns a clone fresnel configuration
  27546. */
  27547. clone(): FresnelParameters;
  27548. /**
  27549. * Serializes the current fresnel parameters to a JSON representation.
  27550. * @return the JSON serialization
  27551. */
  27552. serialize(): any;
  27553. /**
  27554. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27555. * @param parsedFresnelParameters Define the JSON representation
  27556. * @returns the parsed parameters
  27557. */
  27558. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27559. }
  27560. }
  27561. declare module BABYLON {
  27562. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27563. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27564. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27565. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27566. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27567. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27568. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27569. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27570. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27571. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27572. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27573. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27574. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27575. /**
  27576. * Decorator used to define property that can be serialized as reference to a camera
  27577. * @param sourceName defines the name of the property to decorate
  27578. */
  27579. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27580. /**
  27581. * Class used to help serialization objects
  27582. */
  27583. export class SerializationHelper {
  27584. /** @hidden */
  27585. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27586. /** @hidden */
  27587. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27588. /** @hidden */
  27589. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27590. /** @hidden */
  27591. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27592. /**
  27593. * Appends the serialized animations from the source animations
  27594. * @param source Source containing the animations
  27595. * @param destination Target to store the animations
  27596. */
  27597. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27598. /**
  27599. * Static function used to serialized a specific entity
  27600. * @param entity defines the entity to serialize
  27601. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27602. * @returns a JSON compatible object representing the serialization of the entity
  27603. */
  27604. static Serialize<T>(entity: T, serializationObject?: any): any;
  27605. /**
  27606. * Creates a new entity from a serialization data object
  27607. * @param creationFunction defines a function used to instanciated the new entity
  27608. * @param source defines the source serialization data
  27609. * @param scene defines the hosting scene
  27610. * @param rootUrl defines the root url for resources
  27611. * @returns a new entity
  27612. */
  27613. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27614. /**
  27615. * Clones an object
  27616. * @param creationFunction defines the function used to instanciate the new object
  27617. * @param source defines the source object
  27618. * @returns the cloned object
  27619. */
  27620. static Clone<T>(creationFunction: () => T, source: T): T;
  27621. /**
  27622. * Instanciates a new object based on a source one (some data will be shared between both object)
  27623. * @param creationFunction defines the function used to instanciate the new object
  27624. * @param source defines the source object
  27625. * @returns the new object
  27626. */
  27627. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27628. }
  27629. }
  27630. declare module BABYLON {
  27631. /**
  27632. * Class used to manipulate GUIDs
  27633. */
  27634. export class GUID {
  27635. /**
  27636. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27637. * Be aware Math.random() could cause collisions, but:
  27638. * "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"
  27639. * @returns a pseudo random id
  27640. */
  27641. static RandomId(): string;
  27642. }
  27643. }
  27644. declare module BABYLON {
  27645. /**
  27646. * Base class of all the textures in babylon.
  27647. * It groups all the common properties the materials, post process, lights... might need
  27648. * in order to make a correct use of the texture.
  27649. */
  27650. export class BaseTexture implements IAnimatable {
  27651. /**
  27652. * Default anisotropic filtering level for the application.
  27653. * It is set to 4 as a good tradeoff between perf and quality.
  27654. */
  27655. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27656. /**
  27657. * Gets or sets the unique id of the texture
  27658. */
  27659. uniqueId: number;
  27660. /**
  27661. * Define the name of the texture.
  27662. */
  27663. name: string;
  27664. /**
  27665. * Gets or sets an object used to store user defined information.
  27666. */
  27667. metadata: any;
  27668. /**
  27669. * For internal use only. Please do not use.
  27670. */
  27671. reservedDataStore: any;
  27672. private _hasAlpha;
  27673. /**
  27674. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27675. */
  27676. hasAlpha: boolean;
  27677. /**
  27678. * Defines if the alpha value should be determined via the rgb values.
  27679. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27680. */
  27681. getAlphaFromRGB: boolean;
  27682. /**
  27683. * Intensity or strength of the texture.
  27684. * It is commonly used by materials to fine tune the intensity of the texture
  27685. */
  27686. level: number;
  27687. /**
  27688. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27689. * This is part of the texture as textures usually maps to one uv set.
  27690. */
  27691. coordinatesIndex: number;
  27692. private _coordinatesMode;
  27693. /**
  27694. * How a texture is mapped.
  27695. *
  27696. * | Value | Type | Description |
  27697. * | ----- | ----------------------------------- | ----------- |
  27698. * | 0 | EXPLICIT_MODE | |
  27699. * | 1 | SPHERICAL_MODE | |
  27700. * | 2 | PLANAR_MODE | |
  27701. * | 3 | CUBIC_MODE | |
  27702. * | 4 | PROJECTION_MODE | |
  27703. * | 5 | SKYBOX_MODE | |
  27704. * | 6 | INVCUBIC_MODE | |
  27705. * | 7 | EQUIRECTANGULAR_MODE | |
  27706. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27707. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27708. */
  27709. coordinatesMode: number;
  27710. /**
  27711. * | Value | Type | Description |
  27712. * | ----- | ------------------ | ----------- |
  27713. * | 0 | CLAMP_ADDRESSMODE | |
  27714. * | 1 | WRAP_ADDRESSMODE | |
  27715. * | 2 | MIRROR_ADDRESSMODE | |
  27716. */
  27717. wrapU: number;
  27718. /**
  27719. * | Value | Type | Description |
  27720. * | ----- | ------------------ | ----------- |
  27721. * | 0 | CLAMP_ADDRESSMODE | |
  27722. * | 1 | WRAP_ADDRESSMODE | |
  27723. * | 2 | MIRROR_ADDRESSMODE | |
  27724. */
  27725. wrapV: number;
  27726. /**
  27727. * | Value | Type | Description |
  27728. * | ----- | ------------------ | ----------- |
  27729. * | 0 | CLAMP_ADDRESSMODE | |
  27730. * | 1 | WRAP_ADDRESSMODE | |
  27731. * | 2 | MIRROR_ADDRESSMODE | |
  27732. */
  27733. wrapR: number;
  27734. /**
  27735. * With compliant hardware and browser (supporting anisotropic filtering)
  27736. * this defines the level of anisotropic filtering in the texture.
  27737. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27738. */
  27739. anisotropicFilteringLevel: number;
  27740. /**
  27741. * Define if the texture is a cube texture or if false a 2d texture.
  27742. */
  27743. isCube: boolean;
  27744. /**
  27745. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27746. */
  27747. is3D: boolean;
  27748. /**
  27749. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27750. * HDR texture are usually stored in linear space.
  27751. * This only impacts the PBR and Background materials
  27752. */
  27753. gammaSpace: boolean;
  27754. /**
  27755. * Gets or sets whether or not the texture contains RGBD data.
  27756. */
  27757. isRGBD: boolean;
  27758. /**
  27759. * Is Z inverted in the texture (useful in a cube texture).
  27760. */
  27761. invertZ: boolean;
  27762. /**
  27763. * Are mip maps generated for this texture or not.
  27764. */
  27765. readonly noMipmap: boolean;
  27766. /**
  27767. * @hidden
  27768. */
  27769. lodLevelInAlpha: boolean;
  27770. /**
  27771. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27772. */
  27773. lodGenerationOffset: number;
  27774. /**
  27775. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27776. */
  27777. lodGenerationScale: number;
  27778. /**
  27779. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27780. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27781. * average roughness values.
  27782. */
  27783. linearSpecularLOD: boolean;
  27784. /**
  27785. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27786. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27787. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27788. */
  27789. irradianceTexture: Nullable<BaseTexture>;
  27790. /**
  27791. * Define if the texture is a render target.
  27792. */
  27793. isRenderTarget: boolean;
  27794. /**
  27795. * Define the unique id of the texture in the scene.
  27796. */
  27797. readonly uid: string;
  27798. /**
  27799. * Return a string representation of the texture.
  27800. * @returns the texture as a string
  27801. */
  27802. toString(): string;
  27803. /**
  27804. * Get the class name of the texture.
  27805. * @returns "BaseTexture"
  27806. */
  27807. getClassName(): string;
  27808. /**
  27809. * Define the list of animation attached to the texture.
  27810. */
  27811. animations: Animation[];
  27812. /**
  27813. * An event triggered when the texture is disposed.
  27814. */
  27815. onDisposeObservable: Observable<BaseTexture>;
  27816. private _onDisposeObserver;
  27817. /**
  27818. * Callback triggered when the texture has been disposed.
  27819. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27820. */
  27821. onDispose: () => void;
  27822. /**
  27823. * Define the current state of the loading sequence when in delayed load mode.
  27824. */
  27825. delayLoadState: number;
  27826. private _scene;
  27827. /** @hidden */
  27828. _texture: Nullable<InternalTexture>;
  27829. private _uid;
  27830. /**
  27831. * Define if the texture is preventinga material to render or not.
  27832. * If not and the texture is not ready, the engine will use a default black texture instead.
  27833. */
  27834. readonly isBlocking: boolean;
  27835. /**
  27836. * Instantiates a new BaseTexture.
  27837. * Base class of all the textures in babylon.
  27838. * It groups all the common properties the materials, post process, lights... might need
  27839. * in order to make a correct use of the texture.
  27840. * @param scene Define the scene the texture blongs to
  27841. */
  27842. constructor(scene: Nullable<Scene>);
  27843. /**
  27844. * Get the scene the texture belongs to.
  27845. * @returns the scene or null if undefined
  27846. */
  27847. getScene(): Nullable<Scene>;
  27848. /**
  27849. * Get the texture transform matrix used to offset tile the texture for istance.
  27850. * @returns the transformation matrix
  27851. */
  27852. getTextureMatrix(): Matrix;
  27853. /**
  27854. * Get the texture reflection matrix used to rotate/transform the reflection.
  27855. * @returns the reflection matrix
  27856. */
  27857. getReflectionTextureMatrix(): Matrix;
  27858. /**
  27859. * Get the underlying lower level texture from Babylon.
  27860. * @returns the insternal texture
  27861. */
  27862. getInternalTexture(): Nullable<InternalTexture>;
  27863. /**
  27864. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27865. * @returns true if ready or not blocking
  27866. */
  27867. isReadyOrNotBlocking(): boolean;
  27868. /**
  27869. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27870. * @returns true if fully ready
  27871. */
  27872. isReady(): boolean;
  27873. private _cachedSize;
  27874. /**
  27875. * Get the size of the texture.
  27876. * @returns the texture size.
  27877. */
  27878. getSize(): ISize;
  27879. /**
  27880. * Get the base size of the texture.
  27881. * It can be different from the size if the texture has been resized for POT for instance
  27882. * @returns the base size
  27883. */
  27884. getBaseSize(): ISize;
  27885. /**
  27886. * Update the sampling mode of the texture.
  27887. * Default is Trilinear mode.
  27888. *
  27889. * | Value | Type | Description |
  27890. * | ----- | ------------------ | ----------- |
  27891. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27892. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27893. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27894. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27895. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27896. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27897. * | 7 | NEAREST_LINEAR | |
  27898. * | 8 | NEAREST_NEAREST | |
  27899. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27900. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27901. * | 11 | LINEAR_LINEAR | |
  27902. * | 12 | LINEAR_NEAREST | |
  27903. *
  27904. * > _mag_: magnification filter (close to the viewer)
  27905. * > _min_: minification filter (far from the viewer)
  27906. * > _mip_: filter used between mip map levels
  27907. *@param samplingMode Define the new sampling mode of the texture
  27908. */
  27909. updateSamplingMode(samplingMode: number): void;
  27910. /**
  27911. * Scales the texture if is `canRescale()`
  27912. * @param ratio the resize factor we want to use to rescale
  27913. */
  27914. scale(ratio: number): void;
  27915. /**
  27916. * Get if the texture can rescale.
  27917. */
  27918. readonly canRescale: boolean;
  27919. /** @hidden */
  27920. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27921. /** @hidden */
  27922. _rebuild(): void;
  27923. /**
  27924. * Triggers the load sequence in delayed load mode.
  27925. */
  27926. delayLoad(): void;
  27927. /**
  27928. * Clones the texture.
  27929. * @returns the cloned texture
  27930. */
  27931. clone(): Nullable<BaseTexture>;
  27932. /**
  27933. * Get the texture underlying type (INT, FLOAT...)
  27934. */
  27935. readonly textureType: number;
  27936. /**
  27937. * Get the texture underlying format (RGB, RGBA...)
  27938. */
  27939. readonly textureFormat: number;
  27940. /**
  27941. * Indicates that textures need to be re-calculated for all materials
  27942. */
  27943. protected _markAllSubMeshesAsTexturesDirty(): void;
  27944. /**
  27945. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27946. * This will returns an RGBA array buffer containing either in values (0-255) or
  27947. * float values (0-1) depending of the underlying buffer type.
  27948. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27949. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27950. * @param buffer defines a user defined buffer to fill with data (can be null)
  27951. * @returns The Array buffer containing the pixels data.
  27952. */
  27953. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27954. /**
  27955. * Release and destroy the underlying lower level texture aka internalTexture.
  27956. */
  27957. releaseInternalTexture(): void;
  27958. /** @hidden */
  27959. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27960. /** @hidden */
  27961. readonly _lodTextureMid: Nullable<BaseTexture>;
  27962. /** @hidden */
  27963. readonly _lodTextureLow: Nullable<BaseTexture>;
  27964. /**
  27965. * Dispose the texture and release its associated resources.
  27966. */
  27967. dispose(): void;
  27968. /**
  27969. * Serialize the texture into a JSON representation that can be parsed later on.
  27970. * @returns the JSON representation of the texture
  27971. */
  27972. serialize(): any;
  27973. /**
  27974. * Helper function to be called back once a list of texture contains only ready textures.
  27975. * @param textures Define the list of textures to wait for
  27976. * @param callback Define the callback triggered once the entire list will be ready
  27977. */
  27978. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27979. }
  27980. }
  27981. declare module BABYLON {
  27982. /**
  27983. * Options to be used when creating an effect.
  27984. */
  27985. export interface IEffectCreationOptions {
  27986. /**
  27987. * Atrributes that will be used in the shader.
  27988. */
  27989. attributes: string[];
  27990. /**
  27991. * Uniform varible names that will be set in the shader.
  27992. */
  27993. uniformsNames: string[];
  27994. /**
  27995. * Uniform buffer varible names that will be set in the shader.
  27996. */
  27997. uniformBuffersNames: string[];
  27998. /**
  27999. * Sampler texture variable names that will be set in the shader.
  28000. */
  28001. samplers: string[];
  28002. /**
  28003. * Define statements that will be set in the shader.
  28004. */
  28005. defines: any;
  28006. /**
  28007. * Possible fallbacks for this effect to improve performance when needed.
  28008. */
  28009. fallbacks: Nullable<IEffectFallbacks>;
  28010. /**
  28011. * Callback that will be called when the shader is compiled.
  28012. */
  28013. onCompiled: Nullable<(effect: Effect) => void>;
  28014. /**
  28015. * Callback that will be called if an error occurs during shader compilation.
  28016. */
  28017. onError: Nullable<(effect: Effect, errors: string) => void>;
  28018. /**
  28019. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28020. */
  28021. indexParameters?: any;
  28022. /**
  28023. * Max number of lights that can be used in the shader.
  28024. */
  28025. maxSimultaneousLights?: number;
  28026. /**
  28027. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28028. */
  28029. transformFeedbackVaryings?: Nullable<string[]>;
  28030. }
  28031. /**
  28032. * Effect containing vertex and fragment shader that can be executed on an object.
  28033. */
  28034. export class Effect implements IDisposable {
  28035. /**
  28036. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28037. */
  28038. static ShadersRepository: string;
  28039. /**
  28040. * Name of the effect.
  28041. */
  28042. name: any;
  28043. /**
  28044. * String container all the define statements that should be set on the shader.
  28045. */
  28046. defines: string;
  28047. /**
  28048. * Callback that will be called when the shader is compiled.
  28049. */
  28050. onCompiled: Nullable<(effect: Effect) => void>;
  28051. /**
  28052. * Callback that will be called if an error occurs during shader compilation.
  28053. */
  28054. onError: Nullable<(effect: Effect, errors: string) => void>;
  28055. /**
  28056. * Callback that will be called when effect is bound.
  28057. */
  28058. onBind: Nullable<(effect: Effect) => void>;
  28059. /**
  28060. * Unique ID of the effect.
  28061. */
  28062. uniqueId: number;
  28063. /**
  28064. * Observable that will be called when the shader is compiled.
  28065. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28066. */
  28067. onCompileObservable: Observable<Effect>;
  28068. /**
  28069. * Observable that will be called if an error occurs during shader compilation.
  28070. */
  28071. onErrorObservable: Observable<Effect>;
  28072. /** @hidden */
  28073. _onBindObservable: Nullable<Observable<Effect>>;
  28074. /**
  28075. * Observable that will be called when effect is bound.
  28076. */
  28077. readonly onBindObservable: Observable<Effect>;
  28078. /** @hidden */
  28079. _bonesComputationForcedToCPU: boolean;
  28080. private static _uniqueIdSeed;
  28081. private _engine;
  28082. private _uniformBuffersNames;
  28083. private _uniformsNames;
  28084. private _samplerList;
  28085. private _samplers;
  28086. private _isReady;
  28087. private _compilationError;
  28088. private _allFallbacksProcessed;
  28089. private _attributesNames;
  28090. private _attributes;
  28091. private _uniforms;
  28092. /**
  28093. * Key for the effect.
  28094. * @hidden
  28095. */
  28096. _key: string;
  28097. private _indexParameters;
  28098. private _fallbacks;
  28099. private _vertexSourceCode;
  28100. private _fragmentSourceCode;
  28101. private _vertexSourceCodeOverride;
  28102. private _fragmentSourceCodeOverride;
  28103. private _transformFeedbackVaryings;
  28104. /**
  28105. * Compiled shader to webGL program.
  28106. * @hidden
  28107. */
  28108. _pipelineContext: Nullable<IPipelineContext>;
  28109. private _valueCache;
  28110. private static _baseCache;
  28111. /**
  28112. * Instantiates an effect.
  28113. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28114. * @param baseName Name of the effect.
  28115. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28116. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28117. * @param samplers List of sampler variables that will be passed to the shader.
  28118. * @param engine Engine to be used to render the effect
  28119. * @param defines Define statements to be added to the shader.
  28120. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28121. * @param onCompiled Callback that will be called when the shader is compiled.
  28122. * @param onError Callback that will be called if an error occurs during shader compilation.
  28123. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28124. */
  28125. 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);
  28126. private _useFinalCode;
  28127. /**
  28128. * Unique key for this effect
  28129. */
  28130. readonly key: string;
  28131. /**
  28132. * If the effect has been compiled and prepared.
  28133. * @returns if the effect is compiled and prepared.
  28134. */
  28135. isReady(): boolean;
  28136. private _isReadyInternal;
  28137. /**
  28138. * The engine the effect was initialized with.
  28139. * @returns the engine.
  28140. */
  28141. getEngine(): Engine;
  28142. /**
  28143. * The pipeline context for this effect
  28144. * @returns the associated pipeline context
  28145. */
  28146. getPipelineContext(): Nullable<IPipelineContext>;
  28147. /**
  28148. * The set of names of attribute variables for the shader.
  28149. * @returns An array of attribute names.
  28150. */
  28151. getAttributesNames(): string[];
  28152. /**
  28153. * Returns the attribute at the given index.
  28154. * @param index The index of the attribute.
  28155. * @returns The location of the attribute.
  28156. */
  28157. getAttributeLocation(index: number): number;
  28158. /**
  28159. * Returns the attribute based on the name of the variable.
  28160. * @param name of the attribute to look up.
  28161. * @returns the attribute location.
  28162. */
  28163. getAttributeLocationByName(name: string): number;
  28164. /**
  28165. * The number of attributes.
  28166. * @returns the numnber of attributes.
  28167. */
  28168. getAttributesCount(): number;
  28169. /**
  28170. * Gets the index of a uniform variable.
  28171. * @param uniformName of the uniform to look up.
  28172. * @returns the index.
  28173. */
  28174. getUniformIndex(uniformName: string): number;
  28175. /**
  28176. * Returns the attribute based on the name of the variable.
  28177. * @param uniformName of the uniform to look up.
  28178. * @returns the location of the uniform.
  28179. */
  28180. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28181. /**
  28182. * Returns an array of sampler variable names
  28183. * @returns The array of sampler variable neames.
  28184. */
  28185. getSamplers(): string[];
  28186. /**
  28187. * The error from the last compilation.
  28188. * @returns the error string.
  28189. */
  28190. getCompilationError(): string;
  28191. /**
  28192. * Gets a boolean indicating that all fallbacks were used during compilation
  28193. * @returns true if all fallbacks were used
  28194. */
  28195. allFallbacksProcessed(): boolean;
  28196. /**
  28197. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28198. * @param func The callback to be used.
  28199. */
  28200. executeWhenCompiled(func: (effect: Effect) => void): void;
  28201. private _checkIsReady;
  28202. private _loadShader;
  28203. /**
  28204. * Recompiles the webGL program
  28205. * @param vertexSourceCode The source code for the vertex shader.
  28206. * @param fragmentSourceCode The source code for the fragment shader.
  28207. * @param onCompiled Callback called when completed.
  28208. * @param onError Callback called on error.
  28209. * @hidden
  28210. */
  28211. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28212. /**
  28213. * Prepares the effect
  28214. * @hidden
  28215. */
  28216. _prepareEffect(): void;
  28217. private _processCompilationErrors;
  28218. /**
  28219. * Checks if the effect is supported. (Must be called after compilation)
  28220. */
  28221. readonly isSupported: boolean;
  28222. /**
  28223. * Binds a texture to the engine to be used as output of the shader.
  28224. * @param channel Name of the output variable.
  28225. * @param texture Texture to bind.
  28226. * @hidden
  28227. */
  28228. _bindTexture(channel: string, texture: InternalTexture): void;
  28229. /**
  28230. * Sets a texture on the engine to be used in the shader.
  28231. * @param channel Name of the sampler variable.
  28232. * @param texture Texture to set.
  28233. */
  28234. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28235. /**
  28236. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28237. * @param channel Name of the sampler variable.
  28238. * @param texture Texture to set.
  28239. */
  28240. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28241. /**
  28242. * Sets an array of textures on the engine to be used in the shader.
  28243. * @param channel Name of the variable.
  28244. * @param textures Textures to set.
  28245. */
  28246. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28247. /**
  28248. * 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)
  28249. * @param channel Name of the sampler variable.
  28250. * @param postProcess Post process to get the input texture from.
  28251. */
  28252. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28253. /**
  28254. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28255. * 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)
  28256. * @param channel Name of the sampler variable.
  28257. * @param postProcess Post process to get the output texture from.
  28258. */
  28259. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28260. /** @hidden */
  28261. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28262. /** @hidden */
  28263. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28264. /** @hidden */
  28265. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28266. /** @hidden */
  28267. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28268. /**
  28269. * Binds a buffer to a uniform.
  28270. * @param buffer Buffer to bind.
  28271. * @param name Name of the uniform variable to bind to.
  28272. */
  28273. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28274. /**
  28275. * Binds block to a uniform.
  28276. * @param blockName Name of the block to bind.
  28277. * @param index Index to bind.
  28278. */
  28279. bindUniformBlock(blockName: string, index: number): void;
  28280. /**
  28281. * Sets an interger value on a uniform variable.
  28282. * @param uniformName Name of the variable.
  28283. * @param value Value to be set.
  28284. * @returns this effect.
  28285. */
  28286. setInt(uniformName: string, value: number): Effect;
  28287. /**
  28288. * Sets an int array on a uniform variable.
  28289. * @param uniformName Name of the variable.
  28290. * @param array array to be set.
  28291. * @returns this effect.
  28292. */
  28293. setIntArray(uniformName: string, array: Int32Array): Effect;
  28294. /**
  28295. * 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)
  28296. * @param uniformName Name of the variable.
  28297. * @param array array to be set.
  28298. * @returns this effect.
  28299. */
  28300. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28301. /**
  28302. * 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)
  28303. * @param uniformName Name of the variable.
  28304. * @param array array to be set.
  28305. * @returns this effect.
  28306. */
  28307. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28308. /**
  28309. * 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)
  28310. * @param uniformName Name of the variable.
  28311. * @param array array to be set.
  28312. * @returns this effect.
  28313. */
  28314. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28315. /**
  28316. * Sets an float array on a uniform variable.
  28317. * @param uniformName Name of the variable.
  28318. * @param array array to be set.
  28319. * @returns this effect.
  28320. */
  28321. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28322. /**
  28323. * 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)
  28324. * @param uniformName Name of the variable.
  28325. * @param array array to be set.
  28326. * @returns this effect.
  28327. */
  28328. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28329. /**
  28330. * 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)
  28331. * @param uniformName Name of the variable.
  28332. * @param array array to be set.
  28333. * @returns this effect.
  28334. */
  28335. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28336. /**
  28337. * 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)
  28338. * @param uniformName Name of the variable.
  28339. * @param array array to be set.
  28340. * @returns this effect.
  28341. */
  28342. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28343. /**
  28344. * Sets an array on a uniform variable.
  28345. * @param uniformName Name of the variable.
  28346. * @param array array to be set.
  28347. * @returns this effect.
  28348. */
  28349. setArray(uniformName: string, array: number[]): Effect;
  28350. /**
  28351. * 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)
  28352. * @param uniformName Name of the variable.
  28353. * @param array array to be set.
  28354. * @returns this effect.
  28355. */
  28356. setArray2(uniformName: string, array: number[]): Effect;
  28357. /**
  28358. * 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)
  28359. * @param uniformName Name of the variable.
  28360. * @param array array to be set.
  28361. * @returns this effect.
  28362. */
  28363. setArray3(uniformName: string, array: number[]): Effect;
  28364. /**
  28365. * 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)
  28366. * @param uniformName Name of the variable.
  28367. * @param array array to be set.
  28368. * @returns this effect.
  28369. */
  28370. setArray4(uniformName: string, array: number[]): Effect;
  28371. /**
  28372. * Sets matrices on a uniform variable.
  28373. * @param uniformName Name of the variable.
  28374. * @param matrices matrices to be set.
  28375. * @returns this effect.
  28376. */
  28377. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28378. /**
  28379. * Sets matrix on a uniform variable.
  28380. * @param uniformName Name of the variable.
  28381. * @param matrix matrix to be set.
  28382. * @returns this effect.
  28383. */
  28384. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28385. /**
  28386. * 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)
  28387. * @param uniformName Name of the variable.
  28388. * @param matrix matrix to be set.
  28389. * @returns this effect.
  28390. */
  28391. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28392. /**
  28393. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28394. * @param uniformName Name of the variable.
  28395. * @param matrix matrix to be set.
  28396. * @returns this effect.
  28397. */
  28398. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28399. /**
  28400. * Sets a float on a uniform variable.
  28401. * @param uniformName Name of the variable.
  28402. * @param value value to be set.
  28403. * @returns this effect.
  28404. */
  28405. setFloat(uniformName: string, value: number): Effect;
  28406. /**
  28407. * Sets a boolean on a uniform variable.
  28408. * @param uniformName Name of the variable.
  28409. * @param bool value to be set.
  28410. * @returns this effect.
  28411. */
  28412. setBool(uniformName: string, bool: boolean): Effect;
  28413. /**
  28414. * Sets a Vector2 on a uniform variable.
  28415. * @param uniformName Name of the variable.
  28416. * @param vector2 vector2 to be set.
  28417. * @returns this effect.
  28418. */
  28419. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28420. /**
  28421. * Sets a float2 on a uniform variable.
  28422. * @param uniformName Name of the variable.
  28423. * @param x First float in float2.
  28424. * @param y Second float in float2.
  28425. * @returns this effect.
  28426. */
  28427. setFloat2(uniformName: string, x: number, y: number): Effect;
  28428. /**
  28429. * Sets a Vector3 on a uniform variable.
  28430. * @param uniformName Name of the variable.
  28431. * @param vector3 Value to be set.
  28432. * @returns this effect.
  28433. */
  28434. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28435. /**
  28436. * Sets a float3 on a uniform variable.
  28437. * @param uniformName Name of the variable.
  28438. * @param x First float in float3.
  28439. * @param y Second float in float3.
  28440. * @param z Third float in float3.
  28441. * @returns this effect.
  28442. */
  28443. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28444. /**
  28445. * Sets a Vector4 on a uniform variable.
  28446. * @param uniformName Name of the variable.
  28447. * @param vector4 Value to be set.
  28448. * @returns this effect.
  28449. */
  28450. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28451. /**
  28452. * Sets a float4 on a uniform variable.
  28453. * @param uniformName Name of the variable.
  28454. * @param x First float in float4.
  28455. * @param y Second float in float4.
  28456. * @param z Third float in float4.
  28457. * @param w Fourth float in float4.
  28458. * @returns this effect.
  28459. */
  28460. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28461. /**
  28462. * Sets a Color3 on a uniform variable.
  28463. * @param uniformName Name of the variable.
  28464. * @param color3 Value to be set.
  28465. * @returns this effect.
  28466. */
  28467. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28468. /**
  28469. * Sets a Color4 on a uniform variable.
  28470. * @param uniformName Name of the variable.
  28471. * @param color3 Value to be set.
  28472. * @param alpha Alpha value to be set.
  28473. * @returns this effect.
  28474. */
  28475. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28476. /**
  28477. * Sets a Color4 on a uniform variable
  28478. * @param uniformName defines the name of the variable
  28479. * @param color4 defines the value to be set
  28480. * @returns this effect.
  28481. */
  28482. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28483. /** Release all associated resources */
  28484. dispose(): void;
  28485. /**
  28486. * This function will add a new shader to the shader store
  28487. * @param name the name of the shader
  28488. * @param pixelShader optional pixel shader content
  28489. * @param vertexShader optional vertex shader content
  28490. */
  28491. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28492. /**
  28493. * Store of each shader (The can be looked up using effect.key)
  28494. */
  28495. static ShadersStore: {
  28496. [key: string]: string;
  28497. };
  28498. /**
  28499. * Store of each included file for a shader (The can be looked up using effect.key)
  28500. */
  28501. static IncludesShadersStore: {
  28502. [key: string]: string;
  28503. };
  28504. /**
  28505. * Resets the cache of effects.
  28506. */
  28507. static ResetCache(): void;
  28508. }
  28509. }
  28510. declare module BABYLON {
  28511. /**
  28512. * Class used to describe the capabilities of the engine relatively to the current browser
  28513. */
  28514. export class EngineCapabilities {
  28515. /** Maximum textures units per fragment shader */
  28516. maxTexturesImageUnits: number;
  28517. /** Maximum texture units per vertex shader */
  28518. maxVertexTextureImageUnits: number;
  28519. /** Maximum textures units in the entire pipeline */
  28520. maxCombinedTexturesImageUnits: number;
  28521. /** Maximum texture size */
  28522. maxTextureSize: number;
  28523. /** Maximum cube texture size */
  28524. maxCubemapTextureSize: number;
  28525. /** Maximum render texture size */
  28526. maxRenderTextureSize: number;
  28527. /** Maximum number of vertex attributes */
  28528. maxVertexAttribs: number;
  28529. /** Maximum number of varyings */
  28530. maxVaryingVectors: number;
  28531. /** Maximum number of uniforms per vertex shader */
  28532. maxVertexUniformVectors: number;
  28533. /** Maximum number of uniforms per fragment shader */
  28534. maxFragmentUniformVectors: number;
  28535. /** Defines if standard derivates (dx/dy) are supported */
  28536. standardDerivatives: boolean;
  28537. /** Defines if s3tc texture compression is supported */
  28538. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28539. /** Defines if pvrtc texture compression is supported */
  28540. pvrtc: any;
  28541. /** Defines if etc1 texture compression is supported */
  28542. etc1: any;
  28543. /** Defines if etc2 texture compression is supported */
  28544. etc2: any;
  28545. /** Defines if astc texture compression is supported */
  28546. astc: any;
  28547. /** Defines if float textures are supported */
  28548. textureFloat: boolean;
  28549. /** Defines if vertex array objects are supported */
  28550. vertexArrayObject: boolean;
  28551. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28552. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28553. /** Gets the maximum level of anisotropy supported */
  28554. maxAnisotropy: number;
  28555. /** Defines if instancing is supported */
  28556. instancedArrays: boolean;
  28557. /** Defines if 32 bits indices are supported */
  28558. uintIndices: boolean;
  28559. /** Defines if high precision shaders are supported */
  28560. highPrecisionShaderSupported: boolean;
  28561. /** Defines if depth reading in the fragment shader is supported */
  28562. fragmentDepthSupported: boolean;
  28563. /** Defines if float texture linear filtering is supported*/
  28564. textureFloatLinearFiltering: boolean;
  28565. /** Defines if rendering to float textures is supported */
  28566. textureFloatRender: boolean;
  28567. /** Defines if half float textures are supported*/
  28568. textureHalfFloat: boolean;
  28569. /** Defines if half float texture linear filtering is supported*/
  28570. textureHalfFloatLinearFiltering: boolean;
  28571. /** Defines if rendering to half float textures is supported */
  28572. textureHalfFloatRender: boolean;
  28573. /** Defines if textureLOD shader command is supported */
  28574. textureLOD: boolean;
  28575. /** Defines if draw buffers extension is supported */
  28576. drawBuffersExtension: boolean;
  28577. /** Defines if depth textures are supported */
  28578. depthTextureExtension: boolean;
  28579. /** Defines if float color buffer are supported */
  28580. colorBufferFloat: boolean;
  28581. /** Gets disjoint timer query extension (null if not supported) */
  28582. timerQuery: EXT_disjoint_timer_query;
  28583. /** Defines if timestamp can be used with timer query */
  28584. canUseTimestampForTimerQuery: boolean;
  28585. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28586. multiview: any;
  28587. /** Function used to let the system compiles shaders in background */
  28588. parallelShaderCompile: {
  28589. COMPLETION_STATUS_KHR: number;
  28590. };
  28591. /** Max number of texture samples for MSAA */
  28592. maxMSAASamples: number;
  28593. /** Defines if the blend min max extension is supported */
  28594. blendMinMax: boolean;
  28595. }
  28596. }
  28597. declare module BABYLON {
  28598. /**
  28599. * @hidden
  28600. **/
  28601. export class DepthCullingState {
  28602. private _isDepthTestDirty;
  28603. private _isDepthMaskDirty;
  28604. private _isDepthFuncDirty;
  28605. private _isCullFaceDirty;
  28606. private _isCullDirty;
  28607. private _isZOffsetDirty;
  28608. private _isFrontFaceDirty;
  28609. private _depthTest;
  28610. private _depthMask;
  28611. private _depthFunc;
  28612. private _cull;
  28613. private _cullFace;
  28614. private _zOffset;
  28615. private _frontFace;
  28616. /**
  28617. * Initializes the state.
  28618. */
  28619. constructor();
  28620. readonly isDirty: boolean;
  28621. zOffset: number;
  28622. cullFace: Nullable<number>;
  28623. cull: Nullable<boolean>;
  28624. depthFunc: Nullable<number>;
  28625. depthMask: boolean;
  28626. depthTest: boolean;
  28627. frontFace: Nullable<number>;
  28628. reset(): void;
  28629. apply(gl: WebGLRenderingContext): void;
  28630. }
  28631. }
  28632. declare module BABYLON {
  28633. /**
  28634. * @hidden
  28635. **/
  28636. export class StencilState {
  28637. /** 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 */
  28638. static readonly ALWAYS: number;
  28639. /** Passed to stencilOperation to specify that stencil value must be kept */
  28640. static readonly KEEP: number;
  28641. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28642. static readonly REPLACE: number;
  28643. private _isStencilTestDirty;
  28644. private _isStencilMaskDirty;
  28645. private _isStencilFuncDirty;
  28646. private _isStencilOpDirty;
  28647. private _stencilTest;
  28648. private _stencilMask;
  28649. private _stencilFunc;
  28650. private _stencilFuncRef;
  28651. private _stencilFuncMask;
  28652. private _stencilOpStencilFail;
  28653. private _stencilOpDepthFail;
  28654. private _stencilOpStencilDepthPass;
  28655. readonly isDirty: boolean;
  28656. stencilFunc: number;
  28657. stencilFuncRef: number;
  28658. stencilFuncMask: number;
  28659. stencilOpStencilFail: number;
  28660. stencilOpDepthFail: number;
  28661. stencilOpStencilDepthPass: number;
  28662. stencilMask: number;
  28663. stencilTest: boolean;
  28664. constructor();
  28665. reset(): void;
  28666. apply(gl: WebGLRenderingContext): void;
  28667. }
  28668. }
  28669. declare module BABYLON {
  28670. /**
  28671. * @hidden
  28672. **/
  28673. export class AlphaState {
  28674. private _isAlphaBlendDirty;
  28675. private _isBlendFunctionParametersDirty;
  28676. private _isBlendEquationParametersDirty;
  28677. private _isBlendConstantsDirty;
  28678. private _alphaBlend;
  28679. private _blendFunctionParameters;
  28680. private _blendEquationParameters;
  28681. private _blendConstants;
  28682. /**
  28683. * Initializes the state.
  28684. */
  28685. constructor();
  28686. readonly isDirty: boolean;
  28687. alphaBlend: boolean;
  28688. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28689. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28690. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28691. reset(): void;
  28692. apply(gl: WebGLRenderingContext): void;
  28693. }
  28694. }
  28695. declare module BABYLON {
  28696. /** @hidden */
  28697. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28698. attributeProcessor(attribute: string): string;
  28699. varyingProcessor(varying: string, isFragment: boolean): string;
  28700. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28701. }
  28702. }
  28703. declare module BABYLON {
  28704. /**
  28705. * Interface for attribute information associated with buffer instanciation
  28706. */
  28707. export class InstancingAttributeInfo {
  28708. /**
  28709. * Index/offset of the attribute in the vertex shader
  28710. */
  28711. index: number;
  28712. /**
  28713. * size of the attribute, 1, 2, 3 or 4
  28714. */
  28715. attributeSize: number;
  28716. /**
  28717. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28718. * default is FLOAT
  28719. */
  28720. attribyteType: number;
  28721. /**
  28722. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28723. */
  28724. normalized: boolean;
  28725. /**
  28726. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28727. */
  28728. offset: number;
  28729. /**
  28730. * Name of the GLSL attribute, for debugging purpose only
  28731. */
  28732. attributeName: string;
  28733. }
  28734. }
  28735. declare module BABYLON {
  28736. interface ThinEngine {
  28737. /**
  28738. * Update a video texture
  28739. * @param texture defines the texture to update
  28740. * @param video defines the video element to use
  28741. * @param invertY defines if data must be stored with Y axis inverted
  28742. */
  28743. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28744. }
  28745. }
  28746. declare module BABYLON {
  28747. /**
  28748. * Settings for finer control over video usage
  28749. */
  28750. export interface VideoTextureSettings {
  28751. /**
  28752. * Applies `autoplay` to video, if specified
  28753. */
  28754. autoPlay?: boolean;
  28755. /**
  28756. * Applies `loop` to video, if specified
  28757. */
  28758. loop?: boolean;
  28759. /**
  28760. * Automatically updates internal texture from video at every frame in the render loop
  28761. */
  28762. autoUpdateTexture: boolean;
  28763. /**
  28764. * Image src displayed during the video loading or until the user interacts with the video.
  28765. */
  28766. poster?: string;
  28767. }
  28768. /**
  28769. * If you want to display a video in your scene, this is the special texture for that.
  28770. * This special texture works similar to other textures, with the exception of a few parameters.
  28771. * @see https://doc.babylonjs.com/how_to/video_texture
  28772. */
  28773. export class VideoTexture extends Texture {
  28774. /**
  28775. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28776. */
  28777. readonly autoUpdateTexture: boolean;
  28778. /**
  28779. * The video instance used by the texture internally
  28780. */
  28781. readonly video: HTMLVideoElement;
  28782. private _onUserActionRequestedObservable;
  28783. /**
  28784. * Event triggerd when a dom action is required by the user to play the video.
  28785. * This happens due to recent changes in browser policies preventing video to auto start.
  28786. */
  28787. readonly onUserActionRequestedObservable: Observable<Texture>;
  28788. private _generateMipMaps;
  28789. private _engine;
  28790. private _stillImageCaptured;
  28791. private _displayingPosterTexture;
  28792. private _settings;
  28793. private _createInternalTextureOnEvent;
  28794. private _frameId;
  28795. /**
  28796. * Creates a video texture.
  28797. * If you want to display a video in your scene, this is the special texture for that.
  28798. * This special texture works similar to other textures, with the exception of a few parameters.
  28799. * @see https://doc.babylonjs.com/how_to/video_texture
  28800. * @param name optional name, will detect from video source, if not defined
  28801. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28802. * @param scene is obviously the current scene.
  28803. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28804. * @param invertY is false by default but can be used to invert video on Y axis
  28805. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28806. * @param settings allows finer control over video usage
  28807. */
  28808. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28809. private _getName;
  28810. private _getVideo;
  28811. private _createInternalTexture;
  28812. private reset;
  28813. /**
  28814. * @hidden Internal method to initiate `update`.
  28815. */
  28816. _rebuild(): void;
  28817. /**
  28818. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28819. */
  28820. update(): void;
  28821. /**
  28822. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28823. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28824. */
  28825. updateTexture(isVisible: boolean): void;
  28826. protected _updateInternalTexture: () => void;
  28827. /**
  28828. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28829. * @param url New url.
  28830. */
  28831. updateURL(url: string): void;
  28832. /**
  28833. * Dispose the texture and release its associated resources.
  28834. */
  28835. dispose(): void;
  28836. /**
  28837. * Creates a video texture straight from a stream.
  28838. * @param scene Define the scene the texture should be created in
  28839. * @param stream Define the stream the texture should be created from
  28840. * @returns The created video texture as a promise
  28841. */
  28842. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28843. /**
  28844. * Creates a video texture straight from your WebCam video feed.
  28845. * @param scene Define the scene the texture should be created in
  28846. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28847. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28848. * @returns The created video texture as a promise
  28849. */
  28850. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28851. minWidth: number;
  28852. maxWidth: number;
  28853. minHeight: number;
  28854. maxHeight: number;
  28855. deviceId: string;
  28856. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28857. /**
  28858. * Creates a video texture straight from your WebCam video feed.
  28859. * @param scene Define the scene the texture should be created in
  28860. * @param onReady Define a callback to triggered once the texture will be ready
  28861. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28862. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28863. */
  28864. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28865. minWidth: number;
  28866. maxWidth: number;
  28867. minHeight: number;
  28868. maxHeight: number;
  28869. deviceId: string;
  28870. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28871. }
  28872. }
  28873. declare module BABYLON {
  28874. /**
  28875. * Defines the interface used by objects working like Scene
  28876. * @hidden
  28877. */
  28878. interface ISceneLike {
  28879. _addPendingData(data: any): void;
  28880. _removePendingData(data: any): void;
  28881. offlineProvider: IOfflineProvider;
  28882. }
  28883. /** Interface defining initialization parameters for Engine class */
  28884. export interface EngineOptions extends WebGLContextAttributes {
  28885. /**
  28886. * Defines if the engine should no exceed a specified device ratio
  28887. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28888. */
  28889. limitDeviceRatio?: number;
  28890. /**
  28891. * Defines if webvr should be enabled automatically
  28892. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28893. */
  28894. autoEnableWebVR?: boolean;
  28895. /**
  28896. * Defines if webgl2 should be turned off even if supported
  28897. * @see http://doc.babylonjs.com/features/webgl2
  28898. */
  28899. disableWebGL2Support?: boolean;
  28900. /**
  28901. * Defines if webaudio should be initialized as well
  28902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28903. */
  28904. audioEngine?: boolean;
  28905. /**
  28906. * Defines if animations should run using a deterministic lock step
  28907. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28908. */
  28909. deterministicLockstep?: boolean;
  28910. /** Defines the maximum steps to use with deterministic lock step mode */
  28911. lockstepMaxSteps?: number;
  28912. /**
  28913. * Defines that engine should ignore context lost events
  28914. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28915. */
  28916. doNotHandleContextLost?: boolean;
  28917. /**
  28918. * Defines that engine should ignore modifying touch action attribute and style
  28919. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28920. */
  28921. doNotHandleTouchAction?: boolean;
  28922. /**
  28923. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28924. */
  28925. useHighPrecisionFloats?: boolean;
  28926. }
  28927. /**
  28928. * The base engine class (root of all engines)
  28929. */
  28930. export class ThinEngine {
  28931. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28932. static ExceptionList: ({
  28933. key: string;
  28934. capture: string;
  28935. captureConstraint: number;
  28936. targets: string[];
  28937. } | {
  28938. key: string;
  28939. capture: null;
  28940. captureConstraint: null;
  28941. targets: string[];
  28942. })[];
  28943. /** @hidden */
  28944. static _TextureLoaders: IInternalTextureLoader[];
  28945. /**
  28946. * Returns the current npm package of the sdk
  28947. */
  28948. static readonly NpmPackage: string;
  28949. /**
  28950. * Returns the current version of the framework
  28951. */
  28952. static readonly Version: string;
  28953. /**
  28954. * Returns a string describing the current engine
  28955. */
  28956. readonly description: string;
  28957. /**
  28958. * Gets or sets the epsilon value used by collision engine
  28959. */
  28960. static CollisionsEpsilon: number;
  28961. /**
  28962. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28963. */
  28964. static ShadersRepository: string;
  28965. /** @hidden */
  28966. _shaderProcessor: IShaderProcessor;
  28967. /**
  28968. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28969. */
  28970. forcePOTTextures: boolean;
  28971. /**
  28972. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28973. */
  28974. isFullscreen: boolean;
  28975. /**
  28976. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28977. */
  28978. cullBackFaces: boolean;
  28979. /**
  28980. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28981. */
  28982. renderEvenInBackground: boolean;
  28983. /**
  28984. * Gets or sets a boolean indicating that cache can be kept between frames
  28985. */
  28986. preventCacheWipeBetweenFrames: boolean;
  28987. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28988. validateShaderPrograms: boolean;
  28989. /**
  28990. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28991. */
  28992. disableUniformBuffers: boolean;
  28993. /** @hidden */
  28994. _uniformBuffers: UniformBuffer[];
  28995. /**
  28996. * Gets a boolean indicating that the engine supports uniform buffers
  28997. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28998. */
  28999. readonly supportsUniformBuffers: boolean;
  29000. /** @hidden */
  29001. _gl: WebGLRenderingContext;
  29002. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29003. protected _windowIsBackground: boolean;
  29004. protected _webGLVersion: number;
  29005. protected _highPrecisionShadersAllowed: boolean;
  29006. /** @hidden */
  29007. readonly _shouldUseHighPrecisionShader: boolean;
  29008. /**
  29009. * Gets a boolean indicating that only power of 2 textures are supported
  29010. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29011. */
  29012. readonly needPOTTextures: boolean;
  29013. /** @hidden */
  29014. _badOS: boolean;
  29015. /** @hidden */
  29016. _badDesktopOS: boolean;
  29017. private _hardwareScalingLevel;
  29018. /** @hidden */
  29019. _caps: EngineCapabilities;
  29020. private _isStencilEnable;
  29021. protected _colorWrite: boolean;
  29022. private _glVersion;
  29023. private _glRenderer;
  29024. private _glVendor;
  29025. /** @hidden */
  29026. _videoTextureSupported: boolean;
  29027. protected _renderingQueueLaunched: boolean;
  29028. protected _activeRenderLoops: (() => void)[];
  29029. /**
  29030. * Observable signaled when a context lost event is raised
  29031. */
  29032. onContextLostObservable: Observable<ThinEngine>;
  29033. /**
  29034. * Observable signaled when a context restored event is raised
  29035. */
  29036. onContextRestoredObservable: Observable<ThinEngine>;
  29037. private _onContextLost;
  29038. private _onContextRestored;
  29039. protected _contextWasLost: boolean;
  29040. /** @hidden */
  29041. _doNotHandleContextLost: boolean;
  29042. /**
  29043. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29045. */
  29046. doNotHandleContextLost: boolean;
  29047. /**
  29048. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29049. */
  29050. disableVertexArrayObjects: boolean;
  29051. /** @hidden */
  29052. protected _depthCullingState: DepthCullingState;
  29053. /** @hidden */
  29054. protected _stencilState: StencilState;
  29055. /** @hidden */
  29056. protected _alphaState: AlphaState;
  29057. /** @hidden */
  29058. _internalTexturesCache: InternalTexture[];
  29059. /** @hidden */
  29060. protected _activeChannel: number;
  29061. private _currentTextureChannel;
  29062. /** @hidden */
  29063. protected _boundTexturesCache: {
  29064. [key: string]: Nullable<InternalTexture>;
  29065. };
  29066. /** @hidden */
  29067. protected _currentEffect: Nullable<Effect>;
  29068. /** @hidden */
  29069. protected _currentProgram: Nullable<WebGLProgram>;
  29070. private _compiledEffects;
  29071. private _vertexAttribArraysEnabled;
  29072. /** @hidden */
  29073. protected _cachedViewport: Nullable<IViewportLike>;
  29074. private _cachedVertexArrayObject;
  29075. /** @hidden */
  29076. protected _cachedVertexBuffers: any;
  29077. /** @hidden */
  29078. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29079. /** @hidden */
  29080. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29081. /** @hidden */
  29082. _currentRenderTarget: Nullable<InternalTexture>;
  29083. private _uintIndicesCurrentlySet;
  29084. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29085. /** @hidden */
  29086. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29087. private _currentBufferPointers;
  29088. private _currentInstanceLocations;
  29089. private _currentInstanceBuffers;
  29090. private _textureUnits;
  29091. /** @hidden */
  29092. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29093. /** @hidden */
  29094. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29095. /** @hidden */
  29096. _bindedRenderFunction: any;
  29097. private _vaoRecordInProgress;
  29098. private _mustWipeVertexAttributes;
  29099. private _emptyTexture;
  29100. private _emptyCubeTexture;
  29101. private _emptyTexture3D;
  29102. /** @hidden */
  29103. _frameHandler: number;
  29104. private _nextFreeTextureSlots;
  29105. private _maxSimultaneousTextures;
  29106. private _activeRequests;
  29107. protected _texturesSupported: string[];
  29108. /** @hidden */
  29109. _textureFormatInUse: Nullable<string>;
  29110. protected readonly _supportsHardwareTextureRescaling: boolean;
  29111. /**
  29112. * Gets the list of texture formats supported
  29113. */
  29114. readonly texturesSupported: Array<string>;
  29115. /**
  29116. * Gets the list of texture formats in use
  29117. */
  29118. readonly textureFormatInUse: Nullable<string>;
  29119. /**
  29120. * Gets the current viewport
  29121. */
  29122. readonly currentViewport: Nullable<IViewportLike>;
  29123. /**
  29124. * Gets the default empty texture
  29125. */
  29126. readonly emptyTexture: InternalTexture;
  29127. /**
  29128. * Gets the default empty 3D texture
  29129. */
  29130. readonly emptyTexture3D: InternalTexture;
  29131. /**
  29132. * Gets the default empty cube texture
  29133. */
  29134. readonly emptyCubeTexture: InternalTexture;
  29135. /**
  29136. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29137. */
  29138. readonly premultipliedAlpha: boolean;
  29139. /**
  29140. * Observable event triggered before each texture is initialized
  29141. */
  29142. onBeforeTextureInitObservable: Observable<Texture>;
  29143. /**
  29144. * Creates a new engine
  29145. * @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
  29146. * @param antialias defines enable antialiasing (default: false)
  29147. * @param options defines further options to be sent to the getContext() function
  29148. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29149. */
  29150. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29151. private _rebuildInternalTextures;
  29152. private _rebuildEffects;
  29153. /**
  29154. * Gets a boolean indicating if all created effects are ready
  29155. * @returns true if all effects are ready
  29156. */
  29157. areAllEffectsReady(): boolean;
  29158. protected _rebuildBuffers(): void;
  29159. private _initGLContext;
  29160. /**
  29161. * Gets version of the current webGL context
  29162. */
  29163. readonly webGLVersion: number;
  29164. /**
  29165. * Gets a string idenfifying the name of the class
  29166. * @returns "Engine" string
  29167. */
  29168. getClassName(): string;
  29169. /**
  29170. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29171. */
  29172. readonly isStencilEnable: boolean;
  29173. /** @hidden */
  29174. _prepareWorkingCanvas(): void;
  29175. /**
  29176. * Reset the texture cache to empty state
  29177. */
  29178. resetTextureCache(): void;
  29179. /**
  29180. * Gets an object containing information about the current webGL context
  29181. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29182. */
  29183. getGlInfo(): {
  29184. vendor: string;
  29185. renderer: string;
  29186. version: string;
  29187. };
  29188. /**
  29189. * Defines the hardware scaling level.
  29190. * By default the hardware scaling level is computed from the window device ratio.
  29191. * 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.
  29192. * @param level defines the level to use
  29193. */
  29194. setHardwareScalingLevel(level: number): void;
  29195. /**
  29196. * Gets the current hardware scaling level.
  29197. * By default the hardware scaling level is computed from the window device ratio.
  29198. * 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.
  29199. * @returns a number indicating the current hardware scaling level
  29200. */
  29201. getHardwareScalingLevel(): number;
  29202. /**
  29203. * Gets the list of loaded textures
  29204. * @returns an array containing all loaded textures
  29205. */
  29206. getLoadedTexturesCache(): InternalTexture[];
  29207. /**
  29208. * Gets the object containing all engine capabilities
  29209. * @returns the EngineCapabilities object
  29210. */
  29211. getCaps(): EngineCapabilities;
  29212. /**
  29213. * stop executing a render loop function and remove it from the execution array
  29214. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29215. */
  29216. stopRenderLoop(renderFunction?: () => void): void;
  29217. /** @hidden */
  29218. _renderLoop(): void;
  29219. /**
  29220. * Gets the HTML canvas attached with the current webGL context
  29221. * @returns a HTML canvas
  29222. */
  29223. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29224. /**
  29225. * Gets host window
  29226. * @returns the host window object
  29227. */
  29228. getHostWindow(): Nullable<Window>;
  29229. /**
  29230. * Gets the current render width
  29231. * @param useScreen defines if screen size must be used (or the current render target if any)
  29232. * @returns a number defining the current render width
  29233. */
  29234. getRenderWidth(useScreen?: boolean): number;
  29235. /**
  29236. * Gets the current render height
  29237. * @param useScreen defines if screen size must be used (or the current render target if any)
  29238. * @returns a number defining the current render height
  29239. */
  29240. getRenderHeight(useScreen?: boolean): number;
  29241. /**
  29242. * Can be used to override the current requestAnimationFrame requester.
  29243. * @hidden
  29244. */
  29245. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29246. /**
  29247. * Register and execute a render loop. The engine can have more than one render function
  29248. * @param renderFunction defines the function to continuously execute
  29249. */
  29250. runRenderLoop(renderFunction: () => void): void;
  29251. /**
  29252. * Clear the current render buffer or the current render target (if any is set up)
  29253. * @param color defines the color to use
  29254. * @param backBuffer defines if the back buffer must be cleared
  29255. * @param depth defines if the depth buffer must be cleared
  29256. * @param stencil defines if the stencil buffer must be cleared
  29257. */
  29258. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29259. private _viewportCached;
  29260. /** @hidden */
  29261. _viewport(x: number, y: number, width: number, height: number): void;
  29262. /**
  29263. * Set the WebGL's viewport
  29264. * @param viewport defines the viewport element to be used
  29265. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29266. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29267. */
  29268. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29269. /**
  29270. * Begin a new frame
  29271. */
  29272. beginFrame(): void;
  29273. /**
  29274. * Enf the current frame
  29275. */
  29276. endFrame(): void;
  29277. /**
  29278. * Resize the view according to the canvas' size
  29279. */
  29280. resize(): void;
  29281. /**
  29282. * Force a specific size of the canvas
  29283. * @param width defines the new canvas' width
  29284. * @param height defines the new canvas' height
  29285. */
  29286. setSize(width: number, height: number): void;
  29287. /**
  29288. * Binds the frame buffer to the specified texture.
  29289. * @param texture The texture to render to or null for the default canvas
  29290. * @param faceIndex The face of the texture to render to in case of cube texture
  29291. * @param requiredWidth The width of the target to render to
  29292. * @param requiredHeight The height of the target to render to
  29293. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29294. * @param depthStencilTexture The depth stencil texture to use to render
  29295. * @param lodLevel defines le lod level to bind to the frame buffer
  29296. */
  29297. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29298. /** @hidden */
  29299. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29300. /**
  29301. * Unbind the current render target texture from the webGL context
  29302. * @param texture defines the render target texture to unbind
  29303. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29304. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29305. */
  29306. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29307. /**
  29308. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29309. */
  29310. flushFramebuffer(): void;
  29311. /**
  29312. * Unbind the current render target and bind the default framebuffer
  29313. */
  29314. restoreDefaultFramebuffer(): void;
  29315. private _resetVertexBufferBinding;
  29316. /**
  29317. * Creates a vertex buffer
  29318. * @param data the data for the vertex buffer
  29319. * @returns the new WebGL static buffer
  29320. */
  29321. createVertexBuffer(data: DataArray): DataBuffer;
  29322. private _createVertexBuffer;
  29323. /**
  29324. * Creates a dynamic vertex buffer
  29325. * @param data the data for the dynamic vertex buffer
  29326. * @returns the new WebGL dynamic buffer
  29327. */
  29328. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29329. /**
  29330. * Updates a dynamic vertex buffer.
  29331. * @param vertexBuffer the vertex buffer to update
  29332. * @param data the data used to update the vertex buffer
  29333. * @param byteOffset the byte offset of the data
  29334. * @param byteLength the byte length of the data
  29335. */
  29336. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29337. protected _resetIndexBufferBinding(): void;
  29338. /**
  29339. * Creates a new index buffer
  29340. * @param indices defines the content of the index buffer
  29341. * @param updatable defines if the index buffer must be updatable
  29342. * @returns a new webGL buffer
  29343. */
  29344. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29345. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29346. /**
  29347. * Bind a webGL buffer to the webGL context
  29348. * @param buffer defines the buffer to bind
  29349. */
  29350. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29351. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29352. private bindBuffer;
  29353. /**
  29354. * update the bound buffer with the given data
  29355. * @param data defines the data to update
  29356. */
  29357. updateArrayBuffer(data: Float32Array): void;
  29358. private _vertexAttribPointer;
  29359. private _bindIndexBufferWithCache;
  29360. private _bindVertexBuffersAttributes;
  29361. /**
  29362. * Records a vertex array object
  29363. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29364. * @param vertexBuffers defines the list of vertex buffers to store
  29365. * @param indexBuffer defines the index buffer to store
  29366. * @param effect defines the effect to store
  29367. * @returns the new vertex array object
  29368. */
  29369. recordVertexArrayObject(vertexBuffers: {
  29370. [key: string]: VertexBuffer;
  29371. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29372. /**
  29373. * Bind a specific vertex array object
  29374. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29375. * @param vertexArrayObject defines the vertex array object to bind
  29376. * @param indexBuffer defines the index buffer to bind
  29377. */
  29378. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29379. /**
  29380. * Bind webGl buffers directly to the webGL context
  29381. * @param vertexBuffer defines the vertex buffer to bind
  29382. * @param indexBuffer defines the index buffer to bind
  29383. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29384. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29385. * @param effect defines the effect associated with the vertex buffer
  29386. */
  29387. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29388. private _unbindVertexArrayObject;
  29389. /**
  29390. * Bind a list of vertex buffers to the webGL context
  29391. * @param vertexBuffers defines the list of vertex buffers to bind
  29392. * @param indexBuffer defines the index buffer to bind
  29393. * @param effect defines the effect associated with the vertex buffers
  29394. */
  29395. bindBuffers(vertexBuffers: {
  29396. [key: string]: Nullable<VertexBuffer>;
  29397. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29398. /**
  29399. * Unbind all instance attributes
  29400. */
  29401. unbindInstanceAttributes(): void;
  29402. /**
  29403. * Release and free the memory of a vertex array object
  29404. * @param vao defines the vertex array object to delete
  29405. */
  29406. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29407. /** @hidden */
  29408. _releaseBuffer(buffer: DataBuffer): boolean;
  29409. protected _deleteBuffer(buffer: DataBuffer): void;
  29410. /**
  29411. * Creates a webGL buffer to use with instanciation
  29412. * @param capacity defines the size of the buffer
  29413. * @returns the webGL buffer
  29414. */
  29415. createInstancesBuffer(capacity: number): DataBuffer;
  29416. /**
  29417. * Delete a webGL buffer used with instanciation
  29418. * @param buffer defines the webGL buffer to delete
  29419. */
  29420. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29421. /**
  29422. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29423. * @param instancesBuffer defines the webGL buffer to update and bind
  29424. * @param data defines the data to store in the buffer
  29425. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29426. */
  29427. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29428. /**
  29429. * Apply all cached states (depth, culling, stencil and alpha)
  29430. */
  29431. applyStates(): void;
  29432. /**
  29433. * Send a draw order
  29434. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29435. * @param indexStart defines the starting index
  29436. * @param indexCount defines the number of index to draw
  29437. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29438. */
  29439. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29440. /**
  29441. * Draw a list of points
  29442. * @param verticesStart defines the index of first vertex to draw
  29443. * @param verticesCount defines the count of vertices to draw
  29444. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29445. */
  29446. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29447. /**
  29448. * Draw a list of unindexed primitives
  29449. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29450. * @param verticesStart defines the index of first vertex to draw
  29451. * @param verticesCount defines the count of vertices to draw
  29452. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29453. */
  29454. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29455. /**
  29456. * Draw a list of indexed primitives
  29457. * @param fillMode defines the primitive to use
  29458. * @param indexStart defines the starting index
  29459. * @param indexCount defines the number of index to draw
  29460. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29461. */
  29462. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29463. /**
  29464. * Draw a list of unindexed primitives
  29465. * @param fillMode defines the primitive to use
  29466. * @param verticesStart defines the index of first vertex to draw
  29467. * @param verticesCount defines the count of vertices to draw
  29468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29469. */
  29470. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29471. private _drawMode;
  29472. /** @hidden */
  29473. protected _reportDrawCall(): void;
  29474. /** @hidden */
  29475. _releaseEffect(effect: Effect): void;
  29476. /** @hidden */
  29477. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29478. /**
  29479. * Create a new effect (used to store vertex/fragment shaders)
  29480. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29481. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29482. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29483. * @param samplers defines an array of string used to represent textures
  29484. * @param defines defines the string containing the defines to use to compile the shaders
  29485. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29486. * @param onCompiled defines a function to call when the effect creation is successful
  29487. * @param onError defines a function to call when the effect creation has failed
  29488. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29489. * @returns the new Effect
  29490. */
  29491. 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;
  29492. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29493. private _compileShader;
  29494. private _compileRawShader;
  29495. /**
  29496. * Directly creates a webGL program
  29497. * @param pipelineContext defines the pipeline context to attach to
  29498. * @param vertexCode defines the vertex shader code to use
  29499. * @param fragmentCode defines the fragment shader code to use
  29500. * @param context defines the webGL context to use (if not set, the current one will be used)
  29501. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29502. * @returns the new webGL program
  29503. */
  29504. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29505. /**
  29506. * Creates a webGL program
  29507. * @param pipelineContext defines the pipeline context to attach to
  29508. * @param vertexCode defines the vertex shader code to use
  29509. * @param fragmentCode defines the fragment shader code to use
  29510. * @param defines defines the string containing the defines to use to compile the shaders
  29511. * @param context defines the webGL context to use (if not set, the current one will be used)
  29512. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29513. * @returns the new webGL program
  29514. */
  29515. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29516. /**
  29517. * Creates a new pipeline context
  29518. * @returns the new pipeline
  29519. */
  29520. createPipelineContext(): IPipelineContext;
  29521. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29522. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29523. /** @hidden */
  29524. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29525. /** @hidden */
  29526. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29527. /** @hidden */
  29528. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29529. /**
  29530. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29531. * @param pipelineContext defines the pipeline context to use
  29532. * @param uniformsNames defines the list of uniform names
  29533. * @returns an array of webGL uniform locations
  29534. */
  29535. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29536. /**
  29537. * Gets the lsit of active attributes for a given webGL program
  29538. * @param pipelineContext defines the pipeline context to use
  29539. * @param attributesNames defines the list of attribute names to get
  29540. * @returns an array of indices indicating the offset of each attribute
  29541. */
  29542. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29543. /**
  29544. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29545. * @param effect defines the effect to activate
  29546. */
  29547. enableEffect(effect: Nullable<Effect>): void;
  29548. /**
  29549. * Set the value of an uniform to an array of int32
  29550. * @param uniform defines the webGL uniform location where to store the value
  29551. * @param array defines the array of int32 to store
  29552. */
  29553. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29554. /**
  29555. * Set the value of an uniform to an array of int32 (stored as vec2)
  29556. * @param uniform defines the webGL uniform location where to store the value
  29557. * @param array defines the array of int32 to store
  29558. */
  29559. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29560. /**
  29561. * Set the value of an uniform to an array of int32 (stored as vec3)
  29562. * @param uniform defines the webGL uniform location where to store the value
  29563. * @param array defines the array of int32 to store
  29564. */
  29565. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29566. /**
  29567. * Set the value of an uniform to an array of int32 (stored as vec4)
  29568. * @param uniform defines the webGL uniform location where to store the value
  29569. * @param array defines the array of int32 to store
  29570. */
  29571. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29572. /**
  29573. * Set the value of an uniform to an array of float32
  29574. * @param uniform defines the webGL uniform location where to store the value
  29575. * @param array defines the array of float32 to store
  29576. */
  29577. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29578. /**
  29579. * Set the value of an uniform to an array of float32 (stored as vec2)
  29580. * @param uniform defines the webGL uniform location where to store the value
  29581. * @param array defines the array of float32 to store
  29582. */
  29583. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29584. /**
  29585. * Set the value of an uniform to an array of float32 (stored as vec3)
  29586. * @param uniform defines the webGL uniform location where to store the value
  29587. * @param array defines the array of float32 to store
  29588. */
  29589. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29590. /**
  29591. * Set the value of an uniform to an array of float32 (stored as vec4)
  29592. * @param uniform defines the webGL uniform location where to store the value
  29593. * @param array defines the array of float32 to store
  29594. */
  29595. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29596. /**
  29597. * Set the value of an uniform to an array of number
  29598. * @param uniform defines the webGL uniform location where to store the value
  29599. * @param array defines the array of number to store
  29600. */
  29601. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29602. /**
  29603. * Set the value of an uniform to an array of number (stored as vec2)
  29604. * @param uniform defines the webGL uniform location where to store the value
  29605. * @param array defines the array of number to store
  29606. */
  29607. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29608. /**
  29609. * Set the value of an uniform to an array of number (stored as vec3)
  29610. * @param uniform defines the webGL uniform location where to store the value
  29611. * @param array defines the array of number to store
  29612. */
  29613. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29614. /**
  29615. * Set the value of an uniform to an array of number (stored as vec4)
  29616. * @param uniform defines the webGL uniform location where to store the value
  29617. * @param array defines the array of number to store
  29618. */
  29619. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29620. /**
  29621. * Set the value of an uniform to an array of float32 (stored as matrices)
  29622. * @param uniform defines the webGL uniform location where to store the value
  29623. * @param matrices defines the array of float32 to store
  29624. */
  29625. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29626. /**
  29627. * Set the value of an uniform to a matrix (3x3)
  29628. * @param uniform defines the webGL uniform location where to store the value
  29629. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29630. */
  29631. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29632. /**
  29633. * Set the value of an uniform to a matrix (2x2)
  29634. * @param uniform defines the webGL uniform location where to store the value
  29635. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29636. */
  29637. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29638. /**
  29639. * Set the value of an uniform to a number (int)
  29640. * @param uniform defines the webGL uniform location where to store the value
  29641. * @param value defines the int number to store
  29642. */
  29643. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29644. /**
  29645. * Set the value of an uniform to a number (float)
  29646. * @param uniform defines the webGL uniform location where to store the value
  29647. * @param value defines the float number to store
  29648. */
  29649. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29650. /**
  29651. * Set the value of an uniform to a vec2
  29652. * @param uniform defines the webGL uniform location where to store the value
  29653. * @param x defines the 1st component of the value
  29654. * @param y defines the 2nd component of the value
  29655. */
  29656. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29657. /**
  29658. * Set the value of an uniform to a vec3
  29659. * @param uniform defines the webGL uniform location where to store the value
  29660. * @param x defines the 1st component of the value
  29661. * @param y defines the 2nd component of the value
  29662. * @param z defines the 3rd component of the value
  29663. */
  29664. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29665. /**
  29666. * Set the value of an uniform to a boolean
  29667. * @param uniform defines the webGL uniform location where to store the value
  29668. * @param bool defines the boolean to store
  29669. */
  29670. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29671. /**
  29672. * Set the value of an uniform to a vec4
  29673. * @param uniform defines the webGL uniform location where to store the value
  29674. * @param x defines the 1st component of the value
  29675. * @param y defines the 2nd component of the value
  29676. * @param z defines the 3rd component of the value
  29677. * @param w defines the 4th component of the value
  29678. */
  29679. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29680. /**
  29681. * Sets a Color4 on a uniform variable
  29682. * @param uniform defines the uniform location
  29683. * @param color4 defines the value to be set
  29684. */
  29685. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29686. /**
  29687. * Gets the depth culling state manager
  29688. */
  29689. readonly depthCullingState: DepthCullingState;
  29690. /**
  29691. * Gets the alpha state manager
  29692. */
  29693. readonly alphaState: AlphaState;
  29694. /**
  29695. * Gets the stencil state manager
  29696. */
  29697. readonly stencilState: StencilState;
  29698. /**
  29699. * Clears the list of texture accessible through engine.
  29700. * This can help preventing texture load conflict due to name collision.
  29701. */
  29702. clearInternalTexturesCache(): void;
  29703. /**
  29704. * Force the entire cache to be cleared
  29705. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29706. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29707. */
  29708. wipeCaches(bruteForce?: boolean): void;
  29709. /** @hidden */
  29710. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29711. min: number;
  29712. mag: number;
  29713. };
  29714. /** @hidden */
  29715. _createTexture(): WebGLTexture;
  29716. /**
  29717. * Usually called from Texture.ts.
  29718. * Passed information to create a WebGLTexture
  29719. * @param urlArg defines a value which contains one of the following:
  29720. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29721. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29722. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29723. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29724. * @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)
  29725. * @param scene needed for loading to the correct scene
  29726. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29727. * @param onLoad optional callback to be called upon successful completion
  29728. * @param onError optional callback to be called upon failure
  29729. * @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
  29730. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29731. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29732. * @param forcedExtension defines the extension to use to pick the right loader
  29733. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29734. * @param mimeType defines an optional mime type
  29735. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29736. */
  29737. 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;
  29738. /**
  29739. * @hidden
  29740. */
  29741. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29742. /**
  29743. * Creates a raw texture
  29744. * @param data defines the data to store in the texture
  29745. * @param width defines the width of the texture
  29746. * @param height defines the height of the texture
  29747. * @param format defines the format of the data
  29748. * @param generateMipMaps defines if the engine should generate the mip levels
  29749. * @param invertY defines if data must be stored with Y axis inverted
  29750. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29751. * @param compression defines the compression used (null by default)
  29752. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29753. * @returns the raw texture inside an InternalTexture
  29754. */
  29755. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29756. /**
  29757. * Creates a new raw cube texture
  29758. * @param data defines the array of data to use to create each face
  29759. * @param size defines the size of the textures
  29760. * @param format defines the format of the data
  29761. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29762. * @param generateMipMaps defines if the engine should generate the mip levels
  29763. * @param invertY defines if data must be stored with Y axis inverted
  29764. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29765. * @param compression defines the compression used (null by default)
  29766. * @returns the cube texture as an InternalTexture
  29767. */
  29768. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29769. /**
  29770. * Creates a new raw 3D texture
  29771. * @param data defines the data used to create the texture
  29772. * @param width defines the width of the texture
  29773. * @param height defines the height of the texture
  29774. * @param depth defines the depth of the texture
  29775. * @param format defines the format of the texture
  29776. * @param generateMipMaps defines if the engine must generate mip levels
  29777. * @param invertY defines if data must be stored with Y axis inverted
  29778. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29779. * @param compression defines the compressed used (can be null)
  29780. * @param textureType defines the compressed used (can be null)
  29781. * @returns a new raw 3D texture (stored in an InternalTexture)
  29782. */
  29783. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29784. private _unpackFlipYCached;
  29785. /**
  29786. * In case you are sharing the context with other applications, it might
  29787. * be interested to not cache the unpack flip y state to ensure a consistent
  29788. * value would be set.
  29789. */
  29790. enableUnpackFlipYCached: boolean;
  29791. /** @hidden */
  29792. _unpackFlipY(value: boolean): void;
  29793. /** @hidden */
  29794. _getUnpackAlignement(): number;
  29795. /**
  29796. * Update the sampling mode of a given texture
  29797. * @param samplingMode defines the required sampling mode
  29798. * @param texture defines the texture to update
  29799. */
  29800. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29801. /**
  29802. * Updates a depth texture Comparison Mode and Function.
  29803. * If the comparison Function is equal to 0, the mode will be set to none.
  29804. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29805. * @param texture The texture to set the comparison function for
  29806. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29807. */
  29808. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29809. /** @hidden */
  29810. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29811. width: number;
  29812. height: number;
  29813. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29814. /**
  29815. * Creates a depth stencil texture.
  29816. * This is only available in WebGL 2 or with the depth texture extension available.
  29817. * @param size The size of face edge in the texture.
  29818. * @param options The options defining the texture.
  29819. * @returns The texture
  29820. */
  29821. createDepthStencilTexture(size: number | {
  29822. width: number;
  29823. height: number;
  29824. }, options: DepthTextureCreationOptions): InternalTexture;
  29825. /**
  29826. * Creates a depth stencil texture.
  29827. * This is only available in WebGL 2 or with the depth texture extension available.
  29828. * @param size The size of face edge in the texture.
  29829. * @param options The options defining the texture.
  29830. * @returns The texture
  29831. */
  29832. private _createDepthStencilTexture;
  29833. /** @hidden */
  29834. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29835. /** @hidden */
  29836. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29837. /** @hidden */
  29838. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29839. /** @hidden */
  29840. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  29841. /**
  29842. * @hidden
  29843. */
  29844. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29845. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29846. private _prepareWebGLTexture;
  29847. /** @hidden */
  29848. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29849. /** @hidden */
  29850. _releaseFramebufferObjects(texture: InternalTexture): void;
  29851. /** @hidden */
  29852. _releaseTexture(texture: InternalTexture): void;
  29853. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29854. protected _setProgram(program: WebGLProgram): void;
  29855. protected _boundUniforms: {
  29856. [key: number]: WebGLUniformLocation;
  29857. };
  29858. /**
  29859. * Binds an effect to the webGL context
  29860. * @param effect defines the effect to bind
  29861. */
  29862. bindSamplers(effect: Effect): void;
  29863. private _activateCurrentTexture;
  29864. /** @hidden */
  29865. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29866. /** @hidden */
  29867. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29868. /**
  29869. * Unbind all textures from the webGL context
  29870. */
  29871. unbindAllTextures(): void;
  29872. /**
  29873. * Sets a texture to the according uniform.
  29874. * @param channel The texture channel
  29875. * @param uniform The uniform to set
  29876. * @param texture The texture to apply
  29877. */
  29878. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29879. private _bindSamplerUniformToChannel;
  29880. private _getTextureWrapMode;
  29881. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29882. /**
  29883. * Sets an array of texture to the webGL context
  29884. * @param channel defines the channel where the texture array must be set
  29885. * @param uniform defines the associated uniform location
  29886. * @param textures defines the array of textures to bind
  29887. */
  29888. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29889. /** @hidden */
  29890. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29891. private _setTextureParameterFloat;
  29892. private _setTextureParameterInteger;
  29893. /**
  29894. * Unbind all vertex attributes from the webGL context
  29895. */
  29896. unbindAllAttributes(): void;
  29897. /**
  29898. * 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
  29899. */
  29900. releaseEffects(): void;
  29901. /**
  29902. * Dispose and release all associated resources
  29903. */
  29904. dispose(): void;
  29905. /**
  29906. * Attach a new callback raised when context lost event is fired
  29907. * @param callback defines the callback to call
  29908. */
  29909. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29910. /**
  29911. * Attach a new callback raised when context restored event is fired
  29912. * @param callback defines the callback to call
  29913. */
  29914. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29915. /**
  29916. * Get the current error code of the webGL context
  29917. * @returns the error code
  29918. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29919. */
  29920. getError(): number;
  29921. private _canRenderToFloatFramebuffer;
  29922. private _canRenderToHalfFloatFramebuffer;
  29923. private _canRenderToFramebuffer;
  29924. /** @hidden */
  29925. _getWebGLTextureType(type: number): number;
  29926. /** @hidden */
  29927. _getInternalFormat(format: number): number;
  29928. /** @hidden */
  29929. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29930. /** @hidden */
  29931. _getRGBAMultiSampleBufferFormat(type: number): number;
  29932. /** @hidden */
  29933. _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;
  29934. /**
  29935. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29936. * @returns true if the engine can be created
  29937. * @ignorenaming
  29938. */
  29939. static isSupported(): boolean;
  29940. /**
  29941. * Find the next highest power of two.
  29942. * @param x Number to start search from.
  29943. * @return Next highest power of two.
  29944. */
  29945. static CeilingPOT(x: number): number;
  29946. /**
  29947. * Find the next lowest power of two.
  29948. * @param x Number to start search from.
  29949. * @return Next lowest power of two.
  29950. */
  29951. static FloorPOT(x: number): number;
  29952. /**
  29953. * Find the nearest power of two.
  29954. * @param x Number to start search from.
  29955. * @return Next nearest power of two.
  29956. */
  29957. static NearestPOT(x: number): number;
  29958. /**
  29959. * Get the closest exponent of two
  29960. * @param value defines the value to approximate
  29961. * @param max defines the maximum value to return
  29962. * @param mode defines how to define the closest value
  29963. * @returns closest exponent of two of the given value
  29964. */
  29965. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29966. /**
  29967. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29968. * @param func - the function to be called
  29969. * @param requester - the object that will request the next frame. Falls back to window.
  29970. * @returns frame number
  29971. */
  29972. static QueueNewFrame(func: () => void, requester?: any): number;
  29973. }
  29974. }
  29975. declare module BABYLON {
  29976. /**
  29977. * Class representing spherical harmonics coefficients to the 3rd degree
  29978. */
  29979. export class SphericalHarmonics {
  29980. /**
  29981. * Defines whether or not the harmonics have been prescaled for rendering.
  29982. */
  29983. preScaled: boolean;
  29984. /**
  29985. * The l0,0 coefficients of the spherical harmonics
  29986. */
  29987. l00: Vector3;
  29988. /**
  29989. * The l1,-1 coefficients of the spherical harmonics
  29990. */
  29991. l1_1: Vector3;
  29992. /**
  29993. * The l1,0 coefficients of the spherical harmonics
  29994. */
  29995. l10: Vector3;
  29996. /**
  29997. * The l1,1 coefficients of the spherical harmonics
  29998. */
  29999. l11: Vector3;
  30000. /**
  30001. * The l2,-2 coefficients of the spherical harmonics
  30002. */
  30003. l2_2: Vector3;
  30004. /**
  30005. * The l2,-1 coefficients of the spherical harmonics
  30006. */
  30007. l2_1: Vector3;
  30008. /**
  30009. * The l2,0 coefficients of the spherical harmonics
  30010. */
  30011. l20: Vector3;
  30012. /**
  30013. * The l2,1 coefficients of the spherical harmonics
  30014. */
  30015. l21: Vector3;
  30016. /**
  30017. * The l2,2 coefficients of the spherical harmonics
  30018. */
  30019. l22: Vector3;
  30020. /**
  30021. * Adds a light to the spherical harmonics
  30022. * @param direction the direction of the light
  30023. * @param color the color of the light
  30024. * @param deltaSolidAngle the delta solid angle of the light
  30025. */
  30026. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30027. /**
  30028. * Scales the spherical harmonics by the given amount
  30029. * @param scale the amount to scale
  30030. */
  30031. scaleInPlace(scale: number): void;
  30032. /**
  30033. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30034. *
  30035. * ```
  30036. * E_lm = A_l * L_lm
  30037. * ```
  30038. *
  30039. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30040. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30041. * the scaling factors are given in equation 9.
  30042. */
  30043. convertIncidentRadianceToIrradiance(): void;
  30044. /**
  30045. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30046. *
  30047. * ```
  30048. * L = (1/pi) * E * rho
  30049. * ```
  30050. *
  30051. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30052. */
  30053. convertIrradianceToLambertianRadiance(): void;
  30054. /**
  30055. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30056. * required operations at run time.
  30057. *
  30058. * This is simply done by scaling back the SH with Ylm constants parameter.
  30059. * The trigonometric part being applied by the shader at run time.
  30060. */
  30061. preScaleForRendering(): void;
  30062. /**
  30063. * Constructs a spherical harmonics from an array.
  30064. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30065. * @returns the spherical harmonics
  30066. */
  30067. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30068. /**
  30069. * Gets the spherical harmonics from polynomial
  30070. * @param polynomial the spherical polynomial
  30071. * @returns the spherical harmonics
  30072. */
  30073. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30074. }
  30075. /**
  30076. * Class representing spherical polynomial coefficients to the 3rd degree
  30077. */
  30078. export class SphericalPolynomial {
  30079. private _harmonics;
  30080. /**
  30081. * The spherical harmonics used to create the polynomials.
  30082. */
  30083. readonly preScaledHarmonics: SphericalHarmonics;
  30084. /**
  30085. * The x coefficients of the spherical polynomial
  30086. */
  30087. x: Vector3;
  30088. /**
  30089. * The y coefficients of the spherical polynomial
  30090. */
  30091. y: Vector3;
  30092. /**
  30093. * The z coefficients of the spherical polynomial
  30094. */
  30095. z: Vector3;
  30096. /**
  30097. * The xx coefficients of the spherical polynomial
  30098. */
  30099. xx: Vector3;
  30100. /**
  30101. * The yy coefficients of the spherical polynomial
  30102. */
  30103. yy: Vector3;
  30104. /**
  30105. * The zz coefficients of the spherical polynomial
  30106. */
  30107. zz: Vector3;
  30108. /**
  30109. * The xy coefficients of the spherical polynomial
  30110. */
  30111. xy: Vector3;
  30112. /**
  30113. * The yz coefficients of the spherical polynomial
  30114. */
  30115. yz: Vector3;
  30116. /**
  30117. * The zx coefficients of the spherical polynomial
  30118. */
  30119. zx: Vector3;
  30120. /**
  30121. * Adds an ambient color to the spherical polynomial
  30122. * @param color the color to add
  30123. */
  30124. addAmbient(color: Color3): void;
  30125. /**
  30126. * Scales the spherical polynomial by the given amount
  30127. * @param scale the amount to scale
  30128. */
  30129. scaleInPlace(scale: number): void;
  30130. /**
  30131. * Gets the spherical polynomial from harmonics
  30132. * @param harmonics the spherical harmonics
  30133. * @returns the spherical polynomial
  30134. */
  30135. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30136. /**
  30137. * Constructs a spherical polynomial from an array.
  30138. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30139. * @returns the spherical polynomial
  30140. */
  30141. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30142. }
  30143. }
  30144. declare module BABYLON {
  30145. /**
  30146. * Defines the source of the internal texture
  30147. */
  30148. export enum InternalTextureSource {
  30149. /**
  30150. * The source of the texture data is unknown
  30151. */
  30152. Unknown = 0,
  30153. /**
  30154. * Texture data comes from an URL
  30155. */
  30156. Url = 1,
  30157. /**
  30158. * Texture data is only used for temporary storage
  30159. */
  30160. Temp = 2,
  30161. /**
  30162. * Texture data comes from raw data (ArrayBuffer)
  30163. */
  30164. Raw = 3,
  30165. /**
  30166. * Texture content is dynamic (video or dynamic texture)
  30167. */
  30168. Dynamic = 4,
  30169. /**
  30170. * Texture content is generated by rendering to it
  30171. */
  30172. RenderTarget = 5,
  30173. /**
  30174. * Texture content is part of a multi render target process
  30175. */
  30176. MultiRenderTarget = 6,
  30177. /**
  30178. * Texture data comes from a cube data file
  30179. */
  30180. Cube = 7,
  30181. /**
  30182. * Texture data comes from a raw cube data
  30183. */
  30184. CubeRaw = 8,
  30185. /**
  30186. * Texture data come from a prefiltered cube data file
  30187. */
  30188. CubePrefiltered = 9,
  30189. /**
  30190. * Texture content is raw 3D data
  30191. */
  30192. Raw3D = 10,
  30193. /**
  30194. * Texture content is a depth texture
  30195. */
  30196. Depth = 11,
  30197. /**
  30198. * Texture data comes from a raw cube data encoded with RGBD
  30199. */
  30200. CubeRawRGBD = 12
  30201. }
  30202. /**
  30203. * Class used to store data associated with WebGL texture data for the engine
  30204. * This class should not be used directly
  30205. */
  30206. export class InternalTexture {
  30207. /** @hidden */
  30208. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30209. /**
  30210. * Defines if the texture is ready
  30211. */
  30212. isReady: boolean;
  30213. /**
  30214. * Defines if the texture is a cube texture
  30215. */
  30216. isCube: boolean;
  30217. /**
  30218. * Defines if the texture contains 3D data
  30219. */
  30220. is3D: boolean;
  30221. /**
  30222. * Defines if the texture contains multiview data
  30223. */
  30224. isMultiview: boolean;
  30225. /**
  30226. * Gets the URL used to load this texture
  30227. */
  30228. url: string;
  30229. /**
  30230. * Gets the sampling mode of the texture
  30231. */
  30232. samplingMode: number;
  30233. /**
  30234. * Gets a boolean indicating if the texture needs mipmaps generation
  30235. */
  30236. generateMipMaps: boolean;
  30237. /**
  30238. * Gets the number of samples used by the texture (WebGL2+ only)
  30239. */
  30240. samples: number;
  30241. /**
  30242. * Gets the type of the texture (int, float...)
  30243. */
  30244. type: number;
  30245. /**
  30246. * Gets the format of the texture (RGB, RGBA...)
  30247. */
  30248. format: number;
  30249. /**
  30250. * Observable called when the texture is loaded
  30251. */
  30252. onLoadedObservable: Observable<InternalTexture>;
  30253. /**
  30254. * Gets the width of the texture
  30255. */
  30256. width: number;
  30257. /**
  30258. * Gets the height of the texture
  30259. */
  30260. height: number;
  30261. /**
  30262. * Gets the depth of the texture
  30263. */
  30264. depth: number;
  30265. /**
  30266. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30267. */
  30268. baseWidth: number;
  30269. /**
  30270. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30271. */
  30272. baseHeight: number;
  30273. /**
  30274. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30275. */
  30276. baseDepth: number;
  30277. /**
  30278. * Gets a boolean indicating if the texture is inverted on Y axis
  30279. */
  30280. invertY: boolean;
  30281. /** @hidden */
  30282. _invertVScale: boolean;
  30283. /** @hidden */
  30284. _associatedChannel: number;
  30285. /** @hidden */
  30286. _source: InternalTextureSource;
  30287. /** @hidden */
  30288. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30289. /** @hidden */
  30290. _bufferView: Nullable<ArrayBufferView>;
  30291. /** @hidden */
  30292. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30293. /** @hidden */
  30294. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30295. /** @hidden */
  30296. _size: number;
  30297. /** @hidden */
  30298. _extension: string;
  30299. /** @hidden */
  30300. _files: Nullable<string[]>;
  30301. /** @hidden */
  30302. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30303. /** @hidden */
  30304. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30305. /** @hidden */
  30306. _framebuffer: Nullable<WebGLFramebuffer>;
  30307. /** @hidden */
  30308. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30309. /** @hidden */
  30310. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30311. /** @hidden */
  30312. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30313. /** @hidden */
  30314. _attachments: Nullable<number[]>;
  30315. /** @hidden */
  30316. _cachedCoordinatesMode: Nullable<number>;
  30317. /** @hidden */
  30318. _cachedWrapU: Nullable<number>;
  30319. /** @hidden */
  30320. _cachedWrapV: Nullable<number>;
  30321. /** @hidden */
  30322. _cachedWrapR: Nullable<number>;
  30323. /** @hidden */
  30324. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30325. /** @hidden */
  30326. _isDisabled: boolean;
  30327. /** @hidden */
  30328. _compression: Nullable<string>;
  30329. /** @hidden */
  30330. _generateStencilBuffer: boolean;
  30331. /** @hidden */
  30332. _generateDepthBuffer: boolean;
  30333. /** @hidden */
  30334. _comparisonFunction: number;
  30335. /** @hidden */
  30336. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30337. /** @hidden */
  30338. _lodGenerationScale: number;
  30339. /** @hidden */
  30340. _lodGenerationOffset: number;
  30341. /** @hidden */
  30342. _colorTextureArray: Nullable<WebGLTexture>;
  30343. /** @hidden */
  30344. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30345. /** @hidden */
  30346. _lodTextureHigh: Nullable<BaseTexture>;
  30347. /** @hidden */
  30348. _lodTextureMid: Nullable<BaseTexture>;
  30349. /** @hidden */
  30350. _lodTextureLow: Nullable<BaseTexture>;
  30351. /** @hidden */
  30352. _isRGBD: boolean;
  30353. /** @hidden */
  30354. _linearSpecularLOD: boolean;
  30355. /** @hidden */
  30356. _irradianceTexture: Nullable<BaseTexture>;
  30357. /** @hidden */
  30358. _webGLTexture: Nullable<WebGLTexture>;
  30359. /** @hidden */
  30360. _references: number;
  30361. private _engine;
  30362. /**
  30363. * Gets the Engine the texture belongs to.
  30364. * @returns The babylon engine
  30365. */
  30366. getEngine(): ThinEngine;
  30367. /**
  30368. * Gets the data source type of the texture
  30369. */
  30370. readonly source: InternalTextureSource;
  30371. /**
  30372. * Creates a new InternalTexture
  30373. * @param engine defines the engine to use
  30374. * @param source defines the type of data that will be used
  30375. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30376. */
  30377. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30378. /**
  30379. * Increments the number of references (ie. the number of Texture that point to it)
  30380. */
  30381. incrementReferences(): void;
  30382. /**
  30383. * Change the size of the texture (not the size of the content)
  30384. * @param width defines the new width
  30385. * @param height defines the new height
  30386. * @param depth defines the new depth (1 by default)
  30387. */
  30388. updateSize(width: int, height: int, depth?: int): void;
  30389. /** @hidden */
  30390. _rebuild(): void;
  30391. /** @hidden */
  30392. _swapAndDie(target: InternalTexture): void;
  30393. /**
  30394. * Dispose the current allocated resources
  30395. */
  30396. dispose(): void;
  30397. }
  30398. }
  30399. declare module BABYLON {
  30400. /**
  30401. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30403. */
  30404. export class Analyser {
  30405. /**
  30406. * Gets or sets the smoothing
  30407. * @ignorenaming
  30408. */
  30409. SMOOTHING: number;
  30410. /**
  30411. * Gets or sets the FFT table size
  30412. * @ignorenaming
  30413. */
  30414. FFT_SIZE: number;
  30415. /**
  30416. * Gets or sets the bar graph amplitude
  30417. * @ignorenaming
  30418. */
  30419. BARGRAPHAMPLITUDE: number;
  30420. /**
  30421. * Gets or sets the position of the debug canvas
  30422. * @ignorenaming
  30423. */
  30424. DEBUGCANVASPOS: {
  30425. x: number;
  30426. y: number;
  30427. };
  30428. /**
  30429. * Gets or sets the debug canvas size
  30430. * @ignorenaming
  30431. */
  30432. DEBUGCANVASSIZE: {
  30433. width: number;
  30434. height: number;
  30435. };
  30436. private _byteFreqs;
  30437. private _byteTime;
  30438. private _floatFreqs;
  30439. private _webAudioAnalyser;
  30440. private _debugCanvas;
  30441. private _debugCanvasContext;
  30442. private _scene;
  30443. private _registerFunc;
  30444. private _audioEngine;
  30445. /**
  30446. * Creates a new analyser
  30447. * @param scene defines hosting scene
  30448. */
  30449. constructor(scene: Scene);
  30450. /**
  30451. * Get the number of data values you will have to play with for the visualization
  30452. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30453. * @returns a number
  30454. */
  30455. getFrequencyBinCount(): number;
  30456. /**
  30457. * Gets the current frequency data as a byte array
  30458. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30459. * @returns a Uint8Array
  30460. */
  30461. getByteFrequencyData(): Uint8Array;
  30462. /**
  30463. * Gets the current waveform as a byte array
  30464. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30465. * @returns a Uint8Array
  30466. */
  30467. getByteTimeDomainData(): Uint8Array;
  30468. /**
  30469. * Gets the current frequency data as a float array
  30470. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30471. * @returns a Float32Array
  30472. */
  30473. getFloatFrequencyData(): Float32Array;
  30474. /**
  30475. * Renders the debug canvas
  30476. */
  30477. drawDebugCanvas(): void;
  30478. /**
  30479. * Stops rendering the debug canvas and removes it
  30480. */
  30481. stopDebugCanvas(): void;
  30482. /**
  30483. * Connects two audio nodes
  30484. * @param inputAudioNode defines first node to connect
  30485. * @param outputAudioNode defines second node to connect
  30486. */
  30487. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30488. /**
  30489. * Releases all associated resources
  30490. */
  30491. dispose(): void;
  30492. }
  30493. }
  30494. declare module BABYLON {
  30495. /**
  30496. * This represents an audio engine and it is responsible
  30497. * to play, synchronize and analyse sounds throughout the application.
  30498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30499. */
  30500. export interface IAudioEngine extends IDisposable {
  30501. /**
  30502. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30503. */
  30504. readonly canUseWebAudio: boolean;
  30505. /**
  30506. * Gets the current AudioContext if available.
  30507. */
  30508. readonly audioContext: Nullable<AudioContext>;
  30509. /**
  30510. * The master gain node defines the global audio volume of your audio engine.
  30511. */
  30512. readonly masterGain: GainNode;
  30513. /**
  30514. * Gets whether or not mp3 are supported by your browser.
  30515. */
  30516. readonly isMP3supported: boolean;
  30517. /**
  30518. * Gets whether or not ogg are supported by your browser.
  30519. */
  30520. readonly isOGGsupported: boolean;
  30521. /**
  30522. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30523. * @ignoreNaming
  30524. */
  30525. WarnedWebAudioUnsupported: boolean;
  30526. /**
  30527. * Defines if the audio engine relies on a custom unlocked button.
  30528. * In this case, the embedded button will not be displayed.
  30529. */
  30530. useCustomUnlockedButton: boolean;
  30531. /**
  30532. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30533. */
  30534. readonly unlocked: boolean;
  30535. /**
  30536. * Event raised when audio has been unlocked on the browser.
  30537. */
  30538. onAudioUnlockedObservable: Observable<AudioEngine>;
  30539. /**
  30540. * Event raised when audio has been locked on the browser.
  30541. */
  30542. onAudioLockedObservable: Observable<AudioEngine>;
  30543. /**
  30544. * Flags the audio engine in Locked state.
  30545. * This happens due to new browser policies preventing audio to autoplay.
  30546. */
  30547. lock(): void;
  30548. /**
  30549. * Unlocks the audio engine once a user action has been done on the dom.
  30550. * This is helpful to resume play once browser policies have been satisfied.
  30551. */
  30552. unlock(): void;
  30553. }
  30554. /**
  30555. * This represents the default audio engine used in babylon.
  30556. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30558. */
  30559. export class AudioEngine implements IAudioEngine {
  30560. private _audioContext;
  30561. private _audioContextInitialized;
  30562. private _muteButton;
  30563. private _hostElement;
  30564. /**
  30565. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30566. */
  30567. canUseWebAudio: boolean;
  30568. /**
  30569. * The master gain node defines the global audio volume of your audio engine.
  30570. */
  30571. masterGain: GainNode;
  30572. /**
  30573. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30574. * @ignoreNaming
  30575. */
  30576. WarnedWebAudioUnsupported: boolean;
  30577. /**
  30578. * Gets whether or not mp3 are supported by your browser.
  30579. */
  30580. isMP3supported: boolean;
  30581. /**
  30582. * Gets whether or not ogg are supported by your browser.
  30583. */
  30584. isOGGsupported: boolean;
  30585. /**
  30586. * Gets whether audio has been unlocked on the device.
  30587. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30588. * a user interaction has happened.
  30589. */
  30590. unlocked: boolean;
  30591. /**
  30592. * Defines if the audio engine relies on a custom unlocked button.
  30593. * In this case, the embedded button will not be displayed.
  30594. */
  30595. useCustomUnlockedButton: boolean;
  30596. /**
  30597. * Event raised when audio has been unlocked on the browser.
  30598. */
  30599. onAudioUnlockedObservable: Observable<AudioEngine>;
  30600. /**
  30601. * Event raised when audio has been locked on the browser.
  30602. */
  30603. onAudioLockedObservable: Observable<AudioEngine>;
  30604. /**
  30605. * Gets the current AudioContext if available.
  30606. */
  30607. readonly audioContext: Nullable<AudioContext>;
  30608. private _connectedAnalyser;
  30609. /**
  30610. * Instantiates a new audio engine.
  30611. *
  30612. * There should be only one per page as some browsers restrict the number
  30613. * of audio contexts you can create.
  30614. * @param hostElement defines the host element where to display the mute icon if necessary
  30615. */
  30616. constructor(hostElement?: Nullable<HTMLElement>);
  30617. /**
  30618. * Flags the audio engine in Locked state.
  30619. * This happens due to new browser policies preventing audio to autoplay.
  30620. */
  30621. lock(): void;
  30622. /**
  30623. * Unlocks the audio engine once a user action has been done on the dom.
  30624. * This is helpful to resume play once browser policies have been satisfied.
  30625. */
  30626. unlock(): void;
  30627. private _resumeAudioContext;
  30628. private _initializeAudioContext;
  30629. private _tryToRun;
  30630. private _triggerRunningState;
  30631. private _triggerSuspendedState;
  30632. private _displayMuteButton;
  30633. private _moveButtonToTopLeft;
  30634. private _onResize;
  30635. private _hideMuteButton;
  30636. /**
  30637. * Destroy and release the resources associated with the audio ccontext.
  30638. */
  30639. dispose(): void;
  30640. /**
  30641. * Gets the global volume sets on the master gain.
  30642. * @returns the global volume if set or -1 otherwise
  30643. */
  30644. getGlobalVolume(): number;
  30645. /**
  30646. * Sets the global volume of your experience (sets on the master gain).
  30647. * @param newVolume Defines the new global volume of the application
  30648. */
  30649. setGlobalVolume(newVolume: number): void;
  30650. /**
  30651. * Connect the audio engine to an audio analyser allowing some amazing
  30652. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30654. * @param analyser The analyser to connect to the engine
  30655. */
  30656. connectToAnalyser(analyser: Analyser): void;
  30657. }
  30658. }
  30659. declare module BABYLON {
  30660. /**
  30661. * Interface used to present a loading screen while loading a scene
  30662. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30663. */
  30664. export interface ILoadingScreen {
  30665. /**
  30666. * Function called to display the loading screen
  30667. */
  30668. displayLoadingUI: () => void;
  30669. /**
  30670. * Function called to hide the loading screen
  30671. */
  30672. hideLoadingUI: () => void;
  30673. /**
  30674. * Gets or sets the color to use for the background
  30675. */
  30676. loadingUIBackgroundColor: string;
  30677. /**
  30678. * Gets or sets the text to display while loading
  30679. */
  30680. loadingUIText: string;
  30681. }
  30682. /**
  30683. * Class used for the default loading screen
  30684. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30685. */
  30686. export class DefaultLoadingScreen implements ILoadingScreen {
  30687. private _renderingCanvas;
  30688. private _loadingText;
  30689. private _loadingDivBackgroundColor;
  30690. private _loadingDiv;
  30691. private _loadingTextDiv;
  30692. /** Gets or sets the logo url to use for the default loading screen */
  30693. static DefaultLogoUrl: string;
  30694. /** Gets or sets the spinner url to use for the default loading screen */
  30695. static DefaultSpinnerUrl: string;
  30696. /**
  30697. * Creates a new default loading screen
  30698. * @param _renderingCanvas defines the canvas used to render the scene
  30699. * @param _loadingText defines the default text to display
  30700. * @param _loadingDivBackgroundColor defines the default background color
  30701. */
  30702. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30703. /**
  30704. * Function called to display the loading screen
  30705. */
  30706. displayLoadingUI(): void;
  30707. /**
  30708. * Function called to hide the loading screen
  30709. */
  30710. hideLoadingUI(): void;
  30711. /**
  30712. * Gets or sets the text to display while loading
  30713. */
  30714. loadingUIText: string;
  30715. /**
  30716. * Gets or sets the color to use for the background
  30717. */
  30718. loadingUIBackgroundColor: string;
  30719. private _resizeLoadingUI;
  30720. }
  30721. }
  30722. declare module BABYLON {
  30723. /**
  30724. * Interface for any object that can request an animation frame
  30725. */
  30726. export interface ICustomAnimationFrameRequester {
  30727. /**
  30728. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30729. */
  30730. renderFunction?: Function;
  30731. /**
  30732. * Called to request the next frame to render to
  30733. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30734. */
  30735. requestAnimationFrame: Function;
  30736. /**
  30737. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30738. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30739. */
  30740. requestID?: number;
  30741. }
  30742. }
  30743. declare module BABYLON {
  30744. /**
  30745. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30746. */
  30747. export class PerformanceMonitor {
  30748. private _enabled;
  30749. private _rollingFrameTime;
  30750. private _lastFrameTimeMs;
  30751. /**
  30752. * constructor
  30753. * @param frameSampleSize The number of samples required to saturate the sliding window
  30754. */
  30755. constructor(frameSampleSize?: number);
  30756. /**
  30757. * Samples current frame
  30758. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30759. */
  30760. sampleFrame(timeMs?: number): void;
  30761. /**
  30762. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30763. */
  30764. readonly averageFrameTime: number;
  30765. /**
  30766. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30767. */
  30768. readonly averageFrameTimeVariance: number;
  30769. /**
  30770. * Returns the frame time of the most recent frame
  30771. */
  30772. readonly instantaneousFrameTime: number;
  30773. /**
  30774. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30775. */
  30776. readonly averageFPS: number;
  30777. /**
  30778. * Returns the average framerate in frames per second using the most recent frame time
  30779. */
  30780. readonly instantaneousFPS: number;
  30781. /**
  30782. * Returns true if enough samples have been taken to completely fill the sliding window
  30783. */
  30784. readonly isSaturated: boolean;
  30785. /**
  30786. * Enables contributions to the sliding window sample set
  30787. */
  30788. enable(): void;
  30789. /**
  30790. * Disables contributions to the sliding window sample set
  30791. * Samples will not be interpolated over the disabled period
  30792. */
  30793. disable(): void;
  30794. /**
  30795. * Returns true if sampling is enabled
  30796. */
  30797. readonly isEnabled: boolean;
  30798. /**
  30799. * Resets performance monitor
  30800. */
  30801. reset(): void;
  30802. }
  30803. /**
  30804. * RollingAverage
  30805. *
  30806. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30807. */
  30808. export class RollingAverage {
  30809. /**
  30810. * Current average
  30811. */
  30812. average: number;
  30813. /**
  30814. * Current variance
  30815. */
  30816. variance: number;
  30817. protected _samples: Array<number>;
  30818. protected _sampleCount: number;
  30819. protected _pos: number;
  30820. protected _m2: number;
  30821. /**
  30822. * constructor
  30823. * @param length The number of samples required to saturate the sliding window
  30824. */
  30825. constructor(length: number);
  30826. /**
  30827. * Adds a sample to the sample set
  30828. * @param v The sample value
  30829. */
  30830. add(v: number): void;
  30831. /**
  30832. * Returns previously added values or null if outside of history or outside the sliding window domain
  30833. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30834. * @return Value previously recorded with add() or null if outside of range
  30835. */
  30836. history(i: number): number;
  30837. /**
  30838. * Returns true if enough samples have been taken to completely fill the sliding window
  30839. * @return true if sample-set saturated
  30840. */
  30841. isSaturated(): boolean;
  30842. /**
  30843. * Resets the rolling average (equivalent to 0 samples taken so far)
  30844. */
  30845. reset(): void;
  30846. /**
  30847. * Wraps a value around the sample range boundaries
  30848. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30849. * @return Wrapped position in sample range
  30850. */
  30851. protected _wrapPosition(i: number): number;
  30852. }
  30853. }
  30854. declare module BABYLON {
  30855. /**
  30856. * This class is used to track a performance counter which is number based.
  30857. * The user has access to many properties which give statistics of different nature.
  30858. *
  30859. * The implementer can track two kinds of Performance Counter: time and count.
  30860. * 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.
  30861. * 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.
  30862. */
  30863. export class PerfCounter {
  30864. /**
  30865. * Gets or sets a global boolean to turn on and off all the counters
  30866. */
  30867. static Enabled: boolean;
  30868. /**
  30869. * Returns the smallest value ever
  30870. */
  30871. readonly min: number;
  30872. /**
  30873. * Returns the biggest value ever
  30874. */
  30875. readonly max: number;
  30876. /**
  30877. * Returns the average value since the performance counter is running
  30878. */
  30879. readonly average: number;
  30880. /**
  30881. * Returns the average value of the last second the counter was monitored
  30882. */
  30883. readonly lastSecAverage: number;
  30884. /**
  30885. * Returns the current value
  30886. */
  30887. readonly current: number;
  30888. /**
  30889. * Gets the accumulated total
  30890. */
  30891. readonly total: number;
  30892. /**
  30893. * Gets the total value count
  30894. */
  30895. readonly count: number;
  30896. /**
  30897. * Creates a new counter
  30898. */
  30899. constructor();
  30900. /**
  30901. * Call this method to start monitoring a new frame.
  30902. * 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.
  30903. */
  30904. fetchNewFrame(): void;
  30905. /**
  30906. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30907. * @param newCount the count value to add to the monitored count
  30908. * @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.
  30909. */
  30910. addCount(newCount: number, fetchResult: boolean): void;
  30911. /**
  30912. * Start monitoring this performance counter
  30913. */
  30914. beginMonitoring(): void;
  30915. /**
  30916. * Compute the time lapsed since the previous beginMonitoring() call.
  30917. * @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
  30918. */
  30919. endMonitoring(newFrame?: boolean): void;
  30920. private _fetchResult;
  30921. private _startMonitoringTime;
  30922. private _min;
  30923. private _max;
  30924. private _average;
  30925. private _current;
  30926. private _totalValueCount;
  30927. private _totalAccumulated;
  30928. private _lastSecAverage;
  30929. private _lastSecAccumulated;
  30930. private _lastSecTime;
  30931. private _lastSecValueCount;
  30932. }
  30933. }
  30934. declare module BABYLON {
  30935. /**
  30936. * Defines the interface used by display changed events
  30937. */
  30938. export interface IDisplayChangedEventArgs {
  30939. /** Gets the vrDisplay object (if any) */
  30940. vrDisplay: Nullable<any>;
  30941. /** Gets a boolean indicating if webVR is supported */
  30942. vrSupported: boolean;
  30943. }
  30944. /**
  30945. * Defines the interface used by objects containing a viewport (like a camera)
  30946. */
  30947. interface IViewportOwnerLike {
  30948. /**
  30949. * Gets or sets the viewport
  30950. */
  30951. viewport: IViewportLike;
  30952. }
  30953. /**
  30954. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30955. */
  30956. export class Engine extends ThinEngine {
  30957. /** Defines that alpha blending is disabled */
  30958. static readonly ALPHA_DISABLE: number;
  30959. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30960. static readonly ALPHA_ADD: number;
  30961. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30962. static readonly ALPHA_COMBINE: number;
  30963. /** Defines that alpha blending to DEST - SRC * DEST */
  30964. static readonly ALPHA_SUBTRACT: number;
  30965. /** Defines that alpha blending to SRC * DEST */
  30966. static readonly ALPHA_MULTIPLY: number;
  30967. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30968. static readonly ALPHA_MAXIMIZED: number;
  30969. /** Defines that alpha blending to SRC + DEST */
  30970. static readonly ALPHA_ONEONE: number;
  30971. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30972. static readonly ALPHA_PREMULTIPLIED: number;
  30973. /**
  30974. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30975. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30976. */
  30977. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30978. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30979. static readonly ALPHA_INTERPOLATE: number;
  30980. /**
  30981. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30982. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30983. */
  30984. static readonly ALPHA_SCREENMODE: number;
  30985. /** Defines that the ressource is not delayed*/
  30986. static readonly DELAYLOADSTATE_NONE: number;
  30987. /** Defines that the ressource was successfully delay loaded */
  30988. static readonly DELAYLOADSTATE_LOADED: number;
  30989. /** Defines that the ressource is currently delay loading */
  30990. static readonly DELAYLOADSTATE_LOADING: number;
  30991. /** Defines that the ressource is delayed and has not started loading */
  30992. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30993. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30994. static readonly NEVER: number;
  30995. /** 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 */
  30996. static readonly ALWAYS: number;
  30997. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30998. static readonly LESS: number;
  30999. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31000. static readonly EQUAL: number;
  31001. /** 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 */
  31002. static readonly LEQUAL: number;
  31003. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31004. static readonly GREATER: number;
  31005. /** 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 */
  31006. static readonly GEQUAL: number;
  31007. /** 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 */
  31008. static readonly NOTEQUAL: number;
  31009. /** Passed to stencilOperation to specify that stencil value must be kept */
  31010. static readonly KEEP: number;
  31011. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31012. static readonly REPLACE: number;
  31013. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31014. static readonly INCR: number;
  31015. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31016. static readonly DECR: number;
  31017. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31018. static readonly INVERT: number;
  31019. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31020. static readonly INCR_WRAP: number;
  31021. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31022. static readonly DECR_WRAP: number;
  31023. /** Texture is not repeating outside of 0..1 UVs */
  31024. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31025. /** Texture is repeating outside of 0..1 UVs */
  31026. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31027. /** Texture is repeating and mirrored */
  31028. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31029. /** ALPHA */
  31030. static readonly TEXTUREFORMAT_ALPHA: number;
  31031. /** LUMINANCE */
  31032. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31033. /** LUMINANCE_ALPHA */
  31034. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31035. /** RGB */
  31036. static readonly TEXTUREFORMAT_RGB: number;
  31037. /** RGBA */
  31038. static readonly TEXTUREFORMAT_RGBA: number;
  31039. /** RED */
  31040. static readonly TEXTUREFORMAT_RED: number;
  31041. /** RED (2nd reference) */
  31042. static readonly TEXTUREFORMAT_R: number;
  31043. /** RG */
  31044. static readonly TEXTUREFORMAT_RG: number;
  31045. /** RED_INTEGER */
  31046. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31047. /** RED_INTEGER (2nd reference) */
  31048. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31049. /** RG_INTEGER */
  31050. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31051. /** RGB_INTEGER */
  31052. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31053. /** RGBA_INTEGER */
  31054. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31055. /** UNSIGNED_BYTE */
  31056. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31057. /** UNSIGNED_BYTE (2nd reference) */
  31058. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31059. /** FLOAT */
  31060. static readonly TEXTURETYPE_FLOAT: number;
  31061. /** HALF_FLOAT */
  31062. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31063. /** BYTE */
  31064. static readonly TEXTURETYPE_BYTE: number;
  31065. /** SHORT */
  31066. static readonly TEXTURETYPE_SHORT: number;
  31067. /** UNSIGNED_SHORT */
  31068. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31069. /** INT */
  31070. static readonly TEXTURETYPE_INT: number;
  31071. /** UNSIGNED_INT */
  31072. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31073. /** UNSIGNED_SHORT_4_4_4_4 */
  31074. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31075. /** UNSIGNED_SHORT_5_5_5_1 */
  31076. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31077. /** UNSIGNED_SHORT_5_6_5 */
  31078. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31079. /** UNSIGNED_INT_2_10_10_10_REV */
  31080. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31081. /** UNSIGNED_INT_24_8 */
  31082. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31083. /** UNSIGNED_INT_10F_11F_11F_REV */
  31084. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31085. /** UNSIGNED_INT_5_9_9_9_REV */
  31086. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31087. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31088. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31089. /** nearest is mag = nearest and min = nearest and mip = linear */
  31090. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31091. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31092. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31093. /** Trilinear is mag = linear and min = linear and mip = linear */
  31094. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31095. /** nearest is mag = nearest and min = nearest and mip = linear */
  31096. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31097. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31098. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31099. /** Trilinear is mag = linear and min = linear and mip = linear */
  31100. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31101. /** mag = nearest and min = nearest and mip = nearest */
  31102. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31103. /** mag = nearest and min = linear and mip = nearest */
  31104. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31105. /** mag = nearest and min = linear and mip = linear */
  31106. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31107. /** mag = nearest and min = linear and mip = none */
  31108. static readonly TEXTURE_NEAREST_LINEAR: number;
  31109. /** mag = nearest and min = nearest and mip = none */
  31110. static readonly TEXTURE_NEAREST_NEAREST: number;
  31111. /** mag = linear and min = nearest and mip = nearest */
  31112. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31113. /** mag = linear and min = nearest and mip = linear */
  31114. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31115. /** mag = linear and min = linear and mip = none */
  31116. static readonly TEXTURE_LINEAR_LINEAR: number;
  31117. /** mag = linear and min = nearest and mip = none */
  31118. static readonly TEXTURE_LINEAR_NEAREST: number;
  31119. /** Explicit coordinates mode */
  31120. static readonly TEXTURE_EXPLICIT_MODE: number;
  31121. /** Spherical coordinates mode */
  31122. static readonly TEXTURE_SPHERICAL_MODE: number;
  31123. /** Planar coordinates mode */
  31124. static readonly TEXTURE_PLANAR_MODE: number;
  31125. /** Cubic coordinates mode */
  31126. static readonly TEXTURE_CUBIC_MODE: number;
  31127. /** Projection coordinates mode */
  31128. static readonly TEXTURE_PROJECTION_MODE: number;
  31129. /** Skybox coordinates mode */
  31130. static readonly TEXTURE_SKYBOX_MODE: number;
  31131. /** Inverse Cubic coordinates mode */
  31132. static readonly TEXTURE_INVCUBIC_MODE: number;
  31133. /** Equirectangular coordinates mode */
  31134. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31135. /** Equirectangular Fixed coordinates mode */
  31136. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31137. /** Equirectangular Fixed Mirrored coordinates mode */
  31138. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31139. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31140. static readonly SCALEMODE_FLOOR: number;
  31141. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31142. static readonly SCALEMODE_NEAREST: number;
  31143. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31144. static readonly SCALEMODE_CEILING: number;
  31145. /**
  31146. * Returns the current npm package of the sdk
  31147. */
  31148. static readonly NpmPackage: string;
  31149. /**
  31150. * Returns the current version of the framework
  31151. */
  31152. static readonly Version: string;
  31153. /** Gets the list of created engines */
  31154. static readonly Instances: Engine[];
  31155. /**
  31156. * Gets the latest created engine
  31157. */
  31158. static readonly LastCreatedEngine: Nullable<Engine>;
  31159. /**
  31160. * Gets the latest created scene
  31161. */
  31162. static readonly LastCreatedScene: Nullable<Scene>;
  31163. /**
  31164. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31165. * @param flag defines which part of the materials must be marked as dirty
  31166. * @param predicate defines a predicate used to filter which materials should be affected
  31167. */
  31168. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31169. /**
  31170. * Method called to create the default loading screen.
  31171. * This can be overriden in your own app.
  31172. * @param canvas The rendering canvas element
  31173. * @returns The loading screen
  31174. */
  31175. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31176. /**
  31177. * Method called to create the default rescale post process on each engine.
  31178. */
  31179. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31180. /**
  31181. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31182. **/
  31183. enableOfflineSupport: boolean;
  31184. /**
  31185. * 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)
  31186. **/
  31187. disableManifestCheck: boolean;
  31188. /**
  31189. * Gets the list of created scenes
  31190. */
  31191. scenes: Scene[];
  31192. /**
  31193. * Event raised when a new scene is created
  31194. */
  31195. onNewSceneAddedObservable: Observable<Scene>;
  31196. /**
  31197. * Gets the list of created postprocesses
  31198. */
  31199. postProcesses: PostProcess[];
  31200. /**
  31201. * Gets a boolean indicating if the pointer is currently locked
  31202. */
  31203. isPointerLock: boolean;
  31204. /**
  31205. * Observable event triggered each time the rendering canvas is resized
  31206. */
  31207. onResizeObservable: Observable<Engine>;
  31208. /**
  31209. * Observable event triggered each time the canvas loses focus
  31210. */
  31211. onCanvasBlurObservable: Observable<Engine>;
  31212. /**
  31213. * Observable event triggered each time the canvas gains focus
  31214. */
  31215. onCanvasFocusObservable: Observable<Engine>;
  31216. /**
  31217. * Observable event triggered each time the canvas receives pointerout event
  31218. */
  31219. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31220. /**
  31221. * Observable raised when the engine begins a new frame
  31222. */
  31223. onBeginFrameObservable: Observable<Engine>;
  31224. /**
  31225. * If set, will be used to request the next animation frame for the render loop
  31226. */
  31227. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31228. /**
  31229. * Observable raised when the engine ends the current frame
  31230. */
  31231. onEndFrameObservable: Observable<Engine>;
  31232. /**
  31233. * Observable raised when the engine is about to compile a shader
  31234. */
  31235. onBeforeShaderCompilationObservable: Observable<Engine>;
  31236. /**
  31237. * Observable raised when the engine has jsut compiled a shader
  31238. */
  31239. onAfterShaderCompilationObservable: Observable<Engine>;
  31240. /**
  31241. * Gets the audio engine
  31242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31243. * @ignorenaming
  31244. */
  31245. static audioEngine: IAudioEngine;
  31246. /**
  31247. * Default AudioEngine factory responsible of creating the Audio Engine.
  31248. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31249. */
  31250. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31251. /**
  31252. * Default offline support factory responsible of creating a tool used to store data locally.
  31253. * By default, this will create a Database object if the workload has been embedded.
  31254. */
  31255. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31256. private _loadingScreen;
  31257. private _pointerLockRequested;
  31258. private _dummyFramebuffer;
  31259. private _rescalePostProcess;
  31260. /** @hidden */
  31261. protected _alphaMode: number;
  31262. /** @hidden */
  31263. protected _alphaEquation: number;
  31264. private _deterministicLockstep;
  31265. private _lockstepMaxSteps;
  31266. protected readonly _supportsHardwareTextureRescaling: boolean;
  31267. private _fps;
  31268. private _deltaTime;
  31269. /** @hidden */
  31270. _drawCalls: PerfCounter;
  31271. /**
  31272. * Turn this value on if you want to pause FPS computation when in background
  31273. */
  31274. disablePerformanceMonitorInBackground: boolean;
  31275. private _performanceMonitor;
  31276. /**
  31277. * Gets the performance monitor attached to this engine
  31278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31279. */
  31280. readonly performanceMonitor: PerformanceMonitor;
  31281. private _onFocus;
  31282. private _onBlur;
  31283. private _onCanvasPointerOut;
  31284. private _onCanvasBlur;
  31285. private _onCanvasFocus;
  31286. private _onFullscreenChange;
  31287. private _onPointerLockChange;
  31288. /**
  31289. * Creates a new engine
  31290. * @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
  31291. * @param antialias defines enable antialiasing (default: false)
  31292. * @param options defines further options to be sent to the getContext() function
  31293. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31294. */
  31295. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31296. /**
  31297. * Gets current aspect ratio
  31298. * @param viewportOwner defines the camera to use to get the aspect ratio
  31299. * @param useScreen defines if screen size must be used (or the current render target if any)
  31300. * @returns a number defining the aspect ratio
  31301. */
  31302. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31303. /**
  31304. * Gets current screen aspect ratio
  31305. * @returns a number defining the aspect ratio
  31306. */
  31307. getScreenAspectRatio(): number;
  31308. /**
  31309. * Gets host document
  31310. * @returns the host document object
  31311. */
  31312. getHostDocument(): Document;
  31313. /**
  31314. * Gets the client rect of the HTML canvas attached with the current webGL context
  31315. * @returns a client rectanglee
  31316. */
  31317. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31318. /**
  31319. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31320. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31321. * @returns true if engine is in deterministic lock step mode
  31322. */
  31323. isDeterministicLockStep(): boolean;
  31324. /**
  31325. * Gets the max steps when engine is running in deterministic lock step
  31326. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31327. * @returns the max steps
  31328. */
  31329. getLockstepMaxSteps(): number;
  31330. /**
  31331. * Force the mipmap generation for the given render target texture
  31332. * @param texture defines the render target texture to use
  31333. */
  31334. generateMipMapsForCubemap(texture: InternalTexture): void;
  31335. /** States */
  31336. /**
  31337. * Set various states to the webGL context
  31338. * @param culling defines backface culling state
  31339. * @param zOffset defines the value to apply to zOffset (0 by default)
  31340. * @param force defines if states must be applied even if cache is up to date
  31341. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31342. */
  31343. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31344. /**
  31345. * Set the z offset to apply to current rendering
  31346. * @param value defines the offset to apply
  31347. */
  31348. setZOffset(value: number): void;
  31349. /**
  31350. * Gets the current value of the zOffset
  31351. * @returns the current zOffset state
  31352. */
  31353. getZOffset(): number;
  31354. /**
  31355. * Enable or disable depth buffering
  31356. * @param enable defines the state to set
  31357. */
  31358. setDepthBuffer(enable: boolean): void;
  31359. /**
  31360. * Gets a boolean indicating if depth writing is enabled
  31361. * @returns the current depth writing state
  31362. */
  31363. getDepthWrite(): boolean;
  31364. /**
  31365. * Enable or disable depth writing
  31366. * @param enable defines the state to set
  31367. */
  31368. setDepthWrite(enable: boolean): void;
  31369. /**
  31370. * Enable or disable color writing
  31371. * @param enable defines the state to set
  31372. */
  31373. setColorWrite(enable: boolean): void;
  31374. /**
  31375. * Gets a boolean indicating if color writing is enabled
  31376. * @returns the current color writing state
  31377. */
  31378. getColorWrite(): boolean;
  31379. /**
  31380. * Sets alpha constants used by some alpha blending modes
  31381. * @param r defines the red component
  31382. * @param g defines the green component
  31383. * @param b defines the blue component
  31384. * @param a defines the alpha component
  31385. */
  31386. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31387. /**
  31388. * Sets the current alpha mode
  31389. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31390. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31391. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31392. */
  31393. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31394. /**
  31395. * Gets the current alpha mode
  31396. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31397. * @returns the current alpha mode
  31398. */
  31399. getAlphaMode(): number;
  31400. /**
  31401. * Sets the current alpha equation
  31402. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31403. */
  31404. setAlphaEquation(equation: number): void;
  31405. /**
  31406. * Gets the current alpha equation.
  31407. * @returns the current alpha equation
  31408. */
  31409. getAlphaEquation(): number;
  31410. /**
  31411. * Gets a boolean indicating if stencil buffer is enabled
  31412. * @returns the current stencil buffer state
  31413. */
  31414. getStencilBuffer(): boolean;
  31415. /**
  31416. * Enable or disable the stencil buffer
  31417. * @param enable defines if the stencil buffer must be enabled or disabled
  31418. */
  31419. setStencilBuffer(enable: boolean): void;
  31420. /**
  31421. * Gets the current stencil mask
  31422. * @returns a number defining the new stencil mask to use
  31423. */
  31424. getStencilMask(): number;
  31425. /**
  31426. * Sets the current stencil mask
  31427. * @param mask defines the new stencil mask to use
  31428. */
  31429. setStencilMask(mask: number): void;
  31430. /**
  31431. * Gets the current stencil function
  31432. * @returns a number defining the stencil function to use
  31433. */
  31434. getStencilFunction(): number;
  31435. /**
  31436. * Gets the current stencil reference value
  31437. * @returns a number defining the stencil reference value to use
  31438. */
  31439. getStencilFunctionReference(): number;
  31440. /**
  31441. * Gets the current stencil mask
  31442. * @returns a number defining the stencil mask to use
  31443. */
  31444. getStencilFunctionMask(): number;
  31445. /**
  31446. * Sets the current stencil function
  31447. * @param stencilFunc defines the new stencil function to use
  31448. */
  31449. setStencilFunction(stencilFunc: number): void;
  31450. /**
  31451. * Sets the current stencil reference
  31452. * @param reference defines the new stencil reference to use
  31453. */
  31454. setStencilFunctionReference(reference: number): void;
  31455. /**
  31456. * Sets the current stencil mask
  31457. * @param mask defines the new stencil mask to use
  31458. */
  31459. setStencilFunctionMask(mask: number): void;
  31460. /**
  31461. * Gets the current stencil operation when stencil fails
  31462. * @returns a number defining stencil operation to use when stencil fails
  31463. */
  31464. getStencilOperationFail(): number;
  31465. /**
  31466. * Gets the current stencil operation when depth fails
  31467. * @returns a number defining stencil operation to use when depth fails
  31468. */
  31469. getStencilOperationDepthFail(): number;
  31470. /**
  31471. * Gets the current stencil operation when stencil passes
  31472. * @returns a number defining stencil operation to use when stencil passes
  31473. */
  31474. getStencilOperationPass(): number;
  31475. /**
  31476. * Sets the stencil operation to use when stencil fails
  31477. * @param operation defines the stencil operation to use when stencil fails
  31478. */
  31479. setStencilOperationFail(operation: number): void;
  31480. /**
  31481. * Sets the stencil operation to use when depth fails
  31482. * @param operation defines the stencil operation to use when depth fails
  31483. */
  31484. setStencilOperationDepthFail(operation: number): void;
  31485. /**
  31486. * Sets the stencil operation to use when stencil passes
  31487. * @param operation defines the stencil operation to use when stencil passes
  31488. */
  31489. setStencilOperationPass(operation: number): void;
  31490. /**
  31491. * Sets a boolean indicating if the dithering state is enabled or disabled
  31492. * @param value defines the dithering state
  31493. */
  31494. setDitheringState(value: boolean): void;
  31495. /**
  31496. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31497. * @param value defines the rasterizer state
  31498. */
  31499. setRasterizerState(value: boolean): void;
  31500. /**
  31501. * Gets the current depth function
  31502. * @returns a number defining the depth function
  31503. */
  31504. getDepthFunction(): Nullable<number>;
  31505. /**
  31506. * Sets the current depth function
  31507. * @param depthFunc defines the function to use
  31508. */
  31509. setDepthFunction(depthFunc: number): void;
  31510. /**
  31511. * Sets the current depth function to GREATER
  31512. */
  31513. setDepthFunctionToGreater(): void;
  31514. /**
  31515. * Sets the current depth function to GEQUAL
  31516. */
  31517. setDepthFunctionToGreaterOrEqual(): void;
  31518. /**
  31519. * Sets the current depth function to LESS
  31520. */
  31521. setDepthFunctionToLess(): void;
  31522. /**
  31523. * Sets the current depth function to LEQUAL
  31524. */
  31525. setDepthFunctionToLessOrEqual(): void;
  31526. private _cachedStencilBuffer;
  31527. private _cachedStencilFunction;
  31528. private _cachedStencilMask;
  31529. private _cachedStencilOperationPass;
  31530. private _cachedStencilOperationFail;
  31531. private _cachedStencilOperationDepthFail;
  31532. private _cachedStencilReference;
  31533. /**
  31534. * Caches the the state of the stencil buffer
  31535. */
  31536. cacheStencilState(): void;
  31537. /**
  31538. * Restores the state of the stencil buffer
  31539. */
  31540. restoreStencilState(): void;
  31541. /**
  31542. * Directly set the WebGL Viewport
  31543. * @param x defines the x coordinate of the viewport (in screen space)
  31544. * @param y defines the y coordinate of the viewport (in screen space)
  31545. * @param width defines the width of the viewport (in screen space)
  31546. * @param height defines the height of the viewport (in screen space)
  31547. * @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
  31548. */
  31549. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31550. /**
  31551. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31552. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31553. * @param y defines the y-coordinate of the corner of the clear rectangle
  31554. * @param width defines the width of the clear rectangle
  31555. * @param height defines the height of the clear rectangle
  31556. * @param clearColor defines the clear color
  31557. */
  31558. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31559. /**
  31560. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31561. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31562. * @param y defines the y-coordinate of the corner of the clear rectangle
  31563. * @param width defines the width of the clear rectangle
  31564. * @param height defines the height of the clear rectangle
  31565. */
  31566. enableScissor(x: number, y: number, width: number, height: number): void;
  31567. /**
  31568. * Disable previously set scissor test rectangle
  31569. */
  31570. disableScissor(): void;
  31571. protected _reportDrawCall(): void;
  31572. /**
  31573. * Initializes a webVR display and starts listening to display change events
  31574. * The onVRDisplayChangedObservable will be notified upon these changes
  31575. * @returns The onVRDisplayChangedObservable
  31576. */
  31577. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31578. /** @hidden */
  31579. _prepareVRComponent(): void;
  31580. /** @hidden */
  31581. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31582. /** @hidden */
  31583. _submitVRFrame(): void;
  31584. /**
  31585. * Call this function to leave webVR mode
  31586. * Will do nothing if webVR is not supported or if there is no webVR device
  31587. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31588. */
  31589. disableVR(): void;
  31590. /**
  31591. * Gets a boolean indicating that the system is in VR mode and is presenting
  31592. * @returns true if VR mode is engaged
  31593. */
  31594. isVRPresenting(): boolean;
  31595. /** @hidden */
  31596. _requestVRFrame(): void;
  31597. /** @hidden */
  31598. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31599. /**
  31600. * Gets the source code of the vertex shader associated with a specific webGL program
  31601. * @param program defines the program to use
  31602. * @returns a string containing the source code of the vertex shader associated with the program
  31603. */
  31604. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31605. /**
  31606. * Gets the source code of the fragment shader associated with a specific webGL program
  31607. * @param program defines the program to use
  31608. * @returns a string containing the source code of the fragment shader associated with the program
  31609. */
  31610. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31611. /**
  31612. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31613. * @param x defines the x coordinate of the rectangle where pixels must be read
  31614. * @param y defines the y coordinate of the rectangle where pixels must be read
  31615. * @param width defines the width of the rectangle where pixels must be read
  31616. * @param height defines the height of the rectangle where pixels must be read
  31617. * @returns a Uint8Array containing RGBA colors
  31618. */
  31619. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31620. /**
  31621. * Sets a depth stencil texture from a render target to the according uniform.
  31622. * @param channel The texture channel
  31623. * @param uniform The uniform to set
  31624. * @param texture The render target texture containing the depth stencil texture to apply
  31625. */
  31626. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31627. /**
  31628. * Sets a texture to the webGL context from a postprocess
  31629. * @param channel defines the channel to use
  31630. * @param postProcess defines the source postprocess
  31631. */
  31632. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31633. /**
  31634. * Binds the output of the passed in post process to the texture channel specified
  31635. * @param channel The channel the texture should be bound to
  31636. * @param postProcess The post process which's output should be bound
  31637. */
  31638. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31639. /** @hidden */
  31640. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31641. protected _rebuildBuffers(): void;
  31642. _renderLoop(): void;
  31643. /**
  31644. * Toggle full screen mode
  31645. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31646. */
  31647. switchFullscreen(requestPointerLock: boolean): void;
  31648. /**
  31649. * Enters full screen mode
  31650. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31651. */
  31652. enterFullscreen(requestPointerLock: boolean): void;
  31653. /**
  31654. * Exits full screen mode
  31655. */
  31656. exitFullscreen(): void;
  31657. /**
  31658. * Enters Pointerlock mode
  31659. */
  31660. enterPointerlock(): void;
  31661. /**
  31662. * Exits Pointerlock mode
  31663. */
  31664. exitPointerlock(): void;
  31665. /**
  31666. * Begin a new frame
  31667. */
  31668. beginFrame(): void;
  31669. /**
  31670. * Enf the current frame
  31671. */
  31672. endFrame(): void;
  31673. resize(): void;
  31674. /**
  31675. * Set the compressed texture format to use, based on the formats you have, and the formats
  31676. * supported by the hardware / browser.
  31677. *
  31678. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31679. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31680. * to API arguments needed to compressed textures. This puts the burden on the container
  31681. * generator to house the arcane code for determining these for current & future formats.
  31682. *
  31683. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31684. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31685. *
  31686. * Note: The result of this call is not taken into account when a texture is base64.
  31687. *
  31688. * @param formatsAvailable defines the list of those format families you have created
  31689. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31690. *
  31691. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31692. * @returns The extension selected.
  31693. */
  31694. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31695. /**
  31696. * Force a specific size of the canvas
  31697. * @param width defines the new canvas' width
  31698. * @param height defines the new canvas' height
  31699. */
  31700. setSize(width: number, height: number): void;
  31701. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31702. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31703. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31704. _releaseTexture(texture: InternalTexture): void;
  31705. /**
  31706. * @hidden
  31707. * Rescales a texture
  31708. * @param source input texutre
  31709. * @param destination destination texture
  31710. * @param scene scene to use to render the resize
  31711. * @param internalFormat format to use when resizing
  31712. * @param onComplete callback to be called when resize has completed
  31713. */
  31714. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31715. /**
  31716. * Gets the current framerate
  31717. * @returns a number representing the framerate
  31718. */
  31719. getFps(): number;
  31720. /**
  31721. * Gets the time spent between current and previous frame
  31722. * @returns a number representing the delta time in ms
  31723. */
  31724. getDeltaTime(): number;
  31725. private _measureFps;
  31726. /**
  31727. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31728. * @param renderTarget The render target to set the frame buffer for
  31729. */
  31730. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31731. /**
  31732. * Update a dynamic index buffer
  31733. * @param indexBuffer defines the target index buffer
  31734. * @param indices defines the data to update
  31735. * @param offset defines the offset in the target index buffer where update should start
  31736. */
  31737. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31738. /**
  31739. * Updates the sample count of a render target texture
  31740. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31741. * @param texture defines the texture to update
  31742. * @param samples defines the sample count to set
  31743. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31744. */
  31745. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31746. /** @hidden */
  31747. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31748. dispose(): void;
  31749. private _disableTouchAction;
  31750. /**
  31751. * Display the loading screen
  31752. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31753. */
  31754. displayLoadingUI(): void;
  31755. /**
  31756. * Hide the loading screen
  31757. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31758. */
  31759. hideLoadingUI(): void;
  31760. /**
  31761. * Gets the current loading screen object
  31762. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31763. */
  31764. /**
  31765. * Sets the current loading screen object
  31766. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31767. */
  31768. loadingScreen: ILoadingScreen;
  31769. /**
  31770. * Sets the current loading screen text
  31771. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31772. */
  31773. loadingUIText: string;
  31774. /**
  31775. * Sets the current loading screen background color
  31776. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31777. */
  31778. loadingUIBackgroundColor: string;
  31779. /** Pointerlock and fullscreen */
  31780. /**
  31781. * Ask the browser to promote the current element to pointerlock mode
  31782. * @param element defines the DOM element to promote
  31783. */
  31784. static _RequestPointerlock(element: HTMLElement): void;
  31785. /**
  31786. * Asks the browser to exit pointerlock mode
  31787. */
  31788. static _ExitPointerlock(): void;
  31789. /**
  31790. * Ask the browser to promote the current element to fullscreen rendering mode
  31791. * @param element defines the DOM element to promote
  31792. */
  31793. static _RequestFullscreen(element: HTMLElement): void;
  31794. /**
  31795. * Asks the browser to exit fullscreen mode
  31796. */
  31797. static _ExitFullscreen(): void;
  31798. }
  31799. }
  31800. declare module BABYLON {
  31801. /**
  31802. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31803. * during the life time of the application.
  31804. */
  31805. export class EngineStore {
  31806. /** Gets the list of created engines */
  31807. static Instances: Engine[];
  31808. /** @hidden */
  31809. static _LastCreatedScene: Nullable<Scene>;
  31810. /**
  31811. * Gets the latest created engine
  31812. */
  31813. static readonly LastCreatedEngine: Nullable<Engine>;
  31814. /**
  31815. * Gets the latest created scene
  31816. */
  31817. static readonly LastCreatedScene: Nullable<Scene>;
  31818. /**
  31819. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31820. * @ignorenaming
  31821. */
  31822. static UseFallbackTexture: boolean;
  31823. /**
  31824. * Texture content used if a texture cannot loaded
  31825. * @ignorenaming
  31826. */
  31827. static FallbackTexture: string;
  31828. }
  31829. }
  31830. declare module BABYLON {
  31831. /**
  31832. * Helper class that provides a small promise polyfill
  31833. */
  31834. export class PromisePolyfill {
  31835. /**
  31836. * Static function used to check if the polyfill is required
  31837. * If this is the case then the function will inject the polyfill to window.Promise
  31838. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31839. */
  31840. static Apply(force?: boolean): void;
  31841. }
  31842. }
  31843. declare module BABYLON {
  31844. /**
  31845. * Interface for screenshot methods with describe argument called `size` as object with options
  31846. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31847. */
  31848. export interface IScreenshotSize {
  31849. /**
  31850. * number in pixels for canvas height
  31851. */
  31852. height?: number;
  31853. /**
  31854. * multiplier allowing render at a higher or lower resolution
  31855. * If value is defined then height and width will be ignored and taken from camera
  31856. */
  31857. precision?: number;
  31858. /**
  31859. * number in pixels for canvas width
  31860. */
  31861. width?: number;
  31862. }
  31863. }
  31864. declare module BABYLON {
  31865. interface IColor4Like {
  31866. r: float;
  31867. g: float;
  31868. b: float;
  31869. a: float;
  31870. }
  31871. /**
  31872. * Class containing a set of static utilities functions
  31873. */
  31874. export class Tools {
  31875. /**
  31876. * Gets or sets the base URL to use to load assets
  31877. */
  31878. static BaseUrl: string;
  31879. /**
  31880. * Enable/Disable Custom HTTP Request Headers globally.
  31881. * default = false
  31882. * @see CustomRequestHeaders
  31883. */
  31884. static UseCustomRequestHeaders: boolean;
  31885. /**
  31886. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31887. * i.e. when loading files, where the server/service expects an Authorization header
  31888. */
  31889. static CustomRequestHeaders: {
  31890. [key: string]: string;
  31891. };
  31892. /**
  31893. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31894. */
  31895. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31896. /**
  31897. * Default behaviour for cors in the application.
  31898. * It can be a string if the expected behavior is identical in the entire app.
  31899. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31900. */
  31901. static CorsBehavior: string | ((url: string | string[]) => string);
  31902. /**
  31903. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31904. * @ignorenaming
  31905. */
  31906. static UseFallbackTexture: boolean;
  31907. /**
  31908. * Use this object to register external classes like custom textures or material
  31909. * to allow the laoders to instantiate them
  31910. */
  31911. static RegisteredExternalClasses: {
  31912. [key: string]: Object;
  31913. };
  31914. /**
  31915. * Texture content used if a texture cannot loaded
  31916. * @ignorenaming
  31917. */
  31918. static fallbackTexture: string;
  31919. /**
  31920. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31921. * @param u defines the coordinate on X axis
  31922. * @param v defines the coordinate on Y axis
  31923. * @param width defines the width of the source data
  31924. * @param height defines the height of the source data
  31925. * @param pixels defines the source byte array
  31926. * @param color defines the output color
  31927. */
  31928. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31929. /**
  31930. * Interpolates between a and b via alpha
  31931. * @param a The lower value (returned when alpha = 0)
  31932. * @param b The upper value (returned when alpha = 1)
  31933. * @param alpha The interpolation-factor
  31934. * @return The mixed value
  31935. */
  31936. static Mix(a: number, b: number, alpha: number): number;
  31937. /**
  31938. * Tries to instantiate a new object from a given class name
  31939. * @param className defines the class name to instantiate
  31940. * @returns the new object or null if the system was not able to do the instantiation
  31941. */
  31942. static Instantiate(className: string): any;
  31943. /**
  31944. * Provides a slice function that will work even on IE
  31945. * @param data defines the array to slice
  31946. * @param start defines the start of the data (optional)
  31947. * @param end defines the end of the data (optional)
  31948. * @returns the new sliced array
  31949. */
  31950. static Slice<T>(data: T, start?: number, end?: number): T;
  31951. /**
  31952. * Polyfill for setImmediate
  31953. * @param action defines the action to execute after the current execution block
  31954. */
  31955. static SetImmediate(action: () => void): void;
  31956. /**
  31957. * Function indicating if a number is an exponent of 2
  31958. * @param value defines the value to test
  31959. * @returns true if the value is an exponent of 2
  31960. */
  31961. static IsExponentOfTwo(value: number): boolean;
  31962. private static _tmpFloatArray;
  31963. /**
  31964. * Returns the nearest 32-bit single precision float representation of a Number
  31965. * @param value A Number. If the parameter is of a different type, it will get converted
  31966. * to a number or to NaN if it cannot be converted
  31967. * @returns number
  31968. */
  31969. static FloatRound(value: number): number;
  31970. /**
  31971. * Extracts the filename from a path
  31972. * @param path defines the path to use
  31973. * @returns the filename
  31974. */
  31975. static GetFilename(path: string): string;
  31976. /**
  31977. * Extracts the "folder" part of a path (everything before the filename).
  31978. * @param uri The URI to extract the info from
  31979. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31980. * @returns The "folder" part of the path
  31981. */
  31982. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31983. /**
  31984. * Extracts text content from a DOM element hierarchy
  31985. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31986. */
  31987. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31988. /**
  31989. * Convert an angle in radians to degrees
  31990. * @param angle defines the angle to convert
  31991. * @returns the angle in degrees
  31992. */
  31993. static ToDegrees(angle: number): number;
  31994. /**
  31995. * Convert an angle in degrees to radians
  31996. * @param angle defines the angle to convert
  31997. * @returns the angle in radians
  31998. */
  31999. static ToRadians(angle: number): number;
  32000. /**
  32001. * Encode a buffer to a base64 string
  32002. * @param buffer defines the buffer to encode
  32003. * @returns the encoded string
  32004. */
  32005. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32006. /**
  32007. * Returns an array if obj is not an array
  32008. * @param obj defines the object to evaluate as an array
  32009. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32010. * @returns either obj directly if obj is an array or a new array containing obj
  32011. */
  32012. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32013. /**
  32014. * Gets the pointer prefix to use
  32015. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32016. */
  32017. static GetPointerPrefix(): string;
  32018. /**
  32019. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32020. * @param url define the url we are trying
  32021. * @param element define the dom element where to configure the cors policy
  32022. */
  32023. static SetCorsBehavior(url: string | string[], element: {
  32024. crossOrigin: string | null;
  32025. }): void;
  32026. /**
  32027. * Removes unwanted characters from an url
  32028. * @param url defines the url to clean
  32029. * @returns the cleaned url
  32030. */
  32031. static CleanUrl(url: string): string;
  32032. /**
  32033. * Gets or sets a function used to pre-process url before using them to load assets
  32034. */
  32035. static PreprocessUrl: (url: string) => string;
  32036. /**
  32037. * Loads an image as an HTMLImageElement.
  32038. * @param input url string, ArrayBuffer, or Blob to load
  32039. * @param onLoad callback called when the image successfully loads
  32040. * @param onError callback called when the image fails to load
  32041. * @param offlineProvider offline provider for caching
  32042. * @param mimeType optional mime type
  32043. * @returns the HTMLImageElement of the loaded image
  32044. */
  32045. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32046. /**
  32047. * Loads a file
  32048. * @param url url string, ArrayBuffer, or Blob to load
  32049. * @param onSuccess callback called when the file successfully loads
  32050. * @param onProgress callback called while file is loading (if the server supports this mode)
  32051. * @param offlineProvider defines the offline provider for caching
  32052. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32053. * @param onError callback called when the file fails to load
  32054. * @returns a file request object
  32055. */
  32056. 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;
  32057. /**
  32058. * Loads a file from a url
  32059. * @param url the file url to load
  32060. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32061. */
  32062. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32063. /**
  32064. * Load a script (identified by an url). When the url returns, the
  32065. * content of this file is added into a new script element, attached to the DOM (body element)
  32066. * @param scriptUrl defines the url of the script to laod
  32067. * @param onSuccess defines the callback called when the script is loaded
  32068. * @param onError defines the callback to call if an error occurs
  32069. * @param scriptId defines the id of the script element
  32070. */
  32071. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32072. /**
  32073. * Load an asynchronous script (identified by an url). When the url returns, the
  32074. * content of this file is added into a new script element, attached to the DOM (body element)
  32075. * @param scriptUrl defines the url of the script to laod
  32076. * @param scriptId defines the id of the script element
  32077. * @returns a promise request object
  32078. */
  32079. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32080. /**
  32081. * Loads a file from a blob
  32082. * @param fileToLoad defines the blob to use
  32083. * @param callback defines the callback to call when data is loaded
  32084. * @param progressCallback defines the callback to call during loading process
  32085. * @returns a file request object
  32086. */
  32087. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32088. /**
  32089. * Loads a file
  32090. * @param fileToLoad defines the file to load
  32091. * @param callback defines the callback to call when data is loaded
  32092. * @param progressCallBack defines the callback to call during loading process
  32093. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32094. * @returns a file request object
  32095. */
  32096. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32097. /**
  32098. * Creates a data url from a given string content
  32099. * @param content defines the content to convert
  32100. * @returns the new data url link
  32101. */
  32102. static FileAsURL(content: string): string;
  32103. /**
  32104. * Format the given number to a specific decimal format
  32105. * @param value defines the number to format
  32106. * @param decimals defines the number of decimals to use
  32107. * @returns the formatted string
  32108. */
  32109. static Format(value: number, decimals?: number): string;
  32110. /**
  32111. * Tries to copy an object by duplicating every property
  32112. * @param source defines the source object
  32113. * @param destination defines the target object
  32114. * @param doNotCopyList defines a list of properties to avoid
  32115. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32116. */
  32117. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32118. /**
  32119. * Gets a boolean indicating if the given object has no own property
  32120. * @param obj defines the object to test
  32121. * @returns true if object has no own property
  32122. */
  32123. static IsEmpty(obj: any): boolean;
  32124. /**
  32125. * Function used to register events at window level
  32126. * @param windowElement defines the Window object to use
  32127. * @param events defines the events to register
  32128. */
  32129. static RegisterTopRootEvents(windowElement: Window, events: {
  32130. name: string;
  32131. handler: Nullable<(e: FocusEvent) => any>;
  32132. }[]): void;
  32133. /**
  32134. * Function used to unregister events from window level
  32135. * @param windowElement defines the Window object to use
  32136. * @param events defines the events to unregister
  32137. */
  32138. static UnregisterTopRootEvents(windowElement: Window, events: {
  32139. name: string;
  32140. handler: Nullable<(e: FocusEvent) => any>;
  32141. }[]): void;
  32142. /**
  32143. * @ignore
  32144. */
  32145. static _ScreenshotCanvas: HTMLCanvasElement;
  32146. /**
  32147. * Dumps the current bound framebuffer
  32148. * @param width defines the rendering width
  32149. * @param height defines the rendering height
  32150. * @param engine defines the hosting engine
  32151. * @param successCallback defines the callback triggered once the data are available
  32152. * @param mimeType defines the mime type of the result
  32153. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32154. */
  32155. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32156. /**
  32157. * Converts the canvas data to blob.
  32158. * This acts as a polyfill for browsers not supporting the to blob function.
  32159. * @param canvas Defines the canvas to extract the data from
  32160. * @param successCallback Defines the callback triggered once the data are available
  32161. * @param mimeType Defines the mime type of the result
  32162. */
  32163. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32164. /**
  32165. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32166. * @param successCallback defines the callback triggered once the data are available
  32167. * @param mimeType defines the mime type of the result
  32168. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32169. */
  32170. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32171. /**
  32172. * Downloads a blob in the browser
  32173. * @param blob defines the blob to download
  32174. * @param fileName defines the name of the downloaded file
  32175. */
  32176. static Download(blob: Blob, fileName: string): void;
  32177. /**
  32178. * Captures a screenshot of the current rendering
  32179. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32180. * @param engine defines the rendering engine
  32181. * @param camera defines the source camera
  32182. * @param size This parameter can be set to a single number or to an object with the
  32183. * following (optional) properties: precision, width, height. If a single number is passed,
  32184. * it will be used for both width and height. If an object is passed, the screenshot size
  32185. * will be derived from the parameters. The precision property is a multiplier allowing
  32186. * rendering at a higher or lower resolution
  32187. * @param successCallback defines the callback receives a single parameter which contains the
  32188. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32189. * src parameter of an <img> to display it
  32190. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32191. * Check your browser for supported MIME types
  32192. */
  32193. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32194. /**
  32195. * Captures a screenshot of the current rendering
  32196. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32197. * @param engine defines the rendering engine
  32198. * @param camera defines the source camera
  32199. * @param size This parameter can be set to a single number or to an object with the
  32200. * following (optional) properties: precision, width, height. If a single number is passed,
  32201. * it will be used for both width and height. If an object is passed, the screenshot size
  32202. * will be derived from the parameters. The precision property is a multiplier allowing
  32203. * rendering at a higher or lower resolution
  32204. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32205. * Check your browser for supported MIME types
  32206. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32207. * to the src parameter of an <img> to display it
  32208. */
  32209. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32210. /**
  32211. * Generates an image screenshot from the specified camera.
  32212. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32213. * @param engine The engine to use for rendering
  32214. * @param camera The camera to use for rendering
  32215. * @param size This parameter can be set to a single number or to an object with the
  32216. * following (optional) properties: precision, width, height. If a single number is passed,
  32217. * it will be used for both width and height. If an object is passed, the screenshot size
  32218. * will be derived from the parameters. The precision property is a multiplier allowing
  32219. * rendering at a higher or lower resolution
  32220. * @param successCallback The callback receives a single parameter which contains the
  32221. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32222. * src parameter of an <img> to display it
  32223. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32224. * Check your browser for supported MIME types
  32225. * @param samples Texture samples (default: 1)
  32226. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32227. * @param fileName A name for for the downloaded file.
  32228. */
  32229. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32230. /**
  32231. * Generates an image screenshot from the specified camera.
  32232. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32233. * @param engine The engine to use for rendering
  32234. * @param camera The camera to use for rendering
  32235. * @param size This parameter can be set to a single number or to an object with the
  32236. * following (optional) properties: precision, width, height. If a single number is passed,
  32237. * it will be used for both width and height. If an object is passed, the screenshot size
  32238. * will be derived from the parameters. The precision property is a multiplier allowing
  32239. * rendering at a higher or lower resolution
  32240. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32241. * Check your browser for supported MIME types
  32242. * @param samples Texture samples (default: 1)
  32243. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32244. * @param fileName A name for for the downloaded file.
  32245. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32246. * to the src parameter of an <img> to display it
  32247. */
  32248. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32249. /**
  32250. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32251. * Be aware Math.random() could cause collisions, but:
  32252. * "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"
  32253. * @returns a pseudo random id
  32254. */
  32255. static RandomId(): string;
  32256. /**
  32257. * Test if the given uri is a base64 string
  32258. * @param uri The uri to test
  32259. * @return True if the uri is a base64 string or false otherwise
  32260. */
  32261. static IsBase64(uri: string): boolean;
  32262. /**
  32263. * Decode the given base64 uri.
  32264. * @param uri The uri to decode
  32265. * @return The decoded base64 data.
  32266. */
  32267. static DecodeBase64(uri: string): ArrayBuffer;
  32268. /**
  32269. * Gets the absolute url.
  32270. * @param url the input url
  32271. * @return the absolute url
  32272. */
  32273. static GetAbsoluteUrl(url: string): string;
  32274. /**
  32275. * No log
  32276. */
  32277. static readonly NoneLogLevel: number;
  32278. /**
  32279. * Only message logs
  32280. */
  32281. static readonly MessageLogLevel: number;
  32282. /**
  32283. * Only warning logs
  32284. */
  32285. static readonly WarningLogLevel: number;
  32286. /**
  32287. * Only error logs
  32288. */
  32289. static readonly ErrorLogLevel: number;
  32290. /**
  32291. * All logs
  32292. */
  32293. static readonly AllLogLevel: number;
  32294. /**
  32295. * Gets a value indicating the number of loading errors
  32296. * @ignorenaming
  32297. */
  32298. static readonly errorsCount: number;
  32299. /**
  32300. * Callback called when a new log is added
  32301. */
  32302. static OnNewCacheEntry: (entry: string) => void;
  32303. /**
  32304. * Log a message to the console
  32305. * @param message defines the message to log
  32306. */
  32307. static Log(message: string): void;
  32308. /**
  32309. * Write a warning message to the console
  32310. * @param message defines the message to log
  32311. */
  32312. static Warn(message: string): void;
  32313. /**
  32314. * Write an error message to the console
  32315. * @param message defines the message to log
  32316. */
  32317. static Error(message: string): void;
  32318. /**
  32319. * Gets current log cache (list of logs)
  32320. */
  32321. static readonly LogCache: string;
  32322. /**
  32323. * Clears the log cache
  32324. */
  32325. static ClearLogCache(): void;
  32326. /**
  32327. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32328. */
  32329. static LogLevels: number;
  32330. /**
  32331. * Checks if the window object exists
  32332. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32333. */
  32334. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32335. /**
  32336. * No performance log
  32337. */
  32338. static readonly PerformanceNoneLogLevel: number;
  32339. /**
  32340. * Use user marks to log performance
  32341. */
  32342. static readonly PerformanceUserMarkLogLevel: number;
  32343. /**
  32344. * Log performance to the console
  32345. */
  32346. static readonly PerformanceConsoleLogLevel: number;
  32347. private static _performance;
  32348. /**
  32349. * Sets the current performance log level
  32350. */
  32351. static PerformanceLogLevel: number;
  32352. private static _StartPerformanceCounterDisabled;
  32353. private static _EndPerformanceCounterDisabled;
  32354. private static _StartUserMark;
  32355. private static _EndUserMark;
  32356. private static _StartPerformanceConsole;
  32357. private static _EndPerformanceConsole;
  32358. /**
  32359. * Starts a performance counter
  32360. */
  32361. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32362. /**
  32363. * Ends a specific performance coutner
  32364. */
  32365. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32366. /**
  32367. * Gets either window.performance.now() if supported or Date.now() else
  32368. */
  32369. static readonly Now: number;
  32370. /**
  32371. * This method will return the name of the class used to create the instance of the given object.
  32372. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32373. * @param object the object to get the class name from
  32374. * @param isType defines if the object is actually a type
  32375. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32376. */
  32377. static GetClassName(object: any, isType?: boolean): string;
  32378. /**
  32379. * Gets the first element of an array satisfying a given predicate
  32380. * @param array defines the array to browse
  32381. * @param predicate defines the predicate to use
  32382. * @returns null if not found or the element
  32383. */
  32384. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32385. /**
  32386. * This method will return the name of the full name of the class, including its owning module (if any).
  32387. * 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).
  32388. * @param object the object to get the class name from
  32389. * @param isType defines if the object is actually a type
  32390. * @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.
  32391. * @ignorenaming
  32392. */
  32393. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32394. /**
  32395. * Returns a promise that resolves after the given amount of time.
  32396. * @param delay Number of milliseconds to delay
  32397. * @returns Promise that resolves after the given amount of time
  32398. */
  32399. static DelayAsync(delay: number): Promise<void>;
  32400. }
  32401. /**
  32402. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32403. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32404. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32405. * @param name The name of the class, case should be preserved
  32406. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32407. */
  32408. export function className(name: string, module?: string): (target: Object) => void;
  32409. /**
  32410. * An implementation of a loop for asynchronous functions.
  32411. */
  32412. export class AsyncLoop {
  32413. /**
  32414. * Defines the number of iterations for the loop
  32415. */
  32416. iterations: number;
  32417. /**
  32418. * Defines the current index of the loop.
  32419. */
  32420. index: number;
  32421. private _done;
  32422. private _fn;
  32423. private _successCallback;
  32424. /**
  32425. * Constructor.
  32426. * @param iterations the number of iterations.
  32427. * @param func the function to run each iteration
  32428. * @param successCallback the callback that will be called upon succesful execution
  32429. * @param offset starting offset.
  32430. */
  32431. constructor(
  32432. /**
  32433. * Defines the number of iterations for the loop
  32434. */
  32435. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32436. /**
  32437. * Execute the next iteration. Must be called after the last iteration was finished.
  32438. */
  32439. executeNext(): void;
  32440. /**
  32441. * Break the loop and run the success callback.
  32442. */
  32443. breakLoop(): void;
  32444. /**
  32445. * Create and run an async loop.
  32446. * @param iterations the number of iterations.
  32447. * @param fn the function to run each iteration
  32448. * @param successCallback the callback that will be called upon succesful execution
  32449. * @param offset starting offset.
  32450. * @returns the created async loop object
  32451. */
  32452. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32453. /**
  32454. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32455. * @param iterations total number of iterations
  32456. * @param syncedIterations number of synchronous iterations in each async iteration.
  32457. * @param fn the function to call each iteration.
  32458. * @param callback a success call back that will be called when iterating stops.
  32459. * @param breakFunction a break condition (optional)
  32460. * @param timeout timeout settings for the setTimeout function. default - 0.
  32461. * @returns the created async loop object
  32462. */
  32463. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32464. }
  32465. }
  32466. declare module BABYLON {
  32467. /**
  32468. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32469. * The underlying implementation relies on an associative array to ensure the best performances.
  32470. * The value can be anything including 'null' but except 'undefined'
  32471. */
  32472. export class StringDictionary<T> {
  32473. /**
  32474. * This will clear this dictionary and copy the content from the 'source' one.
  32475. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32476. * @param source the dictionary to take the content from and copy to this dictionary
  32477. */
  32478. copyFrom(source: StringDictionary<T>): void;
  32479. /**
  32480. * Get a value based from its key
  32481. * @param key the given key to get the matching value from
  32482. * @return the value if found, otherwise undefined is returned
  32483. */
  32484. get(key: string): T | undefined;
  32485. /**
  32486. * Get a value from its key or add it if it doesn't exist.
  32487. * This method will ensure you that a given key/data will be present in the dictionary.
  32488. * @param key the given key to get the matching value from
  32489. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32490. * The factory will only be invoked if there's no data for the given key.
  32491. * @return the value corresponding to the key.
  32492. */
  32493. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32494. /**
  32495. * Get a value from its key if present in the dictionary otherwise add it
  32496. * @param key the key to get the value from
  32497. * @param val if there's no such key/value pair in the dictionary add it with this value
  32498. * @return the value corresponding to the key
  32499. */
  32500. getOrAdd(key: string, val: T): T;
  32501. /**
  32502. * Check if there's a given key in the dictionary
  32503. * @param key the key to check for
  32504. * @return true if the key is present, false otherwise
  32505. */
  32506. contains(key: string): boolean;
  32507. /**
  32508. * Add a new key and its corresponding value
  32509. * @param key the key to add
  32510. * @param value the value corresponding to the key
  32511. * @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
  32512. */
  32513. add(key: string, value: T): boolean;
  32514. /**
  32515. * Update a specific value associated to a key
  32516. * @param key defines the key to use
  32517. * @param value defines the value to store
  32518. * @returns true if the value was updated (or false if the key was not found)
  32519. */
  32520. set(key: string, value: T): boolean;
  32521. /**
  32522. * Get the element of the given key and remove it from the dictionary
  32523. * @param key defines the key to search
  32524. * @returns the value associated with the key or null if not found
  32525. */
  32526. getAndRemove(key: string): Nullable<T>;
  32527. /**
  32528. * Remove a key/value from the dictionary.
  32529. * @param key the key to remove
  32530. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32531. */
  32532. remove(key: string): boolean;
  32533. /**
  32534. * Clear the whole content of the dictionary
  32535. */
  32536. clear(): void;
  32537. /**
  32538. * Gets the current count
  32539. */
  32540. readonly count: number;
  32541. /**
  32542. * Execute a callback on each key/val of the dictionary.
  32543. * Note that you can remove any element in this dictionary in the callback implementation
  32544. * @param callback the callback to execute on a given key/value pair
  32545. */
  32546. forEach(callback: (key: string, val: T) => void): void;
  32547. /**
  32548. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32549. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32550. * Note that you can remove any element in this dictionary in the callback implementation
  32551. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32552. * @returns the first item
  32553. */
  32554. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32555. private _count;
  32556. private _data;
  32557. }
  32558. }
  32559. declare module BABYLON {
  32560. /** @hidden */
  32561. export interface ICollisionCoordinator {
  32562. createCollider(): Collider;
  32563. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32564. init(scene: Scene): void;
  32565. }
  32566. /** @hidden */
  32567. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32568. private _scene;
  32569. private _scaledPosition;
  32570. private _scaledVelocity;
  32571. private _finalPosition;
  32572. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32573. createCollider(): Collider;
  32574. init(scene: Scene): void;
  32575. private _collideWithWorld;
  32576. }
  32577. }
  32578. declare module BABYLON {
  32579. /**
  32580. * Class used to manage all inputs for the scene.
  32581. */
  32582. export class InputManager {
  32583. /** The distance in pixel that you have to move to prevent some events */
  32584. static DragMovementThreshold: number;
  32585. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32586. static LongPressDelay: number;
  32587. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32588. static DoubleClickDelay: number;
  32589. /** If you need to check double click without raising a single click at first click, enable this flag */
  32590. static ExclusiveDoubleClickMode: boolean;
  32591. private _wheelEventName;
  32592. private _onPointerMove;
  32593. private _onPointerDown;
  32594. private _onPointerUp;
  32595. private _initClickEvent;
  32596. private _initActionManager;
  32597. private _delayedSimpleClick;
  32598. private _delayedSimpleClickTimeout;
  32599. private _previousDelayedSimpleClickTimeout;
  32600. private _meshPickProceed;
  32601. private _previousButtonPressed;
  32602. private _currentPickResult;
  32603. private _previousPickResult;
  32604. private _totalPointersPressed;
  32605. private _doubleClickOccured;
  32606. private _pointerOverMesh;
  32607. private _pickedDownMesh;
  32608. private _pickedUpMesh;
  32609. private _pointerX;
  32610. private _pointerY;
  32611. private _unTranslatedPointerX;
  32612. private _unTranslatedPointerY;
  32613. private _startingPointerPosition;
  32614. private _previousStartingPointerPosition;
  32615. private _startingPointerTime;
  32616. private _previousStartingPointerTime;
  32617. private _pointerCaptures;
  32618. private _onKeyDown;
  32619. private _onKeyUp;
  32620. private _onCanvasFocusObserver;
  32621. private _onCanvasBlurObserver;
  32622. private _scene;
  32623. /**
  32624. * Creates a new InputManager
  32625. * @param scene defines the hosting scene
  32626. */
  32627. constructor(scene: Scene);
  32628. /**
  32629. * Gets the mesh that is currently under the pointer
  32630. */
  32631. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32632. /**
  32633. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32634. */
  32635. readonly unTranslatedPointer: Vector2;
  32636. /**
  32637. * Gets or sets the current on-screen X position of the pointer
  32638. */
  32639. pointerX: number;
  32640. /**
  32641. * Gets or sets the current on-screen Y position of the pointer
  32642. */
  32643. pointerY: number;
  32644. private _updatePointerPosition;
  32645. private _processPointerMove;
  32646. private _setRayOnPointerInfo;
  32647. private _checkPrePointerObservable;
  32648. /**
  32649. * Use this method to simulate a pointer move on a mesh
  32650. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32651. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32652. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32653. */
  32654. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32655. /**
  32656. * Use this method to simulate a pointer down on a mesh
  32657. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32658. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32659. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32660. */
  32661. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32662. private _processPointerDown;
  32663. /** @hidden */
  32664. _isPointerSwiping(): boolean;
  32665. /**
  32666. * Use this method to simulate a pointer up on a mesh
  32667. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32668. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32669. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32670. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32671. */
  32672. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32673. private _processPointerUp;
  32674. /**
  32675. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32676. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32677. * @returns true if the pointer was captured
  32678. */
  32679. isPointerCaptured(pointerId?: number): boolean;
  32680. /**
  32681. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32682. * @param attachUp defines if you want to attach events to pointerup
  32683. * @param attachDown defines if you want to attach events to pointerdown
  32684. * @param attachMove defines if you want to attach events to pointermove
  32685. */
  32686. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32687. /**
  32688. * Detaches all event handlers
  32689. */
  32690. detachControl(): void;
  32691. /**
  32692. * Force the value of meshUnderPointer
  32693. * @param mesh defines the mesh to use
  32694. */
  32695. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32696. /**
  32697. * Gets the mesh under the pointer
  32698. * @returns a Mesh or null if no mesh is under the pointer
  32699. */
  32700. getPointerOverMesh(): Nullable<AbstractMesh>;
  32701. }
  32702. }
  32703. declare module BABYLON {
  32704. /**
  32705. * Helper class used to generate session unique ID
  32706. */
  32707. export class UniqueIdGenerator {
  32708. private static _UniqueIdCounter;
  32709. /**
  32710. * Gets an unique (relatively to the current scene) Id
  32711. */
  32712. static readonly UniqueId: number;
  32713. }
  32714. }
  32715. declare module BABYLON {
  32716. /**
  32717. * This class defines the direct association between an animation and a target
  32718. */
  32719. export class TargetedAnimation {
  32720. /**
  32721. * Animation to perform
  32722. */
  32723. animation: Animation;
  32724. /**
  32725. * Target to animate
  32726. */
  32727. target: any;
  32728. /**
  32729. * Serialize the object
  32730. * @returns the JSON object representing the current entity
  32731. */
  32732. serialize(): any;
  32733. }
  32734. /**
  32735. * Use this class to create coordinated animations on multiple targets
  32736. */
  32737. export class AnimationGroup implements IDisposable {
  32738. /** The name of the animation group */
  32739. name: string;
  32740. private _scene;
  32741. private _targetedAnimations;
  32742. private _animatables;
  32743. private _from;
  32744. private _to;
  32745. private _isStarted;
  32746. private _isPaused;
  32747. private _speedRatio;
  32748. private _loopAnimation;
  32749. /**
  32750. * Gets or sets the unique id of the node
  32751. */
  32752. uniqueId: number;
  32753. /**
  32754. * This observable will notify when one animation have ended
  32755. */
  32756. onAnimationEndObservable: Observable<TargetedAnimation>;
  32757. /**
  32758. * Observer raised when one animation loops
  32759. */
  32760. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32761. /**
  32762. * This observable will notify when all animations have ended.
  32763. */
  32764. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32765. /**
  32766. * This observable will notify when all animations have paused.
  32767. */
  32768. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32769. /**
  32770. * This observable will notify when all animations are playing.
  32771. */
  32772. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32773. /**
  32774. * Gets the first frame
  32775. */
  32776. readonly from: number;
  32777. /**
  32778. * Gets the last frame
  32779. */
  32780. readonly to: number;
  32781. /**
  32782. * Define if the animations are started
  32783. */
  32784. readonly isStarted: boolean;
  32785. /**
  32786. * Gets a value indicating that the current group is playing
  32787. */
  32788. readonly isPlaying: boolean;
  32789. /**
  32790. * Gets or sets the speed ratio to use for all animations
  32791. */
  32792. /**
  32793. * Gets or sets the speed ratio to use for all animations
  32794. */
  32795. speedRatio: number;
  32796. /**
  32797. * Gets or sets if all animations should loop or not
  32798. */
  32799. loopAnimation: boolean;
  32800. /**
  32801. * Gets the targeted animations for this animation group
  32802. */
  32803. readonly targetedAnimations: Array<TargetedAnimation>;
  32804. /**
  32805. * returning the list of animatables controlled by this animation group.
  32806. */
  32807. readonly animatables: Array<Animatable>;
  32808. /**
  32809. * Instantiates a new Animation Group.
  32810. * This helps managing several animations at once.
  32811. * @see http://doc.babylonjs.com/how_to/group
  32812. * @param name Defines the name of the group
  32813. * @param scene Defines the scene the group belongs to
  32814. */
  32815. constructor(
  32816. /** The name of the animation group */
  32817. name: string, scene?: Nullable<Scene>);
  32818. /**
  32819. * Add an animation (with its target) in the group
  32820. * @param animation defines the animation we want to add
  32821. * @param target defines the target of the animation
  32822. * @returns the TargetedAnimation object
  32823. */
  32824. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32825. /**
  32826. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32827. * It can add constant keys at begin or end
  32828. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32829. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32830. * @returns the animation group
  32831. */
  32832. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32833. /**
  32834. * Start all animations on given targets
  32835. * @param loop defines if animations must loop
  32836. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32837. * @param from defines the from key (optional)
  32838. * @param to defines the to key (optional)
  32839. * @returns the current animation group
  32840. */
  32841. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32842. /**
  32843. * Pause all animations
  32844. * @returns the animation group
  32845. */
  32846. pause(): AnimationGroup;
  32847. /**
  32848. * Play all animations to initial state
  32849. * This function will start() the animations if they were not started or will restart() them if they were paused
  32850. * @param loop defines if animations must loop
  32851. * @returns the animation group
  32852. */
  32853. play(loop?: boolean): AnimationGroup;
  32854. /**
  32855. * Reset all animations to initial state
  32856. * @returns the animation group
  32857. */
  32858. reset(): AnimationGroup;
  32859. /**
  32860. * Restart animations from key 0
  32861. * @returns the animation group
  32862. */
  32863. restart(): AnimationGroup;
  32864. /**
  32865. * Stop all animations
  32866. * @returns the animation group
  32867. */
  32868. stop(): AnimationGroup;
  32869. /**
  32870. * Set animation weight for all animatables
  32871. * @param weight defines the weight to use
  32872. * @return the animationGroup
  32873. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32874. */
  32875. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32876. /**
  32877. * Synchronize and normalize all animatables with a source animatable
  32878. * @param root defines the root animatable to synchronize with
  32879. * @return the animationGroup
  32880. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32881. */
  32882. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32883. /**
  32884. * Goes to a specific frame in this animation group
  32885. * @param frame the frame number to go to
  32886. * @return the animationGroup
  32887. */
  32888. goToFrame(frame: number): AnimationGroup;
  32889. /**
  32890. * Dispose all associated resources
  32891. */
  32892. dispose(): void;
  32893. private _checkAnimationGroupEnded;
  32894. /**
  32895. * Clone the current animation group and returns a copy
  32896. * @param newName defines the name of the new group
  32897. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32898. * @returns the new aniamtion group
  32899. */
  32900. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32901. /**
  32902. * Serializes the animationGroup to an object
  32903. * @returns Serialized object
  32904. */
  32905. serialize(): any;
  32906. /**
  32907. * Returns a new AnimationGroup object parsed from the source provided.
  32908. * @param parsedAnimationGroup defines the source
  32909. * @param scene defines the scene that will receive the animationGroup
  32910. * @returns a new AnimationGroup
  32911. */
  32912. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32913. /**
  32914. * Returns the string "AnimationGroup"
  32915. * @returns "AnimationGroup"
  32916. */
  32917. getClassName(): string;
  32918. /**
  32919. * Creates a detailled string about the object
  32920. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32921. * @returns a string representing the object
  32922. */
  32923. toString(fullDetails?: boolean): string;
  32924. }
  32925. }
  32926. declare module BABYLON {
  32927. /**
  32928. * Define an interface for all classes that will hold resources
  32929. */
  32930. export interface IDisposable {
  32931. /**
  32932. * Releases all held resources
  32933. */
  32934. dispose(): void;
  32935. }
  32936. /** Interface defining initialization parameters for Scene class */
  32937. export interface SceneOptions {
  32938. /**
  32939. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32940. * It will improve performance when the number of geometries becomes important.
  32941. */
  32942. useGeometryUniqueIdsMap?: boolean;
  32943. /**
  32944. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32945. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32946. */
  32947. useMaterialMeshMap?: boolean;
  32948. /**
  32949. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32950. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32951. */
  32952. useClonedMeshhMap?: boolean;
  32953. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32954. virtual?: boolean;
  32955. }
  32956. /**
  32957. * Represents a scene to be rendered by the engine.
  32958. * @see http://doc.babylonjs.com/features/scene
  32959. */
  32960. export class Scene extends AbstractScene implements IAnimatable {
  32961. /** The fog is deactivated */
  32962. static readonly FOGMODE_NONE: number;
  32963. /** The fog density is following an exponential function */
  32964. static readonly FOGMODE_EXP: number;
  32965. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32966. static readonly FOGMODE_EXP2: number;
  32967. /** The fog density is following a linear function. */
  32968. static readonly FOGMODE_LINEAR: number;
  32969. /**
  32970. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32971. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32972. */
  32973. static MinDeltaTime: number;
  32974. /**
  32975. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32976. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32977. */
  32978. static MaxDeltaTime: number;
  32979. /**
  32980. * Factory used to create the default material.
  32981. * @param name The name of the material to create
  32982. * @param scene The scene to create the material for
  32983. * @returns The default material
  32984. */
  32985. static DefaultMaterialFactory(scene: Scene): Material;
  32986. /**
  32987. * Factory used to create the a collision coordinator.
  32988. * @returns The collision coordinator
  32989. */
  32990. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32991. /** @hidden */
  32992. _inputManager: InputManager;
  32993. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32994. cameraToUseForPointers: Nullable<Camera>;
  32995. /** @hidden */
  32996. readonly _isScene: boolean;
  32997. /**
  32998. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32999. */
  33000. autoClear: boolean;
  33001. /**
  33002. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33003. */
  33004. autoClearDepthAndStencil: boolean;
  33005. /**
  33006. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33007. */
  33008. clearColor: Color4;
  33009. /**
  33010. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33011. */
  33012. ambientColor: Color3;
  33013. /**
  33014. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33015. * It should only be one of the following (if not the default embedded one):
  33016. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33017. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33018. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33019. * The material properties need to be setup according to the type of texture in use.
  33020. */
  33021. environmentBRDFTexture: BaseTexture;
  33022. /** @hidden */
  33023. protected _environmentTexture: Nullable<BaseTexture>;
  33024. /**
  33025. * Texture used in all pbr material as the reflection texture.
  33026. * As in the majority of the scene they are the same (exception for multi room and so on),
  33027. * this is easier to reference from here than from all the materials.
  33028. */
  33029. /**
  33030. * Texture used in all pbr material as the reflection texture.
  33031. * As in the majority of the scene they are the same (exception for multi room and so on),
  33032. * this is easier to set here than in all the materials.
  33033. */
  33034. environmentTexture: Nullable<BaseTexture>;
  33035. /** @hidden */
  33036. protected _environmentIntensity: number;
  33037. /**
  33038. * Intensity of the environment in all pbr material.
  33039. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33040. * As in the majority of the scene they are the same (exception for multi room and so on),
  33041. * this is easier to reference from here than from all the materials.
  33042. */
  33043. /**
  33044. * Intensity of the environment in all pbr material.
  33045. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33046. * As in the majority of the scene they are the same (exception for multi room and so on),
  33047. * this is easier to set here than in all the materials.
  33048. */
  33049. environmentIntensity: number;
  33050. /** @hidden */
  33051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33052. /**
  33053. * Default image processing configuration used either in the rendering
  33054. * Forward main pass or through the imageProcessingPostProcess if present.
  33055. * As in the majority of the scene they are the same (exception for multi camera),
  33056. * this is easier to reference from here than from all the materials and post process.
  33057. *
  33058. * No setter as we it is a shared configuration, you can set the values instead.
  33059. */
  33060. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33061. private _forceWireframe;
  33062. /**
  33063. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33064. */
  33065. forceWireframe: boolean;
  33066. private _forcePointsCloud;
  33067. /**
  33068. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33069. */
  33070. forcePointsCloud: boolean;
  33071. /**
  33072. * Gets or sets the active clipplane 1
  33073. */
  33074. clipPlane: Nullable<Plane>;
  33075. /**
  33076. * Gets or sets the active clipplane 2
  33077. */
  33078. clipPlane2: Nullable<Plane>;
  33079. /**
  33080. * Gets or sets the active clipplane 3
  33081. */
  33082. clipPlane3: Nullable<Plane>;
  33083. /**
  33084. * Gets or sets the active clipplane 4
  33085. */
  33086. clipPlane4: Nullable<Plane>;
  33087. /**
  33088. * Gets or sets a boolean indicating if animations are enabled
  33089. */
  33090. animationsEnabled: boolean;
  33091. private _animationPropertiesOverride;
  33092. /**
  33093. * Gets or sets the animation properties override
  33094. */
  33095. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33096. /**
  33097. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33098. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33099. */
  33100. useConstantAnimationDeltaTime: boolean;
  33101. /**
  33102. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33103. * Please note that it requires to run a ray cast through the scene on every frame
  33104. */
  33105. constantlyUpdateMeshUnderPointer: boolean;
  33106. /**
  33107. * Defines the HTML cursor to use when hovering over interactive elements
  33108. */
  33109. hoverCursor: string;
  33110. /**
  33111. * Defines the HTML default cursor to use (empty by default)
  33112. */
  33113. defaultCursor: string;
  33114. /**
  33115. * Defines wether cursors are handled by the scene.
  33116. */
  33117. doNotHandleCursors: boolean;
  33118. /**
  33119. * This is used to call preventDefault() on pointer down
  33120. * in order to block unwanted artifacts like system double clicks
  33121. */
  33122. preventDefaultOnPointerDown: boolean;
  33123. /**
  33124. * This is used to call preventDefault() on pointer up
  33125. * in order to block unwanted artifacts like system double clicks
  33126. */
  33127. preventDefaultOnPointerUp: boolean;
  33128. /**
  33129. * Gets or sets user defined metadata
  33130. */
  33131. metadata: any;
  33132. /**
  33133. * For internal use only. Please do not use.
  33134. */
  33135. reservedDataStore: any;
  33136. /**
  33137. * Gets the name of the plugin used to load this scene (null by default)
  33138. */
  33139. loadingPluginName: string;
  33140. /**
  33141. * Use this array to add regular expressions used to disable offline support for specific urls
  33142. */
  33143. disableOfflineSupportExceptionRules: RegExp[];
  33144. /**
  33145. * An event triggered when the scene is disposed.
  33146. */
  33147. onDisposeObservable: Observable<Scene>;
  33148. private _onDisposeObserver;
  33149. /** Sets a function to be executed when this scene is disposed. */
  33150. onDispose: () => void;
  33151. /**
  33152. * An event triggered before rendering the scene (right after animations and physics)
  33153. */
  33154. onBeforeRenderObservable: Observable<Scene>;
  33155. private _onBeforeRenderObserver;
  33156. /** Sets a function to be executed before rendering this scene */
  33157. beforeRender: Nullable<() => void>;
  33158. /**
  33159. * An event triggered after rendering the scene
  33160. */
  33161. onAfterRenderObservable: Observable<Scene>;
  33162. /**
  33163. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33164. */
  33165. onAfterRenderCameraObservable: Observable<Camera>;
  33166. private _onAfterRenderObserver;
  33167. /** Sets a function to be executed after rendering this scene */
  33168. afterRender: Nullable<() => void>;
  33169. /**
  33170. * An event triggered before animating the scene
  33171. */
  33172. onBeforeAnimationsObservable: Observable<Scene>;
  33173. /**
  33174. * An event triggered after animations processing
  33175. */
  33176. onAfterAnimationsObservable: Observable<Scene>;
  33177. /**
  33178. * An event triggered before draw calls are ready to be sent
  33179. */
  33180. onBeforeDrawPhaseObservable: Observable<Scene>;
  33181. /**
  33182. * An event triggered after draw calls have been sent
  33183. */
  33184. onAfterDrawPhaseObservable: Observable<Scene>;
  33185. /**
  33186. * An event triggered when the scene is ready
  33187. */
  33188. onReadyObservable: Observable<Scene>;
  33189. /**
  33190. * An event triggered before rendering a camera
  33191. */
  33192. onBeforeCameraRenderObservable: Observable<Camera>;
  33193. private _onBeforeCameraRenderObserver;
  33194. /** Sets a function to be executed before rendering a camera*/
  33195. beforeCameraRender: () => void;
  33196. /**
  33197. * An event triggered after rendering a camera
  33198. */
  33199. onAfterCameraRenderObservable: Observable<Camera>;
  33200. private _onAfterCameraRenderObserver;
  33201. /** Sets a function to be executed after rendering a camera*/
  33202. afterCameraRender: () => void;
  33203. /**
  33204. * An event triggered when active meshes evaluation is about to start
  33205. */
  33206. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33207. /**
  33208. * An event triggered when active meshes evaluation is done
  33209. */
  33210. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33211. /**
  33212. * An event triggered when particles rendering is about to start
  33213. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33214. */
  33215. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33216. /**
  33217. * An event triggered when particles rendering is done
  33218. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33219. */
  33220. onAfterParticlesRenderingObservable: Observable<Scene>;
  33221. /**
  33222. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33223. */
  33224. onDataLoadedObservable: Observable<Scene>;
  33225. /**
  33226. * An event triggered when a camera is created
  33227. */
  33228. onNewCameraAddedObservable: Observable<Camera>;
  33229. /**
  33230. * An event triggered when a camera is removed
  33231. */
  33232. onCameraRemovedObservable: Observable<Camera>;
  33233. /**
  33234. * An event triggered when a light is created
  33235. */
  33236. onNewLightAddedObservable: Observable<Light>;
  33237. /**
  33238. * An event triggered when a light is removed
  33239. */
  33240. onLightRemovedObservable: Observable<Light>;
  33241. /**
  33242. * An event triggered when a geometry is created
  33243. */
  33244. onNewGeometryAddedObservable: Observable<Geometry>;
  33245. /**
  33246. * An event triggered when a geometry is removed
  33247. */
  33248. onGeometryRemovedObservable: Observable<Geometry>;
  33249. /**
  33250. * An event triggered when a transform node is created
  33251. */
  33252. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33253. /**
  33254. * An event triggered when a transform node is removed
  33255. */
  33256. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33257. /**
  33258. * An event triggered when a mesh is created
  33259. */
  33260. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33261. /**
  33262. * An event triggered when a mesh is removed
  33263. */
  33264. onMeshRemovedObservable: Observable<AbstractMesh>;
  33265. /**
  33266. * An event triggered when a skeleton is created
  33267. */
  33268. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33269. /**
  33270. * An event triggered when a skeleton is removed
  33271. */
  33272. onSkeletonRemovedObservable: Observable<Skeleton>;
  33273. /**
  33274. * An event triggered when a material is created
  33275. */
  33276. onNewMaterialAddedObservable: Observable<Material>;
  33277. /**
  33278. * An event triggered when a material is removed
  33279. */
  33280. onMaterialRemovedObservable: Observable<Material>;
  33281. /**
  33282. * An event triggered when a texture is created
  33283. */
  33284. onNewTextureAddedObservable: Observable<BaseTexture>;
  33285. /**
  33286. * An event triggered when a texture is removed
  33287. */
  33288. onTextureRemovedObservable: Observable<BaseTexture>;
  33289. /**
  33290. * An event triggered when render targets are about to be rendered
  33291. * Can happen multiple times per frame.
  33292. */
  33293. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33294. /**
  33295. * An event triggered when render targets were rendered.
  33296. * Can happen multiple times per frame.
  33297. */
  33298. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33299. /**
  33300. * An event triggered before calculating deterministic simulation step
  33301. */
  33302. onBeforeStepObservable: Observable<Scene>;
  33303. /**
  33304. * An event triggered after calculating deterministic simulation step
  33305. */
  33306. onAfterStepObservable: Observable<Scene>;
  33307. /**
  33308. * An event triggered when the activeCamera property is updated
  33309. */
  33310. onActiveCameraChanged: Observable<Scene>;
  33311. /**
  33312. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33313. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33314. * 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)
  33315. */
  33316. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33317. /**
  33318. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33319. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33320. * 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)
  33321. */
  33322. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33323. /**
  33324. * This Observable will when a mesh has been imported into the scene.
  33325. */
  33326. onMeshImportedObservable: Observable<AbstractMesh>;
  33327. /**
  33328. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33329. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33330. */
  33331. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33332. /** @hidden */
  33333. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33334. /**
  33335. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33336. */
  33337. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33338. /**
  33339. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33340. */
  33341. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33342. /**
  33343. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33344. */
  33345. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33346. /** Callback called when a pointer move is detected */
  33347. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33348. /** Callback called when a pointer down is detected */
  33349. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33350. /** Callback called when a pointer up is detected */
  33351. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33352. /** Callback called when a pointer pick is detected */
  33353. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33354. /**
  33355. * 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).
  33356. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33357. */
  33358. onPrePointerObservable: Observable<PointerInfoPre>;
  33359. /**
  33360. * Observable event triggered each time an input event is received from the rendering canvas
  33361. */
  33362. onPointerObservable: Observable<PointerInfo>;
  33363. /**
  33364. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33365. */
  33366. readonly unTranslatedPointer: Vector2;
  33367. /**
  33368. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33369. */
  33370. static DragMovementThreshold: number;
  33371. /**
  33372. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33373. */
  33374. static LongPressDelay: number;
  33375. /**
  33376. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33377. */
  33378. static DoubleClickDelay: number;
  33379. /** If you need to check double click without raising a single click at first click, enable this flag */
  33380. static ExclusiveDoubleClickMode: boolean;
  33381. /** @hidden */
  33382. _mirroredCameraPosition: Nullable<Vector3>;
  33383. /**
  33384. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33385. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33386. */
  33387. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33388. /**
  33389. * Observable event triggered each time an keyboard event is received from the hosting window
  33390. */
  33391. onKeyboardObservable: Observable<KeyboardInfo>;
  33392. private _useRightHandedSystem;
  33393. /**
  33394. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33395. */
  33396. useRightHandedSystem: boolean;
  33397. private _timeAccumulator;
  33398. private _currentStepId;
  33399. private _currentInternalStep;
  33400. /**
  33401. * Sets the step Id used by deterministic lock step
  33402. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33403. * @param newStepId defines the step Id
  33404. */
  33405. setStepId(newStepId: number): void;
  33406. /**
  33407. * Gets the step Id used by deterministic lock step
  33408. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33409. * @returns the step Id
  33410. */
  33411. getStepId(): number;
  33412. /**
  33413. * Gets the internal step used by deterministic lock step
  33414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33415. * @returns the internal step
  33416. */
  33417. getInternalStep(): number;
  33418. private _fogEnabled;
  33419. /**
  33420. * Gets or sets a boolean indicating if fog is enabled on this scene
  33421. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33422. * (Default is true)
  33423. */
  33424. fogEnabled: boolean;
  33425. private _fogMode;
  33426. /**
  33427. * Gets or sets the fog mode to use
  33428. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33429. * | mode | value |
  33430. * | --- | --- |
  33431. * | FOGMODE_NONE | 0 |
  33432. * | FOGMODE_EXP | 1 |
  33433. * | FOGMODE_EXP2 | 2 |
  33434. * | FOGMODE_LINEAR | 3 |
  33435. */
  33436. fogMode: number;
  33437. /**
  33438. * Gets or sets the fog color to use
  33439. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33440. * (Default is Color3(0.2, 0.2, 0.3))
  33441. */
  33442. fogColor: Color3;
  33443. /**
  33444. * Gets or sets the fog density to use
  33445. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33446. * (Default is 0.1)
  33447. */
  33448. fogDensity: number;
  33449. /**
  33450. * Gets or sets the fog start distance to use
  33451. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33452. * (Default is 0)
  33453. */
  33454. fogStart: number;
  33455. /**
  33456. * Gets or sets the fog end distance to use
  33457. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33458. * (Default is 1000)
  33459. */
  33460. fogEnd: number;
  33461. private _shadowsEnabled;
  33462. /**
  33463. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33464. */
  33465. shadowsEnabled: boolean;
  33466. private _lightsEnabled;
  33467. /**
  33468. * Gets or sets a boolean indicating if lights are enabled on this scene
  33469. */
  33470. lightsEnabled: boolean;
  33471. /** All of the active cameras added to this scene. */
  33472. activeCameras: Camera[];
  33473. /** @hidden */
  33474. _activeCamera: Nullable<Camera>;
  33475. /** Gets or sets the current active camera */
  33476. activeCamera: Nullable<Camera>;
  33477. private _defaultMaterial;
  33478. /** The default material used on meshes when no material is affected */
  33479. /** The default material used on meshes when no material is affected */
  33480. defaultMaterial: Material;
  33481. private _texturesEnabled;
  33482. /**
  33483. * Gets or sets a boolean indicating if textures are enabled on this scene
  33484. */
  33485. texturesEnabled: boolean;
  33486. /**
  33487. * Gets or sets a boolean indicating if particles are enabled on this scene
  33488. */
  33489. particlesEnabled: boolean;
  33490. /**
  33491. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33492. */
  33493. spritesEnabled: boolean;
  33494. private _skeletonsEnabled;
  33495. /**
  33496. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33497. */
  33498. skeletonsEnabled: boolean;
  33499. /**
  33500. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33501. */
  33502. lensFlaresEnabled: boolean;
  33503. /**
  33504. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33505. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33506. */
  33507. collisionsEnabled: boolean;
  33508. private _collisionCoordinator;
  33509. /** @hidden */
  33510. readonly collisionCoordinator: ICollisionCoordinator;
  33511. /**
  33512. * Defines the gravity applied to this scene (used only for collisions)
  33513. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33514. */
  33515. gravity: Vector3;
  33516. /**
  33517. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33518. */
  33519. postProcessesEnabled: boolean;
  33520. /**
  33521. * The list of postprocesses added to the scene
  33522. */
  33523. postProcesses: PostProcess[];
  33524. /**
  33525. * Gets the current postprocess manager
  33526. */
  33527. postProcessManager: PostProcessManager;
  33528. /**
  33529. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33530. */
  33531. renderTargetsEnabled: boolean;
  33532. /**
  33533. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33534. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33535. */
  33536. dumpNextRenderTargets: boolean;
  33537. /**
  33538. * The list of user defined render targets added to the scene
  33539. */
  33540. customRenderTargets: RenderTargetTexture[];
  33541. /**
  33542. * Defines if texture loading must be delayed
  33543. * If true, textures will only be loaded when they need to be rendered
  33544. */
  33545. useDelayedTextureLoading: boolean;
  33546. /**
  33547. * Gets the list of meshes imported to the scene through SceneLoader
  33548. */
  33549. importedMeshesFiles: String[];
  33550. /**
  33551. * Gets or sets a boolean indicating if probes are enabled on this scene
  33552. */
  33553. probesEnabled: boolean;
  33554. /**
  33555. * Gets or sets the current offline provider to use to store scene data
  33556. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33557. */
  33558. offlineProvider: IOfflineProvider;
  33559. /**
  33560. * Gets or sets the action manager associated with the scene
  33561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33562. */
  33563. actionManager: AbstractActionManager;
  33564. private _meshesForIntersections;
  33565. /**
  33566. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33567. */
  33568. proceduralTexturesEnabled: boolean;
  33569. private _engine;
  33570. private _totalVertices;
  33571. /** @hidden */
  33572. _activeIndices: PerfCounter;
  33573. /** @hidden */
  33574. _activeParticles: PerfCounter;
  33575. /** @hidden */
  33576. _activeBones: PerfCounter;
  33577. private _animationRatio;
  33578. /** @hidden */
  33579. _animationTimeLast: number;
  33580. /** @hidden */
  33581. _animationTime: number;
  33582. /**
  33583. * Gets or sets a general scale for animation speed
  33584. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33585. */
  33586. animationTimeScale: number;
  33587. /** @hidden */
  33588. _cachedMaterial: Nullable<Material>;
  33589. /** @hidden */
  33590. _cachedEffect: Nullable<Effect>;
  33591. /** @hidden */
  33592. _cachedVisibility: Nullable<number>;
  33593. private _renderId;
  33594. private _frameId;
  33595. private _executeWhenReadyTimeoutId;
  33596. private _intermediateRendering;
  33597. private _viewUpdateFlag;
  33598. private _projectionUpdateFlag;
  33599. /** @hidden */
  33600. _toBeDisposed: Nullable<IDisposable>[];
  33601. private _activeRequests;
  33602. /** @hidden */
  33603. _pendingData: any[];
  33604. private _isDisposed;
  33605. /**
  33606. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33607. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33608. */
  33609. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33610. private _activeMeshes;
  33611. private _processedMaterials;
  33612. private _renderTargets;
  33613. /** @hidden */
  33614. _activeParticleSystems: SmartArray<IParticleSystem>;
  33615. private _activeSkeletons;
  33616. private _softwareSkinnedMeshes;
  33617. private _renderingManager;
  33618. /** @hidden */
  33619. _activeAnimatables: Animatable[];
  33620. private _transformMatrix;
  33621. private _sceneUbo;
  33622. /** @hidden */
  33623. _viewMatrix: Matrix;
  33624. private _projectionMatrix;
  33625. /** @hidden */
  33626. _forcedViewPosition: Nullable<Vector3>;
  33627. /** @hidden */
  33628. _frustumPlanes: Plane[];
  33629. /**
  33630. * Gets the list of frustum planes (built from the active camera)
  33631. */
  33632. readonly frustumPlanes: Plane[];
  33633. /**
  33634. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33635. * This is useful if there are more lights that the maximum simulteanous authorized
  33636. */
  33637. requireLightSorting: boolean;
  33638. /** @hidden */
  33639. readonly useMaterialMeshMap: boolean;
  33640. /** @hidden */
  33641. readonly useClonedMeshhMap: boolean;
  33642. private _externalData;
  33643. private _uid;
  33644. /**
  33645. * @hidden
  33646. * Backing store of defined scene components.
  33647. */
  33648. _components: ISceneComponent[];
  33649. /**
  33650. * @hidden
  33651. * Backing store of defined scene components.
  33652. */
  33653. _serializableComponents: ISceneSerializableComponent[];
  33654. /**
  33655. * List of components to register on the next registration step.
  33656. */
  33657. private _transientComponents;
  33658. /**
  33659. * Registers the transient components if needed.
  33660. */
  33661. private _registerTransientComponents;
  33662. /**
  33663. * @hidden
  33664. * Add a component to the scene.
  33665. * Note that the ccomponent could be registered on th next frame if this is called after
  33666. * the register component stage.
  33667. * @param component Defines the component to add to the scene
  33668. */
  33669. _addComponent(component: ISceneComponent): void;
  33670. /**
  33671. * @hidden
  33672. * Gets a component from the scene.
  33673. * @param name defines the name of the component to retrieve
  33674. * @returns the component or null if not present
  33675. */
  33676. _getComponent(name: string): Nullable<ISceneComponent>;
  33677. /**
  33678. * @hidden
  33679. * Defines the actions happening before camera updates.
  33680. */
  33681. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33682. /**
  33683. * @hidden
  33684. * Defines the actions happening before clear the canvas.
  33685. */
  33686. _beforeClearStage: Stage<SimpleStageAction>;
  33687. /**
  33688. * @hidden
  33689. * Defines the actions when collecting render targets for the frame.
  33690. */
  33691. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33692. /**
  33693. * @hidden
  33694. * Defines the actions happening for one camera in the frame.
  33695. */
  33696. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33697. /**
  33698. * @hidden
  33699. * Defines the actions happening during the per mesh ready checks.
  33700. */
  33701. _isReadyForMeshStage: Stage<MeshStageAction>;
  33702. /**
  33703. * @hidden
  33704. * Defines the actions happening before evaluate active mesh checks.
  33705. */
  33706. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33707. /**
  33708. * @hidden
  33709. * Defines the actions happening during the evaluate sub mesh checks.
  33710. */
  33711. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33712. /**
  33713. * @hidden
  33714. * Defines the actions happening during the active mesh stage.
  33715. */
  33716. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33717. /**
  33718. * @hidden
  33719. * Defines the actions happening during the per camera render target step.
  33720. */
  33721. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33722. /**
  33723. * @hidden
  33724. * Defines the actions happening just before the active camera is drawing.
  33725. */
  33726. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33727. /**
  33728. * @hidden
  33729. * Defines the actions happening just before a render target is drawing.
  33730. */
  33731. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33732. /**
  33733. * @hidden
  33734. * Defines the actions happening just before a rendering group is drawing.
  33735. */
  33736. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33737. /**
  33738. * @hidden
  33739. * Defines the actions happening just before a mesh is drawing.
  33740. */
  33741. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33742. /**
  33743. * @hidden
  33744. * Defines the actions happening just after a mesh has been drawn.
  33745. */
  33746. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33747. /**
  33748. * @hidden
  33749. * Defines the actions happening just after a rendering group has been drawn.
  33750. */
  33751. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33752. /**
  33753. * @hidden
  33754. * Defines the actions happening just after the active camera has been drawn.
  33755. */
  33756. _afterCameraDrawStage: Stage<CameraStageAction>;
  33757. /**
  33758. * @hidden
  33759. * Defines the actions happening just after a render target has been drawn.
  33760. */
  33761. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33762. /**
  33763. * @hidden
  33764. * Defines the actions happening just after rendering all cameras and computing intersections.
  33765. */
  33766. _afterRenderStage: Stage<SimpleStageAction>;
  33767. /**
  33768. * @hidden
  33769. * Defines the actions happening when a pointer move event happens.
  33770. */
  33771. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33772. /**
  33773. * @hidden
  33774. * Defines the actions happening when a pointer down event happens.
  33775. */
  33776. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33777. /**
  33778. * @hidden
  33779. * Defines the actions happening when a pointer up event happens.
  33780. */
  33781. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33782. /**
  33783. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33784. */
  33785. private geometriesByUniqueId;
  33786. /**
  33787. * Creates a new Scene
  33788. * @param engine defines the engine to use to render this scene
  33789. * @param options defines the scene options
  33790. */
  33791. constructor(engine: Engine, options?: SceneOptions);
  33792. /**
  33793. * Gets a string idenfifying the name of the class
  33794. * @returns "Scene" string
  33795. */
  33796. getClassName(): string;
  33797. private _defaultMeshCandidates;
  33798. /**
  33799. * @hidden
  33800. */
  33801. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33802. private _defaultSubMeshCandidates;
  33803. /**
  33804. * @hidden
  33805. */
  33806. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33807. /**
  33808. * Sets the default candidate providers for the scene.
  33809. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33810. * and getCollidingSubMeshCandidates to their default function
  33811. */
  33812. setDefaultCandidateProviders(): void;
  33813. /**
  33814. * Gets the mesh that is currently under the pointer
  33815. */
  33816. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33817. /**
  33818. * Gets or sets the current on-screen X position of the pointer
  33819. */
  33820. pointerX: number;
  33821. /**
  33822. * Gets or sets the current on-screen Y position of the pointer
  33823. */
  33824. pointerY: number;
  33825. /**
  33826. * Gets the cached material (ie. the latest rendered one)
  33827. * @returns the cached material
  33828. */
  33829. getCachedMaterial(): Nullable<Material>;
  33830. /**
  33831. * Gets the cached effect (ie. the latest rendered one)
  33832. * @returns the cached effect
  33833. */
  33834. getCachedEffect(): Nullable<Effect>;
  33835. /**
  33836. * Gets the cached visibility state (ie. the latest rendered one)
  33837. * @returns the cached visibility state
  33838. */
  33839. getCachedVisibility(): Nullable<number>;
  33840. /**
  33841. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33842. * @param material defines the current material
  33843. * @param effect defines the current effect
  33844. * @param visibility defines the current visibility state
  33845. * @returns true if one parameter is not cached
  33846. */
  33847. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33848. /**
  33849. * Gets the engine associated with the scene
  33850. * @returns an Engine
  33851. */
  33852. getEngine(): Engine;
  33853. /**
  33854. * Gets the total number of vertices rendered per frame
  33855. * @returns the total number of vertices rendered per frame
  33856. */
  33857. getTotalVertices(): number;
  33858. /**
  33859. * Gets the performance counter for total vertices
  33860. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33861. */
  33862. readonly totalVerticesPerfCounter: PerfCounter;
  33863. /**
  33864. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33865. * @returns the total number of active indices rendered per frame
  33866. */
  33867. getActiveIndices(): number;
  33868. /**
  33869. * Gets the performance counter for active indices
  33870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33871. */
  33872. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33873. /**
  33874. * Gets the total number of active particles rendered per frame
  33875. * @returns the total number of active particles rendered per frame
  33876. */
  33877. getActiveParticles(): number;
  33878. /**
  33879. * Gets the performance counter for active particles
  33880. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33881. */
  33882. readonly activeParticlesPerfCounter: PerfCounter;
  33883. /**
  33884. * Gets the total number of active bones rendered per frame
  33885. * @returns the total number of active bones rendered per frame
  33886. */
  33887. getActiveBones(): number;
  33888. /**
  33889. * Gets the performance counter for active bones
  33890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33891. */
  33892. readonly activeBonesPerfCounter: PerfCounter;
  33893. /**
  33894. * Gets the array of active meshes
  33895. * @returns an array of AbstractMesh
  33896. */
  33897. getActiveMeshes(): SmartArray<AbstractMesh>;
  33898. /**
  33899. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33900. * @returns a number
  33901. */
  33902. getAnimationRatio(): number;
  33903. /**
  33904. * Gets an unique Id for the current render phase
  33905. * @returns a number
  33906. */
  33907. getRenderId(): number;
  33908. /**
  33909. * Gets an unique Id for the current frame
  33910. * @returns a number
  33911. */
  33912. getFrameId(): number;
  33913. /** Call this function if you want to manually increment the render Id*/
  33914. incrementRenderId(): void;
  33915. private _createUbo;
  33916. /**
  33917. * Use this method to simulate a pointer move on a mesh
  33918. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33919. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33920. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33921. * @returns the current scene
  33922. */
  33923. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33924. /**
  33925. * Use this method to simulate a pointer down on a mesh
  33926. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33927. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33928. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33929. * @returns the current scene
  33930. */
  33931. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33932. /**
  33933. * Use this method to simulate a pointer up on a mesh
  33934. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33935. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33936. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33937. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33938. * @returns the current scene
  33939. */
  33940. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33941. /**
  33942. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33943. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33944. * @returns true if the pointer was captured
  33945. */
  33946. isPointerCaptured(pointerId?: number): boolean;
  33947. /**
  33948. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33949. * @param attachUp defines if you want to attach events to pointerup
  33950. * @param attachDown defines if you want to attach events to pointerdown
  33951. * @param attachMove defines if you want to attach events to pointermove
  33952. */
  33953. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33954. /** Detaches all event handlers*/
  33955. detachControl(): void;
  33956. /**
  33957. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33958. * Delay loaded resources are not taking in account
  33959. * @return true if all required resources are ready
  33960. */
  33961. isReady(): boolean;
  33962. /** Resets all cached information relative to material (including effect and visibility) */
  33963. resetCachedMaterial(): void;
  33964. /**
  33965. * Registers a function to be called before every frame render
  33966. * @param func defines the function to register
  33967. */
  33968. registerBeforeRender(func: () => void): void;
  33969. /**
  33970. * Unregisters a function called before every frame render
  33971. * @param func defines the function to unregister
  33972. */
  33973. unregisterBeforeRender(func: () => void): void;
  33974. /**
  33975. * Registers a function to be called after every frame render
  33976. * @param func defines the function to register
  33977. */
  33978. registerAfterRender(func: () => void): void;
  33979. /**
  33980. * Unregisters a function called after every frame render
  33981. * @param func defines the function to unregister
  33982. */
  33983. unregisterAfterRender(func: () => void): void;
  33984. private _executeOnceBeforeRender;
  33985. /**
  33986. * The provided function will run before render once and will be disposed afterwards.
  33987. * A timeout delay can be provided so that the function will be executed in N ms.
  33988. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33989. * @param func The function to be executed.
  33990. * @param timeout optional delay in ms
  33991. */
  33992. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33993. /** @hidden */
  33994. _addPendingData(data: any): void;
  33995. /** @hidden */
  33996. _removePendingData(data: any): void;
  33997. /**
  33998. * Returns the number of items waiting to be loaded
  33999. * @returns the number of items waiting to be loaded
  34000. */
  34001. getWaitingItemsCount(): number;
  34002. /**
  34003. * Returns a boolean indicating if the scene is still loading data
  34004. */
  34005. readonly isLoading: boolean;
  34006. /**
  34007. * Registers a function to be executed when the scene is ready
  34008. * @param {Function} func - the function to be executed
  34009. */
  34010. executeWhenReady(func: () => void): void;
  34011. /**
  34012. * Returns a promise that resolves when the scene is ready
  34013. * @returns A promise that resolves when the scene is ready
  34014. */
  34015. whenReadyAsync(): Promise<void>;
  34016. /** @hidden */
  34017. _checkIsReady(): void;
  34018. /**
  34019. * Gets all animatable attached to the scene
  34020. */
  34021. readonly animatables: Animatable[];
  34022. /**
  34023. * Resets the last animation time frame.
  34024. * Useful to override when animations start running when loading a scene for the first time.
  34025. */
  34026. resetLastAnimationTimeFrame(): void;
  34027. /**
  34028. * Gets the current view matrix
  34029. * @returns a Matrix
  34030. */
  34031. getViewMatrix(): Matrix;
  34032. /**
  34033. * Gets the current projection matrix
  34034. * @returns a Matrix
  34035. */
  34036. getProjectionMatrix(): Matrix;
  34037. /**
  34038. * Gets the current transform matrix
  34039. * @returns a Matrix made of View * Projection
  34040. */
  34041. getTransformMatrix(): Matrix;
  34042. /**
  34043. * Sets the current transform matrix
  34044. * @param viewL defines the View matrix to use
  34045. * @param projectionL defines the Projection matrix to use
  34046. * @param viewR defines the right View matrix to use (if provided)
  34047. * @param projectionR defines the right Projection matrix to use (if provided)
  34048. */
  34049. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34050. /**
  34051. * Gets the uniform buffer used to store scene data
  34052. * @returns a UniformBuffer
  34053. */
  34054. getSceneUniformBuffer(): UniformBuffer;
  34055. /**
  34056. * Gets an unique (relatively to the current scene) Id
  34057. * @returns an unique number for the scene
  34058. */
  34059. getUniqueId(): number;
  34060. /**
  34061. * Add a mesh to the list of scene's meshes
  34062. * @param newMesh defines the mesh to add
  34063. * @param recursive if all child meshes should also be added to the scene
  34064. */
  34065. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34066. /**
  34067. * Remove a mesh for the list of scene's meshes
  34068. * @param toRemove defines the mesh to remove
  34069. * @param recursive if all child meshes should also be removed from the scene
  34070. * @returns the index where the mesh was in the mesh list
  34071. */
  34072. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34073. /**
  34074. * Add a transform node to the list of scene's transform nodes
  34075. * @param newTransformNode defines the transform node to add
  34076. */
  34077. addTransformNode(newTransformNode: TransformNode): void;
  34078. /**
  34079. * Remove a transform node for the list of scene's transform nodes
  34080. * @param toRemove defines the transform node to remove
  34081. * @returns the index where the transform node was in the transform node list
  34082. */
  34083. removeTransformNode(toRemove: TransformNode): number;
  34084. /**
  34085. * Remove a skeleton for the list of scene's skeletons
  34086. * @param toRemove defines the skeleton to remove
  34087. * @returns the index where the skeleton was in the skeleton list
  34088. */
  34089. removeSkeleton(toRemove: Skeleton): number;
  34090. /**
  34091. * Remove a morph target for the list of scene's morph targets
  34092. * @param toRemove defines the morph target to remove
  34093. * @returns the index where the morph target was in the morph target list
  34094. */
  34095. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34096. /**
  34097. * Remove a light for the list of scene's lights
  34098. * @param toRemove defines the light to remove
  34099. * @returns the index where the light was in the light list
  34100. */
  34101. removeLight(toRemove: Light): number;
  34102. /**
  34103. * Remove a camera for the list of scene's cameras
  34104. * @param toRemove defines the camera to remove
  34105. * @returns the index where the camera was in the camera list
  34106. */
  34107. removeCamera(toRemove: Camera): number;
  34108. /**
  34109. * Remove a particle system for the list of scene's particle systems
  34110. * @param toRemove defines the particle system to remove
  34111. * @returns the index where the particle system was in the particle system list
  34112. */
  34113. removeParticleSystem(toRemove: IParticleSystem): number;
  34114. /**
  34115. * Remove a animation for the list of scene's animations
  34116. * @param toRemove defines the animation to remove
  34117. * @returns the index where the animation was in the animation list
  34118. */
  34119. removeAnimation(toRemove: Animation): number;
  34120. /**
  34121. * Will stop the animation of the given target
  34122. * @param target - the target
  34123. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34124. * @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)
  34125. */
  34126. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34127. /**
  34128. * Removes the given animation group from this scene.
  34129. * @param toRemove The animation group to remove
  34130. * @returns The index of the removed animation group
  34131. */
  34132. removeAnimationGroup(toRemove: AnimationGroup): number;
  34133. /**
  34134. * Removes the given multi-material from this scene.
  34135. * @param toRemove The multi-material to remove
  34136. * @returns The index of the removed multi-material
  34137. */
  34138. removeMultiMaterial(toRemove: MultiMaterial): number;
  34139. /**
  34140. * Removes the given material from this scene.
  34141. * @param toRemove The material to remove
  34142. * @returns The index of the removed material
  34143. */
  34144. removeMaterial(toRemove: Material): number;
  34145. /**
  34146. * Removes the given action manager from this scene.
  34147. * @param toRemove The action manager to remove
  34148. * @returns The index of the removed action manager
  34149. */
  34150. removeActionManager(toRemove: AbstractActionManager): number;
  34151. /**
  34152. * Removes the given texture from this scene.
  34153. * @param toRemove The texture to remove
  34154. * @returns The index of the removed texture
  34155. */
  34156. removeTexture(toRemove: BaseTexture): number;
  34157. /**
  34158. * Adds the given light to this scene
  34159. * @param newLight The light to add
  34160. */
  34161. addLight(newLight: Light): void;
  34162. /**
  34163. * Sorts the list list based on light priorities
  34164. */
  34165. sortLightsByPriority(): void;
  34166. /**
  34167. * Adds the given camera to this scene
  34168. * @param newCamera The camera to add
  34169. */
  34170. addCamera(newCamera: Camera): void;
  34171. /**
  34172. * Adds the given skeleton to this scene
  34173. * @param newSkeleton The skeleton to add
  34174. */
  34175. addSkeleton(newSkeleton: Skeleton): void;
  34176. /**
  34177. * Adds the given particle system to this scene
  34178. * @param newParticleSystem The particle system to add
  34179. */
  34180. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34181. /**
  34182. * Adds the given animation to this scene
  34183. * @param newAnimation The animation to add
  34184. */
  34185. addAnimation(newAnimation: Animation): void;
  34186. /**
  34187. * Adds the given animation group to this scene.
  34188. * @param newAnimationGroup The animation group to add
  34189. */
  34190. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34191. /**
  34192. * Adds the given multi-material to this scene
  34193. * @param newMultiMaterial The multi-material to add
  34194. */
  34195. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34196. /**
  34197. * Adds the given material to this scene
  34198. * @param newMaterial The material to add
  34199. */
  34200. addMaterial(newMaterial: Material): void;
  34201. /**
  34202. * Adds the given morph target to this scene
  34203. * @param newMorphTargetManager The morph target to add
  34204. */
  34205. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34206. /**
  34207. * Adds the given geometry to this scene
  34208. * @param newGeometry The geometry to add
  34209. */
  34210. addGeometry(newGeometry: Geometry): void;
  34211. /**
  34212. * Adds the given action manager to this scene
  34213. * @param newActionManager The action manager to add
  34214. */
  34215. addActionManager(newActionManager: AbstractActionManager): void;
  34216. /**
  34217. * Adds the given texture to this scene.
  34218. * @param newTexture The texture to add
  34219. */
  34220. addTexture(newTexture: BaseTexture): void;
  34221. /**
  34222. * Switch active camera
  34223. * @param newCamera defines the new active camera
  34224. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34225. */
  34226. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34227. /**
  34228. * sets the active camera of the scene using its ID
  34229. * @param id defines the camera's ID
  34230. * @return the new active camera or null if none found.
  34231. */
  34232. setActiveCameraByID(id: string): Nullable<Camera>;
  34233. /**
  34234. * sets the active camera of the scene using its name
  34235. * @param name defines the camera's name
  34236. * @returns the new active camera or null if none found.
  34237. */
  34238. setActiveCameraByName(name: string): Nullable<Camera>;
  34239. /**
  34240. * get an animation group using its name
  34241. * @param name defines the material's name
  34242. * @return the animation group or null if none found.
  34243. */
  34244. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34245. /**
  34246. * Get a material using its unique id
  34247. * @param uniqueId defines the material's unique id
  34248. * @return the material or null if none found.
  34249. */
  34250. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34251. /**
  34252. * get a material using its id
  34253. * @param id defines the material's ID
  34254. * @return the material or null if none found.
  34255. */
  34256. getMaterialByID(id: string): Nullable<Material>;
  34257. /**
  34258. * Gets a the last added material using a given id
  34259. * @param id defines the material's ID
  34260. * @return the last material with the given id or null if none found.
  34261. */
  34262. getLastMaterialByID(id: string): Nullable<Material>;
  34263. /**
  34264. * Gets a material using its name
  34265. * @param name defines the material's name
  34266. * @return the material or null if none found.
  34267. */
  34268. getMaterialByName(name: string): Nullable<Material>;
  34269. /**
  34270. * Get a texture using its unique id
  34271. * @param uniqueId defines the texture's unique id
  34272. * @return the texture or null if none found.
  34273. */
  34274. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34275. /**
  34276. * Gets a camera using its id
  34277. * @param id defines the id to look for
  34278. * @returns the camera or null if not found
  34279. */
  34280. getCameraByID(id: string): Nullable<Camera>;
  34281. /**
  34282. * Gets a camera using its unique id
  34283. * @param uniqueId defines the unique id to look for
  34284. * @returns the camera or null if not found
  34285. */
  34286. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34287. /**
  34288. * Gets a camera using its name
  34289. * @param name defines the camera's name
  34290. * @return the camera or null if none found.
  34291. */
  34292. getCameraByName(name: string): Nullable<Camera>;
  34293. /**
  34294. * Gets a bone using its id
  34295. * @param id defines the bone's id
  34296. * @return the bone or null if not found
  34297. */
  34298. getBoneByID(id: string): Nullable<Bone>;
  34299. /**
  34300. * Gets a bone using its id
  34301. * @param name defines the bone's name
  34302. * @return the bone or null if not found
  34303. */
  34304. getBoneByName(name: string): Nullable<Bone>;
  34305. /**
  34306. * Gets a light node using its name
  34307. * @param name defines the the light's name
  34308. * @return the light or null if none found.
  34309. */
  34310. getLightByName(name: string): Nullable<Light>;
  34311. /**
  34312. * Gets a light node using its id
  34313. * @param id defines the light's id
  34314. * @return the light or null if none found.
  34315. */
  34316. getLightByID(id: string): Nullable<Light>;
  34317. /**
  34318. * Gets a light node using its scene-generated unique ID
  34319. * @param uniqueId defines the light's unique id
  34320. * @return the light or null if none found.
  34321. */
  34322. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34323. /**
  34324. * Gets a particle system by id
  34325. * @param id defines the particle system id
  34326. * @return the corresponding system or null if none found
  34327. */
  34328. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34329. /**
  34330. * Gets a geometry using its ID
  34331. * @param id defines the geometry's id
  34332. * @return the geometry or null if none found.
  34333. */
  34334. getGeometryByID(id: string): Nullable<Geometry>;
  34335. private _getGeometryByUniqueID;
  34336. /**
  34337. * Add a new geometry to this scene
  34338. * @param geometry defines the geometry to be added to the scene.
  34339. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34340. * @return a boolean defining if the geometry was added or not
  34341. */
  34342. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34343. /**
  34344. * Removes an existing geometry
  34345. * @param geometry defines the geometry to be removed from the scene
  34346. * @return a boolean defining if the geometry was removed or not
  34347. */
  34348. removeGeometry(geometry: Geometry): boolean;
  34349. /**
  34350. * Gets the list of geometries attached to the scene
  34351. * @returns an array of Geometry
  34352. */
  34353. getGeometries(): Geometry[];
  34354. /**
  34355. * Gets the first added mesh found of a given ID
  34356. * @param id defines the id to search for
  34357. * @return the mesh found or null if not found at all
  34358. */
  34359. getMeshByID(id: string): Nullable<AbstractMesh>;
  34360. /**
  34361. * Gets a list of meshes using their id
  34362. * @param id defines the id to search for
  34363. * @returns a list of meshes
  34364. */
  34365. getMeshesByID(id: string): Array<AbstractMesh>;
  34366. /**
  34367. * Gets the first added transform node found of a given ID
  34368. * @param id defines the id to search for
  34369. * @return the found transform node or null if not found at all.
  34370. */
  34371. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34372. /**
  34373. * Gets a transform node with its auto-generated unique id
  34374. * @param uniqueId efines the unique id to search for
  34375. * @return the found transform node or null if not found at all.
  34376. */
  34377. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34378. /**
  34379. * Gets a list of transform nodes using their id
  34380. * @param id defines the id to search for
  34381. * @returns a list of transform nodes
  34382. */
  34383. getTransformNodesByID(id: string): Array<TransformNode>;
  34384. /**
  34385. * Gets a mesh with its auto-generated unique id
  34386. * @param uniqueId defines the unique id to search for
  34387. * @return the found mesh or null if not found at all.
  34388. */
  34389. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34390. /**
  34391. * Gets a the last added mesh using a given id
  34392. * @param id defines the id to search for
  34393. * @return the found mesh or null if not found at all.
  34394. */
  34395. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34396. /**
  34397. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34398. * @param id defines the id to search for
  34399. * @return the found node or null if not found at all
  34400. */
  34401. getLastEntryByID(id: string): Nullable<Node>;
  34402. /**
  34403. * Gets a node (Mesh, Camera, Light) using a given id
  34404. * @param id defines the id to search for
  34405. * @return the found node or null if not found at all
  34406. */
  34407. getNodeByID(id: string): Nullable<Node>;
  34408. /**
  34409. * Gets a node (Mesh, Camera, Light) using a given name
  34410. * @param name defines the name to search for
  34411. * @return the found node or null if not found at all.
  34412. */
  34413. getNodeByName(name: string): Nullable<Node>;
  34414. /**
  34415. * Gets a mesh using a given name
  34416. * @param name defines the name to search for
  34417. * @return the found mesh or null if not found at all.
  34418. */
  34419. getMeshByName(name: string): Nullable<AbstractMesh>;
  34420. /**
  34421. * Gets a transform node using a given name
  34422. * @param name defines the name to search for
  34423. * @return the found transform node or null if not found at all.
  34424. */
  34425. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34426. /**
  34427. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34428. * @param id defines the id to search for
  34429. * @return the found skeleton or null if not found at all.
  34430. */
  34431. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34432. /**
  34433. * Gets a skeleton using a given auto generated unique id
  34434. * @param uniqueId defines the unique id to search for
  34435. * @return the found skeleton or null if not found at all.
  34436. */
  34437. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34438. /**
  34439. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34440. * @param id defines the id to search for
  34441. * @return the found skeleton or null if not found at all.
  34442. */
  34443. getSkeletonById(id: string): Nullable<Skeleton>;
  34444. /**
  34445. * Gets a skeleton using a given name
  34446. * @param name defines the name to search for
  34447. * @return the found skeleton or null if not found at all.
  34448. */
  34449. getSkeletonByName(name: string): Nullable<Skeleton>;
  34450. /**
  34451. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34452. * @param id defines the id to search for
  34453. * @return the found morph target manager or null if not found at all.
  34454. */
  34455. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34456. /**
  34457. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34458. * @param id defines the id to search for
  34459. * @return the found morph target or null if not found at all.
  34460. */
  34461. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34462. /**
  34463. * Gets a boolean indicating if the given mesh is active
  34464. * @param mesh defines the mesh to look for
  34465. * @returns true if the mesh is in the active list
  34466. */
  34467. isActiveMesh(mesh: AbstractMesh): boolean;
  34468. /**
  34469. * Return a unique id as a string which can serve as an identifier for the scene
  34470. */
  34471. readonly uid: string;
  34472. /**
  34473. * Add an externaly attached data from its key.
  34474. * This method call will fail and return false, if such key already exists.
  34475. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34476. * @param key the unique key that identifies the data
  34477. * @param data the data object to associate to the key for this Engine instance
  34478. * @return true if no such key were already present and the data was added successfully, false otherwise
  34479. */
  34480. addExternalData<T>(key: string, data: T): boolean;
  34481. /**
  34482. * Get an externaly attached data from its key
  34483. * @param key the unique key that identifies the data
  34484. * @return the associated data, if present (can be null), or undefined if not present
  34485. */
  34486. getExternalData<T>(key: string): Nullable<T>;
  34487. /**
  34488. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34489. * @param key the unique key that identifies the data
  34490. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34491. * @return the associated data, can be null if the factory returned null.
  34492. */
  34493. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34494. /**
  34495. * Remove an externaly attached data from the Engine instance
  34496. * @param key the unique key that identifies the data
  34497. * @return true if the data was successfully removed, false if it doesn't exist
  34498. */
  34499. removeExternalData(key: string): boolean;
  34500. private _evaluateSubMesh;
  34501. /**
  34502. * Clear the processed materials smart array preventing retention point in material dispose.
  34503. */
  34504. freeProcessedMaterials(): void;
  34505. private _preventFreeActiveMeshesAndRenderingGroups;
  34506. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34507. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34508. * when disposing several meshes in a row or a hierarchy of meshes.
  34509. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34510. */
  34511. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34512. /**
  34513. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34514. */
  34515. freeActiveMeshes(): void;
  34516. /**
  34517. * Clear the info related to rendering groups preventing retention points during dispose.
  34518. */
  34519. freeRenderingGroups(): void;
  34520. /** @hidden */
  34521. _isInIntermediateRendering(): boolean;
  34522. /**
  34523. * Lambda returning the list of potentially active meshes.
  34524. */
  34525. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34526. /**
  34527. * Lambda returning the list of potentially active sub meshes.
  34528. */
  34529. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34530. /**
  34531. * Lambda returning the list of potentially intersecting sub meshes.
  34532. */
  34533. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34534. /**
  34535. * Lambda returning the list of potentially colliding sub meshes.
  34536. */
  34537. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34538. private _activeMeshesFrozen;
  34539. /**
  34540. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34541. * @returns the current scene
  34542. */
  34543. freezeActiveMeshes(): Scene;
  34544. /**
  34545. * Use this function to restart evaluating active meshes on every frame
  34546. * @returns the current scene
  34547. */
  34548. unfreezeActiveMeshes(): Scene;
  34549. private _evaluateActiveMeshes;
  34550. private _activeMesh;
  34551. /**
  34552. * Update the transform matrix to update from the current active camera
  34553. * @param force defines a boolean used to force the update even if cache is up to date
  34554. */
  34555. updateTransformMatrix(force?: boolean): void;
  34556. private _bindFrameBuffer;
  34557. /** @hidden */
  34558. _allowPostProcessClearColor: boolean;
  34559. /** @hidden */
  34560. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34561. private _processSubCameras;
  34562. private _checkIntersections;
  34563. /** @hidden */
  34564. _advancePhysicsEngineStep(step: number): void;
  34565. /**
  34566. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34567. */
  34568. getDeterministicFrameTime: () => number;
  34569. /** @hidden */
  34570. _animate(): void;
  34571. /** Execute all animations (for a frame) */
  34572. animate(): void;
  34573. /**
  34574. * Render the scene
  34575. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34576. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34577. */
  34578. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34579. /**
  34580. * Freeze all materials
  34581. * A frozen material will not be updatable but should be faster to render
  34582. */
  34583. freezeMaterials(): void;
  34584. /**
  34585. * Unfreeze all materials
  34586. * A frozen material will not be updatable but should be faster to render
  34587. */
  34588. unfreezeMaterials(): void;
  34589. /**
  34590. * Releases all held ressources
  34591. */
  34592. dispose(): void;
  34593. /**
  34594. * Gets if the scene is already disposed
  34595. */
  34596. readonly isDisposed: boolean;
  34597. /**
  34598. * Call this function to reduce memory footprint of the scene.
  34599. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34600. */
  34601. clearCachedVertexData(): void;
  34602. /**
  34603. * This function will remove the local cached buffer data from texture.
  34604. * It will save memory but will prevent the texture from being rebuilt
  34605. */
  34606. cleanCachedTextureBuffer(): void;
  34607. /**
  34608. * Get the world extend vectors with an optional filter
  34609. *
  34610. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34611. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34612. */
  34613. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34614. min: Vector3;
  34615. max: Vector3;
  34616. };
  34617. /**
  34618. * Creates a ray that can be used to pick in the scene
  34619. * @param x defines the x coordinate of the origin (on-screen)
  34620. * @param y defines the y coordinate of the origin (on-screen)
  34621. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34622. * @param camera defines the camera to use for the picking
  34623. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34624. * @returns a Ray
  34625. */
  34626. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34627. /**
  34628. * Creates a ray that can be used to pick in the scene
  34629. * @param x defines the x coordinate of the origin (on-screen)
  34630. * @param y defines the y coordinate of the origin (on-screen)
  34631. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34632. * @param result defines the ray where to store the picking ray
  34633. * @param camera defines the camera to use for the picking
  34634. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34635. * @returns the current scene
  34636. */
  34637. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34638. /**
  34639. * Creates a ray that can be used to pick in the scene
  34640. * @param x defines the x coordinate of the origin (on-screen)
  34641. * @param y defines the y coordinate of the origin (on-screen)
  34642. * @param camera defines the camera to use for the picking
  34643. * @returns a Ray
  34644. */
  34645. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34646. /**
  34647. * Creates a ray that can be used to pick in the scene
  34648. * @param x defines the x coordinate of the origin (on-screen)
  34649. * @param y defines the y coordinate of the origin (on-screen)
  34650. * @param result defines the ray where to store the picking ray
  34651. * @param camera defines the camera to use for the picking
  34652. * @returns the current scene
  34653. */
  34654. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34655. /** Launch a ray to try to pick a mesh in the scene
  34656. * @param x position on screen
  34657. * @param y position on screen
  34658. * @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
  34659. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34660. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34661. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34662. * @returns a PickingInfo
  34663. */
  34664. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34665. /** Use the given ray to pick a mesh in the scene
  34666. * @param ray The ray to use to pick meshes
  34667. * @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
  34668. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34669. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34670. * @returns a PickingInfo
  34671. */
  34672. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34673. /**
  34674. * Launch a ray to try to pick a mesh in the scene
  34675. * @param x X position on screen
  34676. * @param y Y position on screen
  34677. * @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
  34678. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34679. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34680. * @returns an array of PickingInfo
  34681. */
  34682. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34683. /**
  34684. * Launch a ray to try to pick a mesh in the scene
  34685. * @param ray Ray to use
  34686. * @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
  34687. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34688. * @returns an array of PickingInfo
  34689. */
  34690. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34691. /**
  34692. * Force the value of meshUnderPointer
  34693. * @param mesh defines the mesh to use
  34694. */
  34695. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34696. /**
  34697. * Gets the mesh under the pointer
  34698. * @returns a Mesh or null if no mesh is under the pointer
  34699. */
  34700. getPointerOverMesh(): Nullable<AbstractMesh>;
  34701. /** @hidden */
  34702. _rebuildGeometries(): void;
  34703. /** @hidden */
  34704. _rebuildTextures(): void;
  34705. private _getByTags;
  34706. /**
  34707. * Get a list of meshes by tags
  34708. * @param tagsQuery defines the tags query to use
  34709. * @param forEach defines a predicate used to filter results
  34710. * @returns an array of Mesh
  34711. */
  34712. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34713. /**
  34714. * Get a list of cameras by tags
  34715. * @param tagsQuery defines the tags query to use
  34716. * @param forEach defines a predicate used to filter results
  34717. * @returns an array of Camera
  34718. */
  34719. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34720. /**
  34721. * Get a list of lights by tags
  34722. * @param tagsQuery defines the tags query to use
  34723. * @param forEach defines a predicate used to filter results
  34724. * @returns an array of Light
  34725. */
  34726. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34727. /**
  34728. * Get a list of materials by tags
  34729. * @param tagsQuery defines the tags query to use
  34730. * @param forEach defines a predicate used to filter results
  34731. * @returns an array of Material
  34732. */
  34733. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34734. /**
  34735. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34736. * This allowed control for front to back rendering or reversly depending of the special needs.
  34737. *
  34738. * @param renderingGroupId The rendering group id corresponding to its index
  34739. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34740. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34741. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34742. */
  34743. 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;
  34744. /**
  34745. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34746. *
  34747. * @param renderingGroupId The rendering group id corresponding to its index
  34748. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34749. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34750. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34751. */
  34752. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34753. /**
  34754. * Gets the current auto clear configuration for one rendering group of the rendering
  34755. * manager.
  34756. * @param index the rendering group index to get the information for
  34757. * @returns The auto clear setup for the requested rendering group
  34758. */
  34759. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34760. private _blockMaterialDirtyMechanism;
  34761. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34762. blockMaterialDirtyMechanism: boolean;
  34763. /**
  34764. * Will flag all materials as dirty to trigger new shader compilation
  34765. * @param flag defines the flag used to specify which material part must be marked as dirty
  34766. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34767. */
  34768. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34769. /** @hidden */
  34770. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34771. /** @hidden */
  34772. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34773. }
  34774. }
  34775. declare module BABYLON {
  34776. /**
  34777. * Set of assets to keep when moving a scene into an asset container.
  34778. */
  34779. export class KeepAssets extends AbstractScene {
  34780. }
  34781. /**
  34782. * Container with a set of assets that can be added or removed from a scene.
  34783. */
  34784. export class AssetContainer extends AbstractScene {
  34785. /**
  34786. * The scene the AssetContainer belongs to.
  34787. */
  34788. scene: Scene;
  34789. /**
  34790. * Instantiates an AssetContainer.
  34791. * @param scene The scene the AssetContainer belongs to.
  34792. */
  34793. constructor(scene: Scene);
  34794. /**
  34795. * Adds all the assets from the container to the scene.
  34796. */
  34797. addAllToScene(): void;
  34798. /**
  34799. * Removes all the assets in the container from the scene
  34800. */
  34801. removeAllFromScene(): void;
  34802. /**
  34803. * Disposes all the assets in the container
  34804. */
  34805. dispose(): void;
  34806. private _moveAssets;
  34807. /**
  34808. * Removes all the assets contained in the scene and adds them to the container.
  34809. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34810. */
  34811. moveAllFromScene(keepAssets?: KeepAssets): void;
  34812. /**
  34813. * 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.
  34814. * @returns the root mesh
  34815. */
  34816. createRootMesh(): Mesh;
  34817. }
  34818. }
  34819. declare module BABYLON {
  34820. /**
  34821. * Defines how the parser contract is defined.
  34822. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34823. */
  34824. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34825. /**
  34826. * Defines how the individual parser contract is defined.
  34827. * These parser can parse an individual asset
  34828. */
  34829. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34830. /**
  34831. * Base class of the scene acting as a container for the different elements composing a scene.
  34832. * This class is dynamically extended by the different components of the scene increasing
  34833. * flexibility and reducing coupling
  34834. */
  34835. export abstract class AbstractScene {
  34836. /**
  34837. * Stores the list of available parsers in the application.
  34838. */
  34839. private static _BabylonFileParsers;
  34840. /**
  34841. * Stores the list of available individual parsers in the application.
  34842. */
  34843. private static _IndividualBabylonFileParsers;
  34844. /**
  34845. * Adds a parser in the list of available ones
  34846. * @param name Defines the name of the parser
  34847. * @param parser Defines the parser to add
  34848. */
  34849. static AddParser(name: string, parser: BabylonFileParser): void;
  34850. /**
  34851. * Gets a general parser from the list of avaialble ones
  34852. * @param name Defines the name of the parser
  34853. * @returns the requested parser or null
  34854. */
  34855. static GetParser(name: string): Nullable<BabylonFileParser>;
  34856. /**
  34857. * Adds n individual parser in the list of available ones
  34858. * @param name Defines the name of the parser
  34859. * @param parser Defines the parser to add
  34860. */
  34861. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34862. /**
  34863. * Gets an individual parser from the list of avaialble ones
  34864. * @param name Defines the name of the parser
  34865. * @returns the requested parser or null
  34866. */
  34867. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34868. /**
  34869. * Parser json data and populate both a scene and its associated container object
  34870. * @param jsonData Defines the data to parse
  34871. * @param scene Defines the scene to parse the data for
  34872. * @param container Defines the container attached to the parsing sequence
  34873. * @param rootUrl Defines the root url of the data
  34874. */
  34875. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34876. /**
  34877. * Gets the list of root nodes (ie. nodes with no parent)
  34878. */
  34879. rootNodes: Node[];
  34880. /** All of the cameras added to this scene
  34881. * @see http://doc.babylonjs.com/babylon101/cameras
  34882. */
  34883. cameras: Camera[];
  34884. /**
  34885. * All of the lights added to this scene
  34886. * @see http://doc.babylonjs.com/babylon101/lights
  34887. */
  34888. lights: Light[];
  34889. /**
  34890. * All of the (abstract) meshes added to this scene
  34891. */
  34892. meshes: AbstractMesh[];
  34893. /**
  34894. * The list of skeletons added to the scene
  34895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34896. */
  34897. skeletons: Skeleton[];
  34898. /**
  34899. * All of the particle systems added to this scene
  34900. * @see http://doc.babylonjs.com/babylon101/particles
  34901. */
  34902. particleSystems: IParticleSystem[];
  34903. /**
  34904. * Gets a list of Animations associated with the scene
  34905. */
  34906. animations: Animation[];
  34907. /**
  34908. * All of the animation groups added to this scene
  34909. * @see http://doc.babylonjs.com/how_to/group
  34910. */
  34911. animationGroups: AnimationGroup[];
  34912. /**
  34913. * All of the multi-materials added to this scene
  34914. * @see http://doc.babylonjs.com/how_to/multi_materials
  34915. */
  34916. multiMaterials: MultiMaterial[];
  34917. /**
  34918. * All of the materials added to this scene
  34919. * In the context of a Scene, it is not supposed to be modified manually.
  34920. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34921. * Note also that the order of the Material wihin the array is not significant and might change.
  34922. * @see http://doc.babylonjs.com/babylon101/materials
  34923. */
  34924. materials: Material[];
  34925. /**
  34926. * The list of morph target managers added to the scene
  34927. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34928. */
  34929. morphTargetManagers: MorphTargetManager[];
  34930. /**
  34931. * The list of geometries used in the scene.
  34932. */
  34933. geometries: Geometry[];
  34934. /**
  34935. * All of the tranform nodes added to this scene
  34936. * In the context of a Scene, it is not supposed to be modified manually.
  34937. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34938. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34939. * @see http://doc.babylonjs.com/how_to/transformnode
  34940. */
  34941. transformNodes: TransformNode[];
  34942. /**
  34943. * ActionManagers available on the scene.
  34944. */
  34945. actionManagers: AbstractActionManager[];
  34946. /**
  34947. * Textures to keep.
  34948. */
  34949. textures: BaseTexture[];
  34950. /**
  34951. * Environment texture for the scene
  34952. */
  34953. environmentTexture: Nullable<BaseTexture>;
  34954. }
  34955. }
  34956. declare module BABYLON {
  34957. /**
  34958. * Interface used to define options for Sound class
  34959. */
  34960. export interface ISoundOptions {
  34961. /**
  34962. * Does the sound autoplay once loaded.
  34963. */
  34964. autoplay?: boolean;
  34965. /**
  34966. * Does the sound loop after it finishes playing once.
  34967. */
  34968. loop?: boolean;
  34969. /**
  34970. * Sound's volume
  34971. */
  34972. volume?: number;
  34973. /**
  34974. * Is it a spatial sound?
  34975. */
  34976. spatialSound?: boolean;
  34977. /**
  34978. * Maximum distance to hear that sound
  34979. */
  34980. maxDistance?: number;
  34981. /**
  34982. * Uses user defined attenuation function
  34983. */
  34984. useCustomAttenuation?: boolean;
  34985. /**
  34986. * Define the roll off factor of spatial sounds.
  34987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34988. */
  34989. rolloffFactor?: number;
  34990. /**
  34991. * Define the reference distance the sound should be heard perfectly.
  34992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34993. */
  34994. refDistance?: number;
  34995. /**
  34996. * Define the distance attenuation model the sound will follow.
  34997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34998. */
  34999. distanceModel?: string;
  35000. /**
  35001. * Defines the playback speed (1 by default)
  35002. */
  35003. playbackRate?: number;
  35004. /**
  35005. * Defines if the sound is from a streaming source
  35006. */
  35007. streaming?: boolean;
  35008. /**
  35009. * Defines an optional length (in seconds) inside the sound file
  35010. */
  35011. length?: number;
  35012. /**
  35013. * Defines an optional offset (in seconds) inside the sound file
  35014. */
  35015. offset?: number;
  35016. /**
  35017. * If true, URLs will not be required to state the audio file codec to use.
  35018. */
  35019. skipCodecCheck?: boolean;
  35020. }
  35021. /**
  35022. * Defines a sound that can be played in the application.
  35023. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35025. */
  35026. export class Sound {
  35027. /**
  35028. * The name of the sound in the scene.
  35029. */
  35030. name: string;
  35031. /**
  35032. * Does the sound autoplay once loaded.
  35033. */
  35034. autoplay: boolean;
  35035. /**
  35036. * Does the sound loop after it finishes playing once.
  35037. */
  35038. loop: boolean;
  35039. /**
  35040. * Does the sound use a custom attenuation curve to simulate the falloff
  35041. * happening when the source gets further away from the camera.
  35042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35043. */
  35044. useCustomAttenuation: boolean;
  35045. /**
  35046. * The sound track id this sound belongs to.
  35047. */
  35048. soundTrackId: number;
  35049. /**
  35050. * Is this sound currently played.
  35051. */
  35052. isPlaying: boolean;
  35053. /**
  35054. * Is this sound currently paused.
  35055. */
  35056. isPaused: boolean;
  35057. /**
  35058. * Does this sound enables spatial sound.
  35059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35060. */
  35061. spatialSound: boolean;
  35062. /**
  35063. * Define the reference distance the sound should be heard perfectly.
  35064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35065. */
  35066. refDistance: number;
  35067. /**
  35068. * Define the roll off factor of spatial sounds.
  35069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35070. */
  35071. rolloffFactor: number;
  35072. /**
  35073. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35075. */
  35076. maxDistance: number;
  35077. /**
  35078. * Define the distance attenuation model the sound will follow.
  35079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35080. */
  35081. distanceModel: string;
  35082. /**
  35083. * @hidden
  35084. * Back Compat
  35085. **/
  35086. onended: () => any;
  35087. /**
  35088. * Observable event when the current playing sound finishes.
  35089. */
  35090. onEndedObservable: Observable<Sound>;
  35091. private _panningModel;
  35092. private _playbackRate;
  35093. private _streaming;
  35094. private _startTime;
  35095. private _startOffset;
  35096. private _position;
  35097. /** @hidden */
  35098. _positionInEmitterSpace: boolean;
  35099. private _localDirection;
  35100. private _volume;
  35101. private _isReadyToPlay;
  35102. private _isDirectional;
  35103. private _readyToPlayCallback;
  35104. private _audioBuffer;
  35105. private _soundSource;
  35106. private _streamingSource;
  35107. private _soundPanner;
  35108. private _soundGain;
  35109. private _inputAudioNode;
  35110. private _outputAudioNode;
  35111. private _coneInnerAngle;
  35112. private _coneOuterAngle;
  35113. private _coneOuterGain;
  35114. private _scene;
  35115. private _connectedTransformNode;
  35116. private _customAttenuationFunction;
  35117. private _registerFunc;
  35118. private _isOutputConnected;
  35119. private _htmlAudioElement;
  35120. private _urlType;
  35121. private _length?;
  35122. private _offset?;
  35123. /** @hidden */
  35124. static _SceneComponentInitialization: (scene: Scene) => void;
  35125. /**
  35126. * Create a sound and attach it to a scene
  35127. * @param name Name of your sound
  35128. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35129. * @param scene defines the scene the sound belongs to
  35130. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35131. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35132. */
  35133. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35134. /**
  35135. * Release the sound and its associated resources
  35136. */
  35137. dispose(): void;
  35138. /**
  35139. * Gets if the sounds is ready to be played or not.
  35140. * @returns true if ready, otherwise false
  35141. */
  35142. isReady(): boolean;
  35143. private _soundLoaded;
  35144. /**
  35145. * Sets the data of the sound from an audiobuffer
  35146. * @param audioBuffer The audioBuffer containing the data
  35147. */
  35148. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35149. /**
  35150. * Updates the current sounds options such as maxdistance, loop...
  35151. * @param options A JSON object containing values named as the object properties
  35152. */
  35153. updateOptions(options: ISoundOptions): void;
  35154. private _createSpatialParameters;
  35155. private _updateSpatialParameters;
  35156. /**
  35157. * Switch the panning model to HRTF:
  35158. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35160. */
  35161. switchPanningModelToHRTF(): void;
  35162. /**
  35163. * Switch the panning model to Equal Power:
  35164. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35166. */
  35167. switchPanningModelToEqualPower(): void;
  35168. private _switchPanningModel;
  35169. /**
  35170. * Connect this sound to a sound track audio node like gain...
  35171. * @param soundTrackAudioNode the sound track audio node to connect to
  35172. */
  35173. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35174. /**
  35175. * Transform this sound into a directional source
  35176. * @param coneInnerAngle Size of the inner cone in degree
  35177. * @param coneOuterAngle Size of the outer cone in degree
  35178. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35179. */
  35180. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35181. /**
  35182. * Gets or sets the inner angle for the directional cone.
  35183. */
  35184. /**
  35185. * Gets or sets the inner angle for the directional cone.
  35186. */
  35187. directionalConeInnerAngle: number;
  35188. /**
  35189. * Gets or sets the outer angle for the directional cone.
  35190. */
  35191. /**
  35192. * Gets or sets the outer angle for the directional cone.
  35193. */
  35194. directionalConeOuterAngle: number;
  35195. /**
  35196. * Sets the position of the emitter if spatial sound is enabled
  35197. * @param newPosition Defines the new posisiton
  35198. */
  35199. setPosition(newPosition: Vector3): void;
  35200. /**
  35201. * Sets the local direction of the emitter if spatial sound is enabled
  35202. * @param newLocalDirection Defines the new local direction
  35203. */
  35204. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35205. private _updateDirection;
  35206. /** @hidden */
  35207. updateDistanceFromListener(): void;
  35208. /**
  35209. * Sets a new custom attenuation function for the sound.
  35210. * @param callback Defines the function used for the attenuation
  35211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35212. */
  35213. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35214. /**
  35215. * Play the sound
  35216. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35217. * @param offset (optional) Start the sound at a specific time in seconds
  35218. * @param length (optional) Sound duration (in seconds)
  35219. */
  35220. play(time?: number, offset?: number, length?: number): void;
  35221. private _onended;
  35222. /**
  35223. * Stop the sound
  35224. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35225. */
  35226. stop(time?: number): void;
  35227. /**
  35228. * Put the sound in pause
  35229. */
  35230. pause(): void;
  35231. /**
  35232. * Sets a dedicated volume for this sounds
  35233. * @param newVolume Define the new volume of the sound
  35234. * @param time Define time for gradual change to new volume
  35235. */
  35236. setVolume(newVolume: number, time?: number): void;
  35237. /**
  35238. * Set the sound play back rate
  35239. * @param newPlaybackRate Define the playback rate the sound should be played at
  35240. */
  35241. setPlaybackRate(newPlaybackRate: number): void;
  35242. /**
  35243. * Gets the volume of the sound.
  35244. * @returns the volume of the sound
  35245. */
  35246. getVolume(): number;
  35247. /**
  35248. * Attach the sound to a dedicated mesh
  35249. * @param transformNode The transform node to connect the sound with
  35250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35251. */
  35252. attachToMesh(transformNode: TransformNode): void;
  35253. /**
  35254. * Detach the sound from the previously attached mesh
  35255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35256. */
  35257. detachFromMesh(): void;
  35258. private _onRegisterAfterWorldMatrixUpdate;
  35259. /**
  35260. * Clone the current sound in the scene.
  35261. * @returns the new sound clone
  35262. */
  35263. clone(): Nullable<Sound>;
  35264. /**
  35265. * Gets the current underlying audio buffer containing the data
  35266. * @returns the audio buffer
  35267. */
  35268. getAudioBuffer(): Nullable<AudioBuffer>;
  35269. /**
  35270. * Serializes the Sound in a JSON representation
  35271. * @returns the JSON representation of the sound
  35272. */
  35273. serialize(): any;
  35274. /**
  35275. * Parse a JSON representation of a sound to innstantiate in a given scene
  35276. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35277. * @param scene Define the scene the new parsed sound should be created in
  35278. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35279. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35280. * @returns the newly parsed sound
  35281. */
  35282. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35283. }
  35284. }
  35285. declare module BABYLON {
  35286. /**
  35287. * This defines an action helpful to play a defined sound on a triggered action.
  35288. */
  35289. export class PlaySoundAction extends Action {
  35290. private _sound;
  35291. /**
  35292. * Instantiate the action
  35293. * @param triggerOptions defines the trigger options
  35294. * @param sound defines the sound to play
  35295. * @param condition defines the trigger related conditions
  35296. */
  35297. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35298. /** @hidden */
  35299. _prepare(): void;
  35300. /**
  35301. * Execute the action and play the sound.
  35302. */
  35303. execute(): void;
  35304. /**
  35305. * Serializes the actions and its related information.
  35306. * @param parent defines the object to serialize in
  35307. * @returns the serialized object
  35308. */
  35309. serialize(parent: any): any;
  35310. }
  35311. /**
  35312. * This defines an action helpful to stop a defined sound on a triggered action.
  35313. */
  35314. export class StopSoundAction extends Action {
  35315. private _sound;
  35316. /**
  35317. * Instantiate the action
  35318. * @param triggerOptions defines the trigger options
  35319. * @param sound defines the sound to stop
  35320. * @param condition defines the trigger related conditions
  35321. */
  35322. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35323. /** @hidden */
  35324. _prepare(): void;
  35325. /**
  35326. * Execute the action and stop the sound.
  35327. */
  35328. execute(): void;
  35329. /**
  35330. * Serializes the actions and its related information.
  35331. * @param parent defines the object to serialize in
  35332. * @returns the serialized object
  35333. */
  35334. serialize(parent: any): any;
  35335. }
  35336. }
  35337. declare module BABYLON {
  35338. /**
  35339. * This defines an action responsible to change the value of a property
  35340. * by interpolating between its current value and the newly set one once triggered.
  35341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35342. */
  35343. export class InterpolateValueAction extends Action {
  35344. /**
  35345. * Defines the path of the property where the value should be interpolated
  35346. */
  35347. propertyPath: string;
  35348. /**
  35349. * Defines the target value at the end of the interpolation.
  35350. */
  35351. value: any;
  35352. /**
  35353. * Defines the time it will take for the property to interpolate to the value.
  35354. */
  35355. duration: number;
  35356. /**
  35357. * Defines if the other scene animations should be stopped when the action has been triggered
  35358. */
  35359. stopOtherAnimations?: boolean;
  35360. /**
  35361. * Defines a callback raised once the interpolation animation has been done.
  35362. */
  35363. onInterpolationDone?: () => void;
  35364. /**
  35365. * Observable triggered once the interpolation animation has been done.
  35366. */
  35367. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35368. private _target;
  35369. private _effectiveTarget;
  35370. private _property;
  35371. /**
  35372. * Instantiate the action
  35373. * @param triggerOptions defines the trigger options
  35374. * @param target defines the object containing the value to interpolate
  35375. * @param propertyPath defines the path to the property in the target object
  35376. * @param value defines the target value at the end of the interpolation
  35377. * @param duration deines the time it will take for the property to interpolate to the value.
  35378. * @param condition defines the trigger related conditions
  35379. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35380. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35381. */
  35382. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35383. /** @hidden */
  35384. _prepare(): void;
  35385. /**
  35386. * Execute the action starts the value interpolation.
  35387. */
  35388. execute(): void;
  35389. /**
  35390. * Serializes the actions and its related information.
  35391. * @param parent defines the object to serialize in
  35392. * @returns the serialized object
  35393. */
  35394. serialize(parent: any): any;
  35395. }
  35396. }
  35397. declare module BABYLON {
  35398. /**
  35399. * Options allowed during the creation of a sound track.
  35400. */
  35401. export interface ISoundTrackOptions {
  35402. /**
  35403. * The volume the sound track should take during creation
  35404. */
  35405. volume?: number;
  35406. /**
  35407. * Define if the sound track is the main sound track of the scene
  35408. */
  35409. mainTrack?: boolean;
  35410. }
  35411. /**
  35412. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35413. * It will be also used in a future release to apply effects on a specific track.
  35414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35415. */
  35416. export class SoundTrack {
  35417. /**
  35418. * The unique identifier of the sound track in the scene.
  35419. */
  35420. id: number;
  35421. /**
  35422. * The list of sounds included in the sound track.
  35423. */
  35424. soundCollection: Array<Sound>;
  35425. private _outputAudioNode;
  35426. private _scene;
  35427. private _isMainTrack;
  35428. private _connectedAnalyser;
  35429. private _options;
  35430. private _isInitialized;
  35431. /**
  35432. * Creates a new sound track.
  35433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35434. * @param scene Define the scene the sound track belongs to
  35435. * @param options
  35436. */
  35437. constructor(scene: Scene, options?: ISoundTrackOptions);
  35438. private _initializeSoundTrackAudioGraph;
  35439. /**
  35440. * Release the sound track and its associated resources
  35441. */
  35442. dispose(): void;
  35443. /**
  35444. * Adds a sound to this sound track
  35445. * @param sound define the cound to add
  35446. * @ignoreNaming
  35447. */
  35448. AddSound(sound: Sound): void;
  35449. /**
  35450. * Removes a sound to this sound track
  35451. * @param sound define the cound to remove
  35452. * @ignoreNaming
  35453. */
  35454. RemoveSound(sound: Sound): void;
  35455. /**
  35456. * Set a global volume for the full sound track.
  35457. * @param newVolume Define the new volume of the sound track
  35458. */
  35459. setVolume(newVolume: number): void;
  35460. /**
  35461. * Switch the panning model to HRTF:
  35462. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35464. */
  35465. switchPanningModelToHRTF(): void;
  35466. /**
  35467. * Switch the panning model to Equal Power:
  35468. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35470. */
  35471. switchPanningModelToEqualPower(): void;
  35472. /**
  35473. * Connect the sound track to an audio analyser allowing some amazing
  35474. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35476. * @param analyser The analyser to connect to the engine
  35477. */
  35478. connectToAnalyser(analyser: Analyser): void;
  35479. }
  35480. }
  35481. declare module BABYLON {
  35482. interface AbstractScene {
  35483. /**
  35484. * The list of sounds used in the scene.
  35485. */
  35486. sounds: Nullable<Array<Sound>>;
  35487. }
  35488. interface Scene {
  35489. /**
  35490. * @hidden
  35491. * Backing field
  35492. */
  35493. _mainSoundTrack: SoundTrack;
  35494. /**
  35495. * The main sound track played by the scene.
  35496. * It cotains your primary collection of sounds.
  35497. */
  35498. mainSoundTrack: SoundTrack;
  35499. /**
  35500. * The list of sound tracks added to the scene
  35501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35502. */
  35503. soundTracks: Nullable<Array<SoundTrack>>;
  35504. /**
  35505. * Gets a sound using a given name
  35506. * @param name defines the name to search for
  35507. * @return the found sound or null if not found at all.
  35508. */
  35509. getSoundByName(name: string): Nullable<Sound>;
  35510. /**
  35511. * Gets or sets if audio support is enabled
  35512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35513. */
  35514. audioEnabled: boolean;
  35515. /**
  35516. * Gets or sets if audio will be output to headphones
  35517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35518. */
  35519. headphone: boolean;
  35520. /**
  35521. * Gets or sets custom audio listener position provider
  35522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35523. */
  35524. audioListenerPositionProvider: Nullable<() => Vector3>;
  35525. }
  35526. /**
  35527. * Defines the sound scene component responsible to manage any sounds
  35528. * in a given scene.
  35529. */
  35530. export class AudioSceneComponent implements ISceneSerializableComponent {
  35531. /**
  35532. * The component name helpfull to identify the component in the list of scene components.
  35533. */
  35534. readonly name: string;
  35535. /**
  35536. * The scene the component belongs to.
  35537. */
  35538. scene: Scene;
  35539. private _audioEnabled;
  35540. /**
  35541. * Gets whether audio is enabled or not.
  35542. * Please use related enable/disable method to switch state.
  35543. */
  35544. readonly audioEnabled: boolean;
  35545. private _headphone;
  35546. /**
  35547. * Gets whether audio is outputing to headphone or not.
  35548. * Please use the according Switch methods to change output.
  35549. */
  35550. readonly headphone: boolean;
  35551. private _audioListenerPositionProvider;
  35552. /**
  35553. * Gets the current audio listener position provider
  35554. */
  35555. /**
  35556. * Sets a custom listener position for all sounds in the scene
  35557. * By default, this is the position of the first active camera
  35558. */
  35559. audioListenerPositionProvider: Nullable<() => Vector3>;
  35560. /**
  35561. * Creates a new instance of the component for the given scene
  35562. * @param scene Defines the scene to register the component in
  35563. */
  35564. constructor(scene: Scene);
  35565. /**
  35566. * Registers the component in a given scene
  35567. */
  35568. register(): void;
  35569. /**
  35570. * Rebuilds the elements related to this component in case of
  35571. * context lost for instance.
  35572. */
  35573. rebuild(): void;
  35574. /**
  35575. * Serializes the component data to the specified json object
  35576. * @param serializationObject The object to serialize to
  35577. */
  35578. serialize(serializationObject: any): void;
  35579. /**
  35580. * Adds all the elements from the container to the scene
  35581. * @param container the container holding the elements
  35582. */
  35583. addFromContainer(container: AbstractScene): void;
  35584. /**
  35585. * Removes all the elements in the container from the scene
  35586. * @param container contains the elements to remove
  35587. * @param dispose if the removed element should be disposed (default: false)
  35588. */
  35589. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35590. /**
  35591. * Disposes the component and the associated ressources.
  35592. */
  35593. dispose(): void;
  35594. /**
  35595. * Disables audio in the associated scene.
  35596. */
  35597. disableAudio(): void;
  35598. /**
  35599. * Enables audio in the associated scene.
  35600. */
  35601. enableAudio(): void;
  35602. /**
  35603. * Switch audio to headphone output.
  35604. */
  35605. switchAudioModeForHeadphones(): void;
  35606. /**
  35607. * Switch audio to normal speakers.
  35608. */
  35609. switchAudioModeForNormalSpeakers(): void;
  35610. private _afterRender;
  35611. }
  35612. }
  35613. declare module BABYLON {
  35614. /**
  35615. * Wraps one or more Sound objects and selects one with random weight for playback.
  35616. */
  35617. export class WeightedSound {
  35618. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35619. loop: boolean;
  35620. private _coneInnerAngle;
  35621. private _coneOuterAngle;
  35622. private _volume;
  35623. /** A Sound is currently playing. */
  35624. isPlaying: boolean;
  35625. /** A Sound is currently paused. */
  35626. isPaused: boolean;
  35627. private _sounds;
  35628. private _weights;
  35629. private _currentIndex?;
  35630. /**
  35631. * Creates a new WeightedSound from the list of sounds given.
  35632. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35633. * @param sounds Array of Sounds that will be selected from.
  35634. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35635. */
  35636. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35637. /**
  35638. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35639. */
  35640. /**
  35641. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35642. */
  35643. directionalConeInnerAngle: number;
  35644. /**
  35645. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35646. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35647. */
  35648. /**
  35649. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35650. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35651. */
  35652. directionalConeOuterAngle: number;
  35653. /**
  35654. * Playback volume.
  35655. */
  35656. /**
  35657. * Playback volume.
  35658. */
  35659. volume: number;
  35660. private _onended;
  35661. /**
  35662. * Suspend playback
  35663. */
  35664. pause(): void;
  35665. /**
  35666. * Stop playback
  35667. */
  35668. stop(): void;
  35669. /**
  35670. * Start playback.
  35671. * @param startOffset Position the clip head at a specific time in seconds.
  35672. */
  35673. play(startOffset?: number): void;
  35674. }
  35675. }
  35676. declare module BABYLON {
  35677. /**
  35678. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35680. */
  35681. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35682. /**
  35683. * Gets the name of the behavior.
  35684. */
  35685. readonly name: string;
  35686. /**
  35687. * The easing function used by animations
  35688. */
  35689. static EasingFunction: BackEase;
  35690. /**
  35691. * The easing mode used by animations
  35692. */
  35693. static EasingMode: number;
  35694. /**
  35695. * The duration of the animation, in milliseconds
  35696. */
  35697. transitionDuration: number;
  35698. /**
  35699. * Length of the distance animated by the transition when lower radius is reached
  35700. */
  35701. lowerRadiusTransitionRange: number;
  35702. /**
  35703. * Length of the distance animated by the transition when upper radius is reached
  35704. */
  35705. upperRadiusTransitionRange: number;
  35706. private _autoTransitionRange;
  35707. /**
  35708. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35709. */
  35710. /**
  35711. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35712. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35713. */
  35714. autoTransitionRange: boolean;
  35715. private _attachedCamera;
  35716. private _onAfterCheckInputsObserver;
  35717. private _onMeshTargetChangedObserver;
  35718. /**
  35719. * Initializes the behavior.
  35720. */
  35721. init(): void;
  35722. /**
  35723. * Attaches the behavior to its arc rotate camera.
  35724. * @param camera Defines the camera to attach the behavior to
  35725. */
  35726. attach(camera: ArcRotateCamera): void;
  35727. /**
  35728. * Detaches the behavior from its current arc rotate camera.
  35729. */
  35730. detach(): void;
  35731. private _radiusIsAnimating;
  35732. private _radiusBounceTransition;
  35733. private _animatables;
  35734. private _cachedWheelPrecision;
  35735. /**
  35736. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35737. * @param radiusLimit The limit to check against.
  35738. * @return Bool to indicate if at limit.
  35739. */
  35740. private _isRadiusAtLimit;
  35741. /**
  35742. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35743. * @param radiusDelta The delta by which to animate to. Can be negative.
  35744. */
  35745. private _applyBoundRadiusAnimation;
  35746. /**
  35747. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35748. */
  35749. protected _clearAnimationLocks(): void;
  35750. /**
  35751. * Stops and removes all animations that have been applied to the camera
  35752. */
  35753. stopAllAnimations(): void;
  35754. }
  35755. }
  35756. declare module BABYLON {
  35757. /**
  35758. * 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.
  35759. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35760. */
  35761. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35762. /**
  35763. * Gets the name of the behavior.
  35764. */
  35765. readonly name: string;
  35766. private _mode;
  35767. private _radiusScale;
  35768. private _positionScale;
  35769. private _defaultElevation;
  35770. private _elevationReturnTime;
  35771. private _elevationReturnWaitTime;
  35772. private _zoomStopsAnimation;
  35773. private _framingTime;
  35774. /**
  35775. * The easing function used by animations
  35776. */
  35777. static EasingFunction: ExponentialEase;
  35778. /**
  35779. * The easing mode used by animations
  35780. */
  35781. static EasingMode: number;
  35782. /**
  35783. * Sets the current mode used by the behavior
  35784. */
  35785. /**
  35786. * Gets current mode used by the behavior.
  35787. */
  35788. mode: number;
  35789. /**
  35790. * Sets the scale applied to the radius (1 by default)
  35791. */
  35792. /**
  35793. * Gets the scale applied to the radius
  35794. */
  35795. radiusScale: number;
  35796. /**
  35797. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35798. */
  35799. /**
  35800. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35801. */
  35802. positionScale: number;
  35803. /**
  35804. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35805. * behaviour is triggered, in radians.
  35806. */
  35807. /**
  35808. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35809. * behaviour is triggered, in radians.
  35810. */
  35811. defaultElevation: number;
  35812. /**
  35813. * Sets the time (in milliseconds) taken to return to the default beta position.
  35814. * Negative value indicates camera should not return to default.
  35815. */
  35816. /**
  35817. * Gets the time (in milliseconds) taken to return to the default beta position.
  35818. * Negative value indicates camera should not return to default.
  35819. */
  35820. elevationReturnTime: number;
  35821. /**
  35822. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35823. */
  35824. /**
  35825. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35826. */
  35827. elevationReturnWaitTime: number;
  35828. /**
  35829. * Sets the flag that indicates if user zooming should stop animation.
  35830. */
  35831. /**
  35832. * Gets the flag that indicates if user zooming should stop animation.
  35833. */
  35834. zoomStopsAnimation: boolean;
  35835. /**
  35836. * Sets the transition time when framing the mesh, in milliseconds
  35837. */
  35838. /**
  35839. * Gets the transition time when framing the mesh, in milliseconds
  35840. */
  35841. framingTime: number;
  35842. /**
  35843. * Define if the behavior should automatically change the configured
  35844. * camera limits and sensibilities.
  35845. */
  35846. autoCorrectCameraLimitsAndSensibility: boolean;
  35847. private _onPrePointerObservableObserver;
  35848. private _onAfterCheckInputsObserver;
  35849. private _onMeshTargetChangedObserver;
  35850. private _attachedCamera;
  35851. private _isPointerDown;
  35852. private _lastInteractionTime;
  35853. /**
  35854. * Initializes the behavior.
  35855. */
  35856. init(): void;
  35857. /**
  35858. * Attaches the behavior to its arc rotate camera.
  35859. * @param camera Defines the camera to attach the behavior to
  35860. */
  35861. attach(camera: ArcRotateCamera): void;
  35862. /**
  35863. * Detaches the behavior from its current arc rotate camera.
  35864. */
  35865. detach(): void;
  35866. private _animatables;
  35867. private _betaIsAnimating;
  35868. private _betaTransition;
  35869. private _radiusTransition;
  35870. private _vectorTransition;
  35871. /**
  35872. * Targets the given mesh and updates zoom level accordingly.
  35873. * @param mesh The mesh to target.
  35874. * @param radius Optional. If a cached radius position already exists, overrides default.
  35875. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35876. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35877. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35878. */
  35879. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35880. /**
  35881. * Targets the given mesh with its children and updates zoom level accordingly.
  35882. * @param mesh The mesh to target.
  35883. * @param radius Optional. If a cached radius position already exists, overrides default.
  35884. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35885. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35886. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35887. */
  35888. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35889. /**
  35890. * Targets the given meshes with their children and updates zoom level accordingly.
  35891. * @param meshes The mesh to target.
  35892. * @param radius Optional. If a cached radius position already exists, overrides default.
  35893. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35894. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35895. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35896. */
  35897. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35898. /**
  35899. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35900. * @param minimumWorld Determines the smaller position of the bounding box extend
  35901. * @param maximumWorld Determines the bigger position of the bounding box extend
  35902. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35903. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35904. */
  35905. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35906. /**
  35907. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35908. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35909. * frustum width.
  35910. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35911. * to fully enclose the mesh in the viewing frustum.
  35912. */
  35913. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35914. /**
  35915. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35916. * is automatically returned to its default position (expected to be above ground plane).
  35917. */
  35918. private _maintainCameraAboveGround;
  35919. /**
  35920. * Returns the frustum slope based on the canvas ratio and camera FOV
  35921. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35922. */
  35923. private _getFrustumSlope;
  35924. /**
  35925. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35926. */
  35927. private _clearAnimationLocks;
  35928. /**
  35929. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35930. */
  35931. private _applyUserInteraction;
  35932. /**
  35933. * Stops and removes all animations that have been applied to the camera
  35934. */
  35935. stopAllAnimations(): void;
  35936. /**
  35937. * Gets a value indicating if the user is moving the camera
  35938. */
  35939. readonly isUserIsMoving: boolean;
  35940. /**
  35941. * The camera can move all the way towards the mesh.
  35942. */
  35943. static IgnoreBoundsSizeMode: number;
  35944. /**
  35945. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35946. */
  35947. static FitFrustumSidesMode: number;
  35948. }
  35949. }
  35950. declare module BABYLON {
  35951. /**
  35952. * Base class for Camera Pointer Inputs.
  35953. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35954. * for example usage.
  35955. */
  35956. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35957. /**
  35958. * Defines the camera the input is attached to.
  35959. */
  35960. abstract camera: Camera;
  35961. /**
  35962. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35963. */
  35964. protected _altKey: boolean;
  35965. protected _ctrlKey: boolean;
  35966. protected _metaKey: boolean;
  35967. protected _shiftKey: boolean;
  35968. /**
  35969. * Which mouse buttons were pressed at time of last mouse event.
  35970. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35971. */
  35972. protected _buttonsPressed: number;
  35973. /**
  35974. * Defines the buttons associated with the input to handle camera move.
  35975. */
  35976. buttons: number[];
  35977. /**
  35978. * Attach the input controls to a specific dom element to get the input from.
  35979. * @param element Defines the element the controls should be listened from
  35980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35981. */
  35982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35983. /**
  35984. * Detach the current controls from the specified dom element.
  35985. * @param element Defines the element to stop listening the inputs from
  35986. */
  35987. detachControl(element: Nullable<HTMLElement>): void;
  35988. /**
  35989. * Gets the class name of the current input.
  35990. * @returns the class name
  35991. */
  35992. getClassName(): string;
  35993. /**
  35994. * Get the friendly name associated with the input class.
  35995. * @returns the input friendly name
  35996. */
  35997. getSimpleName(): string;
  35998. /**
  35999. * Called on pointer POINTERDOUBLETAP event.
  36000. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36001. */
  36002. protected onDoubleTap(type: string): void;
  36003. /**
  36004. * Called on pointer POINTERMOVE event if only a single touch is active.
  36005. * Override this method to provide functionality.
  36006. */
  36007. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36008. /**
  36009. * Called on pointer POINTERMOVE event if multiple touches are active.
  36010. * Override this method to provide functionality.
  36011. */
  36012. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36013. /**
  36014. * Called on JS contextmenu event.
  36015. * Override this method to provide functionality.
  36016. */
  36017. protected onContextMenu(evt: PointerEvent): void;
  36018. /**
  36019. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36020. * press.
  36021. * Override this method to provide functionality.
  36022. */
  36023. protected onButtonDown(evt: PointerEvent): void;
  36024. /**
  36025. * Called each time a new POINTERUP event occurs. Ie, for each button
  36026. * release.
  36027. * Override this method to provide functionality.
  36028. */
  36029. protected onButtonUp(evt: PointerEvent): void;
  36030. /**
  36031. * Called when window becomes inactive.
  36032. * Override this method to provide functionality.
  36033. */
  36034. protected onLostFocus(): void;
  36035. private _pointerInput;
  36036. private _observer;
  36037. private _onLostFocus;
  36038. private pointA;
  36039. private pointB;
  36040. }
  36041. }
  36042. declare module BABYLON {
  36043. /**
  36044. * Manage the pointers inputs to control an arc rotate camera.
  36045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36046. */
  36047. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36048. /**
  36049. * Defines the camera the input is attached to.
  36050. */
  36051. camera: ArcRotateCamera;
  36052. /**
  36053. * Gets the class name of the current input.
  36054. * @returns the class name
  36055. */
  36056. getClassName(): string;
  36057. /**
  36058. * Defines the buttons associated with the input to handle camera move.
  36059. */
  36060. buttons: number[];
  36061. /**
  36062. * Defines the pointer angular sensibility along the X axis or how fast is
  36063. * the camera rotating.
  36064. */
  36065. angularSensibilityX: number;
  36066. /**
  36067. * Defines the pointer angular sensibility along the Y axis or how fast is
  36068. * the camera rotating.
  36069. */
  36070. angularSensibilityY: number;
  36071. /**
  36072. * Defines the pointer pinch precision or how fast is the camera zooming.
  36073. */
  36074. pinchPrecision: number;
  36075. /**
  36076. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36077. * from 0.
  36078. * It defines the percentage of current camera.radius to use as delta when
  36079. * pinch zoom is used.
  36080. */
  36081. pinchDeltaPercentage: number;
  36082. /**
  36083. * Defines the pointer panning sensibility or how fast is the camera moving.
  36084. */
  36085. panningSensibility: number;
  36086. /**
  36087. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36088. */
  36089. multiTouchPanning: boolean;
  36090. /**
  36091. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36092. * zoom (pinch) through multitouch.
  36093. */
  36094. multiTouchPanAndZoom: boolean;
  36095. /**
  36096. * Revers pinch action direction.
  36097. */
  36098. pinchInwards: boolean;
  36099. private _isPanClick;
  36100. private _twoFingerActivityCount;
  36101. private _isPinching;
  36102. /**
  36103. * Called on pointer POINTERMOVE event if only a single touch is active.
  36104. */
  36105. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36106. /**
  36107. * Called on pointer POINTERDOUBLETAP event.
  36108. */
  36109. protected onDoubleTap(type: string): void;
  36110. /**
  36111. * Called on pointer POINTERMOVE event if multiple touches are active.
  36112. */
  36113. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36114. /**
  36115. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36116. * press.
  36117. */
  36118. protected onButtonDown(evt: PointerEvent): void;
  36119. /**
  36120. * Called each time a new POINTERUP event occurs. Ie, for each button
  36121. * release.
  36122. */
  36123. protected onButtonUp(evt: PointerEvent): void;
  36124. /**
  36125. * Called when window becomes inactive.
  36126. */
  36127. protected onLostFocus(): void;
  36128. }
  36129. }
  36130. declare module BABYLON {
  36131. /**
  36132. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36134. */
  36135. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36136. /**
  36137. * Defines the camera the input is attached to.
  36138. */
  36139. camera: ArcRotateCamera;
  36140. /**
  36141. * Defines the list of key codes associated with the up action (increase alpha)
  36142. */
  36143. keysUp: number[];
  36144. /**
  36145. * Defines the list of key codes associated with the down action (decrease alpha)
  36146. */
  36147. keysDown: number[];
  36148. /**
  36149. * Defines the list of key codes associated with the left action (increase beta)
  36150. */
  36151. keysLeft: number[];
  36152. /**
  36153. * Defines the list of key codes associated with the right action (decrease beta)
  36154. */
  36155. keysRight: number[];
  36156. /**
  36157. * Defines the list of key codes associated with the reset action.
  36158. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36159. */
  36160. keysReset: number[];
  36161. /**
  36162. * Defines the panning sensibility of the inputs.
  36163. * (How fast is the camera paning)
  36164. */
  36165. panningSensibility: number;
  36166. /**
  36167. * Defines the zooming sensibility of the inputs.
  36168. * (How fast is the camera zooming)
  36169. */
  36170. zoomingSensibility: number;
  36171. /**
  36172. * Defines wether maintaining the alt key down switch the movement mode from
  36173. * orientation to zoom.
  36174. */
  36175. useAltToZoom: boolean;
  36176. /**
  36177. * Rotation speed of the camera
  36178. */
  36179. angularSpeed: number;
  36180. private _keys;
  36181. private _ctrlPressed;
  36182. private _altPressed;
  36183. private _onCanvasBlurObserver;
  36184. private _onKeyboardObserver;
  36185. private _engine;
  36186. private _scene;
  36187. /**
  36188. * Attach the input controls to a specific dom element to get the input from.
  36189. * @param element Defines the element the controls should be listened from
  36190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36191. */
  36192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36193. /**
  36194. * Detach the current controls from the specified dom element.
  36195. * @param element Defines the element to stop listening the inputs from
  36196. */
  36197. detachControl(element: Nullable<HTMLElement>): void;
  36198. /**
  36199. * Update the current camera state depending on the inputs that have been used this frame.
  36200. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36201. */
  36202. checkInputs(): void;
  36203. /**
  36204. * Gets the class name of the current intput.
  36205. * @returns the class name
  36206. */
  36207. getClassName(): string;
  36208. /**
  36209. * Get the friendly name associated with the input class.
  36210. * @returns the input friendly name
  36211. */
  36212. getSimpleName(): string;
  36213. }
  36214. }
  36215. declare module BABYLON {
  36216. /**
  36217. * Manage the mouse wheel inputs to control an arc rotate camera.
  36218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36219. */
  36220. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36221. /**
  36222. * Defines the camera the input is attached to.
  36223. */
  36224. camera: ArcRotateCamera;
  36225. /**
  36226. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36227. */
  36228. wheelPrecision: number;
  36229. /**
  36230. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36231. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36232. */
  36233. wheelDeltaPercentage: number;
  36234. private _wheel;
  36235. private _observer;
  36236. private computeDeltaFromMouseWheelLegacyEvent;
  36237. /**
  36238. * Attach the input controls to a specific dom element to get the input from.
  36239. * @param element Defines the element the controls should be listened from
  36240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36241. */
  36242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36243. /**
  36244. * Detach the current controls from the specified dom element.
  36245. * @param element Defines the element to stop listening the inputs from
  36246. */
  36247. detachControl(element: Nullable<HTMLElement>): void;
  36248. /**
  36249. * Gets the class name of the current intput.
  36250. * @returns the class name
  36251. */
  36252. getClassName(): string;
  36253. /**
  36254. * Get the friendly name associated with the input class.
  36255. * @returns the input friendly name
  36256. */
  36257. getSimpleName(): string;
  36258. }
  36259. }
  36260. declare module BABYLON {
  36261. /**
  36262. * Default Inputs manager for the ArcRotateCamera.
  36263. * It groups all the default supported inputs for ease of use.
  36264. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36265. */
  36266. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36267. /**
  36268. * Instantiates a new ArcRotateCameraInputsManager.
  36269. * @param camera Defines the camera the inputs belong to
  36270. */
  36271. constructor(camera: ArcRotateCamera);
  36272. /**
  36273. * Add mouse wheel input support to the input manager.
  36274. * @returns the current input manager
  36275. */
  36276. addMouseWheel(): ArcRotateCameraInputsManager;
  36277. /**
  36278. * Add pointers input support to the input manager.
  36279. * @returns the current input manager
  36280. */
  36281. addPointers(): ArcRotateCameraInputsManager;
  36282. /**
  36283. * Add keyboard input support to the input manager.
  36284. * @returns the current input manager
  36285. */
  36286. addKeyboard(): ArcRotateCameraInputsManager;
  36287. }
  36288. }
  36289. declare module BABYLON {
  36290. /**
  36291. * This represents an orbital type of camera.
  36292. *
  36293. * 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.
  36294. * 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.
  36295. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36296. */
  36297. export class ArcRotateCamera extends TargetCamera {
  36298. /**
  36299. * Defines the rotation angle of the camera along the longitudinal axis.
  36300. */
  36301. alpha: number;
  36302. /**
  36303. * Defines the rotation angle of the camera along the latitudinal axis.
  36304. */
  36305. beta: number;
  36306. /**
  36307. * Defines the radius of the camera from it s target point.
  36308. */
  36309. radius: number;
  36310. protected _target: Vector3;
  36311. protected _targetHost: Nullable<AbstractMesh>;
  36312. /**
  36313. * Defines the target point of the camera.
  36314. * The camera looks towards it form the radius distance.
  36315. */
  36316. target: Vector3;
  36317. /**
  36318. * Define the current local position of the camera in the scene
  36319. */
  36320. position: Vector3;
  36321. protected _upVector: Vector3;
  36322. protected _upToYMatrix: Matrix;
  36323. protected _YToUpMatrix: Matrix;
  36324. /**
  36325. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36326. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36327. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36328. */
  36329. upVector: Vector3;
  36330. /**
  36331. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36332. */
  36333. setMatUp(): void;
  36334. /**
  36335. * Current inertia value on the longitudinal axis.
  36336. * The bigger this number the longer it will take for the camera to stop.
  36337. */
  36338. inertialAlphaOffset: number;
  36339. /**
  36340. * Current inertia value on the latitudinal axis.
  36341. * The bigger this number the longer it will take for the camera to stop.
  36342. */
  36343. inertialBetaOffset: number;
  36344. /**
  36345. * Current inertia value on the radius axis.
  36346. * The bigger this number the longer it will take for the camera to stop.
  36347. */
  36348. inertialRadiusOffset: number;
  36349. /**
  36350. * Minimum allowed angle on the longitudinal axis.
  36351. * This can help limiting how the Camera is able to move in the scene.
  36352. */
  36353. lowerAlphaLimit: Nullable<number>;
  36354. /**
  36355. * Maximum allowed angle on the longitudinal axis.
  36356. * This can help limiting how the Camera is able to move in the scene.
  36357. */
  36358. upperAlphaLimit: Nullable<number>;
  36359. /**
  36360. * Minimum allowed angle on the latitudinal axis.
  36361. * This can help limiting how the Camera is able to move in the scene.
  36362. */
  36363. lowerBetaLimit: number;
  36364. /**
  36365. * Maximum allowed angle on the latitudinal axis.
  36366. * This can help limiting how the Camera is able to move in the scene.
  36367. */
  36368. upperBetaLimit: number;
  36369. /**
  36370. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36371. * This can help limiting how the Camera is able to move in the scene.
  36372. */
  36373. lowerRadiusLimit: Nullable<number>;
  36374. /**
  36375. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36376. * This can help limiting how the Camera is able to move in the scene.
  36377. */
  36378. upperRadiusLimit: Nullable<number>;
  36379. /**
  36380. * Defines the current inertia value used during panning of the camera along the X axis.
  36381. */
  36382. inertialPanningX: number;
  36383. /**
  36384. * Defines the current inertia value used during panning of the camera along the Y axis.
  36385. */
  36386. inertialPanningY: number;
  36387. /**
  36388. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36389. * Basically if your fingers moves away from more than this distance you will be considered
  36390. * in pinch mode.
  36391. */
  36392. pinchToPanMaxDistance: number;
  36393. /**
  36394. * Defines the maximum distance the camera can pan.
  36395. * This could help keeping the cammera always in your scene.
  36396. */
  36397. panningDistanceLimit: Nullable<number>;
  36398. /**
  36399. * Defines the target of the camera before paning.
  36400. */
  36401. panningOriginTarget: Vector3;
  36402. /**
  36403. * Defines the value of the inertia used during panning.
  36404. * 0 would mean stop inertia and one would mean no decelleration at all.
  36405. */
  36406. panningInertia: number;
  36407. /**
  36408. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36409. */
  36410. angularSensibilityX: number;
  36411. /**
  36412. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36413. */
  36414. angularSensibilityY: number;
  36415. /**
  36416. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36417. */
  36418. pinchPrecision: number;
  36419. /**
  36420. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36421. * It will be used instead of pinchDeltaPrecision if different from 0.
  36422. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36423. */
  36424. pinchDeltaPercentage: number;
  36425. /**
  36426. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36427. */
  36428. panningSensibility: number;
  36429. /**
  36430. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36431. */
  36432. keysUp: number[];
  36433. /**
  36434. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36435. */
  36436. keysDown: number[];
  36437. /**
  36438. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36439. */
  36440. keysLeft: number[];
  36441. /**
  36442. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36443. */
  36444. keysRight: number[];
  36445. /**
  36446. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36447. */
  36448. wheelPrecision: number;
  36449. /**
  36450. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36451. * It will be used instead of pinchDeltaPrecision if different from 0.
  36452. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36453. */
  36454. wheelDeltaPercentage: number;
  36455. /**
  36456. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36457. */
  36458. zoomOnFactor: number;
  36459. /**
  36460. * Defines a screen offset for the camera position.
  36461. */
  36462. targetScreenOffset: Vector2;
  36463. /**
  36464. * Allows the camera to be completely reversed.
  36465. * If false the camera can not arrive upside down.
  36466. */
  36467. allowUpsideDown: boolean;
  36468. /**
  36469. * Define if double tap/click is used to restore the previously saved state of the camera.
  36470. */
  36471. useInputToRestoreState: boolean;
  36472. /** @hidden */
  36473. _viewMatrix: Matrix;
  36474. /** @hidden */
  36475. _useCtrlForPanning: boolean;
  36476. /** @hidden */
  36477. _panningMouseButton: number;
  36478. /**
  36479. * Defines the input associated to the camera.
  36480. */
  36481. inputs: ArcRotateCameraInputsManager;
  36482. /** @hidden */
  36483. _reset: () => void;
  36484. /**
  36485. * Defines the allowed panning axis.
  36486. */
  36487. panningAxis: Vector3;
  36488. protected _localDirection: Vector3;
  36489. protected _transformedDirection: Vector3;
  36490. private _bouncingBehavior;
  36491. /**
  36492. * Gets the bouncing behavior of the camera if it has been enabled.
  36493. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36494. */
  36495. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36496. /**
  36497. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36498. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36499. */
  36500. useBouncingBehavior: boolean;
  36501. private _framingBehavior;
  36502. /**
  36503. * Gets the framing behavior of the camera if it has been enabled.
  36504. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36505. */
  36506. readonly framingBehavior: Nullable<FramingBehavior>;
  36507. /**
  36508. * Defines if the framing behavior of the camera is enabled on the camera.
  36509. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36510. */
  36511. useFramingBehavior: boolean;
  36512. private _autoRotationBehavior;
  36513. /**
  36514. * Gets the auto rotation behavior of the camera if it has been enabled.
  36515. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36516. */
  36517. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36518. /**
  36519. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36520. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36521. */
  36522. useAutoRotationBehavior: boolean;
  36523. /**
  36524. * Observable triggered when the mesh target has been changed on the camera.
  36525. */
  36526. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36527. /**
  36528. * Event raised when the camera is colliding with a mesh.
  36529. */
  36530. onCollide: (collidedMesh: AbstractMesh) => void;
  36531. /**
  36532. * Defines whether the camera should check collision with the objects oh the scene.
  36533. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36534. */
  36535. checkCollisions: boolean;
  36536. /**
  36537. * Defines the collision radius of the camera.
  36538. * This simulates a sphere around the camera.
  36539. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36540. */
  36541. collisionRadius: Vector3;
  36542. protected _collider: Collider;
  36543. protected _previousPosition: Vector3;
  36544. protected _collisionVelocity: Vector3;
  36545. protected _newPosition: Vector3;
  36546. protected _previousAlpha: number;
  36547. protected _previousBeta: number;
  36548. protected _previousRadius: number;
  36549. protected _collisionTriggered: boolean;
  36550. protected _targetBoundingCenter: Nullable<Vector3>;
  36551. private _computationVector;
  36552. /**
  36553. * Instantiates a new ArcRotateCamera in a given scene
  36554. * @param name Defines the name of the camera
  36555. * @param alpha Defines the camera rotation along the logitudinal axis
  36556. * @param beta Defines the camera rotation along the latitudinal axis
  36557. * @param radius Defines the camera distance from its target
  36558. * @param target Defines the camera target
  36559. * @param scene Defines the scene the camera belongs to
  36560. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36561. */
  36562. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36563. /** @hidden */
  36564. _initCache(): void;
  36565. /** @hidden */
  36566. _updateCache(ignoreParentClass?: boolean): void;
  36567. protected _getTargetPosition(): Vector3;
  36568. private _storedAlpha;
  36569. private _storedBeta;
  36570. private _storedRadius;
  36571. private _storedTarget;
  36572. private _storedTargetScreenOffset;
  36573. /**
  36574. * Stores the current state of the camera (alpha, beta, radius and target)
  36575. * @returns the camera itself
  36576. */
  36577. storeState(): Camera;
  36578. /**
  36579. * @hidden
  36580. * Restored camera state. You must call storeState() first
  36581. */
  36582. _restoreStateValues(): boolean;
  36583. /** @hidden */
  36584. _isSynchronizedViewMatrix(): boolean;
  36585. /**
  36586. * Attached controls to the current camera.
  36587. * @param element Defines the element the controls should be listened from
  36588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36589. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36590. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36591. */
  36592. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36593. /**
  36594. * Detach the current controls from the camera.
  36595. * The camera will stop reacting to inputs.
  36596. * @param element Defines the element to stop listening the inputs from
  36597. */
  36598. detachControl(element: HTMLElement): void;
  36599. /** @hidden */
  36600. _checkInputs(): void;
  36601. protected _checkLimits(): void;
  36602. /**
  36603. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36604. */
  36605. rebuildAnglesAndRadius(): void;
  36606. /**
  36607. * Use a position to define the current camera related information like alpha, beta and radius
  36608. * @param position Defines the position to set the camera at
  36609. */
  36610. setPosition(position: Vector3): void;
  36611. /**
  36612. * Defines the target the camera should look at.
  36613. * This will automatically adapt alpha beta and radius to fit within the new target.
  36614. * @param target Defines the new target as a Vector or a mesh
  36615. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36616. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36617. */
  36618. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36619. /** @hidden */
  36620. _getViewMatrix(): Matrix;
  36621. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36622. /**
  36623. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36624. * @param meshes Defines the mesh to zoom on
  36625. * @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)
  36626. */
  36627. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36628. /**
  36629. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36630. * The target will be changed but the radius
  36631. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36632. * @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)
  36633. */
  36634. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36635. min: Vector3;
  36636. max: Vector3;
  36637. distance: number;
  36638. }, doNotUpdateMaxZ?: boolean): void;
  36639. /**
  36640. * @override
  36641. * Override Camera.createRigCamera
  36642. */
  36643. createRigCamera(name: string, cameraIndex: number): Camera;
  36644. /**
  36645. * @hidden
  36646. * @override
  36647. * Override Camera._updateRigCameras
  36648. */
  36649. _updateRigCameras(): void;
  36650. /**
  36651. * Destroy the camera and release the current resources hold by it.
  36652. */
  36653. dispose(): void;
  36654. /**
  36655. * Gets the current object class name.
  36656. * @return the class name
  36657. */
  36658. getClassName(): string;
  36659. }
  36660. }
  36661. declare module BABYLON {
  36662. /**
  36663. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36664. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36665. */
  36666. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36667. /**
  36668. * Gets the name of the behavior.
  36669. */
  36670. readonly name: string;
  36671. private _zoomStopsAnimation;
  36672. private _idleRotationSpeed;
  36673. private _idleRotationWaitTime;
  36674. private _idleRotationSpinupTime;
  36675. /**
  36676. * Sets the flag that indicates if user zooming should stop animation.
  36677. */
  36678. /**
  36679. * Gets the flag that indicates if user zooming should stop animation.
  36680. */
  36681. zoomStopsAnimation: boolean;
  36682. /**
  36683. * Sets the default speed at which the camera rotates around the model.
  36684. */
  36685. /**
  36686. * Gets the default speed at which the camera rotates around the model.
  36687. */
  36688. idleRotationSpeed: number;
  36689. /**
  36690. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36691. */
  36692. /**
  36693. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36694. */
  36695. idleRotationWaitTime: number;
  36696. /**
  36697. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36698. */
  36699. /**
  36700. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36701. */
  36702. idleRotationSpinupTime: number;
  36703. /**
  36704. * Gets a value indicating if the camera is currently rotating because of this behavior
  36705. */
  36706. readonly rotationInProgress: boolean;
  36707. private _onPrePointerObservableObserver;
  36708. private _onAfterCheckInputsObserver;
  36709. private _attachedCamera;
  36710. private _isPointerDown;
  36711. private _lastFrameTime;
  36712. private _lastInteractionTime;
  36713. private _cameraRotationSpeed;
  36714. /**
  36715. * Initializes the behavior.
  36716. */
  36717. init(): void;
  36718. /**
  36719. * Attaches the behavior to its arc rotate camera.
  36720. * @param camera Defines the camera to attach the behavior to
  36721. */
  36722. attach(camera: ArcRotateCamera): void;
  36723. /**
  36724. * Detaches the behavior from its current arc rotate camera.
  36725. */
  36726. detach(): void;
  36727. /**
  36728. * Returns true if user is scrolling.
  36729. * @return true if user is scrolling.
  36730. */
  36731. private _userIsZooming;
  36732. private _lastFrameRadius;
  36733. private _shouldAnimationStopForInteraction;
  36734. /**
  36735. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36736. */
  36737. private _applyUserInteraction;
  36738. private _userIsMoving;
  36739. }
  36740. }
  36741. declare module BABYLON {
  36742. /**
  36743. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36744. */
  36745. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36746. private ui;
  36747. /**
  36748. * The name of the behavior
  36749. */
  36750. name: string;
  36751. /**
  36752. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36753. */
  36754. distanceAwayFromFace: number;
  36755. /**
  36756. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36757. */
  36758. distanceAwayFromBottomOfFace: number;
  36759. private _faceVectors;
  36760. private _target;
  36761. private _scene;
  36762. private _onRenderObserver;
  36763. private _tmpMatrix;
  36764. private _tmpVector;
  36765. /**
  36766. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36767. * @param ui The transform node that should be attched to the mesh
  36768. */
  36769. constructor(ui: TransformNode);
  36770. /**
  36771. * Initializes the behavior
  36772. */
  36773. init(): void;
  36774. private _closestFace;
  36775. private _zeroVector;
  36776. private _lookAtTmpMatrix;
  36777. private _lookAtToRef;
  36778. /**
  36779. * Attaches the AttachToBoxBehavior to the passed in mesh
  36780. * @param target The mesh that the specified node will be attached to
  36781. */
  36782. attach(target: Mesh): void;
  36783. /**
  36784. * Detaches the behavior from the mesh
  36785. */
  36786. detach(): void;
  36787. }
  36788. }
  36789. declare module BABYLON {
  36790. /**
  36791. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36792. */
  36793. export class FadeInOutBehavior implements Behavior<Mesh> {
  36794. /**
  36795. * Time in milliseconds to delay before fading in (Default: 0)
  36796. */
  36797. delay: number;
  36798. /**
  36799. * Time in milliseconds for the mesh to fade in (Default: 300)
  36800. */
  36801. fadeInTime: number;
  36802. private _millisecondsPerFrame;
  36803. private _hovered;
  36804. private _hoverValue;
  36805. private _ownerNode;
  36806. /**
  36807. * Instatiates the FadeInOutBehavior
  36808. */
  36809. constructor();
  36810. /**
  36811. * The name of the behavior
  36812. */
  36813. readonly name: string;
  36814. /**
  36815. * Initializes the behavior
  36816. */
  36817. init(): void;
  36818. /**
  36819. * Attaches the fade behavior on the passed in mesh
  36820. * @param ownerNode The mesh that will be faded in/out once attached
  36821. */
  36822. attach(ownerNode: Mesh): void;
  36823. /**
  36824. * Detaches the behavior from the mesh
  36825. */
  36826. detach(): void;
  36827. /**
  36828. * Triggers the mesh to begin fading in or out
  36829. * @param value if the object should fade in or out (true to fade in)
  36830. */
  36831. fadeIn(value: boolean): void;
  36832. private _update;
  36833. private _setAllVisibility;
  36834. }
  36835. }
  36836. declare module BABYLON {
  36837. /**
  36838. * Class containing a set of static utilities functions for managing Pivots
  36839. * @hidden
  36840. */
  36841. export class PivotTools {
  36842. private static _PivotCached;
  36843. private static _OldPivotPoint;
  36844. private static _PivotTranslation;
  36845. private static _PivotTmpVector;
  36846. /** @hidden */
  36847. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36848. /** @hidden */
  36849. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36850. }
  36851. }
  36852. declare module BABYLON {
  36853. /**
  36854. * Class containing static functions to help procedurally build meshes
  36855. */
  36856. export class PlaneBuilder {
  36857. /**
  36858. * Creates a plane mesh
  36859. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36860. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36861. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36863. * * 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
  36864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36865. * @param name defines the name of the mesh
  36866. * @param options defines the options used to create the mesh
  36867. * @param scene defines the hosting scene
  36868. * @returns the plane mesh
  36869. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36870. */
  36871. static CreatePlane(name: string, options: {
  36872. size?: number;
  36873. width?: number;
  36874. height?: number;
  36875. sideOrientation?: number;
  36876. frontUVs?: Vector4;
  36877. backUVs?: Vector4;
  36878. updatable?: boolean;
  36879. sourcePlane?: Plane;
  36880. }, scene?: Nullable<Scene>): Mesh;
  36881. }
  36882. }
  36883. declare module BABYLON {
  36884. /**
  36885. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36886. */
  36887. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36888. private static _AnyMouseID;
  36889. /**
  36890. * Abstract mesh the behavior is set on
  36891. */
  36892. attachedNode: AbstractMesh;
  36893. private _dragPlane;
  36894. private _scene;
  36895. private _pointerObserver;
  36896. private _beforeRenderObserver;
  36897. private static _planeScene;
  36898. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36899. /**
  36900. * 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)
  36901. */
  36902. maxDragAngle: number;
  36903. /**
  36904. * @hidden
  36905. */
  36906. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36907. /**
  36908. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36909. */
  36910. currentDraggingPointerID: number;
  36911. /**
  36912. * The last position where the pointer hit the drag plane in world space
  36913. */
  36914. lastDragPosition: Vector3;
  36915. /**
  36916. * If the behavior is currently in a dragging state
  36917. */
  36918. dragging: boolean;
  36919. /**
  36920. * 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)
  36921. */
  36922. dragDeltaRatio: number;
  36923. /**
  36924. * If the drag plane orientation should be updated during the dragging (Default: true)
  36925. */
  36926. updateDragPlane: boolean;
  36927. private _debugMode;
  36928. private _moving;
  36929. /**
  36930. * Fires each time the attached mesh is dragged with the pointer
  36931. * * delta between last drag position and current drag position in world space
  36932. * * dragDistance along the drag axis
  36933. * * dragPlaneNormal normal of the current drag plane used during the drag
  36934. * * dragPlanePoint in world space where the drag intersects the drag plane
  36935. */
  36936. onDragObservable: Observable<{
  36937. delta: Vector3;
  36938. dragPlanePoint: Vector3;
  36939. dragPlaneNormal: Vector3;
  36940. dragDistance: number;
  36941. pointerId: number;
  36942. }>;
  36943. /**
  36944. * Fires each time a drag begins (eg. mouse down on mesh)
  36945. */
  36946. onDragStartObservable: Observable<{
  36947. dragPlanePoint: Vector3;
  36948. pointerId: number;
  36949. }>;
  36950. /**
  36951. * Fires each time a drag ends (eg. mouse release after drag)
  36952. */
  36953. onDragEndObservable: Observable<{
  36954. dragPlanePoint: Vector3;
  36955. pointerId: number;
  36956. }>;
  36957. /**
  36958. * If the attached mesh should be moved when dragged
  36959. */
  36960. moveAttached: boolean;
  36961. /**
  36962. * If the drag behavior will react to drag events (Default: true)
  36963. */
  36964. enabled: boolean;
  36965. /**
  36966. * If pointer events should start and release the drag (Default: true)
  36967. */
  36968. startAndReleaseDragOnPointerEvents: boolean;
  36969. /**
  36970. * If camera controls should be detached during the drag
  36971. */
  36972. detachCameraControls: boolean;
  36973. /**
  36974. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36975. */
  36976. useObjectOrienationForDragging: boolean;
  36977. private _options;
  36978. /**
  36979. * Creates a pointer drag behavior that can be attached to a mesh
  36980. * @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)
  36981. */
  36982. constructor(options?: {
  36983. dragAxis?: Vector3;
  36984. dragPlaneNormal?: Vector3;
  36985. });
  36986. /**
  36987. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36988. */
  36989. validateDrag: (targetPosition: Vector3) => boolean;
  36990. /**
  36991. * The name of the behavior
  36992. */
  36993. readonly name: string;
  36994. /**
  36995. * Initializes the behavior
  36996. */
  36997. init(): void;
  36998. private _tmpVector;
  36999. private _alternatePickedPoint;
  37000. private _worldDragAxis;
  37001. private _targetPosition;
  37002. private _attachedElement;
  37003. /**
  37004. * Attaches the drag behavior the passed in mesh
  37005. * @param ownerNode The mesh that will be dragged around once attached
  37006. * @param predicate Predicate to use for pick filtering
  37007. */
  37008. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37009. /**
  37010. * Force relase the drag action by code.
  37011. */
  37012. releaseDrag(): void;
  37013. private _startDragRay;
  37014. private _lastPointerRay;
  37015. /**
  37016. * Simulates the start of a pointer drag event on the behavior
  37017. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37018. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37019. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37020. */
  37021. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37022. private _startDrag;
  37023. private _dragDelta;
  37024. private _moveDrag;
  37025. private _pickWithRayOnDragPlane;
  37026. private _pointA;
  37027. private _pointB;
  37028. private _pointC;
  37029. private _lineA;
  37030. private _lineB;
  37031. private _localAxis;
  37032. private _lookAt;
  37033. private _updateDragPlanePosition;
  37034. /**
  37035. * Detaches the behavior from the mesh
  37036. */
  37037. detach(): void;
  37038. }
  37039. }
  37040. declare module BABYLON {
  37041. /**
  37042. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37043. */
  37044. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37045. private _dragBehaviorA;
  37046. private _dragBehaviorB;
  37047. private _startDistance;
  37048. private _initialScale;
  37049. private _targetScale;
  37050. private _ownerNode;
  37051. private _sceneRenderObserver;
  37052. /**
  37053. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37054. */
  37055. constructor();
  37056. /**
  37057. * The name of the behavior
  37058. */
  37059. readonly name: string;
  37060. /**
  37061. * Initializes the behavior
  37062. */
  37063. init(): void;
  37064. private _getCurrentDistance;
  37065. /**
  37066. * Attaches the scale behavior the passed in mesh
  37067. * @param ownerNode The mesh that will be scaled around once attached
  37068. */
  37069. attach(ownerNode: Mesh): void;
  37070. /**
  37071. * Detaches the behavior from the mesh
  37072. */
  37073. detach(): void;
  37074. }
  37075. }
  37076. declare module BABYLON {
  37077. /**
  37078. * 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
  37079. */
  37080. export class SixDofDragBehavior implements Behavior<Mesh> {
  37081. private static _virtualScene;
  37082. private _ownerNode;
  37083. private _sceneRenderObserver;
  37084. private _scene;
  37085. private _targetPosition;
  37086. private _virtualOriginMesh;
  37087. private _virtualDragMesh;
  37088. private _pointerObserver;
  37089. private _moving;
  37090. private _startingOrientation;
  37091. /**
  37092. * 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)
  37093. */
  37094. private zDragFactor;
  37095. /**
  37096. * If the object should rotate to face the drag origin
  37097. */
  37098. rotateDraggedObject: boolean;
  37099. /**
  37100. * If the behavior is currently in a dragging state
  37101. */
  37102. dragging: boolean;
  37103. /**
  37104. * 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)
  37105. */
  37106. dragDeltaRatio: number;
  37107. /**
  37108. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37109. */
  37110. currentDraggingPointerID: number;
  37111. /**
  37112. * If camera controls should be detached during the drag
  37113. */
  37114. detachCameraControls: boolean;
  37115. /**
  37116. * Fires each time a drag starts
  37117. */
  37118. onDragStartObservable: Observable<{}>;
  37119. /**
  37120. * Fires each time a drag ends (eg. mouse release after drag)
  37121. */
  37122. onDragEndObservable: Observable<{}>;
  37123. /**
  37124. * 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
  37125. */
  37126. constructor();
  37127. /**
  37128. * The name of the behavior
  37129. */
  37130. readonly name: string;
  37131. /**
  37132. * Initializes the behavior
  37133. */
  37134. init(): void;
  37135. /**
  37136. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37137. */
  37138. private readonly _pointerCamera;
  37139. /**
  37140. * Attaches the scale behavior the passed in mesh
  37141. * @param ownerNode The mesh that will be scaled around once attached
  37142. */
  37143. attach(ownerNode: Mesh): void;
  37144. /**
  37145. * Detaches the behavior from the mesh
  37146. */
  37147. detach(): void;
  37148. }
  37149. }
  37150. declare module BABYLON {
  37151. /**
  37152. * Class used to apply inverse kinematics to bones
  37153. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37154. */
  37155. export class BoneIKController {
  37156. private static _tmpVecs;
  37157. private static _tmpQuat;
  37158. private static _tmpMats;
  37159. /**
  37160. * Gets or sets the target mesh
  37161. */
  37162. targetMesh: AbstractMesh;
  37163. /** Gets or sets the mesh used as pole */
  37164. poleTargetMesh: AbstractMesh;
  37165. /**
  37166. * Gets or sets the bone used as pole
  37167. */
  37168. poleTargetBone: Nullable<Bone>;
  37169. /**
  37170. * Gets or sets the target position
  37171. */
  37172. targetPosition: Vector3;
  37173. /**
  37174. * Gets or sets the pole target position
  37175. */
  37176. poleTargetPosition: Vector3;
  37177. /**
  37178. * Gets or sets the pole target local offset
  37179. */
  37180. poleTargetLocalOffset: Vector3;
  37181. /**
  37182. * Gets or sets the pole angle
  37183. */
  37184. poleAngle: number;
  37185. /**
  37186. * Gets or sets the mesh associated with the controller
  37187. */
  37188. mesh: AbstractMesh;
  37189. /**
  37190. * 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)
  37191. */
  37192. slerpAmount: number;
  37193. private _bone1Quat;
  37194. private _bone1Mat;
  37195. private _bone2Ang;
  37196. private _bone1;
  37197. private _bone2;
  37198. private _bone1Length;
  37199. private _bone2Length;
  37200. private _maxAngle;
  37201. private _maxReach;
  37202. private _rightHandedSystem;
  37203. private _bendAxis;
  37204. private _slerping;
  37205. private _adjustRoll;
  37206. /**
  37207. * Gets or sets maximum allowed angle
  37208. */
  37209. maxAngle: number;
  37210. /**
  37211. * Creates a new BoneIKController
  37212. * @param mesh defines the mesh to control
  37213. * @param bone defines the bone to control
  37214. * @param options defines options to set up the controller
  37215. */
  37216. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37217. targetMesh?: AbstractMesh;
  37218. poleTargetMesh?: AbstractMesh;
  37219. poleTargetBone?: Bone;
  37220. poleTargetLocalOffset?: Vector3;
  37221. poleAngle?: number;
  37222. bendAxis?: Vector3;
  37223. maxAngle?: number;
  37224. slerpAmount?: number;
  37225. });
  37226. private _setMaxAngle;
  37227. /**
  37228. * Force the controller to update the bones
  37229. */
  37230. update(): void;
  37231. }
  37232. }
  37233. declare module BABYLON {
  37234. /**
  37235. * Class used to make a bone look toward a point in space
  37236. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37237. */
  37238. export class BoneLookController {
  37239. private static _tmpVecs;
  37240. private static _tmpQuat;
  37241. private static _tmpMats;
  37242. /**
  37243. * The target Vector3 that the bone will look at
  37244. */
  37245. target: Vector3;
  37246. /**
  37247. * The mesh that the bone is attached to
  37248. */
  37249. mesh: AbstractMesh;
  37250. /**
  37251. * The bone that will be looking to the target
  37252. */
  37253. bone: Bone;
  37254. /**
  37255. * The up axis of the coordinate system that is used when the bone is rotated
  37256. */
  37257. upAxis: Vector3;
  37258. /**
  37259. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37260. */
  37261. upAxisSpace: Space;
  37262. /**
  37263. * Used to make an adjustment to the yaw of the bone
  37264. */
  37265. adjustYaw: number;
  37266. /**
  37267. * Used to make an adjustment to the pitch of the bone
  37268. */
  37269. adjustPitch: number;
  37270. /**
  37271. * Used to make an adjustment to the roll of the bone
  37272. */
  37273. adjustRoll: number;
  37274. /**
  37275. * 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)
  37276. */
  37277. slerpAmount: number;
  37278. private _minYaw;
  37279. private _maxYaw;
  37280. private _minPitch;
  37281. private _maxPitch;
  37282. private _minYawSin;
  37283. private _minYawCos;
  37284. private _maxYawSin;
  37285. private _maxYawCos;
  37286. private _midYawConstraint;
  37287. private _minPitchTan;
  37288. private _maxPitchTan;
  37289. private _boneQuat;
  37290. private _slerping;
  37291. private _transformYawPitch;
  37292. private _transformYawPitchInv;
  37293. private _firstFrameSkipped;
  37294. private _yawRange;
  37295. private _fowardAxis;
  37296. /**
  37297. * Gets or sets the minimum yaw angle that the bone can look to
  37298. */
  37299. minYaw: number;
  37300. /**
  37301. * Gets or sets the maximum yaw angle that the bone can look to
  37302. */
  37303. maxYaw: number;
  37304. /**
  37305. * Gets or sets the minimum pitch angle that the bone can look to
  37306. */
  37307. minPitch: number;
  37308. /**
  37309. * Gets or sets the maximum pitch angle that the bone can look to
  37310. */
  37311. maxPitch: number;
  37312. /**
  37313. * Create a BoneLookController
  37314. * @param mesh the mesh that the bone belongs to
  37315. * @param bone the bone that will be looking to the target
  37316. * @param target the target Vector3 to look at
  37317. * @param options optional settings:
  37318. * * maxYaw: the maximum angle the bone will yaw to
  37319. * * minYaw: the minimum angle the bone will yaw to
  37320. * * maxPitch: the maximum angle the bone will pitch to
  37321. * * minPitch: the minimum angle the bone will yaw to
  37322. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37323. * * upAxis: the up axis of the coordinate system
  37324. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37325. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37326. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37327. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37328. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37329. * * adjustRoll: used to make an adjustment to the roll of the bone
  37330. **/
  37331. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37332. maxYaw?: number;
  37333. minYaw?: number;
  37334. maxPitch?: number;
  37335. minPitch?: number;
  37336. slerpAmount?: number;
  37337. upAxis?: Vector3;
  37338. upAxisSpace?: Space;
  37339. yawAxis?: Vector3;
  37340. pitchAxis?: Vector3;
  37341. adjustYaw?: number;
  37342. adjustPitch?: number;
  37343. adjustRoll?: number;
  37344. });
  37345. /**
  37346. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37347. */
  37348. update(): void;
  37349. private _getAngleDiff;
  37350. private _getAngleBetween;
  37351. private _isAngleBetween;
  37352. }
  37353. }
  37354. declare module BABYLON {
  37355. /**
  37356. * Manage the gamepad inputs to control an arc rotate camera.
  37357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37358. */
  37359. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37360. /**
  37361. * Defines the camera the input is attached to.
  37362. */
  37363. camera: ArcRotateCamera;
  37364. /**
  37365. * Defines the gamepad the input is gathering event from.
  37366. */
  37367. gamepad: Nullable<Gamepad>;
  37368. /**
  37369. * Defines the gamepad rotation sensiblity.
  37370. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37371. */
  37372. gamepadRotationSensibility: number;
  37373. /**
  37374. * Defines the gamepad move sensiblity.
  37375. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37376. */
  37377. gamepadMoveSensibility: number;
  37378. private _yAxisScale;
  37379. /**
  37380. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37381. */
  37382. invertYAxis: boolean;
  37383. private _onGamepadConnectedObserver;
  37384. private _onGamepadDisconnectedObserver;
  37385. /**
  37386. * Attach the input controls to a specific dom element to get the input from.
  37387. * @param element Defines the element the controls should be listened from
  37388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37389. */
  37390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37391. /**
  37392. * Detach the current controls from the specified dom element.
  37393. * @param element Defines the element to stop listening the inputs from
  37394. */
  37395. detachControl(element: Nullable<HTMLElement>): void;
  37396. /**
  37397. * Update the current camera state depending on the inputs that have been used this frame.
  37398. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37399. */
  37400. checkInputs(): void;
  37401. /**
  37402. * Gets the class name of the current intput.
  37403. * @returns the class name
  37404. */
  37405. getClassName(): string;
  37406. /**
  37407. * Get the friendly name associated with the input class.
  37408. * @returns the input friendly name
  37409. */
  37410. getSimpleName(): string;
  37411. }
  37412. }
  37413. declare module BABYLON {
  37414. interface ArcRotateCameraInputsManager {
  37415. /**
  37416. * Add orientation input support to the input manager.
  37417. * @returns the current input manager
  37418. */
  37419. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37420. }
  37421. /**
  37422. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37424. */
  37425. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37426. /**
  37427. * Defines the camera the input is attached to.
  37428. */
  37429. camera: ArcRotateCamera;
  37430. /**
  37431. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37432. */
  37433. alphaCorrection: number;
  37434. /**
  37435. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37436. */
  37437. gammaCorrection: number;
  37438. private _alpha;
  37439. private _gamma;
  37440. private _dirty;
  37441. private _deviceOrientationHandler;
  37442. /**
  37443. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37444. */
  37445. constructor();
  37446. /**
  37447. * Attach the input controls to a specific dom element to get the input from.
  37448. * @param element Defines the element the controls should be listened from
  37449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37450. */
  37451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37452. /** @hidden */
  37453. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37454. /**
  37455. * Update the current camera state depending on the inputs that have been used this frame.
  37456. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37457. */
  37458. checkInputs(): void;
  37459. /**
  37460. * Detach the current controls from the specified dom element.
  37461. * @param element Defines the element to stop listening the inputs from
  37462. */
  37463. detachControl(element: Nullable<HTMLElement>): void;
  37464. /**
  37465. * Gets the class name of the current intput.
  37466. * @returns the class name
  37467. */
  37468. getClassName(): string;
  37469. /**
  37470. * Get the friendly name associated with the input class.
  37471. * @returns the input friendly name
  37472. */
  37473. getSimpleName(): string;
  37474. }
  37475. }
  37476. declare module BABYLON {
  37477. /**
  37478. * Listen to mouse events to control the camera.
  37479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37480. */
  37481. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37482. /**
  37483. * Defines the camera the input is attached to.
  37484. */
  37485. camera: FlyCamera;
  37486. /**
  37487. * Defines if touch is enabled. (Default is true.)
  37488. */
  37489. touchEnabled: boolean;
  37490. /**
  37491. * Defines the buttons associated with the input to handle camera rotation.
  37492. */
  37493. buttons: number[];
  37494. /**
  37495. * Assign buttons for Yaw control.
  37496. */
  37497. buttonsYaw: number[];
  37498. /**
  37499. * Assign buttons for Pitch control.
  37500. */
  37501. buttonsPitch: number[];
  37502. /**
  37503. * Assign buttons for Roll control.
  37504. */
  37505. buttonsRoll: number[];
  37506. /**
  37507. * Detect if any button is being pressed while mouse is moved.
  37508. * -1 = Mouse locked.
  37509. * 0 = Left button.
  37510. * 1 = Middle Button.
  37511. * 2 = Right Button.
  37512. */
  37513. activeButton: number;
  37514. /**
  37515. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37516. * Higher values reduce its sensitivity.
  37517. */
  37518. angularSensibility: number;
  37519. private _mousemoveCallback;
  37520. private _observer;
  37521. private _rollObserver;
  37522. private previousPosition;
  37523. private noPreventDefault;
  37524. private element;
  37525. /**
  37526. * Listen to mouse events to control the camera.
  37527. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37529. */
  37530. constructor(touchEnabled?: boolean);
  37531. /**
  37532. * Attach the mouse control to the HTML DOM element.
  37533. * @param element Defines the element that listens to the input events.
  37534. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37535. */
  37536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37537. /**
  37538. * Detach the current controls from the specified dom element.
  37539. * @param element Defines the element to stop listening the inputs from
  37540. */
  37541. detachControl(element: Nullable<HTMLElement>): void;
  37542. /**
  37543. * Gets the class name of the current input.
  37544. * @returns the class name.
  37545. */
  37546. getClassName(): string;
  37547. /**
  37548. * Get the friendly name associated with the input class.
  37549. * @returns the input's friendly name.
  37550. */
  37551. getSimpleName(): string;
  37552. private _pointerInput;
  37553. private _onMouseMove;
  37554. /**
  37555. * Rotate camera by mouse offset.
  37556. */
  37557. private rotateCamera;
  37558. }
  37559. }
  37560. declare module BABYLON {
  37561. /**
  37562. * Default Inputs manager for the FlyCamera.
  37563. * It groups all the default supported inputs for ease of use.
  37564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37565. */
  37566. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37567. /**
  37568. * Instantiates a new FlyCameraInputsManager.
  37569. * @param camera Defines the camera the inputs belong to.
  37570. */
  37571. constructor(camera: FlyCamera);
  37572. /**
  37573. * Add keyboard input support to the input manager.
  37574. * @returns the new FlyCameraKeyboardMoveInput().
  37575. */
  37576. addKeyboard(): FlyCameraInputsManager;
  37577. /**
  37578. * Add mouse input support to the input manager.
  37579. * @param touchEnabled Enable touch screen support.
  37580. * @returns the new FlyCameraMouseInput().
  37581. */
  37582. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37583. }
  37584. }
  37585. declare module BABYLON {
  37586. /**
  37587. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37588. * such as in a 3D Space Shooter or a Flight Simulator.
  37589. */
  37590. export class FlyCamera extends TargetCamera {
  37591. /**
  37592. * Define the collision ellipsoid of the camera.
  37593. * This is helpful for simulating a camera body, like a player's body.
  37594. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37595. */
  37596. ellipsoid: Vector3;
  37597. /**
  37598. * Define an offset for the position of the ellipsoid around the camera.
  37599. * This can be helpful if the camera is attached away from the player's body center,
  37600. * such as at its head.
  37601. */
  37602. ellipsoidOffset: Vector3;
  37603. /**
  37604. * Enable or disable collisions of the camera with the rest of the scene objects.
  37605. */
  37606. checkCollisions: boolean;
  37607. /**
  37608. * Enable or disable gravity on the camera.
  37609. */
  37610. applyGravity: boolean;
  37611. /**
  37612. * Define the current direction the camera is moving to.
  37613. */
  37614. cameraDirection: Vector3;
  37615. /**
  37616. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37617. * This overrides and empties cameraRotation.
  37618. */
  37619. rotationQuaternion: Quaternion;
  37620. /**
  37621. * Track Roll to maintain the wanted Rolling when looking around.
  37622. */
  37623. _trackRoll: number;
  37624. /**
  37625. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37626. */
  37627. rollCorrect: number;
  37628. /**
  37629. * Mimic a banked turn, Rolling the camera when Yawing.
  37630. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37631. */
  37632. bankedTurn: boolean;
  37633. /**
  37634. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37635. */
  37636. bankedTurnLimit: number;
  37637. /**
  37638. * Value of 0 disables the banked Roll.
  37639. * Value of 1 is equal to the Yaw angle in radians.
  37640. */
  37641. bankedTurnMultiplier: number;
  37642. /**
  37643. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37644. */
  37645. inputs: FlyCameraInputsManager;
  37646. /**
  37647. * Gets the input sensibility for mouse input.
  37648. * Higher values reduce sensitivity.
  37649. */
  37650. /**
  37651. * Sets the input sensibility for a mouse input.
  37652. * Higher values reduce sensitivity.
  37653. */
  37654. angularSensibility: number;
  37655. /**
  37656. * Get the keys for camera movement forward.
  37657. */
  37658. /**
  37659. * Set the keys for camera movement forward.
  37660. */
  37661. keysForward: number[];
  37662. /**
  37663. * Get the keys for camera movement backward.
  37664. */
  37665. keysBackward: number[];
  37666. /**
  37667. * Get the keys for camera movement up.
  37668. */
  37669. /**
  37670. * Set the keys for camera movement up.
  37671. */
  37672. keysUp: number[];
  37673. /**
  37674. * Get the keys for camera movement down.
  37675. */
  37676. /**
  37677. * Set the keys for camera movement down.
  37678. */
  37679. keysDown: number[];
  37680. /**
  37681. * Get the keys for camera movement left.
  37682. */
  37683. /**
  37684. * Set the keys for camera movement left.
  37685. */
  37686. keysLeft: number[];
  37687. /**
  37688. * Set the keys for camera movement right.
  37689. */
  37690. /**
  37691. * Set the keys for camera movement right.
  37692. */
  37693. keysRight: number[];
  37694. /**
  37695. * Event raised when the camera collides with a mesh in the scene.
  37696. */
  37697. onCollide: (collidedMesh: AbstractMesh) => void;
  37698. private _collider;
  37699. private _needMoveForGravity;
  37700. private _oldPosition;
  37701. private _diffPosition;
  37702. private _newPosition;
  37703. /** @hidden */
  37704. _localDirection: Vector3;
  37705. /** @hidden */
  37706. _transformedDirection: Vector3;
  37707. /**
  37708. * Instantiates a FlyCamera.
  37709. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37710. * such as in a 3D Space Shooter or a Flight Simulator.
  37711. * @param name Define the name of the camera in the scene.
  37712. * @param position Define the starting position of the camera in the scene.
  37713. * @param scene Define the scene the camera belongs to.
  37714. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37715. */
  37716. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37717. /**
  37718. * Attach a control to the HTML DOM element.
  37719. * @param element Defines the element that listens to the input events.
  37720. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37721. */
  37722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37723. /**
  37724. * Detach a control from the HTML DOM element.
  37725. * The camera will stop reacting to that input.
  37726. * @param element Defines the element that listens to the input events.
  37727. */
  37728. detachControl(element: HTMLElement): void;
  37729. private _collisionMask;
  37730. /**
  37731. * Get the mask that the camera ignores in collision events.
  37732. */
  37733. /**
  37734. * Set the mask that the camera ignores in collision events.
  37735. */
  37736. collisionMask: number;
  37737. /** @hidden */
  37738. _collideWithWorld(displacement: Vector3): void;
  37739. /** @hidden */
  37740. private _onCollisionPositionChange;
  37741. /** @hidden */
  37742. _checkInputs(): void;
  37743. /** @hidden */
  37744. _decideIfNeedsToMove(): boolean;
  37745. /** @hidden */
  37746. _updatePosition(): void;
  37747. /**
  37748. * Restore the Roll to its target value at the rate specified.
  37749. * @param rate - Higher means slower restoring.
  37750. * @hidden
  37751. */
  37752. restoreRoll(rate: number): void;
  37753. /**
  37754. * Destroy the camera and release the current resources held by it.
  37755. */
  37756. dispose(): void;
  37757. /**
  37758. * Get the current object class name.
  37759. * @returns the class name.
  37760. */
  37761. getClassName(): string;
  37762. }
  37763. }
  37764. declare module BABYLON {
  37765. /**
  37766. * Listen to keyboard events to control the camera.
  37767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37768. */
  37769. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37770. /**
  37771. * Defines the camera the input is attached to.
  37772. */
  37773. camera: FlyCamera;
  37774. /**
  37775. * The list of keyboard keys used to control the forward move of the camera.
  37776. */
  37777. keysForward: number[];
  37778. /**
  37779. * The list of keyboard keys used to control the backward move of the camera.
  37780. */
  37781. keysBackward: number[];
  37782. /**
  37783. * The list of keyboard keys used to control the forward move of the camera.
  37784. */
  37785. keysUp: number[];
  37786. /**
  37787. * The list of keyboard keys used to control the backward move of the camera.
  37788. */
  37789. keysDown: number[];
  37790. /**
  37791. * The list of keyboard keys used to control the right strafe move of the camera.
  37792. */
  37793. keysRight: number[];
  37794. /**
  37795. * The list of keyboard keys used to control the left strafe move of the camera.
  37796. */
  37797. keysLeft: number[];
  37798. private _keys;
  37799. private _onCanvasBlurObserver;
  37800. private _onKeyboardObserver;
  37801. private _engine;
  37802. private _scene;
  37803. /**
  37804. * Attach the input controls to a specific dom element to get the input from.
  37805. * @param element Defines the element the controls should be listened from
  37806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37807. */
  37808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37809. /**
  37810. * Detach the current controls from the specified dom element.
  37811. * @param element Defines the element to stop listening the inputs from
  37812. */
  37813. detachControl(element: Nullable<HTMLElement>): void;
  37814. /**
  37815. * Gets the class name of the current intput.
  37816. * @returns the class name
  37817. */
  37818. getClassName(): string;
  37819. /** @hidden */
  37820. _onLostFocus(e: FocusEvent): void;
  37821. /**
  37822. * Get the friendly name associated with the input class.
  37823. * @returns the input friendly name
  37824. */
  37825. getSimpleName(): string;
  37826. /**
  37827. * Update the current camera state depending on the inputs that have been used this frame.
  37828. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37829. */
  37830. checkInputs(): void;
  37831. }
  37832. }
  37833. declare module BABYLON {
  37834. /**
  37835. * Manage the mouse wheel inputs to control a follow camera.
  37836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37837. */
  37838. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37839. /**
  37840. * Defines the camera the input is attached to.
  37841. */
  37842. camera: FollowCamera;
  37843. /**
  37844. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37845. */
  37846. axisControlRadius: boolean;
  37847. /**
  37848. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37849. */
  37850. axisControlHeight: boolean;
  37851. /**
  37852. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37853. */
  37854. axisControlRotation: boolean;
  37855. /**
  37856. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37857. * relation to mouseWheel events.
  37858. */
  37859. wheelPrecision: number;
  37860. /**
  37861. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37862. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37863. */
  37864. wheelDeltaPercentage: number;
  37865. private _wheel;
  37866. private _observer;
  37867. /**
  37868. * Attach the input controls to a specific dom element to get the input from.
  37869. * @param element Defines the element the controls should be listened from
  37870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37871. */
  37872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37873. /**
  37874. * Detach the current controls from the specified dom element.
  37875. * @param element Defines the element to stop listening the inputs from
  37876. */
  37877. detachControl(element: Nullable<HTMLElement>): void;
  37878. /**
  37879. * Gets the class name of the current intput.
  37880. * @returns the class name
  37881. */
  37882. getClassName(): string;
  37883. /**
  37884. * Get the friendly name associated with the input class.
  37885. * @returns the input friendly name
  37886. */
  37887. getSimpleName(): string;
  37888. }
  37889. }
  37890. declare module BABYLON {
  37891. /**
  37892. * Manage the pointers inputs to control an follow camera.
  37893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37894. */
  37895. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37896. /**
  37897. * Defines the camera the input is attached to.
  37898. */
  37899. camera: FollowCamera;
  37900. /**
  37901. * Gets the class name of the current input.
  37902. * @returns the class name
  37903. */
  37904. getClassName(): string;
  37905. /**
  37906. * Defines the pointer angular sensibility along the X axis or how fast is
  37907. * the camera rotating.
  37908. * A negative number will reverse the axis direction.
  37909. */
  37910. angularSensibilityX: number;
  37911. /**
  37912. * Defines the pointer angular sensibility along the Y axis or how fast is
  37913. * the camera rotating.
  37914. * A negative number will reverse the axis direction.
  37915. */
  37916. angularSensibilityY: number;
  37917. /**
  37918. * Defines the pointer pinch precision or how fast is the camera zooming.
  37919. * A negative number will reverse the axis direction.
  37920. */
  37921. pinchPrecision: number;
  37922. /**
  37923. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37924. * from 0.
  37925. * It defines the percentage of current camera.radius to use as delta when
  37926. * pinch zoom is used.
  37927. */
  37928. pinchDeltaPercentage: number;
  37929. /**
  37930. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37931. */
  37932. axisXControlRadius: boolean;
  37933. /**
  37934. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37935. */
  37936. axisXControlHeight: boolean;
  37937. /**
  37938. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37939. */
  37940. axisXControlRotation: boolean;
  37941. /**
  37942. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37943. */
  37944. axisYControlRadius: boolean;
  37945. /**
  37946. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37947. */
  37948. axisYControlHeight: boolean;
  37949. /**
  37950. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37951. */
  37952. axisYControlRotation: boolean;
  37953. /**
  37954. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37955. */
  37956. axisPinchControlRadius: boolean;
  37957. /**
  37958. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37959. */
  37960. axisPinchControlHeight: boolean;
  37961. /**
  37962. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37963. */
  37964. axisPinchControlRotation: boolean;
  37965. /**
  37966. * Log error messages if basic misconfiguration has occurred.
  37967. */
  37968. warningEnable: boolean;
  37969. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37970. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37971. private _warningCounter;
  37972. private _warning;
  37973. }
  37974. }
  37975. declare module BABYLON {
  37976. /**
  37977. * Default Inputs manager for the FollowCamera.
  37978. * It groups all the default supported inputs for ease of use.
  37979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37980. */
  37981. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37982. /**
  37983. * Instantiates a new FollowCameraInputsManager.
  37984. * @param camera Defines the camera the inputs belong to
  37985. */
  37986. constructor(camera: FollowCamera);
  37987. /**
  37988. * Add keyboard input support to the input manager.
  37989. * @returns the current input manager
  37990. */
  37991. addKeyboard(): FollowCameraInputsManager;
  37992. /**
  37993. * Add mouse wheel input support to the input manager.
  37994. * @returns the current input manager
  37995. */
  37996. addMouseWheel(): FollowCameraInputsManager;
  37997. /**
  37998. * Add pointers input support to the input manager.
  37999. * @returns the current input manager
  38000. */
  38001. addPointers(): FollowCameraInputsManager;
  38002. /**
  38003. * Add orientation input support to the input manager.
  38004. * @returns the current input manager
  38005. */
  38006. addVRDeviceOrientation(): FollowCameraInputsManager;
  38007. }
  38008. }
  38009. declare module BABYLON {
  38010. /**
  38011. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38012. * an arc rotate version arcFollowCamera are available.
  38013. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38014. */
  38015. export class FollowCamera extends TargetCamera {
  38016. /**
  38017. * Distance the follow camera should follow an object at
  38018. */
  38019. radius: number;
  38020. /**
  38021. * Minimum allowed distance of the camera to the axis of rotation
  38022. * (The camera can not get closer).
  38023. * This can help limiting how the Camera is able to move in the scene.
  38024. */
  38025. lowerRadiusLimit: Nullable<number>;
  38026. /**
  38027. * Maximum allowed distance of the camera to the axis of rotation
  38028. * (The camera can not get further).
  38029. * This can help limiting how the Camera is able to move in the scene.
  38030. */
  38031. upperRadiusLimit: Nullable<number>;
  38032. /**
  38033. * Define a rotation offset between the camera and the object it follows
  38034. */
  38035. rotationOffset: number;
  38036. /**
  38037. * Minimum allowed angle to camera position relative to target object.
  38038. * This can help limiting how the Camera is able to move in the scene.
  38039. */
  38040. lowerRotationOffsetLimit: Nullable<number>;
  38041. /**
  38042. * Maximum allowed angle to camera position relative to target object.
  38043. * This can help limiting how the Camera is able to move in the scene.
  38044. */
  38045. upperRotationOffsetLimit: Nullable<number>;
  38046. /**
  38047. * Define a height offset between the camera and the object it follows.
  38048. * It can help following an object from the top (like a car chaing a plane)
  38049. */
  38050. heightOffset: number;
  38051. /**
  38052. * Minimum allowed height of camera position relative to target object.
  38053. * This can help limiting how the Camera is able to move in the scene.
  38054. */
  38055. lowerHeightOffsetLimit: Nullable<number>;
  38056. /**
  38057. * Maximum allowed height of camera position relative to target object.
  38058. * This can help limiting how the Camera is able to move in the scene.
  38059. */
  38060. upperHeightOffsetLimit: Nullable<number>;
  38061. /**
  38062. * Define how fast the camera can accelerate to follow it s target.
  38063. */
  38064. cameraAcceleration: number;
  38065. /**
  38066. * Define the speed limit of the camera following an object.
  38067. */
  38068. maxCameraSpeed: number;
  38069. /**
  38070. * Define the target of the camera.
  38071. */
  38072. lockedTarget: Nullable<AbstractMesh>;
  38073. /**
  38074. * Defines the input associated with the camera.
  38075. */
  38076. inputs: FollowCameraInputsManager;
  38077. /**
  38078. * Instantiates the follow camera.
  38079. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38080. * @param name Define the name of the camera in the scene
  38081. * @param position Define the position of the camera
  38082. * @param scene Define the scene the camera belong to
  38083. * @param lockedTarget Define the target of the camera
  38084. */
  38085. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38086. private _follow;
  38087. /**
  38088. * Attached controls to the current camera.
  38089. * @param element Defines the element the controls should be listened from
  38090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38091. */
  38092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38093. /**
  38094. * Detach the current controls from the camera.
  38095. * The camera will stop reacting to inputs.
  38096. * @param element Defines the element to stop listening the inputs from
  38097. */
  38098. detachControl(element: HTMLElement): void;
  38099. /** @hidden */
  38100. _checkInputs(): void;
  38101. private _checkLimits;
  38102. /**
  38103. * Gets the camera class name.
  38104. * @returns the class name
  38105. */
  38106. getClassName(): string;
  38107. }
  38108. /**
  38109. * Arc Rotate version of the follow camera.
  38110. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38111. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38112. */
  38113. export class ArcFollowCamera extends TargetCamera {
  38114. /** The longitudinal angle of the camera */
  38115. alpha: number;
  38116. /** The latitudinal angle of the camera */
  38117. beta: number;
  38118. /** The radius of the camera from its target */
  38119. radius: number;
  38120. /** Define the camera target (the messh it should follow) */
  38121. target: Nullable<AbstractMesh>;
  38122. private _cartesianCoordinates;
  38123. /**
  38124. * Instantiates a new ArcFollowCamera
  38125. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38126. * @param name Define the name of the camera
  38127. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38128. * @param beta Define the rotation angle of the camera around the elevation axis
  38129. * @param radius Define the radius of the camera from its target point
  38130. * @param target Define the target of the camera
  38131. * @param scene Define the scene the camera belongs to
  38132. */
  38133. constructor(name: string,
  38134. /** The longitudinal angle of the camera */
  38135. alpha: number,
  38136. /** The latitudinal angle of the camera */
  38137. beta: number,
  38138. /** The radius of the camera from its target */
  38139. radius: number,
  38140. /** Define the camera target (the messh it should follow) */
  38141. target: Nullable<AbstractMesh>, scene: Scene);
  38142. private _follow;
  38143. /** @hidden */
  38144. _checkInputs(): void;
  38145. /**
  38146. * Returns the class name of the object.
  38147. * It is mostly used internally for serialization purposes.
  38148. */
  38149. getClassName(): string;
  38150. }
  38151. }
  38152. declare module BABYLON {
  38153. /**
  38154. * Manage the keyboard inputs to control the movement of a follow camera.
  38155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38156. */
  38157. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38158. /**
  38159. * Defines the camera the input is attached to.
  38160. */
  38161. camera: FollowCamera;
  38162. /**
  38163. * Defines the list of key codes associated with the up action (increase heightOffset)
  38164. */
  38165. keysHeightOffsetIncr: number[];
  38166. /**
  38167. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38168. */
  38169. keysHeightOffsetDecr: number[];
  38170. /**
  38171. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38172. */
  38173. keysHeightOffsetModifierAlt: boolean;
  38174. /**
  38175. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38176. */
  38177. keysHeightOffsetModifierCtrl: boolean;
  38178. /**
  38179. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38180. */
  38181. keysHeightOffsetModifierShift: boolean;
  38182. /**
  38183. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38184. */
  38185. keysRotationOffsetIncr: number[];
  38186. /**
  38187. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38188. */
  38189. keysRotationOffsetDecr: number[];
  38190. /**
  38191. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38192. */
  38193. keysRotationOffsetModifierAlt: boolean;
  38194. /**
  38195. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38196. */
  38197. keysRotationOffsetModifierCtrl: boolean;
  38198. /**
  38199. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38200. */
  38201. keysRotationOffsetModifierShift: boolean;
  38202. /**
  38203. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38204. */
  38205. keysRadiusIncr: number[];
  38206. /**
  38207. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38208. */
  38209. keysRadiusDecr: number[];
  38210. /**
  38211. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38212. */
  38213. keysRadiusModifierAlt: boolean;
  38214. /**
  38215. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38216. */
  38217. keysRadiusModifierCtrl: boolean;
  38218. /**
  38219. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38220. */
  38221. keysRadiusModifierShift: boolean;
  38222. /**
  38223. * Defines the rate of change of heightOffset.
  38224. */
  38225. heightSensibility: number;
  38226. /**
  38227. * Defines the rate of change of rotationOffset.
  38228. */
  38229. rotationSensibility: number;
  38230. /**
  38231. * Defines the rate of change of radius.
  38232. */
  38233. radiusSensibility: number;
  38234. private _keys;
  38235. private _ctrlPressed;
  38236. private _altPressed;
  38237. private _shiftPressed;
  38238. private _onCanvasBlurObserver;
  38239. private _onKeyboardObserver;
  38240. private _engine;
  38241. private _scene;
  38242. /**
  38243. * Attach the input controls to a specific dom element to get the input from.
  38244. * @param element Defines the element the controls should be listened from
  38245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38246. */
  38247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38248. /**
  38249. * Detach the current controls from the specified dom element.
  38250. * @param element Defines the element to stop listening the inputs from
  38251. */
  38252. detachControl(element: Nullable<HTMLElement>): void;
  38253. /**
  38254. * Update the current camera state depending on the inputs that have been used this frame.
  38255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38256. */
  38257. checkInputs(): void;
  38258. /**
  38259. * Gets the class name of the current input.
  38260. * @returns the class name
  38261. */
  38262. getClassName(): string;
  38263. /**
  38264. * Get the friendly name associated with the input class.
  38265. * @returns the input friendly name
  38266. */
  38267. getSimpleName(): string;
  38268. /**
  38269. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38270. * allow modification of the heightOffset value.
  38271. */
  38272. private _modifierHeightOffset;
  38273. /**
  38274. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38275. * allow modification of the rotationOffset value.
  38276. */
  38277. private _modifierRotationOffset;
  38278. /**
  38279. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38280. * allow modification of the radius value.
  38281. */
  38282. private _modifierRadius;
  38283. }
  38284. }
  38285. declare module BABYLON {
  38286. interface FreeCameraInputsManager {
  38287. /**
  38288. * @hidden
  38289. */
  38290. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38291. /**
  38292. * Add orientation input support to the input manager.
  38293. * @returns the current input manager
  38294. */
  38295. addDeviceOrientation(): FreeCameraInputsManager;
  38296. }
  38297. /**
  38298. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38299. * Screen rotation is taken into account.
  38300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38301. */
  38302. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38303. private _camera;
  38304. private _screenOrientationAngle;
  38305. private _constantTranform;
  38306. private _screenQuaternion;
  38307. private _alpha;
  38308. private _beta;
  38309. private _gamma;
  38310. /**
  38311. * Can be used to detect if a device orientation sensor is availible on a device
  38312. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38313. * @returns a promise that will resolve on orientation change
  38314. */
  38315. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38316. /**
  38317. * @hidden
  38318. */
  38319. _onDeviceOrientationChangedObservable: Observable<void>;
  38320. /**
  38321. * Instantiates a new input
  38322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38323. */
  38324. constructor();
  38325. /**
  38326. * Define the camera controlled by the input.
  38327. */
  38328. camera: FreeCamera;
  38329. /**
  38330. * Attach the input controls to a specific dom element to get the input from.
  38331. * @param element Defines the element the controls should be listened from
  38332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38333. */
  38334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38335. private _orientationChanged;
  38336. private _deviceOrientation;
  38337. /**
  38338. * Detach the current controls from the specified dom element.
  38339. * @param element Defines the element to stop listening the inputs from
  38340. */
  38341. detachControl(element: Nullable<HTMLElement>): void;
  38342. /**
  38343. * Update the current camera state depending on the inputs that have been used this frame.
  38344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38345. */
  38346. checkInputs(): void;
  38347. /**
  38348. * Gets the class name of the current intput.
  38349. * @returns the class name
  38350. */
  38351. getClassName(): string;
  38352. /**
  38353. * Get the friendly name associated with the input class.
  38354. * @returns the input friendly name
  38355. */
  38356. getSimpleName(): string;
  38357. }
  38358. }
  38359. declare module BABYLON {
  38360. /**
  38361. * Manage the gamepad inputs to control a free camera.
  38362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38363. */
  38364. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38365. /**
  38366. * Define the camera the input is attached to.
  38367. */
  38368. camera: FreeCamera;
  38369. /**
  38370. * Define the Gamepad controlling the input
  38371. */
  38372. gamepad: Nullable<Gamepad>;
  38373. /**
  38374. * Defines the gamepad rotation sensiblity.
  38375. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38376. */
  38377. gamepadAngularSensibility: number;
  38378. /**
  38379. * Defines the gamepad move sensiblity.
  38380. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38381. */
  38382. gamepadMoveSensibility: number;
  38383. private _yAxisScale;
  38384. /**
  38385. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38386. */
  38387. invertYAxis: boolean;
  38388. private _onGamepadConnectedObserver;
  38389. private _onGamepadDisconnectedObserver;
  38390. private _cameraTransform;
  38391. private _deltaTransform;
  38392. private _vector3;
  38393. private _vector2;
  38394. /**
  38395. * Attach the input controls to a specific dom element to get the input from.
  38396. * @param element Defines the element the controls should be listened from
  38397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38398. */
  38399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38400. /**
  38401. * Detach the current controls from the specified dom element.
  38402. * @param element Defines the element to stop listening the inputs from
  38403. */
  38404. detachControl(element: Nullable<HTMLElement>): void;
  38405. /**
  38406. * Update the current camera state depending on the inputs that have been used this frame.
  38407. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38408. */
  38409. checkInputs(): void;
  38410. /**
  38411. * Gets the class name of the current intput.
  38412. * @returns the class name
  38413. */
  38414. getClassName(): string;
  38415. /**
  38416. * Get the friendly name associated with the input class.
  38417. * @returns the input friendly name
  38418. */
  38419. getSimpleName(): string;
  38420. }
  38421. }
  38422. declare module BABYLON {
  38423. /**
  38424. * Defines the potential axis of a Joystick
  38425. */
  38426. export enum JoystickAxis {
  38427. /** X axis */
  38428. X = 0,
  38429. /** Y axis */
  38430. Y = 1,
  38431. /** Z axis */
  38432. Z = 2
  38433. }
  38434. /**
  38435. * Class used to define virtual joystick (used in touch mode)
  38436. */
  38437. export class VirtualJoystick {
  38438. /**
  38439. * Gets or sets a boolean indicating that left and right values must be inverted
  38440. */
  38441. reverseLeftRight: boolean;
  38442. /**
  38443. * Gets or sets a boolean indicating that up and down values must be inverted
  38444. */
  38445. reverseUpDown: boolean;
  38446. /**
  38447. * Gets the offset value for the position (ie. the change of the position value)
  38448. */
  38449. deltaPosition: Vector3;
  38450. /**
  38451. * Gets a boolean indicating if the virtual joystick was pressed
  38452. */
  38453. pressed: boolean;
  38454. /**
  38455. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38456. */
  38457. static Canvas: Nullable<HTMLCanvasElement>;
  38458. private static _globalJoystickIndex;
  38459. private static vjCanvasContext;
  38460. private static vjCanvasWidth;
  38461. private static vjCanvasHeight;
  38462. private static halfWidth;
  38463. private _action;
  38464. private _axisTargetedByLeftAndRight;
  38465. private _axisTargetedByUpAndDown;
  38466. private _joystickSensibility;
  38467. private _inversedSensibility;
  38468. private _joystickPointerID;
  38469. private _joystickColor;
  38470. private _joystickPointerPos;
  38471. private _joystickPreviousPointerPos;
  38472. private _joystickPointerStartPos;
  38473. private _deltaJoystickVector;
  38474. private _leftJoystick;
  38475. private _touches;
  38476. private _onPointerDownHandlerRef;
  38477. private _onPointerMoveHandlerRef;
  38478. private _onPointerUpHandlerRef;
  38479. private _onResize;
  38480. /**
  38481. * Creates a new virtual joystick
  38482. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38483. */
  38484. constructor(leftJoystick?: boolean);
  38485. /**
  38486. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38487. * @param newJoystickSensibility defines the new sensibility
  38488. */
  38489. setJoystickSensibility(newJoystickSensibility: number): void;
  38490. private _onPointerDown;
  38491. private _onPointerMove;
  38492. private _onPointerUp;
  38493. /**
  38494. * Change the color of the virtual joystick
  38495. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38496. */
  38497. setJoystickColor(newColor: string): void;
  38498. /**
  38499. * Defines a callback to call when the joystick is touched
  38500. * @param action defines the callback
  38501. */
  38502. setActionOnTouch(action: () => any): void;
  38503. /**
  38504. * Defines which axis you'd like to control for left & right
  38505. * @param axis defines the axis to use
  38506. */
  38507. setAxisForLeftRight(axis: JoystickAxis): void;
  38508. /**
  38509. * Defines which axis you'd like to control for up & down
  38510. * @param axis defines the axis to use
  38511. */
  38512. setAxisForUpDown(axis: JoystickAxis): void;
  38513. private _drawVirtualJoystick;
  38514. /**
  38515. * Release internal HTML canvas
  38516. */
  38517. releaseCanvas(): void;
  38518. }
  38519. }
  38520. declare module BABYLON {
  38521. interface FreeCameraInputsManager {
  38522. /**
  38523. * Add virtual joystick input support to the input manager.
  38524. * @returns the current input manager
  38525. */
  38526. addVirtualJoystick(): FreeCameraInputsManager;
  38527. }
  38528. /**
  38529. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38531. */
  38532. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38533. /**
  38534. * Defines the camera the input is attached to.
  38535. */
  38536. camera: FreeCamera;
  38537. private _leftjoystick;
  38538. private _rightjoystick;
  38539. /**
  38540. * Gets the left stick of the virtual joystick.
  38541. * @returns The virtual Joystick
  38542. */
  38543. getLeftJoystick(): VirtualJoystick;
  38544. /**
  38545. * Gets the right stick of the virtual joystick.
  38546. * @returns The virtual Joystick
  38547. */
  38548. getRightJoystick(): VirtualJoystick;
  38549. /**
  38550. * Update the current camera state depending on the inputs that have been used this frame.
  38551. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38552. */
  38553. checkInputs(): void;
  38554. /**
  38555. * Attach the input controls to a specific dom element to get the input from.
  38556. * @param element Defines the element the controls should be listened from
  38557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38558. */
  38559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38560. /**
  38561. * Detach the current controls from the specified dom element.
  38562. * @param element Defines the element to stop listening the inputs from
  38563. */
  38564. detachControl(element: Nullable<HTMLElement>): void;
  38565. /**
  38566. * Gets the class name of the current intput.
  38567. * @returns the class name
  38568. */
  38569. getClassName(): string;
  38570. /**
  38571. * Get the friendly name associated with the input class.
  38572. * @returns the input friendly name
  38573. */
  38574. getSimpleName(): string;
  38575. }
  38576. }
  38577. declare module BABYLON {
  38578. /**
  38579. * This represents a FPS type of camera controlled by touch.
  38580. * This is like a universal camera minus the Gamepad controls.
  38581. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38582. */
  38583. export class TouchCamera extends FreeCamera {
  38584. /**
  38585. * Defines the touch sensibility for rotation.
  38586. * The higher the faster.
  38587. */
  38588. touchAngularSensibility: number;
  38589. /**
  38590. * Defines the touch sensibility for move.
  38591. * The higher the faster.
  38592. */
  38593. touchMoveSensibility: number;
  38594. /**
  38595. * Instantiates a new touch camera.
  38596. * This represents a FPS type of camera controlled by touch.
  38597. * This is like a universal camera minus the Gamepad controls.
  38598. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38599. * @param name Define the name of the camera in the scene
  38600. * @param position Define the start position of the camera in the scene
  38601. * @param scene Define the scene the camera belongs to
  38602. */
  38603. constructor(name: string, position: Vector3, scene: Scene);
  38604. /**
  38605. * Gets the current object class name.
  38606. * @return the class name
  38607. */
  38608. getClassName(): string;
  38609. /** @hidden */
  38610. _setupInputs(): void;
  38611. }
  38612. }
  38613. declare module BABYLON {
  38614. /**
  38615. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38616. * being tilted forward or back and left or right.
  38617. */
  38618. export class DeviceOrientationCamera extends FreeCamera {
  38619. private _initialQuaternion;
  38620. private _quaternionCache;
  38621. private _tmpDragQuaternion;
  38622. private _disablePointerInputWhenUsingDeviceOrientation;
  38623. /**
  38624. * Creates a new device orientation camera
  38625. * @param name The name of the camera
  38626. * @param position The start position camera
  38627. * @param scene The scene the camera belongs to
  38628. */
  38629. constructor(name: string, position: Vector3, scene: Scene);
  38630. /**
  38631. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38632. */
  38633. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38634. private _dragFactor;
  38635. /**
  38636. * Enabled turning on the y axis when the orientation sensor is active
  38637. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38638. */
  38639. enableHorizontalDragging(dragFactor?: number): void;
  38640. /**
  38641. * Gets the current instance class name ("DeviceOrientationCamera").
  38642. * This helps avoiding instanceof at run time.
  38643. * @returns the class name
  38644. */
  38645. getClassName(): string;
  38646. /**
  38647. * @hidden
  38648. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38649. */
  38650. _checkInputs(): void;
  38651. /**
  38652. * Reset the camera to its default orientation on the specified axis only.
  38653. * @param axis The axis to reset
  38654. */
  38655. resetToCurrentRotation(axis?: Axis): void;
  38656. }
  38657. }
  38658. declare module BABYLON {
  38659. /**
  38660. * Defines supported buttons for XBox360 compatible gamepads
  38661. */
  38662. export enum Xbox360Button {
  38663. /** A */
  38664. A = 0,
  38665. /** B */
  38666. B = 1,
  38667. /** X */
  38668. X = 2,
  38669. /** Y */
  38670. Y = 3,
  38671. /** Start */
  38672. Start = 4,
  38673. /** Back */
  38674. Back = 5,
  38675. /** Left button */
  38676. LB = 6,
  38677. /** Right button */
  38678. RB = 7,
  38679. /** Left stick */
  38680. LeftStick = 8,
  38681. /** Right stick */
  38682. RightStick = 9
  38683. }
  38684. /** Defines values for XBox360 DPad */
  38685. export enum Xbox360Dpad {
  38686. /** Up */
  38687. Up = 0,
  38688. /** Down */
  38689. Down = 1,
  38690. /** Left */
  38691. Left = 2,
  38692. /** Right */
  38693. Right = 3
  38694. }
  38695. /**
  38696. * Defines a XBox360 gamepad
  38697. */
  38698. export class Xbox360Pad extends Gamepad {
  38699. private _leftTrigger;
  38700. private _rightTrigger;
  38701. private _onlefttriggerchanged;
  38702. private _onrighttriggerchanged;
  38703. private _onbuttondown;
  38704. private _onbuttonup;
  38705. private _ondpaddown;
  38706. private _ondpadup;
  38707. /** Observable raised when a button is pressed */
  38708. onButtonDownObservable: Observable<Xbox360Button>;
  38709. /** Observable raised when a button is released */
  38710. onButtonUpObservable: Observable<Xbox360Button>;
  38711. /** Observable raised when a pad is pressed */
  38712. onPadDownObservable: Observable<Xbox360Dpad>;
  38713. /** Observable raised when a pad is released */
  38714. onPadUpObservable: Observable<Xbox360Dpad>;
  38715. private _buttonA;
  38716. private _buttonB;
  38717. private _buttonX;
  38718. private _buttonY;
  38719. private _buttonBack;
  38720. private _buttonStart;
  38721. private _buttonLB;
  38722. private _buttonRB;
  38723. private _buttonLeftStick;
  38724. private _buttonRightStick;
  38725. private _dPadUp;
  38726. private _dPadDown;
  38727. private _dPadLeft;
  38728. private _dPadRight;
  38729. private _isXboxOnePad;
  38730. /**
  38731. * Creates a new XBox360 gamepad object
  38732. * @param id defines the id of this gamepad
  38733. * @param index defines its index
  38734. * @param gamepad defines the internal HTML gamepad object
  38735. * @param xboxOne defines if it is a XBox One gamepad
  38736. */
  38737. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38738. /**
  38739. * Defines the callback to call when left trigger is pressed
  38740. * @param callback defines the callback to use
  38741. */
  38742. onlefttriggerchanged(callback: (value: number) => void): void;
  38743. /**
  38744. * Defines the callback to call when right trigger is pressed
  38745. * @param callback defines the callback to use
  38746. */
  38747. onrighttriggerchanged(callback: (value: number) => void): void;
  38748. /**
  38749. * Gets the left trigger value
  38750. */
  38751. /**
  38752. * Sets the left trigger value
  38753. */
  38754. leftTrigger: number;
  38755. /**
  38756. * Gets the right trigger value
  38757. */
  38758. /**
  38759. * Sets the right trigger value
  38760. */
  38761. rightTrigger: number;
  38762. /**
  38763. * Defines the callback to call when a button is pressed
  38764. * @param callback defines the callback to use
  38765. */
  38766. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38767. /**
  38768. * Defines the callback to call when a button is released
  38769. * @param callback defines the callback to use
  38770. */
  38771. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38772. /**
  38773. * Defines the callback to call when a pad is pressed
  38774. * @param callback defines the callback to use
  38775. */
  38776. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38777. /**
  38778. * Defines the callback to call when a pad is released
  38779. * @param callback defines the callback to use
  38780. */
  38781. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38782. private _setButtonValue;
  38783. private _setDPadValue;
  38784. /**
  38785. * Gets the value of the `A` button
  38786. */
  38787. /**
  38788. * Sets the value of the `A` button
  38789. */
  38790. buttonA: number;
  38791. /**
  38792. * Gets the value of the `B` button
  38793. */
  38794. /**
  38795. * Sets the value of the `B` button
  38796. */
  38797. buttonB: number;
  38798. /**
  38799. * Gets the value of the `X` button
  38800. */
  38801. /**
  38802. * Sets the value of the `X` button
  38803. */
  38804. buttonX: number;
  38805. /**
  38806. * Gets the value of the `Y` button
  38807. */
  38808. /**
  38809. * Sets the value of the `Y` button
  38810. */
  38811. buttonY: number;
  38812. /**
  38813. * Gets the value of the `Start` button
  38814. */
  38815. /**
  38816. * Sets the value of the `Start` button
  38817. */
  38818. buttonStart: number;
  38819. /**
  38820. * Gets the value of the `Back` button
  38821. */
  38822. /**
  38823. * Sets the value of the `Back` button
  38824. */
  38825. buttonBack: number;
  38826. /**
  38827. * Gets the value of the `Left` button
  38828. */
  38829. /**
  38830. * Sets the value of the `Left` button
  38831. */
  38832. buttonLB: number;
  38833. /**
  38834. * Gets the value of the `Right` button
  38835. */
  38836. /**
  38837. * Sets the value of the `Right` button
  38838. */
  38839. buttonRB: number;
  38840. /**
  38841. * Gets the value of the Left joystick
  38842. */
  38843. /**
  38844. * Sets the value of the Left joystick
  38845. */
  38846. buttonLeftStick: number;
  38847. /**
  38848. * Gets the value of the Right joystick
  38849. */
  38850. /**
  38851. * Sets the value of the Right joystick
  38852. */
  38853. buttonRightStick: number;
  38854. /**
  38855. * Gets the value of D-pad up
  38856. */
  38857. /**
  38858. * Sets the value of D-pad up
  38859. */
  38860. dPadUp: number;
  38861. /**
  38862. * Gets the value of D-pad down
  38863. */
  38864. /**
  38865. * Sets the value of D-pad down
  38866. */
  38867. dPadDown: number;
  38868. /**
  38869. * Gets the value of D-pad left
  38870. */
  38871. /**
  38872. * Sets the value of D-pad left
  38873. */
  38874. dPadLeft: number;
  38875. /**
  38876. * Gets the value of D-pad right
  38877. */
  38878. /**
  38879. * Sets the value of D-pad right
  38880. */
  38881. dPadRight: number;
  38882. /**
  38883. * Force the gamepad to synchronize with device values
  38884. */
  38885. update(): void;
  38886. /**
  38887. * Disposes the gamepad
  38888. */
  38889. dispose(): void;
  38890. }
  38891. }
  38892. declare module BABYLON {
  38893. /**
  38894. * Defines supported buttons for DualShock compatible gamepads
  38895. */
  38896. export enum DualShockButton {
  38897. /** Cross */
  38898. Cross = 0,
  38899. /** Circle */
  38900. Circle = 1,
  38901. /** Square */
  38902. Square = 2,
  38903. /** Triangle */
  38904. Triangle = 3,
  38905. /** Options */
  38906. Options = 4,
  38907. /** Share */
  38908. Share = 5,
  38909. /** L1 */
  38910. L1 = 6,
  38911. /** R1 */
  38912. R1 = 7,
  38913. /** Left stick */
  38914. LeftStick = 8,
  38915. /** Right stick */
  38916. RightStick = 9
  38917. }
  38918. /** Defines values for DualShock DPad */
  38919. export enum DualShockDpad {
  38920. /** Up */
  38921. Up = 0,
  38922. /** Down */
  38923. Down = 1,
  38924. /** Left */
  38925. Left = 2,
  38926. /** Right */
  38927. Right = 3
  38928. }
  38929. /**
  38930. * Defines a DualShock gamepad
  38931. */
  38932. export class DualShockPad extends Gamepad {
  38933. private _leftTrigger;
  38934. private _rightTrigger;
  38935. private _onlefttriggerchanged;
  38936. private _onrighttriggerchanged;
  38937. private _onbuttondown;
  38938. private _onbuttonup;
  38939. private _ondpaddown;
  38940. private _ondpadup;
  38941. /** Observable raised when a button is pressed */
  38942. onButtonDownObservable: Observable<DualShockButton>;
  38943. /** Observable raised when a button is released */
  38944. onButtonUpObservable: Observable<DualShockButton>;
  38945. /** Observable raised when a pad is pressed */
  38946. onPadDownObservable: Observable<DualShockDpad>;
  38947. /** Observable raised when a pad is released */
  38948. onPadUpObservable: Observable<DualShockDpad>;
  38949. private _buttonCross;
  38950. private _buttonCircle;
  38951. private _buttonSquare;
  38952. private _buttonTriangle;
  38953. private _buttonShare;
  38954. private _buttonOptions;
  38955. private _buttonL1;
  38956. private _buttonR1;
  38957. private _buttonLeftStick;
  38958. private _buttonRightStick;
  38959. private _dPadUp;
  38960. private _dPadDown;
  38961. private _dPadLeft;
  38962. private _dPadRight;
  38963. /**
  38964. * Creates a new DualShock gamepad object
  38965. * @param id defines the id of this gamepad
  38966. * @param index defines its index
  38967. * @param gamepad defines the internal HTML gamepad object
  38968. */
  38969. constructor(id: string, index: number, gamepad: any);
  38970. /**
  38971. * Defines the callback to call when left trigger is pressed
  38972. * @param callback defines the callback to use
  38973. */
  38974. onlefttriggerchanged(callback: (value: number) => void): void;
  38975. /**
  38976. * Defines the callback to call when right trigger is pressed
  38977. * @param callback defines the callback to use
  38978. */
  38979. onrighttriggerchanged(callback: (value: number) => void): void;
  38980. /**
  38981. * Gets the left trigger value
  38982. */
  38983. /**
  38984. * Sets the left trigger value
  38985. */
  38986. leftTrigger: number;
  38987. /**
  38988. * Gets the right trigger value
  38989. */
  38990. /**
  38991. * Sets the right trigger value
  38992. */
  38993. rightTrigger: number;
  38994. /**
  38995. * Defines the callback to call when a button is pressed
  38996. * @param callback defines the callback to use
  38997. */
  38998. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38999. /**
  39000. * Defines the callback to call when a button is released
  39001. * @param callback defines the callback to use
  39002. */
  39003. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39004. /**
  39005. * Defines the callback to call when a pad is pressed
  39006. * @param callback defines the callback to use
  39007. */
  39008. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39009. /**
  39010. * Defines the callback to call when a pad is released
  39011. * @param callback defines the callback to use
  39012. */
  39013. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39014. private _setButtonValue;
  39015. private _setDPadValue;
  39016. /**
  39017. * Gets the value of the `Cross` button
  39018. */
  39019. /**
  39020. * Sets the value of the `Cross` button
  39021. */
  39022. buttonCross: number;
  39023. /**
  39024. * Gets the value of the `Circle` button
  39025. */
  39026. /**
  39027. * Sets the value of the `Circle` button
  39028. */
  39029. buttonCircle: number;
  39030. /**
  39031. * Gets the value of the `Square` button
  39032. */
  39033. /**
  39034. * Sets the value of the `Square` button
  39035. */
  39036. buttonSquare: number;
  39037. /**
  39038. * Gets the value of the `Triangle` button
  39039. */
  39040. /**
  39041. * Sets the value of the `Triangle` button
  39042. */
  39043. buttonTriangle: number;
  39044. /**
  39045. * Gets the value of the `Options` button
  39046. */
  39047. /**
  39048. * Sets the value of the `Options` button
  39049. */
  39050. buttonOptions: number;
  39051. /**
  39052. * Gets the value of the `Share` button
  39053. */
  39054. /**
  39055. * Sets the value of the `Share` button
  39056. */
  39057. buttonShare: number;
  39058. /**
  39059. * Gets the value of the `L1` button
  39060. */
  39061. /**
  39062. * Sets the value of the `L1` button
  39063. */
  39064. buttonL1: number;
  39065. /**
  39066. * Gets the value of the `R1` button
  39067. */
  39068. /**
  39069. * Sets the value of the `R1` button
  39070. */
  39071. buttonR1: number;
  39072. /**
  39073. * Gets the value of the Left joystick
  39074. */
  39075. /**
  39076. * Sets the value of the Left joystick
  39077. */
  39078. buttonLeftStick: number;
  39079. /**
  39080. * Gets the value of the Right joystick
  39081. */
  39082. /**
  39083. * Sets the value of the Right joystick
  39084. */
  39085. buttonRightStick: number;
  39086. /**
  39087. * Gets the value of D-pad up
  39088. */
  39089. /**
  39090. * Sets the value of D-pad up
  39091. */
  39092. dPadUp: number;
  39093. /**
  39094. * Gets the value of D-pad down
  39095. */
  39096. /**
  39097. * Sets the value of D-pad down
  39098. */
  39099. dPadDown: number;
  39100. /**
  39101. * Gets the value of D-pad left
  39102. */
  39103. /**
  39104. * Sets the value of D-pad left
  39105. */
  39106. dPadLeft: number;
  39107. /**
  39108. * Gets the value of D-pad right
  39109. */
  39110. /**
  39111. * Sets the value of D-pad right
  39112. */
  39113. dPadRight: number;
  39114. /**
  39115. * Force the gamepad to synchronize with device values
  39116. */
  39117. update(): void;
  39118. /**
  39119. * Disposes the gamepad
  39120. */
  39121. dispose(): void;
  39122. }
  39123. }
  39124. declare module BABYLON {
  39125. /**
  39126. * Manager for handling gamepads
  39127. */
  39128. export class GamepadManager {
  39129. private _scene?;
  39130. private _babylonGamepads;
  39131. private _oneGamepadConnected;
  39132. /** @hidden */
  39133. _isMonitoring: boolean;
  39134. private _gamepadEventSupported;
  39135. private _gamepadSupport;
  39136. /**
  39137. * observable to be triggered when the gamepad controller has been connected
  39138. */
  39139. onGamepadConnectedObservable: Observable<Gamepad>;
  39140. /**
  39141. * observable to be triggered when the gamepad controller has been disconnected
  39142. */
  39143. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39144. private _onGamepadConnectedEvent;
  39145. private _onGamepadDisconnectedEvent;
  39146. /**
  39147. * Initializes the gamepad manager
  39148. * @param _scene BabylonJS scene
  39149. */
  39150. constructor(_scene?: Scene | undefined);
  39151. /**
  39152. * The gamepads in the game pad manager
  39153. */
  39154. readonly gamepads: Gamepad[];
  39155. /**
  39156. * Get the gamepad controllers based on type
  39157. * @param type The type of gamepad controller
  39158. * @returns Nullable gamepad
  39159. */
  39160. getGamepadByType(type?: number): Nullable<Gamepad>;
  39161. /**
  39162. * Disposes the gamepad manager
  39163. */
  39164. dispose(): void;
  39165. private _addNewGamepad;
  39166. private _startMonitoringGamepads;
  39167. private _stopMonitoringGamepads;
  39168. /** @hidden */
  39169. _checkGamepadsStatus(): void;
  39170. private _updateGamepadObjects;
  39171. }
  39172. }
  39173. declare module BABYLON {
  39174. interface Scene {
  39175. /** @hidden */
  39176. _gamepadManager: Nullable<GamepadManager>;
  39177. /**
  39178. * Gets the gamepad manager associated with the scene
  39179. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39180. */
  39181. gamepadManager: GamepadManager;
  39182. }
  39183. /**
  39184. * Interface representing a free camera inputs manager
  39185. */
  39186. interface FreeCameraInputsManager {
  39187. /**
  39188. * Adds gamepad input support to the FreeCameraInputsManager.
  39189. * @returns the FreeCameraInputsManager
  39190. */
  39191. addGamepad(): FreeCameraInputsManager;
  39192. }
  39193. /**
  39194. * Interface representing an arc rotate camera inputs manager
  39195. */
  39196. interface ArcRotateCameraInputsManager {
  39197. /**
  39198. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39199. * @returns the camera inputs manager
  39200. */
  39201. addGamepad(): ArcRotateCameraInputsManager;
  39202. }
  39203. /**
  39204. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39205. */
  39206. export class GamepadSystemSceneComponent implements ISceneComponent {
  39207. /**
  39208. * The component name helpfull to identify the component in the list of scene components.
  39209. */
  39210. readonly name: string;
  39211. /**
  39212. * The scene the component belongs to.
  39213. */
  39214. scene: Scene;
  39215. /**
  39216. * Creates a new instance of the component for the given scene
  39217. * @param scene Defines the scene to register the component in
  39218. */
  39219. constructor(scene: Scene);
  39220. /**
  39221. * Registers the component in a given scene
  39222. */
  39223. register(): void;
  39224. /**
  39225. * Rebuilds the elements related to this component in case of
  39226. * context lost for instance.
  39227. */
  39228. rebuild(): void;
  39229. /**
  39230. * Disposes the component and the associated ressources
  39231. */
  39232. dispose(): void;
  39233. private _beforeCameraUpdate;
  39234. }
  39235. }
  39236. declare module BABYLON {
  39237. /**
  39238. * 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,
  39239. * which still works and will still be found in many Playgrounds.
  39240. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39241. */
  39242. export class UniversalCamera extends TouchCamera {
  39243. /**
  39244. * Defines the gamepad rotation sensiblity.
  39245. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39246. */
  39247. gamepadAngularSensibility: number;
  39248. /**
  39249. * Defines the gamepad move sensiblity.
  39250. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39251. */
  39252. gamepadMoveSensibility: number;
  39253. /**
  39254. * 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,
  39255. * which still works and will still be found in many Playgrounds.
  39256. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39257. * @param name Define the name of the camera in the scene
  39258. * @param position Define the start position of the camera in the scene
  39259. * @param scene Define the scene the camera belongs to
  39260. */
  39261. constructor(name: string, position: Vector3, scene: Scene);
  39262. /**
  39263. * Gets the current object class name.
  39264. * @return the class name
  39265. */
  39266. getClassName(): string;
  39267. }
  39268. }
  39269. declare module BABYLON {
  39270. /**
  39271. * This represents a FPS type of camera. This is only here for back compat purpose.
  39272. * Please use the UniversalCamera instead as both are identical.
  39273. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39274. */
  39275. export class GamepadCamera extends UniversalCamera {
  39276. /**
  39277. * Instantiates a new Gamepad Camera
  39278. * This represents a FPS type of camera. This is only here for back compat purpose.
  39279. * Please use the UniversalCamera instead as both are identical.
  39280. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39281. * @param name Define the name of the camera in the scene
  39282. * @param position Define the start position of the camera in the scene
  39283. * @param scene Define the scene the camera belongs to
  39284. */
  39285. constructor(name: string, position: Vector3, scene: Scene);
  39286. /**
  39287. * Gets the current object class name.
  39288. * @return the class name
  39289. */
  39290. getClassName(): string;
  39291. }
  39292. }
  39293. declare module BABYLON {
  39294. /** @hidden */
  39295. export var passPixelShader: {
  39296. name: string;
  39297. shader: string;
  39298. };
  39299. }
  39300. declare module BABYLON {
  39301. /** @hidden */
  39302. export var passCubePixelShader: {
  39303. name: string;
  39304. shader: string;
  39305. };
  39306. }
  39307. declare module BABYLON {
  39308. /**
  39309. * PassPostProcess which produces an output the same as it's input
  39310. */
  39311. export class PassPostProcess extends PostProcess {
  39312. /**
  39313. * Creates the PassPostProcess
  39314. * @param name The name of the effect.
  39315. * @param options The required width/height ratio to downsize to before computing the render pass.
  39316. * @param camera The camera to apply the render pass to.
  39317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39318. * @param engine The engine which the post process will be applied. (default: current engine)
  39319. * @param reusable If the post process can be reused on the same frame. (default: false)
  39320. * @param textureType The type of texture to be used when performing the post processing.
  39321. * @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)
  39322. */
  39323. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39324. }
  39325. /**
  39326. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39327. */
  39328. export class PassCubePostProcess extends PostProcess {
  39329. private _face;
  39330. /**
  39331. * Gets or sets the cube face to display.
  39332. * * 0 is +X
  39333. * * 1 is -X
  39334. * * 2 is +Y
  39335. * * 3 is -Y
  39336. * * 4 is +Z
  39337. * * 5 is -Z
  39338. */
  39339. face: number;
  39340. /**
  39341. * Creates the PassCubePostProcess
  39342. * @param name The name of the effect.
  39343. * @param options The required width/height ratio to downsize to before computing the render pass.
  39344. * @param camera The camera to apply the render pass to.
  39345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39346. * @param engine The engine which the post process will be applied. (default: current engine)
  39347. * @param reusable If the post process can be reused on the same frame. (default: false)
  39348. * @param textureType The type of texture to be used when performing the post processing.
  39349. * @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)
  39350. */
  39351. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39352. }
  39353. }
  39354. declare module BABYLON {
  39355. /** @hidden */
  39356. export var anaglyphPixelShader: {
  39357. name: string;
  39358. shader: string;
  39359. };
  39360. }
  39361. declare module BABYLON {
  39362. /**
  39363. * Postprocess used to generate anaglyphic rendering
  39364. */
  39365. export class AnaglyphPostProcess extends PostProcess {
  39366. private _passedProcess;
  39367. /**
  39368. * Creates a new AnaglyphPostProcess
  39369. * @param name defines postprocess name
  39370. * @param options defines creation options or target ratio scale
  39371. * @param rigCameras defines cameras using this postprocess
  39372. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39373. * @param engine defines hosting engine
  39374. * @param reusable defines if the postprocess will be reused multiple times per frame
  39375. */
  39376. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39377. }
  39378. }
  39379. declare module BABYLON {
  39380. /**
  39381. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39382. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39383. */
  39384. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39385. /**
  39386. * Creates a new AnaglyphArcRotateCamera
  39387. * @param name defines camera name
  39388. * @param alpha defines alpha angle (in radians)
  39389. * @param beta defines beta angle (in radians)
  39390. * @param radius defines radius
  39391. * @param target defines camera target
  39392. * @param interaxialDistance defines distance between each color axis
  39393. * @param scene defines the hosting scene
  39394. */
  39395. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39396. /**
  39397. * Gets camera class name
  39398. * @returns AnaglyphArcRotateCamera
  39399. */
  39400. getClassName(): string;
  39401. }
  39402. }
  39403. declare module BABYLON {
  39404. /**
  39405. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39406. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39407. */
  39408. export class AnaglyphFreeCamera extends FreeCamera {
  39409. /**
  39410. * Creates a new AnaglyphFreeCamera
  39411. * @param name defines camera name
  39412. * @param position defines initial position
  39413. * @param interaxialDistance defines distance between each color axis
  39414. * @param scene defines the hosting scene
  39415. */
  39416. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39417. /**
  39418. * Gets camera class name
  39419. * @returns AnaglyphFreeCamera
  39420. */
  39421. getClassName(): string;
  39422. }
  39423. }
  39424. declare module BABYLON {
  39425. /**
  39426. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39427. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39428. */
  39429. export class AnaglyphGamepadCamera extends GamepadCamera {
  39430. /**
  39431. * Creates a new AnaglyphGamepadCamera
  39432. * @param name defines camera name
  39433. * @param position defines initial position
  39434. * @param interaxialDistance defines distance between each color axis
  39435. * @param scene defines the hosting scene
  39436. */
  39437. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39438. /**
  39439. * Gets camera class name
  39440. * @returns AnaglyphGamepadCamera
  39441. */
  39442. getClassName(): string;
  39443. }
  39444. }
  39445. declare module BABYLON {
  39446. /**
  39447. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39448. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39449. */
  39450. export class AnaglyphUniversalCamera extends UniversalCamera {
  39451. /**
  39452. * Creates a new AnaglyphUniversalCamera
  39453. * @param name defines camera name
  39454. * @param position defines initial position
  39455. * @param interaxialDistance defines distance between each color axis
  39456. * @param scene defines the hosting scene
  39457. */
  39458. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39459. /**
  39460. * Gets camera class name
  39461. * @returns AnaglyphUniversalCamera
  39462. */
  39463. getClassName(): string;
  39464. }
  39465. }
  39466. declare module BABYLON {
  39467. /** @hidden */
  39468. export var stereoscopicInterlacePixelShader: {
  39469. name: string;
  39470. shader: string;
  39471. };
  39472. }
  39473. declare module BABYLON {
  39474. /**
  39475. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39476. */
  39477. export class StereoscopicInterlacePostProcess extends PostProcess {
  39478. private _stepSize;
  39479. private _passedProcess;
  39480. /**
  39481. * Initializes a StereoscopicInterlacePostProcess
  39482. * @param name The name of the effect.
  39483. * @param rigCameras The rig cameras to be appled to the post process
  39484. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39486. * @param engine The engine which the post process will be applied. (default: current engine)
  39487. * @param reusable If the post process can be reused on the same frame. (default: false)
  39488. */
  39489. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39490. }
  39491. }
  39492. declare module BABYLON {
  39493. /**
  39494. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39495. * @see http://doc.babylonjs.com/features/cameras
  39496. */
  39497. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39498. /**
  39499. * Creates a new StereoscopicArcRotateCamera
  39500. * @param name defines camera name
  39501. * @param alpha defines alpha angle (in radians)
  39502. * @param beta defines beta angle (in radians)
  39503. * @param radius defines radius
  39504. * @param target defines camera target
  39505. * @param interaxialDistance defines distance between each color axis
  39506. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39507. * @param scene defines the hosting scene
  39508. */
  39509. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39510. /**
  39511. * Gets camera class name
  39512. * @returns StereoscopicArcRotateCamera
  39513. */
  39514. getClassName(): string;
  39515. }
  39516. }
  39517. declare module BABYLON {
  39518. /**
  39519. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39520. * @see http://doc.babylonjs.com/features/cameras
  39521. */
  39522. export class StereoscopicFreeCamera extends FreeCamera {
  39523. /**
  39524. * Creates a new StereoscopicFreeCamera
  39525. * @param name defines camera name
  39526. * @param position defines initial position
  39527. * @param interaxialDistance defines distance between each color axis
  39528. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39529. * @param scene defines the hosting scene
  39530. */
  39531. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39532. /**
  39533. * Gets camera class name
  39534. * @returns StereoscopicFreeCamera
  39535. */
  39536. getClassName(): string;
  39537. }
  39538. }
  39539. declare module BABYLON {
  39540. /**
  39541. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39542. * @see http://doc.babylonjs.com/features/cameras
  39543. */
  39544. export class StereoscopicGamepadCamera extends GamepadCamera {
  39545. /**
  39546. * Creates a new StereoscopicGamepadCamera
  39547. * @param name defines camera name
  39548. * @param position defines initial position
  39549. * @param interaxialDistance defines distance between each color axis
  39550. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39551. * @param scene defines the hosting scene
  39552. */
  39553. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39554. /**
  39555. * Gets camera class name
  39556. * @returns StereoscopicGamepadCamera
  39557. */
  39558. getClassName(): string;
  39559. }
  39560. }
  39561. declare module BABYLON {
  39562. /**
  39563. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39564. * @see http://doc.babylonjs.com/features/cameras
  39565. */
  39566. export class StereoscopicUniversalCamera extends UniversalCamera {
  39567. /**
  39568. * Creates a new StereoscopicUniversalCamera
  39569. * @param name defines camera name
  39570. * @param position defines initial position
  39571. * @param interaxialDistance defines distance between each color axis
  39572. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39573. * @param scene defines the hosting scene
  39574. */
  39575. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39576. /**
  39577. * Gets camera class name
  39578. * @returns StereoscopicUniversalCamera
  39579. */
  39580. getClassName(): string;
  39581. }
  39582. }
  39583. declare module BABYLON {
  39584. /**
  39585. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39586. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39587. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39588. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39589. */
  39590. export class VirtualJoysticksCamera extends FreeCamera {
  39591. /**
  39592. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39593. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39594. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39595. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39596. * @param name Define the name of the camera in the scene
  39597. * @param position Define the start position of the camera in the scene
  39598. * @param scene Define the scene the camera belongs to
  39599. */
  39600. constructor(name: string, position: Vector3, scene: Scene);
  39601. /**
  39602. * Gets the current object class name.
  39603. * @return the class name
  39604. */
  39605. getClassName(): string;
  39606. }
  39607. }
  39608. declare module BABYLON {
  39609. /**
  39610. * This represents all the required metrics to create a VR camera.
  39611. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39612. */
  39613. export class VRCameraMetrics {
  39614. /**
  39615. * Define the horizontal resolution off the screen.
  39616. */
  39617. hResolution: number;
  39618. /**
  39619. * Define the vertical resolution off the screen.
  39620. */
  39621. vResolution: number;
  39622. /**
  39623. * Define the horizontal screen size.
  39624. */
  39625. hScreenSize: number;
  39626. /**
  39627. * Define the vertical screen size.
  39628. */
  39629. vScreenSize: number;
  39630. /**
  39631. * Define the vertical screen center position.
  39632. */
  39633. vScreenCenter: number;
  39634. /**
  39635. * Define the distance of the eyes to the screen.
  39636. */
  39637. eyeToScreenDistance: number;
  39638. /**
  39639. * Define the distance between both lenses
  39640. */
  39641. lensSeparationDistance: number;
  39642. /**
  39643. * Define the distance between both viewer's eyes.
  39644. */
  39645. interpupillaryDistance: number;
  39646. /**
  39647. * Define the distortion factor of the VR postprocess.
  39648. * Please, touch with care.
  39649. */
  39650. distortionK: number[];
  39651. /**
  39652. * Define the chromatic aberration correction factors for the VR post process.
  39653. */
  39654. chromaAbCorrection: number[];
  39655. /**
  39656. * Define the scale factor of the post process.
  39657. * The smaller the better but the slower.
  39658. */
  39659. postProcessScaleFactor: number;
  39660. /**
  39661. * Define an offset for the lens center.
  39662. */
  39663. lensCenterOffset: number;
  39664. /**
  39665. * Define if the current vr camera should compensate the distortion of the lense or not.
  39666. */
  39667. compensateDistortion: boolean;
  39668. /**
  39669. * Defines if multiview should be enabled when rendering (Default: false)
  39670. */
  39671. multiviewEnabled: boolean;
  39672. /**
  39673. * Gets the rendering aspect ratio based on the provided resolutions.
  39674. */
  39675. readonly aspectRatio: number;
  39676. /**
  39677. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39678. */
  39679. readonly aspectRatioFov: number;
  39680. /**
  39681. * @hidden
  39682. */
  39683. readonly leftHMatrix: Matrix;
  39684. /**
  39685. * @hidden
  39686. */
  39687. readonly rightHMatrix: Matrix;
  39688. /**
  39689. * @hidden
  39690. */
  39691. readonly leftPreViewMatrix: Matrix;
  39692. /**
  39693. * @hidden
  39694. */
  39695. readonly rightPreViewMatrix: Matrix;
  39696. /**
  39697. * Get the default VRMetrics based on the most generic setup.
  39698. * @returns the default vr metrics
  39699. */
  39700. static GetDefault(): VRCameraMetrics;
  39701. }
  39702. }
  39703. declare module BABYLON {
  39704. /** @hidden */
  39705. export var vrDistortionCorrectionPixelShader: {
  39706. name: string;
  39707. shader: string;
  39708. };
  39709. }
  39710. declare module BABYLON {
  39711. /**
  39712. * VRDistortionCorrectionPostProcess used for mobile VR
  39713. */
  39714. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39715. private _isRightEye;
  39716. private _distortionFactors;
  39717. private _postProcessScaleFactor;
  39718. private _lensCenterOffset;
  39719. private _scaleIn;
  39720. private _scaleFactor;
  39721. private _lensCenter;
  39722. /**
  39723. * Initializes the VRDistortionCorrectionPostProcess
  39724. * @param name The name of the effect.
  39725. * @param camera The camera to apply the render pass to.
  39726. * @param isRightEye If this is for the right eye distortion
  39727. * @param vrMetrics All the required metrics for the VR camera
  39728. */
  39729. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39730. }
  39731. }
  39732. declare module BABYLON {
  39733. /**
  39734. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39735. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39736. */
  39737. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39738. /**
  39739. * Creates a new VRDeviceOrientationArcRotateCamera
  39740. * @param name defines camera name
  39741. * @param alpha defines the camera rotation along the logitudinal axis
  39742. * @param beta defines the camera rotation along the latitudinal axis
  39743. * @param radius defines the camera distance from its target
  39744. * @param target defines the camera target
  39745. * @param scene defines the scene the camera belongs to
  39746. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39747. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39748. */
  39749. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39750. /**
  39751. * Gets camera class name
  39752. * @returns VRDeviceOrientationArcRotateCamera
  39753. */
  39754. getClassName(): string;
  39755. }
  39756. }
  39757. declare module BABYLON {
  39758. /**
  39759. * Camera used to simulate VR rendering (based on FreeCamera)
  39760. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39761. */
  39762. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39763. /**
  39764. * Creates a new VRDeviceOrientationFreeCamera
  39765. * @param name defines camera name
  39766. * @param position defines the start position of the camera
  39767. * @param scene defines the scene the camera belongs to
  39768. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39769. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39770. */
  39771. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39772. /**
  39773. * Gets camera class name
  39774. * @returns VRDeviceOrientationFreeCamera
  39775. */
  39776. getClassName(): string;
  39777. }
  39778. }
  39779. declare module BABYLON {
  39780. /**
  39781. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39782. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39783. */
  39784. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39785. /**
  39786. * Creates a new VRDeviceOrientationGamepadCamera
  39787. * @param name defines camera name
  39788. * @param position defines the start position of the camera
  39789. * @param scene defines the scene the camera belongs to
  39790. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39791. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39792. */
  39793. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39794. /**
  39795. * Gets camera class name
  39796. * @returns VRDeviceOrientationGamepadCamera
  39797. */
  39798. getClassName(): string;
  39799. }
  39800. }
  39801. declare module BABYLON {
  39802. /**
  39803. * Base class of materials working in push mode in babylon JS
  39804. * @hidden
  39805. */
  39806. export class PushMaterial extends Material {
  39807. protected _activeEffect: Effect;
  39808. protected _normalMatrix: Matrix;
  39809. /**
  39810. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39811. * This means that the material can keep using a previous shader while a new one is being compiled.
  39812. * This is mostly used when shader parallel compilation is supported (true by default)
  39813. */
  39814. allowShaderHotSwapping: boolean;
  39815. constructor(name: string, scene: Scene);
  39816. getEffect(): Effect;
  39817. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39818. /**
  39819. * Binds the given world matrix to the active effect
  39820. *
  39821. * @param world the matrix to bind
  39822. */
  39823. bindOnlyWorldMatrix(world: Matrix): void;
  39824. /**
  39825. * Binds the given normal matrix to the active effect
  39826. *
  39827. * @param normalMatrix the matrix to bind
  39828. */
  39829. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39830. bind(world: Matrix, mesh?: Mesh): void;
  39831. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39832. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39833. }
  39834. }
  39835. declare module BABYLON {
  39836. /**
  39837. * This groups all the flags used to control the materials channel.
  39838. */
  39839. export class MaterialFlags {
  39840. private static _DiffuseTextureEnabled;
  39841. /**
  39842. * Are diffuse textures enabled in the application.
  39843. */
  39844. static DiffuseTextureEnabled: boolean;
  39845. private static _AmbientTextureEnabled;
  39846. /**
  39847. * Are ambient textures enabled in the application.
  39848. */
  39849. static AmbientTextureEnabled: boolean;
  39850. private static _OpacityTextureEnabled;
  39851. /**
  39852. * Are opacity textures enabled in the application.
  39853. */
  39854. static OpacityTextureEnabled: boolean;
  39855. private static _ReflectionTextureEnabled;
  39856. /**
  39857. * Are reflection textures enabled in the application.
  39858. */
  39859. static ReflectionTextureEnabled: boolean;
  39860. private static _EmissiveTextureEnabled;
  39861. /**
  39862. * Are emissive textures enabled in the application.
  39863. */
  39864. static EmissiveTextureEnabled: boolean;
  39865. private static _SpecularTextureEnabled;
  39866. /**
  39867. * Are specular textures enabled in the application.
  39868. */
  39869. static SpecularTextureEnabled: boolean;
  39870. private static _BumpTextureEnabled;
  39871. /**
  39872. * Are bump textures enabled in the application.
  39873. */
  39874. static BumpTextureEnabled: boolean;
  39875. private static _LightmapTextureEnabled;
  39876. /**
  39877. * Are lightmap textures enabled in the application.
  39878. */
  39879. static LightmapTextureEnabled: boolean;
  39880. private static _RefractionTextureEnabled;
  39881. /**
  39882. * Are refraction textures enabled in the application.
  39883. */
  39884. static RefractionTextureEnabled: boolean;
  39885. private static _ColorGradingTextureEnabled;
  39886. /**
  39887. * Are color grading textures enabled in the application.
  39888. */
  39889. static ColorGradingTextureEnabled: boolean;
  39890. private static _FresnelEnabled;
  39891. /**
  39892. * Are fresnels enabled in the application.
  39893. */
  39894. static FresnelEnabled: boolean;
  39895. private static _ClearCoatTextureEnabled;
  39896. /**
  39897. * Are clear coat textures enabled in the application.
  39898. */
  39899. static ClearCoatTextureEnabled: boolean;
  39900. private static _ClearCoatBumpTextureEnabled;
  39901. /**
  39902. * Are clear coat bump textures enabled in the application.
  39903. */
  39904. static ClearCoatBumpTextureEnabled: boolean;
  39905. private static _ClearCoatTintTextureEnabled;
  39906. /**
  39907. * Are clear coat tint textures enabled in the application.
  39908. */
  39909. static ClearCoatTintTextureEnabled: boolean;
  39910. private static _SheenTextureEnabled;
  39911. /**
  39912. * Are sheen textures enabled in the application.
  39913. */
  39914. static SheenTextureEnabled: boolean;
  39915. private static _AnisotropicTextureEnabled;
  39916. /**
  39917. * Are anisotropic textures enabled in the application.
  39918. */
  39919. static AnisotropicTextureEnabled: boolean;
  39920. private static _ThicknessTextureEnabled;
  39921. /**
  39922. * Are thickness textures enabled in the application.
  39923. */
  39924. static ThicknessTextureEnabled: boolean;
  39925. }
  39926. }
  39927. declare module BABYLON {
  39928. /** @hidden */
  39929. export var defaultFragmentDeclaration: {
  39930. name: string;
  39931. shader: string;
  39932. };
  39933. }
  39934. declare module BABYLON {
  39935. /** @hidden */
  39936. export var defaultUboDeclaration: {
  39937. name: string;
  39938. shader: string;
  39939. };
  39940. }
  39941. declare module BABYLON {
  39942. /** @hidden */
  39943. export var lightFragmentDeclaration: {
  39944. name: string;
  39945. shader: string;
  39946. };
  39947. }
  39948. declare module BABYLON {
  39949. /** @hidden */
  39950. export var lightUboDeclaration: {
  39951. name: string;
  39952. shader: string;
  39953. };
  39954. }
  39955. declare module BABYLON {
  39956. /** @hidden */
  39957. export var lightsFragmentFunctions: {
  39958. name: string;
  39959. shader: string;
  39960. };
  39961. }
  39962. declare module BABYLON {
  39963. /** @hidden */
  39964. export var shadowsFragmentFunctions: {
  39965. name: string;
  39966. shader: string;
  39967. };
  39968. }
  39969. declare module BABYLON {
  39970. /** @hidden */
  39971. export var fresnelFunction: {
  39972. name: string;
  39973. shader: string;
  39974. };
  39975. }
  39976. declare module BABYLON {
  39977. /** @hidden */
  39978. export var reflectionFunction: {
  39979. name: string;
  39980. shader: string;
  39981. };
  39982. }
  39983. declare module BABYLON {
  39984. /** @hidden */
  39985. export var bumpFragmentFunctions: {
  39986. name: string;
  39987. shader: string;
  39988. };
  39989. }
  39990. declare module BABYLON {
  39991. /** @hidden */
  39992. export var logDepthDeclaration: {
  39993. name: string;
  39994. shader: string;
  39995. };
  39996. }
  39997. declare module BABYLON {
  39998. /** @hidden */
  39999. export var bumpFragment: {
  40000. name: string;
  40001. shader: string;
  40002. };
  40003. }
  40004. declare module BABYLON {
  40005. /** @hidden */
  40006. export var depthPrePass: {
  40007. name: string;
  40008. shader: string;
  40009. };
  40010. }
  40011. declare module BABYLON {
  40012. /** @hidden */
  40013. export var lightFragment: {
  40014. name: string;
  40015. shader: string;
  40016. };
  40017. }
  40018. declare module BABYLON {
  40019. /** @hidden */
  40020. export var logDepthFragment: {
  40021. name: string;
  40022. shader: string;
  40023. };
  40024. }
  40025. declare module BABYLON {
  40026. /** @hidden */
  40027. export var defaultPixelShader: {
  40028. name: string;
  40029. shader: string;
  40030. };
  40031. }
  40032. declare module BABYLON {
  40033. /** @hidden */
  40034. export var defaultVertexDeclaration: {
  40035. name: string;
  40036. shader: string;
  40037. };
  40038. }
  40039. declare module BABYLON {
  40040. /** @hidden */
  40041. export var bumpVertexDeclaration: {
  40042. name: string;
  40043. shader: string;
  40044. };
  40045. }
  40046. declare module BABYLON {
  40047. /** @hidden */
  40048. export var bumpVertex: {
  40049. name: string;
  40050. shader: string;
  40051. };
  40052. }
  40053. declare module BABYLON {
  40054. /** @hidden */
  40055. export var fogVertex: {
  40056. name: string;
  40057. shader: string;
  40058. };
  40059. }
  40060. declare module BABYLON {
  40061. /** @hidden */
  40062. export var shadowsVertex: {
  40063. name: string;
  40064. shader: string;
  40065. };
  40066. }
  40067. declare module BABYLON {
  40068. /** @hidden */
  40069. export var pointCloudVertex: {
  40070. name: string;
  40071. shader: string;
  40072. };
  40073. }
  40074. declare module BABYLON {
  40075. /** @hidden */
  40076. export var logDepthVertex: {
  40077. name: string;
  40078. shader: string;
  40079. };
  40080. }
  40081. declare module BABYLON {
  40082. /** @hidden */
  40083. export var defaultVertexShader: {
  40084. name: string;
  40085. shader: string;
  40086. };
  40087. }
  40088. declare module BABYLON {
  40089. /** @hidden */
  40090. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40091. MAINUV1: boolean;
  40092. MAINUV2: boolean;
  40093. DIFFUSE: boolean;
  40094. DIFFUSEDIRECTUV: number;
  40095. AMBIENT: boolean;
  40096. AMBIENTDIRECTUV: number;
  40097. OPACITY: boolean;
  40098. OPACITYDIRECTUV: number;
  40099. OPACITYRGB: boolean;
  40100. REFLECTION: boolean;
  40101. EMISSIVE: boolean;
  40102. EMISSIVEDIRECTUV: number;
  40103. SPECULAR: boolean;
  40104. SPECULARDIRECTUV: number;
  40105. BUMP: boolean;
  40106. BUMPDIRECTUV: number;
  40107. PARALLAX: boolean;
  40108. PARALLAXOCCLUSION: boolean;
  40109. SPECULAROVERALPHA: boolean;
  40110. CLIPPLANE: boolean;
  40111. CLIPPLANE2: boolean;
  40112. CLIPPLANE3: boolean;
  40113. CLIPPLANE4: boolean;
  40114. ALPHATEST: boolean;
  40115. DEPTHPREPASS: boolean;
  40116. ALPHAFROMDIFFUSE: boolean;
  40117. POINTSIZE: boolean;
  40118. FOG: boolean;
  40119. SPECULARTERM: boolean;
  40120. DIFFUSEFRESNEL: boolean;
  40121. OPACITYFRESNEL: boolean;
  40122. REFLECTIONFRESNEL: boolean;
  40123. REFRACTIONFRESNEL: boolean;
  40124. EMISSIVEFRESNEL: boolean;
  40125. FRESNEL: boolean;
  40126. NORMAL: boolean;
  40127. UV1: boolean;
  40128. UV2: boolean;
  40129. VERTEXCOLOR: boolean;
  40130. VERTEXALPHA: boolean;
  40131. NUM_BONE_INFLUENCERS: number;
  40132. BonesPerMesh: number;
  40133. BONETEXTURE: boolean;
  40134. INSTANCES: boolean;
  40135. GLOSSINESS: boolean;
  40136. ROUGHNESS: boolean;
  40137. EMISSIVEASILLUMINATION: boolean;
  40138. LINKEMISSIVEWITHDIFFUSE: boolean;
  40139. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40140. LIGHTMAP: boolean;
  40141. LIGHTMAPDIRECTUV: number;
  40142. OBJECTSPACE_NORMALMAP: boolean;
  40143. USELIGHTMAPASSHADOWMAP: boolean;
  40144. REFLECTIONMAP_3D: boolean;
  40145. REFLECTIONMAP_SPHERICAL: boolean;
  40146. REFLECTIONMAP_PLANAR: boolean;
  40147. REFLECTIONMAP_CUBIC: boolean;
  40148. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40149. REFLECTIONMAP_PROJECTION: boolean;
  40150. REFLECTIONMAP_SKYBOX: boolean;
  40151. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40152. REFLECTIONMAP_EXPLICIT: boolean;
  40153. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40154. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40155. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40156. INVERTCUBICMAP: boolean;
  40157. LOGARITHMICDEPTH: boolean;
  40158. REFRACTION: boolean;
  40159. REFRACTIONMAP_3D: boolean;
  40160. REFLECTIONOVERALPHA: boolean;
  40161. TWOSIDEDLIGHTING: boolean;
  40162. SHADOWFLOAT: boolean;
  40163. MORPHTARGETS: boolean;
  40164. MORPHTARGETS_NORMAL: boolean;
  40165. MORPHTARGETS_TANGENT: boolean;
  40166. MORPHTARGETS_UV: boolean;
  40167. NUM_MORPH_INFLUENCERS: number;
  40168. NONUNIFORMSCALING: boolean;
  40169. PREMULTIPLYALPHA: boolean;
  40170. IMAGEPROCESSING: boolean;
  40171. VIGNETTE: boolean;
  40172. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40173. VIGNETTEBLENDMODEOPAQUE: boolean;
  40174. TONEMAPPING: boolean;
  40175. TONEMAPPING_ACES: boolean;
  40176. CONTRAST: boolean;
  40177. COLORCURVES: boolean;
  40178. COLORGRADING: boolean;
  40179. COLORGRADING3D: boolean;
  40180. SAMPLER3DGREENDEPTH: boolean;
  40181. SAMPLER3DBGRMAP: boolean;
  40182. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40183. MULTIVIEW: boolean;
  40184. /**
  40185. * If the reflection texture on this material is in linear color space
  40186. * @hidden
  40187. */
  40188. IS_REFLECTION_LINEAR: boolean;
  40189. /**
  40190. * If the refraction texture on this material is in linear color space
  40191. * @hidden
  40192. */
  40193. IS_REFRACTION_LINEAR: boolean;
  40194. EXPOSURE: boolean;
  40195. constructor();
  40196. setReflectionMode(modeToEnable: string): void;
  40197. }
  40198. /**
  40199. * This is the default material used in Babylon. It is the best trade off between quality
  40200. * and performances.
  40201. * @see http://doc.babylonjs.com/babylon101/materials
  40202. */
  40203. export class StandardMaterial extends PushMaterial {
  40204. private _diffuseTexture;
  40205. /**
  40206. * The basic texture of the material as viewed under a light.
  40207. */
  40208. diffuseTexture: Nullable<BaseTexture>;
  40209. private _ambientTexture;
  40210. /**
  40211. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40212. */
  40213. ambientTexture: Nullable<BaseTexture>;
  40214. private _opacityTexture;
  40215. /**
  40216. * Define the transparency of the material from a texture.
  40217. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40218. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40219. */
  40220. opacityTexture: Nullable<BaseTexture>;
  40221. private _reflectionTexture;
  40222. /**
  40223. * Define the texture used to display the reflection.
  40224. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40225. */
  40226. reflectionTexture: Nullable<BaseTexture>;
  40227. private _emissiveTexture;
  40228. /**
  40229. * Define texture of the material as if self lit.
  40230. * This will be mixed in the final result even in the absence of light.
  40231. */
  40232. emissiveTexture: Nullable<BaseTexture>;
  40233. private _specularTexture;
  40234. /**
  40235. * Define how the color and intensity of the highlight given by the light in the material.
  40236. */
  40237. specularTexture: Nullable<BaseTexture>;
  40238. private _bumpTexture;
  40239. /**
  40240. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40241. * 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.
  40242. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40243. */
  40244. bumpTexture: Nullable<BaseTexture>;
  40245. private _lightmapTexture;
  40246. /**
  40247. * Complex lighting can be computationally expensive to compute at runtime.
  40248. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40249. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40250. */
  40251. lightmapTexture: Nullable<BaseTexture>;
  40252. private _refractionTexture;
  40253. /**
  40254. * Define the texture used to display the refraction.
  40255. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40256. */
  40257. refractionTexture: Nullable<BaseTexture>;
  40258. /**
  40259. * The color of the material lit by the environmental background lighting.
  40260. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40261. */
  40262. ambientColor: Color3;
  40263. /**
  40264. * The basic color of the material as viewed under a light.
  40265. */
  40266. diffuseColor: Color3;
  40267. /**
  40268. * Define how the color and intensity of the highlight given by the light in the material.
  40269. */
  40270. specularColor: Color3;
  40271. /**
  40272. * Define the color of the material as if self lit.
  40273. * This will be mixed in the final result even in the absence of light.
  40274. */
  40275. emissiveColor: Color3;
  40276. /**
  40277. * Defines how sharp are the highlights in the material.
  40278. * The bigger the value the sharper giving a more glossy feeling to the result.
  40279. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40280. */
  40281. specularPower: number;
  40282. private _useAlphaFromDiffuseTexture;
  40283. /**
  40284. * Does the transparency come from the diffuse texture alpha channel.
  40285. */
  40286. useAlphaFromDiffuseTexture: boolean;
  40287. private _useEmissiveAsIllumination;
  40288. /**
  40289. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40290. */
  40291. useEmissiveAsIllumination: boolean;
  40292. private _linkEmissiveWithDiffuse;
  40293. /**
  40294. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40295. * the emissive level when the final color is close to one.
  40296. */
  40297. linkEmissiveWithDiffuse: boolean;
  40298. private _useSpecularOverAlpha;
  40299. /**
  40300. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40301. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40302. */
  40303. useSpecularOverAlpha: boolean;
  40304. private _useReflectionOverAlpha;
  40305. /**
  40306. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40307. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40308. */
  40309. useReflectionOverAlpha: boolean;
  40310. private _disableLighting;
  40311. /**
  40312. * Does lights from the scene impacts this material.
  40313. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40314. */
  40315. disableLighting: boolean;
  40316. private _useObjectSpaceNormalMap;
  40317. /**
  40318. * Allows using an object space normal map (instead of tangent space).
  40319. */
  40320. useObjectSpaceNormalMap: boolean;
  40321. private _useParallax;
  40322. /**
  40323. * Is parallax enabled or not.
  40324. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40325. */
  40326. useParallax: boolean;
  40327. private _useParallaxOcclusion;
  40328. /**
  40329. * Is parallax occlusion enabled or not.
  40330. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40331. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40332. */
  40333. useParallaxOcclusion: boolean;
  40334. /**
  40335. * 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.
  40336. */
  40337. parallaxScaleBias: number;
  40338. private _roughness;
  40339. /**
  40340. * Helps to define how blurry the reflections should appears in the material.
  40341. */
  40342. roughness: number;
  40343. /**
  40344. * In case of refraction, define the value of the index of refraction.
  40345. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40346. */
  40347. indexOfRefraction: number;
  40348. /**
  40349. * Invert the refraction texture alongside the y axis.
  40350. * It can be useful with procedural textures or probe for instance.
  40351. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40352. */
  40353. invertRefractionY: boolean;
  40354. /**
  40355. * Defines the alpha limits in alpha test mode.
  40356. */
  40357. alphaCutOff: number;
  40358. private _useLightmapAsShadowmap;
  40359. /**
  40360. * In case of light mapping, define whether the map contains light or shadow informations.
  40361. */
  40362. useLightmapAsShadowmap: boolean;
  40363. private _diffuseFresnelParameters;
  40364. /**
  40365. * Define the diffuse fresnel parameters of the material.
  40366. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40367. */
  40368. diffuseFresnelParameters: FresnelParameters;
  40369. private _opacityFresnelParameters;
  40370. /**
  40371. * Define the opacity fresnel parameters of the material.
  40372. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40373. */
  40374. opacityFresnelParameters: FresnelParameters;
  40375. private _reflectionFresnelParameters;
  40376. /**
  40377. * Define the reflection fresnel parameters of the material.
  40378. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40379. */
  40380. reflectionFresnelParameters: FresnelParameters;
  40381. private _refractionFresnelParameters;
  40382. /**
  40383. * Define the refraction fresnel parameters of the material.
  40384. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40385. */
  40386. refractionFresnelParameters: FresnelParameters;
  40387. private _emissiveFresnelParameters;
  40388. /**
  40389. * Define the emissive fresnel parameters of the material.
  40390. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40391. */
  40392. emissiveFresnelParameters: FresnelParameters;
  40393. private _useReflectionFresnelFromSpecular;
  40394. /**
  40395. * If true automatically deducts the fresnels values from the material specularity.
  40396. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40397. */
  40398. useReflectionFresnelFromSpecular: boolean;
  40399. private _useGlossinessFromSpecularMapAlpha;
  40400. /**
  40401. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40402. */
  40403. useGlossinessFromSpecularMapAlpha: boolean;
  40404. private _maxSimultaneousLights;
  40405. /**
  40406. * Defines the maximum number of lights that can be used in the material
  40407. */
  40408. maxSimultaneousLights: number;
  40409. private _invertNormalMapX;
  40410. /**
  40411. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40412. */
  40413. invertNormalMapX: boolean;
  40414. private _invertNormalMapY;
  40415. /**
  40416. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40417. */
  40418. invertNormalMapY: boolean;
  40419. private _twoSidedLighting;
  40420. /**
  40421. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40422. */
  40423. twoSidedLighting: boolean;
  40424. /**
  40425. * Default configuration related to image processing available in the standard Material.
  40426. */
  40427. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40428. /**
  40429. * Gets the image processing configuration used either in this material.
  40430. */
  40431. /**
  40432. * Sets the Default image processing configuration used either in the this material.
  40433. *
  40434. * If sets to null, the scene one is in use.
  40435. */
  40436. imageProcessingConfiguration: ImageProcessingConfiguration;
  40437. /**
  40438. * Keep track of the image processing observer to allow dispose and replace.
  40439. */
  40440. private _imageProcessingObserver;
  40441. /**
  40442. * Attaches a new image processing configuration to the Standard Material.
  40443. * @param configuration
  40444. */
  40445. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40446. /**
  40447. * Gets wether the color curves effect is enabled.
  40448. */
  40449. /**
  40450. * Sets wether the color curves effect is enabled.
  40451. */
  40452. cameraColorCurvesEnabled: boolean;
  40453. /**
  40454. * Gets wether the color grading effect is enabled.
  40455. */
  40456. /**
  40457. * Gets wether the color grading effect is enabled.
  40458. */
  40459. cameraColorGradingEnabled: boolean;
  40460. /**
  40461. * Gets wether tonemapping is enabled or not.
  40462. */
  40463. /**
  40464. * Sets wether tonemapping is enabled or not
  40465. */
  40466. cameraToneMappingEnabled: boolean;
  40467. /**
  40468. * The camera exposure used on this material.
  40469. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40470. * This corresponds to a photographic exposure.
  40471. */
  40472. /**
  40473. * The camera exposure used on this material.
  40474. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40475. * This corresponds to a photographic exposure.
  40476. */
  40477. cameraExposure: number;
  40478. /**
  40479. * Gets The camera contrast used on this material.
  40480. */
  40481. /**
  40482. * Sets The camera contrast used on this material.
  40483. */
  40484. cameraContrast: number;
  40485. /**
  40486. * Gets the Color Grading 2D Lookup Texture.
  40487. */
  40488. /**
  40489. * Sets the Color Grading 2D Lookup Texture.
  40490. */
  40491. cameraColorGradingTexture: Nullable<BaseTexture>;
  40492. /**
  40493. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40494. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40495. * 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;
  40496. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40497. */
  40498. /**
  40499. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40500. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40501. * 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;
  40502. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40503. */
  40504. cameraColorCurves: Nullable<ColorCurves>;
  40505. /**
  40506. * Custom callback helping to override the default shader used in the material.
  40507. */
  40508. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40509. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40510. protected _worldViewProjectionMatrix: Matrix;
  40511. protected _globalAmbientColor: Color3;
  40512. protected _useLogarithmicDepth: boolean;
  40513. protected _rebuildInParallel: boolean;
  40514. /**
  40515. * Instantiates a new standard material.
  40516. * This is the default material used in Babylon. It is the best trade off between quality
  40517. * and performances.
  40518. * @see http://doc.babylonjs.com/babylon101/materials
  40519. * @param name Define the name of the material in the scene
  40520. * @param scene Define the scene the material belong to
  40521. */
  40522. constructor(name: string, scene: Scene);
  40523. /**
  40524. * Gets a boolean indicating that current material needs to register RTT
  40525. */
  40526. readonly hasRenderTargetTextures: boolean;
  40527. /**
  40528. * Gets the current class name of the material e.g. "StandardMaterial"
  40529. * Mainly use in serialization.
  40530. * @returns the class name
  40531. */
  40532. getClassName(): string;
  40533. /**
  40534. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40535. * You can try switching to logarithmic depth.
  40536. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40537. */
  40538. useLogarithmicDepth: boolean;
  40539. /**
  40540. * Specifies if the material will require alpha blending
  40541. * @returns a boolean specifying if alpha blending is needed
  40542. */
  40543. needAlphaBlending(): boolean;
  40544. /**
  40545. * Specifies if this material should be rendered in alpha test mode
  40546. * @returns a boolean specifying if an alpha test is needed.
  40547. */
  40548. needAlphaTesting(): boolean;
  40549. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40550. /**
  40551. * Get the texture used for alpha test purpose.
  40552. * @returns the diffuse texture in case of the standard material.
  40553. */
  40554. getAlphaTestTexture(): Nullable<BaseTexture>;
  40555. /**
  40556. * Get if the submesh is ready to be used and all its information available.
  40557. * Child classes can use it to update shaders
  40558. * @param mesh defines the mesh to check
  40559. * @param subMesh defines which submesh to check
  40560. * @param useInstances specifies that instances should be used
  40561. * @returns a boolean indicating that the submesh is ready or not
  40562. */
  40563. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40564. /**
  40565. * Builds the material UBO layouts.
  40566. * Used internally during the effect preparation.
  40567. */
  40568. buildUniformLayout(): void;
  40569. /**
  40570. * Unbinds the material from the mesh
  40571. */
  40572. unbind(): void;
  40573. /**
  40574. * Binds the submesh to this material by preparing the effect and shader to draw
  40575. * @param world defines the world transformation matrix
  40576. * @param mesh defines the mesh containing the submesh
  40577. * @param subMesh defines the submesh to bind the material to
  40578. */
  40579. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40580. /**
  40581. * Get the list of animatables in the material.
  40582. * @returns the list of animatables object used in the material
  40583. */
  40584. getAnimatables(): IAnimatable[];
  40585. /**
  40586. * Gets the active textures from the material
  40587. * @returns an array of textures
  40588. */
  40589. getActiveTextures(): BaseTexture[];
  40590. /**
  40591. * Specifies if the material uses a texture
  40592. * @param texture defines the texture to check against the material
  40593. * @returns a boolean specifying if the material uses the texture
  40594. */
  40595. hasTexture(texture: BaseTexture): boolean;
  40596. /**
  40597. * Disposes the material
  40598. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40599. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40600. */
  40601. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40602. /**
  40603. * Makes a duplicate of the material, and gives it a new name
  40604. * @param name defines the new name for the duplicated material
  40605. * @returns the cloned material
  40606. */
  40607. clone(name: string): StandardMaterial;
  40608. /**
  40609. * Serializes this material in a JSON representation
  40610. * @returns the serialized material object
  40611. */
  40612. serialize(): any;
  40613. /**
  40614. * Creates a standard material from parsed material data
  40615. * @param source defines the JSON representation of the material
  40616. * @param scene defines the hosting scene
  40617. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40618. * @returns a new standard material
  40619. */
  40620. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40621. /**
  40622. * Are diffuse textures enabled in the application.
  40623. */
  40624. static DiffuseTextureEnabled: boolean;
  40625. /**
  40626. * Are ambient textures enabled in the application.
  40627. */
  40628. static AmbientTextureEnabled: boolean;
  40629. /**
  40630. * Are opacity textures enabled in the application.
  40631. */
  40632. static OpacityTextureEnabled: boolean;
  40633. /**
  40634. * Are reflection textures enabled in the application.
  40635. */
  40636. static ReflectionTextureEnabled: boolean;
  40637. /**
  40638. * Are emissive textures enabled in the application.
  40639. */
  40640. static EmissiveTextureEnabled: boolean;
  40641. /**
  40642. * Are specular textures enabled in the application.
  40643. */
  40644. static SpecularTextureEnabled: boolean;
  40645. /**
  40646. * Are bump textures enabled in the application.
  40647. */
  40648. static BumpTextureEnabled: boolean;
  40649. /**
  40650. * Are lightmap textures enabled in the application.
  40651. */
  40652. static LightmapTextureEnabled: boolean;
  40653. /**
  40654. * Are refraction textures enabled in the application.
  40655. */
  40656. static RefractionTextureEnabled: boolean;
  40657. /**
  40658. * Are color grading textures enabled in the application.
  40659. */
  40660. static ColorGradingTextureEnabled: boolean;
  40661. /**
  40662. * Are fresnels enabled in the application.
  40663. */
  40664. static FresnelEnabled: boolean;
  40665. }
  40666. }
  40667. declare module BABYLON {
  40668. /** @hidden */
  40669. export var imageProcessingPixelShader: {
  40670. name: string;
  40671. shader: string;
  40672. };
  40673. }
  40674. declare module BABYLON {
  40675. /**
  40676. * ImageProcessingPostProcess
  40677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40678. */
  40679. export class ImageProcessingPostProcess extends PostProcess {
  40680. /**
  40681. * Default configuration related to image processing available in the PBR Material.
  40682. */
  40683. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40684. /**
  40685. * Gets the image processing configuration used either in this material.
  40686. */
  40687. /**
  40688. * Sets the Default image processing configuration used either in the this material.
  40689. *
  40690. * If sets to null, the scene one is in use.
  40691. */
  40692. imageProcessingConfiguration: ImageProcessingConfiguration;
  40693. /**
  40694. * Keep track of the image processing observer to allow dispose and replace.
  40695. */
  40696. private _imageProcessingObserver;
  40697. /**
  40698. * Attaches a new image processing configuration to the PBR Material.
  40699. * @param configuration
  40700. */
  40701. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40702. /**
  40703. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40704. */
  40705. /**
  40706. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40707. */
  40708. colorCurves: Nullable<ColorCurves>;
  40709. /**
  40710. * Gets wether the color curves effect is enabled.
  40711. */
  40712. /**
  40713. * Sets wether the color curves effect is enabled.
  40714. */
  40715. colorCurvesEnabled: boolean;
  40716. /**
  40717. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40718. */
  40719. /**
  40720. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40721. */
  40722. colorGradingTexture: Nullable<BaseTexture>;
  40723. /**
  40724. * Gets wether the color grading effect is enabled.
  40725. */
  40726. /**
  40727. * Gets wether the color grading effect is enabled.
  40728. */
  40729. colorGradingEnabled: boolean;
  40730. /**
  40731. * Gets exposure used in the effect.
  40732. */
  40733. /**
  40734. * Sets exposure used in the effect.
  40735. */
  40736. exposure: number;
  40737. /**
  40738. * Gets wether tonemapping is enabled or not.
  40739. */
  40740. /**
  40741. * Sets wether tonemapping is enabled or not
  40742. */
  40743. toneMappingEnabled: boolean;
  40744. /**
  40745. * Gets the type of tone mapping effect.
  40746. */
  40747. /**
  40748. * Sets the type of tone mapping effect.
  40749. */
  40750. toneMappingType: number;
  40751. /**
  40752. * Gets contrast used in the effect.
  40753. */
  40754. /**
  40755. * Sets contrast used in the effect.
  40756. */
  40757. contrast: number;
  40758. /**
  40759. * Gets Vignette stretch size.
  40760. */
  40761. /**
  40762. * Sets Vignette stretch size.
  40763. */
  40764. vignetteStretch: number;
  40765. /**
  40766. * Gets Vignette centre X Offset.
  40767. */
  40768. /**
  40769. * Sets Vignette centre X Offset.
  40770. */
  40771. vignetteCentreX: number;
  40772. /**
  40773. * Gets Vignette centre Y Offset.
  40774. */
  40775. /**
  40776. * Sets Vignette centre Y Offset.
  40777. */
  40778. vignetteCentreY: number;
  40779. /**
  40780. * Gets Vignette weight or intensity of the vignette effect.
  40781. */
  40782. /**
  40783. * Sets Vignette weight or intensity of the vignette effect.
  40784. */
  40785. vignetteWeight: number;
  40786. /**
  40787. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40788. * if vignetteEnabled is set to true.
  40789. */
  40790. /**
  40791. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40792. * if vignetteEnabled is set to true.
  40793. */
  40794. vignetteColor: Color4;
  40795. /**
  40796. * Gets Camera field of view used by the Vignette effect.
  40797. */
  40798. /**
  40799. * Sets Camera field of view used by the Vignette effect.
  40800. */
  40801. vignetteCameraFov: number;
  40802. /**
  40803. * Gets the vignette blend mode allowing different kind of effect.
  40804. */
  40805. /**
  40806. * Sets the vignette blend mode allowing different kind of effect.
  40807. */
  40808. vignetteBlendMode: number;
  40809. /**
  40810. * Gets wether the vignette effect is enabled.
  40811. */
  40812. /**
  40813. * Sets wether the vignette effect is enabled.
  40814. */
  40815. vignetteEnabled: boolean;
  40816. private _fromLinearSpace;
  40817. /**
  40818. * Gets wether the input of the processing is in Gamma or Linear Space.
  40819. */
  40820. /**
  40821. * Sets wether the input of the processing is in Gamma or Linear Space.
  40822. */
  40823. fromLinearSpace: boolean;
  40824. /**
  40825. * Defines cache preventing GC.
  40826. */
  40827. private _defines;
  40828. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40829. /**
  40830. * "ImageProcessingPostProcess"
  40831. * @returns "ImageProcessingPostProcess"
  40832. */
  40833. getClassName(): string;
  40834. protected _updateParameters(): void;
  40835. dispose(camera?: Camera): void;
  40836. }
  40837. }
  40838. declare module BABYLON {
  40839. /**
  40840. * Class containing static functions to help procedurally build meshes
  40841. */
  40842. export class GroundBuilder {
  40843. /**
  40844. * Creates a ground mesh
  40845. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40846. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40848. * @param name defines the name of the mesh
  40849. * @param options defines the options used to create the mesh
  40850. * @param scene defines the hosting scene
  40851. * @returns the ground mesh
  40852. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40853. */
  40854. static CreateGround(name: string, options: {
  40855. width?: number;
  40856. height?: number;
  40857. subdivisions?: number;
  40858. subdivisionsX?: number;
  40859. subdivisionsY?: number;
  40860. updatable?: boolean;
  40861. }, scene: any): Mesh;
  40862. /**
  40863. * Creates a tiled ground mesh
  40864. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40865. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40866. * * 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
  40867. * * 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
  40868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40869. * @param name defines the name of the mesh
  40870. * @param options defines the options used to create the mesh
  40871. * @param scene defines the hosting scene
  40872. * @returns the tiled ground mesh
  40873. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40874. */
  40875. static CreateTiledGround(name: string, options: {
  40876. xmin: number;
  40877. zmin: number;
  40878. xmax: number;
  40879. zmax: number;
  40880. subdivisions?: {
  40881. w: number;
  40882. h: number;
  40883. };
  40884. precision?: {
  40885. w: number;
  40886. h: number;
  40887. };
  40888. updatable?: boolean;
  40889. }, scene?: Nullable<Scene>): Mesh;
  40890. /**
  40891. * Creates a ground mesh from a height map
  40892. * * The parameter `url` sets the URL of the height map image resource.
  40893. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40894. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40895. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40896. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40897. * * 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.
  40898. * * 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).
  40899. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40901. * @param name defines the name of the mesh
  40902. * @param url defines the url to the height map
  40903. * @param options defines the options used to create the mesh
  40904. * @param scene defines the hosting scene
  40905. * @returns the ground mesh
  40906. * @see https://doc.babylonjs.com/babylon101/height_map
  40907. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40908. */
  40909. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40910. width?: number;
  40911. height?: number;
  40912. subdivisions?: number;
  40913. minHeight?: number;
  40914. maxHeight?: number;
  40915. colorFilter?: Color3;
  40916. alphaFilter?: number;
  40917. updatable?: boolean;
  40918. onReady?: (mesh: GroundMesh) => void;
  40919. }, scene?: Nullable<Scene>): GroundMesh;
  40920. }
  40921. }
  40922. declare module BABYLON {
  40923. /**
  40924. * Class containing static functions to help procedurally build meshes
  40925. */
  40926. export class TorusBuilder {
  40927. /**
  40928. * Creates a torus mesh
  40929. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40930. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40931. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40933. * * 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
  40934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40935. * @param name defines the name of the mesh
  40936. * @param options defines the options used to create the mesh
  40937. * @param scene defines the hosting scene
  40938. * @returns the torus mesh
  40939. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40940. */
  40941. static CreateTorus(name: string, options: {
  40942. diameter?: number;
  40943. thickness?: number;
  40944. tessellation?: number;
  40945. updatable?: boolean;
  40946. sideOrientation?: number;
  40947. frontUVs?: Vector4;
  40948. backUVs?: Vector4;
  40949. }, scene: any): Mesh;
  40950. }
  40951. }
  40952. declare module BABYLON {
  40953. /**
  40954. * Class containing static functions to help procedurally build meshes
  40955. */
  40956. export class CylinderBuilder {
  40957. /**
  40958. * Creates a cylinder or a cone mesh
  40959. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40960. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40961. * * 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.
  40962. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40963. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40964. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40965. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40966. * * 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).
  40967. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40968. * * 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).
  40969. * * 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
  40970. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40971. * * 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
  40972. * * 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.
  40973. * * If `enclose` is false, a ring surface is one element.
  40974. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40975. * * 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
  40976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40977. * * 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
  40978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40979. * @param name defines the name of the mesh
  40980. * @param options defines the options used to create the mesh
  40981. * @param scene defines the hosting scene
  40982. * @returns the cylinder mesh
  40983. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40984. */
  40985. static CreateCylinder(name: string, options: {
  40986. height?: number;
  40987. diameterTop?: number;
  40988. diameterBottom?: number;
  40989. diameter?: number;
  40990. tessellation?: number;
  40991. subdivisions?: number;
  40992. arc?: number;
  40993. faceColors?: Color4[];
  40994. faceUV?: Vector4[];
  40995. updatable?: boolean;
  40996. hasRings?: boolean;
  40997. enclose?: boolean;
  40998. cap?: number;
  40999. sideOrientation?: number;
  41000. frontUVs?: Vector4;
  41001. backUVs?: Vector4;
  41002. }, scene: any): Mesh;
  41003. }
  41004. }
  41005. declare module BABYLON {
  41006. /**
  41007. * Options to modify the vr teleportation behavior.
  41008. */
  41009. export interface VRTeleportationOptions {
  41010. /**
  41011. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41012. */
  41013. floorMeshName?: string;
  41014. /**
  41015. * A list of meshes to be used as the teleportation floor. (default: empty)
  41016. */
  41017. floorMeshes?: Mesh[];
  41018. }
  41019. /**
  41020. * Options to modify the vr experience helper's behavior.
  41021. */
  41022. export interface VRExperienceHelperOptions extends WebVROptions {
  41023. /**
  41024. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41025. */
  41026. createDeviceOrientationCamera?: boolean;
  41027. /**
  41028. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41029. */
  41030. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41031. /**
  41032. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41033. */
  41034. laserToggle?: boolean;
  41035. /**
  41036. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41037. */
  41038. floorMeshes?: Mesh[];
  41039. /**
  41040. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41041. */
  41042. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41043. }
  41044. /**
  41045. * Event containing information after VR has been entered
  41046. */
  41047. export class OnAfterEnteringVRObservableEvent {
  41048. /**
  41049. * If entering vr was successful
  41050. */
  41051. success: boolean;
  41052. }
  41053. /**
  41054. * Helps to quickly add VR support to an existing scene.
  41055. * See http://doc.babylonjs.com/how_to/webvr_helper
  41056. */
  41057. export class VRExperienceHelper {
  41058. /** Options to modify the vr experience helper's behavior. */
  41059. webVROptions: VRExperienceHelperOptions;
  41060. private _scene;
  41061. private _position;
  41062. private _btnVR;
  41063. private _btnVRDisplayed;
  41064. private _webVRsupported;
  41065. private _webVRready;
  41066. private _webVRrequesting;
  41067. private _webVRpresenting;
  41068. private _hasEnteredVR;
  41069. private _fullscreenVRpresenting;
  41070. private _canvas;
  41071. private _webVRCamera;
  41072. private _vrDeviceOrientationCamera;
  41073. private _deviceOrientationCamera;
  41074. private _existingCamera;
  41075. private _onKeyDown;
  41076. private _onVrDisplayPresentChange;
  41077. private _onVRDisplayChanged;
  41078. private _onVRRequestPresentStart;
  41079. private _onVRRequestPresentComplete;
  41080. /**
  41081. * 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)
  41082. */
  41083. enableGazeEvenWhenNoPointerLock: boolean;
  41084. /**
  41085. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41086. */
  41087. exitVROnDoubleTap: boolean;
  41088. /**
  41089. * Observable raised right before entering VR.
  41090. */
  41091. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41092. /**
  41093. * Observable raised when entering VR has completed.
  41094. */
  41095. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41096. /**
  41097. * Observable raised when exiting VR.
  41098. */
  41099. onExitingVRObservable: Observable<VRExperienceHelper>;
  41100. /**
  41101. * Observable raised when controller mesh is loaded.
  41102. */
  41103. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41104. /** Return this.onEnteringVRObservable
  41105. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41106. */
  41107. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41108. /** Return this.onExitingVRObservable
  41109. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41110. */
  41111. readonly onExitingVR: Observable<VRExperienceHelper>;
  41112. /** Return this.onControllerMeshLoadedObservable
  41113. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41114. */
  41115. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41116. private _rayLength;
  41117. private _useCustomVRButton;
  41118. private _teleportationRequested;
  41119. private _teleportActive;
  41120. private _floorMeshName;
  41121. private _floorMeshesCollection;
  41122. private _rotationAllowed;
  41123. private _teleportBackwardsVector;
  41124. private _teleportationTarget;
  41125. private _isDefaultTeleportationTarget;
  41126. private _postProcessMove;
  41127. private _teleportationFillColor;
  41128. private _teleportationBorderColor;
  41129. private _rotationAngle;
  41130. private _haloCenter;
  41131. private _cameraGazer;
  41132. private _padSensibilityUp;
  41133. private _padSensibilityDown;
  41134. private _leftController;
  41135. private _rightController;
  41136. /**
  41137. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41138. */
  41139. onNewMeshSelected: Observable<AbstractMesh>;
  41140. /**
  41141. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41142. * This observable will provide the mesh and the controller used to select the mesh
  41143. */
  41144. onMeshSelectedWithController: Observable<{
  41145. mesh: AbstractMesh;
  41146. controller: WebVRController;
  41147. }>;
  41148. /**
  41149. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41150. */
  41151. onNewMeshPicked: Observable<PickingInfo>;
  41152. private _circleEase;
  41153. /**
  41154. * Observable raised before camera teleportation
  41155. */
  41156. onBeforeCameraTeleport: Observable<Vector3>;
  41157. /**
  41158. * Observable raised after camera teleportation
  41159. */
  41160. onAfterCameraTeleport: Observable<Vector3>;
  41161. /**
  41162. * Observable raised when current selected mesh gets unselected
  41163. */
  41164. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41165. private _raySelectionPredicate;
  41166. /**
  41167. * To be optionaly changed by user to define custom ray selection
  41168. */
  41169. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41170. /**
  41171. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41172. */
  41173. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41174. /**
  41175. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41176. */
  41177. teleportationEnabled: boolean;
  41178. private _defaultHeight;
  41179. private _teleportationInitialized;
  41180. private _interactionsEnabled;
  41181. private _interactionsRequested;
  41182. private _displayGaze;
  41183. private _displayLaserPointer;
  41184. /**
  41185. * The mesh used to display where the user is going to teleport.
  41186. */
  41187. /**
  41188. * Sets the mesh to be used to display where the user is going to teleport.
  41189. */
  41190. teleportationTarget: Mesh;
  41191. /**
  41192. * 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
  41193. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41194. * See http://doc.babylonjs.com/resources/baking_transformations
  41195. */
  41196. gazeTrackerMesh: Mesh;
  41197. /**
  41198. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41199. */
  41200. updateGazeTrackerScale: boolean;
  41201. /**
  41202. * If the gaze trackers color should be updated when selecting meshes
  41203. */
  41204. updateGazeTrackerColor: boolean;
  41205. /**
  41206. * If the controller laser color should be updated when selecting meshes
  41207. */
  41208. updateControllerLaserColor: boolean;
  41209. /**
  41210. * The gaze tracking mesh corresponding to the left controller
  41211. */
  41212. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41213. /**
  41214. * The gaze tracking mesh corresponding to the right controller
  41215. */
  41216. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41217. /**
  41218. * If the ray of the gaze should be displayed.
  41219. */
  41220. /**
  41221. * Sets if the ray of the gaze should be displayed.
  41222. */
  41223. displayGaze: boolean;
  41224. /**
  41225. * If the ray of the LaserPointer should be displayed.
  41226. */
  41227. /**
  41228. * Sets if the ray of the LaserPointer should be displayed.
  41229. */
  41230. displayLaserPointer: boolean;
  41231. /**
  41232. * The deviceOrientationCamera used as the camera when not in VR.
  41233. */
  41234. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41235. /**
  41236. * Based on the current WebVR support, returns the current VR camera used.
  41237. */
  41238. readonly currentVRCamera: Nullable<Camera>;
  41239. /**
  41240. * The webVRCamera which is used when in VR.
  41241. */
  41242. readonly webVRCamera: WebVRFreeCamera;
  41243. /**
  41244. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41245. */
  41246. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41247. /**
  41248. * The html button that is used to trigger entering into VR.
  41249. */
  41250. readonly vrButton: Nullable<HTMLButtonElement>;
  41251. private readonly _teleportationRequestInitiated;
  41252. /**
  41253. * Defines wether or not Pointer lock should be requested when switching to
  41254. * full screen.
  41255. */
  41256. requestPointerLockOnFullScreen: boolean;
  41257. /**
  41258. * Instantiates a VRExperienceHelper.
  41259. * Helps to quickly add VR support to an existing scene.
  41260. * @param scene The scene the VRExperienceHelper belongs to.
  41261. * @param webVROptions Options to modify the vr experience helper's behavior.
  41262. */
  41263. constructor(scene: Scene,
  41264. /** Options to modify the vr experience helper's behavior. */
  41265. webVROptions?: VRExperienceHelperOptions);
  41266. private _onDefaultMeshLoaded;
  41267. private _onResize;
  41268. private _onFullscreenChange;
  41269. /**
  41270. * Gets a value indicating if we are currently in VR mode.
  41271. */
  41272. readonly isInVRMode: boolean;
  41273. private onVrDisplayPresentChange;
  41274. private onVRDisplayChanged;
  41275. private moveButtonToBottomRight;
  41276. private displayVRButton;
  41277. private updateButtonVisibility;
  41278. private _cachedAngularSensibility;
  41279. /**
  41280. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41281. * Otherwise, will use the fullscreen API.
  41282. */
  41283. enterVR(): void;
  41284. /**
  41285. * Attempt to exit VR, or fullscreen.
  41286. */
  41287. exitVR(): void;
  41288. /**
  41289. * The position of the vr experience helper.
  41290. */
  41291. /**
  41292. * Sets the position of the vr experience helper.
  41293. */
  41294. position: Vector3;
  41295. /**
  41296. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41297. */
  41298. enableInteractions(): void;
  41299. private readonly _noControllerIsActive;
  41300. private beforeRender;
  41301. private _isTeleportationFloor;
  41302. /**
  41303. * Adds a floor mesh to be used for teleportation.
  41304. * @param floorMesh the mesh to be used for teleportation.
  41305. */
  41306. addFloorMesh(floorMesh: Mesh): void;
  41307. /**
  41308. * Removes a floor mesh from being used for teleportation.
  41309. * @param floorMesh the mesh to be removed.
  41310. */
  41311. removeFloorMesh(floorMesh: Mesh): void;
  41312. /**
  41313. * Enables interactions and teleportation using the VR controllers and gaze.
  41314. * @param vrTeleportationOptions options to modify teleportation behavior.
  41315. */
  41316. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41317. private _onNewGamepadConnected;
  41318. private _tryEnableInteractionOnController;
  41319. private _onNewGamepadDisconnected;
  41320. private _enableInteractionOnController;
  41321. private _checkTeleportWithRay;
  41322. private _checkRotate;
  41323. private _checkTeleportBackwards;
  41324. private _enableTeleportationOnController;
  41325. private _createTeleportationCircles;
  41326. private _displayTeleportationTarget;
  41327. private _hideTeleportationTarget;
  41328. private _rotateCamera;
  41329. private _moveTeleportationSelectorTo;
  41330. private _workingVector;
  41331. private _workingQuaternion;
  41332. private _workingMatrix;
  41333. /**
  41334. * Teleports the users feet to the desired location
  41335. * @param location The location where the user's feet should be placed
  41336. */
  41337. teleportCamera(location: Vector3): void;
  41338. private _convertNormalToDirectionOfRay;
  41339. private _castRayAndSelectObject;
  41340. private _notifySelectedMeshUnselected;
  41341. /**
  41342. * Sets the color of the laser ray from the vr controllers.
  41343. * @param color new color for the ray.
  41344. */
  41345. changeLaserColor(color: Color3): void;
  41346. /**
  41347. * Sets the color of the ray from the vr headsets gaze.
  41348. * @param color new color for the ray.
  41349. */
  41350. changeGazeColor(color: Color3): void;
  41351. /**
  41352. * Exits VR and disposes of the vr experience helper
  41353. */
  41354. dispose(): void;
  41355. /**
  41356. * Gets the name of the VRExperienceHelper class
  41357. * @returns "VRExperienceHelper"
  41358. */
  41359. getClassName(): string;
  41360. }
  41361. }
  41362. declare module BABYLON {
  41363. /**
  41364. * Manages an XRSession to work with Babylon's engine
  41365. * @see https://doc.babylonjs.com/how_to/webxr
  41366. */
  41367. export class WebXRSessionManager implements IDisposable {
  41368. private scene;
  41369. /**
  41370. * Fires every time a new xrFrame arrives which can be used to update the camera
  41371. */
  41372. onXRFrameObservable: Observable<any>;
  41373. /**
  41374. * Fires when the xr session is ended either by the device or manually done
  41375. */
  41376. onXRSessionEnded: Observable<any>;
  41377. /**
  41378. * Underlying xr session
  41379. */
  41380. session: XRSession;
  41381. /**
  41382. * Type of reference space used when creating the session
  41383. */
  41384. referenceSpace: XRReferenceSpace;
  41385. /** @hidden */
  41386. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41387. /**
  41388. * Current XR frame
  41389. */
  41390. currentFrame: Nullable<XRFrame>;
  41391. private _xrNavigator;
  41392. private baseLayer;
  41393. /**
  41394. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41395. * @param scene The scene which the session should be created for
  41396. */
  41397. constructor(scene: Scene);
  41398. /**
  41399. * Initializes the manager
  41400. * After initialization enterXR can be called to start an XR session
  41401. * @returns Promise which resolves after it is initialized
  41402. */
  41403. initializeAsync(): Promise<void>;
  41404. /**
  41405. * Initializes an xr session
  41406. * @param xrSessionMode mode to initialize
  41407. * @returns a promise which will resolve once the session has been initialized
  41408. */
  41409. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41410. /**
  41411. * Sets the reference space on the xr session
  41412. * @param referenceSpace space to set
  41413. * @returns a promise that will resolve once the reference space has been set
  41414. */
  41415. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41416. /**
  41417. * Updates the render state of the session
  41418. * @param state state to set
  41419. * @returns a promise that resolves once the render state has been updated
  41420. */
  41421. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41422. /**
  41423. * Starts rendering to the xr layer
  41424. * @returns a promise that will resolve once rendering has started
  41425. */
  41426. startRenderingToXRAsync(): Promise<void>;
  41427. /**
  41428. * Stops the xrSession and restores the renderloop
  41429. * @returns Promise which resolves after it exits XR
  41430. */
  41431. exitXRAsync(): Promise<unknown>;
  41432. /**
  41433. * Checks if a session would be supported for the creation options specified
  41434. * @param sessionMode session mode to check if supported eg. immersive-vr
  41435. * @returns true if supported
  41436. */
  41437. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41438. /**
  41439. * @hidden
  41440. * Converts the render layer of xrSession to a render target
  41441. * @param session session to create render target for
  41442. * @param scene scene the new render target should be created for
  41443. */
  41444. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41445. /**
  41446. * Disposes of the session manager
  41447. */
  41448. dispose(): void;
  41449. }
  41450. }
  41451. declare module BABYLON {
  41452. /**
  41453. * WebXR Camera which holds the views for the xrSession
  41454. * @see https://doc.babylonjs.com/how_to/webxr
  41455. */
  41456. export class WebXRCamera extends FreeCamera {
  41457. private static _TmpMatrix;
  41458. /**
  41459. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41460. * @param name the name of the camera
  41461. * @param scene the scene to add the camera to
  41462. */
  41463. constructor(name: string, scene: Scene);
  41464. private _updateNumberOfRigCameras;
  41465. /** @hidden */
  41466. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41467. /**
  41468. * Updates the cameras position from the current pose information of the XR session
  41469. * @param xrSessionManager the session containing pose information
  41470. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41471. */
  41472. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41473. }
  41474. }
  41475. declare module BABYLON {
  41476. /**
  41477. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41478. */
  41479. export class WebXRManagedOutputCanvas implements IDisposable {
  41480. private helper;
  41481. private _canvas;
  41482. /**
  41483. * xrpresent context of the canvas which can be used to display/mirror xr content
  41484. */
  41485. canvasContext: WebGLRenderingContext;
  41486. /**
  41487. * xr layer for the canvas
  41488. */
  41489. xrLayer: Nullable<XRWebGLLayer>;
  41490. /**
  41491. * Initializes the xr layer for the session
  41492. * @param xrSession xr session
  41493. * @returns a promise that will resolve once the XR Layer has been created
  41494. */
  41495. initializeXRLayerAsync(xrSession: any): any;
  41496. /**
  41497. * Initializes the canvas to be added/removed upon entering/exiting xr
  41498. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41499. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41500. */
  41501. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41502. /**
  41503. * Disposes of the object
  41504. */
  41505. dispose(): void;
  41506. private _setManagedOutputCanvas;
  41507. private _addCanvas;
  41508. private _removeCanvas;
  41509. }
  41510. }
  41511. declare module BABYLON {
  41512. /**
  41513. * States of the webXR experience
  41514. */
  41515. export enum WebXRState {
  41516. /**
  41517. * Transitioning to being in XR mode
  41518. */
  41519. ENTERING_XR = 0,
  41520. /**
  41521. * Transitioning to non XR mode
  41522. */
  41523. EXITING_XR = 1,
  41524. /**
  41525. * In XR mode and presenting
  41526. */
  41527. IN_XR = 2,
  41528. /**
  41529. * Not entered XR mode
  41530. */
  41531. NOT_IN_XR = 3
  41532. }
  41533. /**
  41534. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41535. * @see https://doc.babylonjs.com/how_to/webxr
  41536. */
  41537. export class WebXRExperienceHelper implements IDisposable {
  41538. private scene;
  41539. /**
  41540. * 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
  41541. */
  41542. container: AbstractMesh;
  41543. /**
  41544. * Camera used to render xr content
  41545. */
  41546. camera: WebXRCamera;
  41547. /**
  41548. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41549. */
  41550. state: WebXRState;
  41551. private _setState;
  41552. private static _TmpVector;
  41553. /**
  41554. * Fires when the state of the experience helper has changed
  41555. */
  41556. onStateChangedObservable: Observable<WebXRState>;
  41557. /** Session manager used to keep track of xr session */
  41558. sessionManager: WebXRSessionManager;
  41559. private _nonVRCamera;
  41560. private _originalSceneAutoClear;
  41561. private _supported;
  41562. /**
  41563. * Creates the experience helper
  41564. * @param scene the scene to attach the experience helper to
  41565. * @returns a promise for the experience helper
  41566. */
  41567. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41568. /**
  41569. * Creates a WebXRExperienceHelper
  41570. * @param scene The scene the helper should be created in
  41571. */
  41572. private constructor();
  41573. /**
  41574. * Exits XR mode and returns the scene to its original state
  41575. * @returns promise that resolves after xr mode has exited
  41576. */
  41577. exitXRAsync(): Promise<unknown>;
  41578. /**
  41579. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41580. * @param sessionCreationOptions options for the XR session
  41581. * @param referenceSpaceType frame of reference of the XR session
  41582. * @param outputCanvas the output canvas that will be used to enter XR mode
  41583. * @returns promise that resolves after xr mode has entered
  41584. */
  41585. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41586. /**
  41587. * Updates the global position of the camera by moving the camera's container
  41588. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41589. * @param position The desired global position of the camera
  41590. */
  41591. setPositionOfCameraUsingContainer(position: Vector3): void;
  41592. /**
  41593. * Rotates the xr camera by rotating the camera's container around the camera's position
  41594. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41595. * @param rotation the desired quaternion rotation to apply to the camera
  41596. */
  41597. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41598. /**
  41599. * Disposes of the experience helper
  41600. */
  41601. dispose(): void;
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /**
  41606. * Button which can be used to enter a different mode of XR
  41607. */
  41608. export class WebXREnterExitUIButton {
  41609. /** button element */
  41610. element: HTMLElement;
  41611. /** XR initialization options for the button */
  41612. sessionMode: XRSessionMode;
  41613. /** Reference space type */
  41614. referenceSpaceType: XRReferenceSpaceType;
  41615. /**
  41616. * Creates a WebXREnterExitUIButton
  41617. * @param element button element
  41618. * @param sessionMode XR initialization session mode
  41619. * @param referenceSpaceType the type of reference space to be used
  41620. */
  41621. constructor(
  41622. /** button element */
  41623. element: HTMLElement,
  41624. /** XR initialization options for the button */
  41625. sessionMode: XRSessionMode,
  41626. /** Reference space type */
  41627. referenceSpaceType: XRReferenceSpaceType);
  41628. /**
  41629. * Overwritable function which can be used to update the button's visuals when the state changes
  41630. * @param activeButton the current active button in the UI
  41631. */
  41632. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41633. }
  41634. /**
  41635. * Options to create the webXR UI
  41636. */
  41637. export class WebXREnterExitUIOptions {
  41638. /**
  41639. * Context to enter xr with
  41640. */
  41641. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41642. /**
  41643. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41644. */
  41645. customButtons?: Array<WebXREnterExitUIButton>;
  41646. }
  41647. /**
  41648. * UI to allow the user to enter/exit XR mode
  41649. */
  41650. export class WebXREnterExitUI implements IDisposable {
  41651. private scene;
  41652. private _overlay;
  41653. private _buttons;
  41654. private _activeButton;
  41655. /**
  41656. * Fired every time the active button is changed.
  41657. *
  41658. * When xr is entered via a button that launches xr that button will be the callback parameter
  41659. *
  41660. * When exiting xr the callback parameter will be null)
  41661. */
  41662. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41663. /**
  41664. * Creates UI to allow the user to enter/exit XR mode
  41665. * @param scene the scene to add the ui to
  41666. * @param helper the xr experience helper to enter/exit xr with
  41667. * @param options options to configure the UI
  41668. * @returns the created ui
  41669. */
  41670. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41671. private constructor();
  41672. private _updateButtons;
  41673. /**
  41674. * Disposes of the object
  41675. */
  41676. dispose(): void;
  41677. }
  41678. }
  41679. declare module BABYLON {
  41680. /**
  41681. * Represents an XR input
  41682. */
  41683. export class WebXRController {
  41684. private scene;
  41685. /** The underlying input source for the controller */
  41686. inputSource: XRInputSource;
  41687. private parentContainer;
  41688. /**
  41689. * 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
  41690. */
  41691. grip?: AbstractMesh;
  41692. /**
  41693. * Pointer which can be used to select objects or attach a visible laser to
  41694. */
  41695. pointer: AbstractMesh;
  41696. /**
  41697. * Event that fires when the controller is removed/disposed
  41698. */
  41699. onDisposeObservable: Observable<{}>;
  41700. private _tmpMatrix;
  41701. private _tmpQuaternion;
  41702. private _tmpVector;
  41703. /**
  41704. * Creates the controller
  41705. * @see https://doc.babylonjs.com/how_to/webxr
  41706. * @param scene the scene which the controller should be associated to
  41707. * @param inputSource the underlying input source for the controller
  41708. * @param parentContainer parent that the controller meshes should be children of
  41709. */
  41710. constructor(scene: Scene,
  41711. /** The underlying input source for the controller */
  41712. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41713. /**
  41714. * Updates the controller pose based on the given XRFrame
  41715. * @param xrFrame xr frame to update the pose with
  41716. * @param referenceSpace reference space to use
  41717. */
  41718. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41719. /**
  41720. * Gets a world space ray coming from the controller
  41721. * @param result the resulting ray
  41722. */
  41723. getWorldPointerRayToRef(result: Ray): void;
  41724. /**
  41725. * Disposes of the object
  41726. */
  41727. dispose(): void;
  41728. }
  41729. }
  41730. declare module BABYLON {
  41731. /**
  41732. * XR input used to track XR inputs such as controllers/rays
  41733. */
  41734. export class WebXRInput implements IDisposable {
  41735. /**
  41736. * Base experience the input listens to
  41737. */
  41738. baseExperience: WebXRExperienceHelper;
  41739. /**
  41740. * XR controllers being tracked
  41741. */
  41742. controllers: Array<WebXRController>;
  41743. private _frameObserver;
  41744. private _stateObserver;
  41745. /**
  41746. * Event when a controller has been connected/added
  41747. */
  41748. onControllerAddedObservable: Observable<WebXRController>;
  41749. /**
  41750. * Event when a controller has been removed/disconnected
  41751. */
  41752. onControllerRemovedObservable: Observable<WebXRController>;
  41753. /**
  41754. * Initializes the WebXRInput
  41755. * @param baseExperience experience helper which the input should be created for
  41756. */
  41757. constructor(
  41758. /**
  41759. * Base experience the input listens to
  41760. */
  41761. baseExperience: WebXRExperienceHelper);
  41762. private _onInputSourcesChange;
  41763. private _addAndRemoveControllers;
  41764. /**
  41765. * Disposes of the object
  41766. */
  41767. dispose(): void;
  41768. }
  41769. }
  41770. declare module BABYLON {
  41771. /**
  41772. * Enables teleportation
  41773. */
  41774. export class WebXRControllerTeleportation {
  41775. private _teleportationFillColor;
  41776. private _teleportationBorderColor;
  41777. private _tmpRay;
  41778. private _tmpVector;
  41779. /**
  41780. * Creates a WebXRControllerTeleportation
  41781. * @param input input manager to add teleportation to
  41782. * @param floorMeshes floormeshes which can be teleported to
  41783. */
  41784. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41785. }
  41786. }
  41787. declare module BABYLON {
  41788. /**
  41789. * Handles pointer input automatically for the pointer of XR controllers
  41790. */
  41791. export class WebXRControllerPointerSelection {
  41792. private static _idCounter;
  41793. private _tmpRay;
  41794. /**
  41795. * Creates a WebXRControllerPointerSelection
  41796. * @param input input manager to setup pointer selection
  41797. */
  41798. constructor(input: WebXRInput);
  41799. private _convertNormalToDirectionOfRay;
  41800. private _updatePointerDistance;
  41801. }
  41802. }
  41803. declare module BABYLON {
  41804. /**
  41805. * Class used to represent data loading progression
  41806. */
  41807. export class SceneLoaderProgressEvent {
  41808. /** defines if data length to load can be evaluated */
  41809. readonly lengthComputable: boolean;
  41810. /** defines the loaded data length */
  41811. readonly loaded: number;
  41812. /** defines the data length to load */
  41813. readonly total: number;
  41814. /**
  41815. * Create a new progress event
  41816. * @param lengthComputable defines if data length to load can be evaluated
  41817. * @param loaded defines the loaded data length
  41818. * @param total defines the data length to load
  41819. */
  41820. constructor(
  41821. /** defines if data length to load can be evaluated */
  41822. lengthComputable: boolean,
  41823. /** defines the loaded data length */
  41824. loaded: number,
  41825. /** defines the data length to load */
  41826. total: number);
  41827. /**
  41828. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41829. * @param event defines the source event
  41830. * @returns a new SceneLoaderProgressEvent
  41831. */
  41832. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41833. }
  41834. /**
  41835. * Interface used by SceneLoader plugins to define supported file extensions
  41836. */
  41837. export interface ISceneLoaderPluginExtensions {
  41838. /**
  41839. * Defines the list of supported extensions
  41840. */
  41841. [extension: string]: {
  41842. isBinary: boolean;
  41843. };
  41844. }
  41845. /**
  41846. * Interface used by SceneLoader plugin factory
  41847. */
  41848. export interface ISceneLoaderPluginFactory {
  41849. /**
  41850. * Defines the name of the factory
  41851. */
  41852. name: string;
  41853. /**
  41854. * Function called to create a new plugin
  41855. * @return the new plugin
  41856. */
  41857. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41858. /**
  41859. * Boolean indicating if the plugin can direct load specific data
  41860. */
  41861. canDirectLoad?: (data: string) => boolean;
  41862. }
  41863. /**
  41864. * Interface used to define a SceneLoader plugin
  41865. */
  41866. export interface ISceneLoaderPlugin {
  41867. /**
  41868. * The friendly name of this plugin.
  41869. */
  41870. name: string;
  41871. /**
  41872. * The file extensions supported by this plugin.
  41873. */
  41874. extensions: string | ISceneLoaderPluginExtensions;
  41875. /**
  41876. * Import meshes into a scene.
  41877. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41878. * @param scene The scene to import into
  41879. * @param data The data to import
  41880. * @param rootUrl The root url for scene and resources
  41881. * @param meshes The meshes array to import into
  41882. * @param particleSystems The particle systems array to import into
  41883. * @param skeletons The skeletons array to import into
  41884. * @param onError The callback when import fails
  41885. * @returns True if successful or false otherwise
  41886. */
  41887. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41888. /**
  41889. * Load into a scene.
  41890. * @param scene The scene to load into
  41891. * @param data The data to import
  41892. * @param rootUrl The root url for scene and resources
  41893. * @param onError The callback when import fails
  41894. * @returns true if successful or false otherwise
  41895. */
  41896. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41897. /**
  41898. * The callback that returns true if the data can be directly loaded.
  41899. */
  41900. canDirectLoad?: (data: string) => boolean;
  41901. /**
  41902. * The callback that allows custom handling of the root url based on the response url.
  41903. */
  41904. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41905. /**
  41906. * Load into an asset container.
  41907. * @param scene The scene to load into
  41908. * @param data The data to import
  41909. * @param rootUrl The root url for scene and resources
  41910. * @param onError The callback when import fails
  41911. * @returns The loaded asset container
  41912. */
  41913. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41914. }
  41915. /**
  41916. * Interface used to define an async SceneLoader plugin
  41917. */
  41918. export interface ISceneLoaderPluginAsync {
  41919. /**
  41920. * The friendly name of this plugin.
  41921. */
  41922. name: string;
  41923. /**
  41924. * The file extensions supported by this plugin.
  41925. */
  41926. extensions: string | ISceneLoaderPluginExtensions;
  41927. /**
  41928. * Import meshes into a scene.
  41929. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41930. * @param scene The scene to import into
  41931. * @param data The data to import
  41932. * @param rootUrl The root url for scene and resources
  41933. * @param onProgress The callback when the load progresses
  41934. * @param fileName Defines the name of the file to load
  41935. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41936. */
  41937. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41938. meshes: AbstractMesh[];
  41939. particleSystems: IParticleSystem[];
  41940. skeletons: Skeleton[];
  41941. animationGroups: AnimationGroup[];
  41942. }>;
  41943. /**
  41944. * Load into a scene.
  41945. * @param scene The scene to load into
  41946. * @param data The data to import
  41947. * @param rootUrl The root url for scene and resources
  41948. * @param onProgress The callback when the load progresses
  41949. * @param fileName Defines the name of the file to load
  41950. * @returns Nothing
  41951. */
  41952. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41953. /**
  41954. * The callback that returns true if the data can be directly loaded.
  41955. */
  41956. canDirectLoad?: (data: string) => boolean;
  41957. /**
  41958. * The callback that allows custom handling of the root url based on the response url.
  41959. */
  41960. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41961. /**
  41962. * Load into an asset container.
  41963. * @param scene The scene to load into
  41964. * @param data The data to import
  41965. * @param rootUrl The root url for scene and resources
  41966. * @param onProgress The callback when the load progresses
  41967. * @param fileName Defines the name of the file to load
  41968. * @returns The loaded asset container
  41969. */
  41970. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41971. }
  41972. /**
  41973. * Class used to load scene from various file formats using registered plugins
  41974. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41975. */
  41976. export class SceneLoader {
  41977. /**
  41978. * No logging while loading
  41979. */
  41980. static readonly NO_LOGGING: number;
  41981. /**
  41982. * Minimal logging while loading
  41983. */
  41984. static readonly MINIMAL_LOGGING: number;
  41985. /**
  41986. * Summary logging while loading
  41987. */
  41988. static readonly SUMMARY_LOGGING: number;
  41989. /**
  41990. * Detailled logging while loading
  41991. */
  41992. static readonly DETAILED_LOGGING: number;
  41993. /**
  41994. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41995. */
  41996. static ForceFullSceneLoadingForIncremental: boolean;
  41997. /**
  41998. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41999. */
  42000. static ShowLoadingScreen: boolean;
  42001. /**
  42002. * Defines the current logging level (while loading the scene)
  42003. * @ignorenaming
  42004. */
  42005. static loggingLevel: number;
  42006. /**
  42007. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42008. */
  42009. static CleanBoneMatrixWeights: boolean;
  42010. /**
  42011. * Event raised when a plugin is used to load a scene
  42012. */
  42013. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42014. private static _registeredPlugins;
  42015. private static _getDefaultPlugin;
  42016. private static _getPluginForExtension;
  42017. private static _getPluginForDirectLoad;
  42018. private static _getPluginForFilename;
  42019. private static _getDirectLoad;
  42020. private static _loadData;
  42021. private static _getFileInfo;
  42022. /**
  42023. * Gets a plugin that can load the given extension
  42024. * @param extension defines the extension to load
  42025. * @returns a plugin or null if none works
  42026. */
  42027. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42028. /**
  42029. * Gets a boolean indicating that the given extension can be loaded
  42030. * @param extension defines the extension to load
  42031. * @returns true if the extension is supported
  42032. */
  42033. static IsPluginForExtensionAvailable(extension: string): boolean;
  42034. /**
  42035. * Adds a new plugin to the list of registered plugins
  42036. * @param plugin defines the plugin to add
  42037. */
  42038. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42039. /**
  42040. * Import meshes into a scene
  42041. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42042. * @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)
  42043. * @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)
  42044. * @param scene the instance of BABYLON.Scene to append to
  42045. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42046. * @param onProgress a callback with a progress event for each file being loaded
  42047. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42048. * @param pluginExtension the extension used to determine the plugin
  42049. * @returns The loaded plugin
  42050. */
  42051. 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>;
  42052. /**
  42053. * Import meshes into a scene
  42054. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42055. * @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)
  42056. * @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)
  42057. * @param scene the instance of BABYLON.Scene to append to
  42058. * @param onProgress a callback with a progress event for each file being loaded
  42059. * @param pluginExtension the extension used to determine the plugin
  42060. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42061. */
  42062. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42063. meshes: AbstractMesh[];
  42064. particleSystems: IParticleSystem[];
  42065. skeletons: Skeleton[];
  42066. animationGroups: AnimationGroup[];
  42067. }>;
  42068. /**
  42069. * Load a scene
  42070. * @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)
  42071. * @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)
  42072. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42073. * @param onSuccess a callback with the scene when import succeeds
  42074. * @param onProgress a callback with a progress event for each file being loaded
  42075. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42076. * @param pluginExtension the extension used to determine the plugin
  42077. * @returns The loaded plugin
  42078. */
  42079. 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>;
  42080. /**
  42081. * Load a scene
  42082. * @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)
  42083. * @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)
  42084. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42085. * @param onProgress a callback with a progress event for each file being loaded
  42086. * @param pluginExtension the extension used to determine the plugin
  42087. * @returns The loaded scene
  42088. */
  42089. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42090. /**
  42091. * Append a scene
  42092. * @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)
  42093. * @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)
  42094. * @param scene is the instance of BABYLON.Scene to append to
  42095. * @param onSuccess a callback with the scene when import succeeds
  42096. * @param onProgress a callback with a progress event for each file being loaded
  42097. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42098. * @param pluginExtension the extension used to determine the plugin
  42099. * @returns The loaded plugin
  42100. */
  42101. 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>;
  42102. /**
  42103. * Append a scene
  42104. * @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)
  42105. * @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)
  42106. * @param scene is the instance of BABYLON.Scene to append to
  42107. * @param onProgress a callback with a progress event for each file being loaded
  42108. * @param pluginExtension the extension used to determine the plugin
  42109. * @returns The given scene
  42110. */
  42111. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42112. /**
  42113. * Load a scene into an asset container
  42114. * @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)
  42115. * @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)
  42116. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42117. * @param onSuccess a callback with the scene when import succeeds
  42118. * @param onProgress a callback with a progress event for each file being loaded
  42119. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42120. * @param pluginExtension the extension used to determine the plugin
  42121. * @returns The loaded plugin
  42122. */
  42123. 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>;
  42124. /**
  42125. * Load a scene into an asset container
  42126. * @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)
  42127. * @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)
  42128. * @param scene is the instance of Scene to append to
  42129. * @param onProgress a callback with a progress event for each file being loaded
  42130. * @param pluginExtension the extension used to determine the plugin
  42131. * @returns The loaded asset container
  42132. */
  42133. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42134. }
  42135. }
  42136. declare module BABYLON {
  42137. /**
  42138. * Generic Controller
  42139. */
  42140. export class GenericController extends WebVRController {
  42141. /**
  42142. * Base Url for the controller model.
  42143. */
  42144. static readonly MODEL_BASE_URL: string;
  42145. /**
  42146. * File name for the controller model.
  42147. */
  42148. static readonly MODEL_FILENAME: string;
  42149. /**
  42150. * Creates a new GenericController from a gamepad
  42151. * @param vrGamepad the gamepad that the controller should be created from
  42152. */
  42153. constructor(vrGamepad: any);
  42154. /**
  42155. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42156. * @param scene scene in which to add meshes
  42157. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42158. */
  42159. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42160. /**
  42161. * Called once for each button that changed state since the last frame
  42162. * @param buttonIdx Which button index changed
  42163. * @param state New state of the button
  42164. * @param changes Which properties on the state changed since last frame
  42165. */
  42166. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42167. }
  42168. }
  42169. declare module BABYLON {
  42170. /**
  42171. * Defines the WindowsMotionController object that the state of the windows motion controller
  42172. */
  42173. export class WindowsMotionController extends WebVRController {
  42174. /**
  42175. * The base url used to load the left and right controller models
  42176. */
  42177. static MODEL_BASE_URL: string;
  42178. /**
  42179. * The name of the left controller model file
  42180. */
  42181. static MODEL_LEFT_FILENAME: string;
  42182. /**
  42183. * The name of the right controller model file
  42184. */
  42185. static MODEL_RIGHT_FILENAME: string;
  42186. /**
  42187. * The controller name prefix for this controller type
  42188. */
  42189. static readonly GAMEPAD_ID_PREFIX: string;
  42190. /**
  42191. * The controller id pattern for this controller type
  42192. */
  42193. private static readonly GAMEPAD_ID_PATTERN;
  42194. private _loadedMeshInfo;
  42195. private readonly _mapping;
  42196. /**
  42197. * Fired when the trackpad on this controller is clicked
  42198. */
  42199. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42200. /**
  42201. * Fired when the trackpad on this controller is modified
  42202. */
  42203. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42204. /**
  42205. * The current x and y values of this controller's trackpad
  42206. */
  42207. trackpad: StickValues;
  42208. /**
  42209. * Creates a new WindowsMotionController from a gamepad
  42210. * @param vrGamepad the gamepad that the controller should be created from
  42211. */
  42212. constructor(vrGamepad: any);
  42213. /**
  42214. * Fired when the trigger on this controller is modified
  42215. */
  42216. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42217. /**
  42218. * Fired when the menu button on this controller is modified
  42219. */
  42220. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42221. /**
  42222. * Fired when the grip button on this controller is modified
  42223. */
  42224. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42225. /**
  42226. * Fired when the thumbstick button on this controller is modified
  42227. */
  42228. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42229. /**
  42230. * Fired when the touchpad button on this controller is modified
  42231. */
  42232. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42233. /**
  42234. * Fired when the touchpad values on this controller are modified
  42235. */
  42236. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42237. private _updateTrackpad;
  42238. /**
  42239. * Called once per frame by the engine.
  42240. */
  42241. update(): void;
  42242. /**
  42243. * Called once for each button that changed state since the last frame
  42244. * @param buttonIdx Which button index changed
  42245. * @param state New state of the button
  42246. * @param changes Which properties on the state changed since last frame
  42247. */
  42248. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42249. /**
  42250. * Moves the buttons on the controller mesh based on their current state
  42251. * @param buttonName the name of the button to move
  42252. * @param buttonValue the value of the button which determines the buttons new position
  42253. */
  42254. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42255. /**
  42256. * Moves the axis on the controller mesh based on its current state
  42257. * @param axis the index of the axis
  42258. * @param axisValue the value of the axis which determines the meshes new position
  42259. * @hidden
  42260. */
  42261. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42262. /**
  42263. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42264. * @param scene scene in which to add meshes
  42265. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42266. */
  42267. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42268. /**
  42269. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42270. * can be transformed by button presses and axes values, based on this._mapping.
  42271. *
  42272. * @param scene scene in which the meshes exist
  42273. * @param meshes list of meshes that make up the controller model to process
  42274. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42275. */
  42276. private processModel;
  42277. private createMeshInfo;
  42278. /**
  42279. * Gets the ray of the controller in the direction the controller is pointing
  42280. * @param length the length the resulting ray should be
  42281. * @returns a ray in the direction the controller is pointing
  42282. */
  42283. getForwardRay(length?: number): Ray;
  42284. /**
  42285. * Disposes of the controller
  42286. */
  42287. dispose(): void;
  42288. }
  42289. }
  42290. declare module BABYLON {
  42291. /**
  42292. * Oculus Touch Controller
  42293. */
  42294. export class OculusTouchController extends WebVRController {
  42295. /**
  42296. * Base Url for the controller model.
  42297. */
  42298. static MODEL_BASE_URL: string;
  42299. /**
  42300. * File name for the left controller model.
  42301. */
  42302. static MODEL_LEFT_FILENAME: string;
  42303. /**
  42304. * File name for the right controller model.
  42305. */
  42306. static MODEL_RIGHT_FILENAME: string;
  42307. /**
  42308. * Base Url for the Quest controller model.
  42309. */
  42310. static QUEST_MODEL_BASE_URL: string;
  42311. /**
  42312. * @hidden
  42313. * If the controllers are running on a device that needs the updated Quest controller models
  42314. */
  42315. static _IsQuest: boolean;
  42316. /**
  42317. * Fired when the secondary trigger on this controller is modified
  42318. */
  42319. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42320. /**
  42321. * Fired when the thumb rest on this controller is modified
  42322. */
  42323. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42324. /**
  42325. * Creates a new OculusTouchController from a gamepad
  42326. * @param vrGamepad the gamepad that the controller should be created from
  42327. */
  42328. constructor(vrGamepad: any);
  42329. /**
  42330. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42331. * @param scene scene in which to add meshes
  42332. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42333. */
  42334. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42335. /**
  42336. * Fired when the A button on this controller is modified
  42337. */
  42338. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42339. /**
  42340. * Fired when the B button on this controller is modified
  42341. */
  42342. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42343. /**
  42344. * Fired when the X button on this controller is modified
  42345. */
  42346. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42347. /**
  42348. * Fired when the Y button on this controller is modified
  42349. */
  42350. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42351. /**
  42352. * Called once for each button that changed state since the last frame
  42353. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42354. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42355. * 2) secondary trigger (same)
  42356. * 3) A (right) X (left), touch, pressed = value
  42357. * 4) B / Y
  42358. * 5) thumb rest
  42359. * @param buttonIdx Which button index changed
  42360. * @param state New state of the button
  42361. * @param changes Which properties on the state changed since last frame
  42362. */
  42363. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42364. }
  42365. }
  42366. declare module BABYLON {
  42367. /**
  42368. * Vive Controller
  42369. */
  42370. export class ViveController extends WebVRController {
  42371. /**
  42372. * Base Url for the controller model.
  42373. */
  42374. static MODEL_BASE_URL: string;
  42375. /**
  42376. * File name for the controller model.
  42377. */
  42378. static MODEL_FILENAME: string;
  42379. /**
  42380. * Creates a new ViveController from a gamepad
  42381. * @param vrGamepad the gamepad that the controller should be created from
  42382. */
  42383. constructor(vrGamepad: any);
  42384. /**
  42385. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42386. * @param scene scene in which to add meshes
  42387. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42388. */
  42389. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42390. /**
  42391. * Fired when the left button on this controller is modified
  42392. */
  42393. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42394. /**
  42395. * Fired when the right button on this controller is modified
  42396. */
  42397. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42398. /**
  42399. * Fired when the menu button on this controller is modified
  42400. */
  42401. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42402. /**
  42403. * Called once for each button that changed state since the last frame
  42404. * Vive mapping:
  42405. * 0: touchpad
  42406. * 1: trigger
  42407. * 2: left AND right buttons
  42408. * 3: menu button
  42409. * @param buttonIdx Which button index changed
  42410. * @param state New state of the button
  42411. * @param changes Which properties on the state changed since last frame
  42412. */
  42413. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42414. }
  42415. }
  42416. declare module BABYLON {
  42417. /**
  42418. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42419. */
  42420. export class WebXRControllerModelLoader {
  42421. /**
  42422. * Creates the WebXRControllerModelLoader
  42423. * @param input xr input that creates the controllers
  42424. */
  42425. constructor(input: WebXRInput);
  42426. }
  42427. }
  42428. declare module BABYLON {
  42429. /**
  42430. * Contains an array of blocks representing the octree
  42431. */
  42432. export interface IOctreeContainer<T> {
  42433. /**
  42434. * Blocks within the octree
  42435. */
  42436. blocks: Array<OctreeBlock<T>>;
  42437. }
  42438. /**
  42439. * Class used to store a cell in an octree
  42440. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42441. */
  42442. export class OctreeBlock<T> {
  42443. /**
  42444. * Gets the content of the current block
  42445. */
  42446. entries: T[];
  42447. /**
  42448. * Gets the list of block children
  42449. */
  42450. blocks: Array<OctreeBlock<T>>;
  42451. private _depth;
  42452. private _maxDepth;
  42453. private _capacity;
  42454. private _minPoint;
  42455. private _maxPoint;
  42456. private _boundingVectors;
  42457. private _creationFunc;
  42458. /**
  42459. * Creates a new block
  42460. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42461. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42462. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42463. * @param depth defines the current depth of this block in the octree
  42464. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42465. * @param creationFunc defines a callback to call when an element is added to the block
  42466. */
  42467. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42468. /**
  42469. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42470. */
  42471. readonly capacity: number;
  42472. /**
  42473. * Gets the minimum vector (in world space) of the block's bounding box
  42474. */
  42475. readonly minPoint: Vector3;
  42476. /**
  42477. * Gets the maximum vector (in world space) of the block's bounding box
  42478. */
  42479. readonly maxPoint: Vector3;
  42480. /**
  42481. * Add a new element to this block
  42482. * @param entry defines the element to add
  42483. */
  42484. addEntry(entry: T): void;
  42485. /**
  42486. * Remove an element from this block
  42487. * @param entry defines the element to remove
  42488. */
  42489. removeEntry(entry: T): void;
  42490. /**
  42491. * Add an array of elements to this block
  42492. * @param entries defines the array of elements to add
  42493. */
  42494. addEntries(entries: T[]): void;
  42495. /**
  42496. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42497. * @param frustumPlanes defines the frustum planes to test
  42498. * @param selection defines the array to store current content if selection is positive
  42499. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42500. */
  42501. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42502. /**
  42503. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42504. * @param sphereCenter defines the bounding sphere center
  42505. * @param sphereRadius defines the bounding sphere radius
  42506. * @param selection defines the array to store current content if selection is positive
  42507. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42508. */
  42509. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42510. /**
  42511. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42512. * @param ray defines the ray to test with
  42513. * @param selection defines the array to store current content if selection is positive
  42514. */
  42515. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42516. /**
  42517. * Subdivide the content into child blocks (this block will then be empty)
  42518. */
  42519. createInnerBlocks(): void;
  42520. /**
  42521. * @hidden
  42522. */
  42523. 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;
  42524. }
  42525. }
  42526. declare module BABYLON {
  42527. /**
  42528. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42529. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42530. */
  42531. export class Octree<T> {
  42532. /** 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.) */
  42533. maxDepth: number;
  42534. /**
  42535. * Blocks within the octree containing objects
  42536. */
  42537. blocks: Array<OctreeBlock<T>>;
  42538. /**
  42539. * Content stored in the octree
  42540. */
  42541. dynamicContent: T[];
  42542. private _maxBlockCapacity;
  42543. private _selectionContent;
  42544. private _creationFunc;
  42545. /**
  42546. * Creates a octree
  42547. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42548. * @param creationFunc function to be used to instatiate the octree
  42549. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42550. * @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.)
  42551. */
  42552. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42553. /** 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.) */
  42554. maxDepth?: number);
  42555. /**
  42556. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42557. * @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);
  42558. * @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);
  42559. * @param entries meshes to be added to the octree blocks
  42560. */
  42561. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42562. /**
  42563. * Adds a mesh to the octree
  42564. * @param entry Mesh to add to the octree
  42565. */
  42566. addMesh(entry: T): void;
  42567. /**
  42568. * Remove an element from the octree
  42569. * @param entry defines the element to remove
  42570. */
  42571. removeMesh(entry: T): void;
  42572. /**
  42573. * Selects an array of meshes within the frustum
  42574. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42575. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42576. * @returns array of meshes within the frustum
  42577. */
  42578. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42579. /**
  42580. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42581. * @param sphereCenter defines the bounding sphere center
  42582. * @param sphereRadius defines the bounding sphere radius
  42583. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42584. * @returns an array of objects that intersect the sphere
  42585. */
  42586. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42587. /**
  42588. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42589. * @param ray defines the ray to test with
  42590. * @returns array of intersected objects
  42591. */
  42592. intersectsRay(ray: Ray): SmartArray<T>;
  42593. /**
  42594. * Adds a mesh into the octree block if it intersects the block
  42595. */
  42596. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42597. /**
  42598. * Adds a submesh into the octree block if it intersects the block
  42599. */
  42600. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42601. }
  42602. }
  42603. declare module BABYLON {
  42604. interface Scene {
  42605. /**
  42606. * @hidden
  42607. * Backing Filed
  42608. */
  42609. _selectionOctree: Octree<AbstractMesh>;
  42610. /**
  42611. * Gets the octree used to boost mesh selection (picking)
  42612. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42613. */
  42614. selectionOctree: Octree<AbstractMesh>;
  42615. /**
  42616. * Creates or updates the octree used to boost selection (picking)
  42617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42618. * @param maxCapacity defines the maximum capacity per leaf
  42619. * @param maxDepth defines the maximum depth of the octree
  42620. * @returns an octree of AbstractMesh
  42621. */
  42622. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42623. }
  42624. interface AbstractMesh {
  42625. /**
  42626. * @hidden
  42627. * Backing Field
  42628. */
  42629. _submeshesOctree: Octree<SubMesh>;
  42630. /**
  42631. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42632. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42633. * @param maxCapacity defines the maximum size of each block (64 by default)
  42634. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42635. * @returns the new octree
  42636. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42638. */
  42639. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42640. }
  42641. /**
  42642. * Defines the octree scene component responsible to manage any octrees
  42643. * in a given scene.
  42644. */
  42645. export class OctreeSceneComponent {
  42646. /**
  42647. * The component name help to identify the component in the list of scene components.
  42648. */
  42649. readonly name: string;
  42650. /**
  42651. * The scene the component belongs to.
  42652. */
  42653. scene: Scene;
  42654. /**
  42655. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42656. */
  42657. readonly checksIsEnabled: boolean;
  42658. /**
  42659. * Creates a new instance of the component for the given scene
  42660. * @param scene Defines the scene to register the component in
  42661. */
  42662. constructor(scene: Scene);
  42663. /**
  42664. * Registers the component in a given scene
  42665. */
  42666. register(): void;
  42667. /**
  42668. * Return the list of active meshes
  42669. * @returns the list of active meshes
  42670. */
  42671. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42672. /**
  42673. * Return the list of active sub meshes
  42674. * @param mesh The mesh to get the candidates sub meshes from
  42675. * @returns the list of active sub meshes
  42676. */
  42677. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42678. private _tempRay;
  42679. /**
  42680. * Return the list of sub meshes intersecting with a given local ray
  42681. * @param mesh defines the mesh to find the submesh for
  42682. * @param localRay defines the ray in local space
  42683. * @returns the list of intersecting sub meshes
  42684. */
  42685. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42686. /**
  42687. * Return the list of sub meshes colliding with a collider
  42688. * @param mesh defines the mesh to find the submesh for
  42689. * @param collider defines the collider to evaluate the collision against
  42690. * @returns the list of colliding sub meshes
  42691. */
  42692. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42693. /**
  42694. * Rebuilds the elements related to this component in case of
  42695. * context lost for instance.
  42696. */
  42697. rebuild(): void;
  42698. /**
  42699. * Disposes the component and the associated ressources.
  42700. */
  42701. dispose(): void;
  42702. }
  42703. }
  42704. declare module BABYLON {
  42705. /**
  42706. * Renders a layer on top of an existing scene
  42707. */
  42708. export class UtilityLayerRenderer implements IDisposable {
  42709. /** the original scene that will be rendered on top of */
  42710. originalScene: Scene;
  42711. private _pointerCaptures;
  42712. private _lastPointerEvents;
  42713. private static _DefaultUtilityLayer;
  42714. private static _DefaultKeepDepthUtilityLayer;
  42715. private _sharedGizmoLight;
  42716. private _renderCamera;
  42717. /**
  42718. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42719. * @returns the camera that is used when rendering the utility layer
  42720. */
  42721. getRenderCamera(): Nullable<Camera>;
  42722. /**
  42723. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42724. * @param cam the camera that should be used when rendering the utility layer
  42725. */
  42726. setRenderCamera(cam: Nullable<Camera>): void;
  42727. /**
  42728. * @hidden
  42729. * Light which used by gizmos to get light shading
  42730. */
  42731. _getSharedGizmoLight(): HemisphericLight;
  42732. /**
  42733. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42734. */
  42735. pickUtilitySceneFirst: boolean;
  42736. /**
  42737. * 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)
  42738. */
  42739. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42740. /**
  42741. * 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)
  42742. */
  42743. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42744. /**
  42745. * The scene that is rendered on top of the original scene
  42746. */
  42747. utilityLayerScene: Scene;
  42748. /**
  42749. * If the utility layer should automatically be rendered on top of existing scene
  42750. */
  42751. shouldRender: boolean;
  42752. /**
  42753. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42754. */
  42755. onlyCheckPointerDownEvents: boolean;
  42756. /**
  42757. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42758. */
  42759. processAllEvents: boolean;
  42760. /**
  42761. * Observable raised when the pointer move from the utility layer scene to the main scene
  42762. */
  42763. onPointerOutObservable: Observable<number>;
  42764. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42765. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42766. private _afterRenderObserver;
  42767. private _sceneDisposeObserver;
  42768. private _originalPointerObserver;
  42769. /**
  42770. * Instantiates a UtilityLayerRenderer
  42771. * @param originalScene the original scene that will be rendered on top of
  42772. * @param handleEvents boolean indicating if the utility layer should handle events
  42773. */
  42774. constructor(
  42775. /** the original scene that will be rendered on top of */
  42776. originalScene: Scene, handleEvents?: boolean);
  42777. private _notifyObservers;
  42778. /**
  42779. * Renders the utility layers scene on top of the original scene
  42780. */
  42781. render(): void;
  42782. /**
  42783. * Disposes of the renderer
  42784. */
  42785. dispose(): void;
  42786. private _updateCamera;
  42787. }
  42788. }
  42789. declare module BABYLON {
  42790. /**
  42791. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42792. */
  42793. export class Gizmo implements IDisposable {
  42794. /** The utility layer the gizmo will be added to */
  42795. gizmoLayer: UtilityLayerRenderer;
  42796. /**
  42797. * The root mesh of the gizmo
  42798. */
  42799. _rootMesh: Mesh;
  42800. private _attachedMesh;
  42801. /**
  42802. * Ratio for the scale of the gizmo (Default: 1)
  42803. */
  42804. scaleRatio: number;
  42805. /**
  42806. * If a custom mesh has been set (Default: false)
  42807. */
  42808. protected _customMeshSet: boolean;
  42809. /**
  42810. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42811. * * When set, interactions will be enabled
  42812. */
  42813. attachedMesh: Nullable<AbstractMesh>;
  42814. /**
  42815. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42816. * @param mesh The mesh to replace the default mesh of the gizmo
  42817. */
  42818. setCustomMesh(mesh: Mesh): void;
  42819. /**
  42820. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42821. */
  42822. updateGizmoRotationToMatchAttachedMesh: boolean;
  42823. /**
  42824. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42825. */
  42826. updateGizmoPositionToMatchAttachedMesh: boolean;
  42827. /**
  42828. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42829. */
  42830. updateScale: boolean;
  42831. protected _interactionsEnabled: boolean;
  42832. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42833. private _beforeRenderObserver;
  42834. private _tempVector;
  42835. /**
  42836. * Creates a gizmo
  42837. * @param gizmoLayer The utility layer the gizmo will be added to
  42838. */
  42839. constructor(
  42840. /** The utility layer the gizmo will be added to */
  42841. gizmoLayer?: UtilityLayerRenderer);
  42842. /**
  42843. * Updates the gizmo to match the attached mesh's position/rotation
  42844. */
  42845. protected _update(): void;
  42846. /**
  42847. * Disposes of the gizmo
  42848. */
  42849. dispose(): void;
  42850. }
  42851. }
  42852. declare module BABYLON {
  42853. /**
  42854. * Single plane drag gizmo
  42855. */
  42856. export class PlaneDragGizmo extends Gizmo {
  42857. /**
  42858. * Drag behavior responsible for the gizmos dragging interactions
  42859. */
  42860. dragBehavior: PointerDragBehavior;
  42861. private _pointerObserver;
  42862. /**
  42863. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42864. */
  42865. snapDistance: number;
  42866. /**
  42867. * Event that fires each time the gizmo snaps to a new location.
  42868. * * snapDistance is the the change in distance
  42869. */
  42870. onSnapObservable: Observable<{
  42871. snapDistance: number;
  42872. }>;
  42873. private _plane;
  42874. private _coloredMaterial;
  42875. private _hoverMaterial;
  42876. private _isEnabled;
  42877. private _parent;
  42878. /** @hidden */
  42879. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42880. /** @hidden */
  42881. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42882. /**
  42883. * Creates a PlaneDragGizmo
  42884. * @param gizmoLayer The utility layer the gizmo will be added to
  42885. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42886. * @param color The color of the gizmo
  42887. */
  42888. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42889. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42890. /**
  42891. * If the gizmo is enabled
  42892. */
  42893. isEnabled: boolean;
  42894. /**
  42895. * Disposes of the gizmo
  42896. */
  42897. dispose(): void;
  42898. }
  42899. }
  42900. declare module BABYLON {
  42901. /**
  42902. * Gizmo that enables dragging a mesh along 3 axis
  42903. */
  42904. export class PositionGizmo extends Gizmo {
  42905. /**
  42906. * Internal gizmo used for interactions on the x axis
  42907. */
  42908. xGizmo: AxisDragGizmo;
  42909. /**
  42910. * Internal gizmo used for interactions on the y axis
  42911. */
  42912. yGizmo: AxisDragGizmo;
  42913. /**
  42914. * Internal gizmo used for interactions on the z axis
  42915. */
  42916. zGizmo: AxisDragGizmo;
  42917. /**
  42918. * Internal gizmo used for interactions on the yz plane
  42919. */
  42920. xPlaneGizmo: PlaneDragGizmo;
  42921. /**
  42922. * Internal gizmo used for interactions on the xz plane
  42923. */
  42924. yPlaneGizmo: PlaneDragGizmo;
  42925. /**
  42926. * Internal gizmo used for interactions on the xy plane
  42927. */
  42928. zPlaneGizmo: PlaneDragGizmo;
  42929. /**
  42930. * private variables
  42931. */
  42932. private _meshAttached;
  42933. private _updateGizmoRotationToMatchAttachedMesh;
  42934. private _snapDistance;
  42935. private _scaleRatio;
  42936. /** Fires an event when any of it's sub gizmos are dragged */
  42937. onDragStartObservable: Observable<unknown>;
  42938. /** Fires an event when any of it's sub gizmos are released from dragging */
  42939. onDragEndObservable: Observable<unknown>;
  42940. /**
  42941. * If set to true, planar drag is enabled
  42942. */
  42943. private _planarGizmoEnabled;
  42944. attachedMesh: Nullable<AbstractMesh>;
  42945. /**
  42946. * Creates a PositionGizmo
  42947. * @param gizmoLayer The utility layer the gizmo will be added to
  42948. */
  42949. constructor(gizmoLayer?: UtilityLayerRenderer);
  42950. /**
  42951. * If the planar drag gizmo is enabled
  42952. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42953. */
  42954. planarGizmoEnabled: boolean;
  42955. updateGizmoRotationToMatchAttachedMesh: boolean;
  42956. /**
  42957. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42958. */
  42959. snapDistance: number;
  42960. /**
  42961. * Ratio for the scale of the gizmo (Default: 1)
  42962. */
  42963. scaleRatio: number;
  42964. /**
  42965. * Disposes of the gizmo
  42966. */
  42967. dispose(): void;
  42968. /**
  42969. * CustomMeshes are not supported by this gizmo
  42970. * @param mesh The mesh to replace the default mesh of the gizmo
  42971. */
  42972. setCustomMesh(mesh: Mesh): void;
  42973. }
  42974. }
  42975. declare module BABYLON {
  42976. /**
  42977. * Single axis drag gizmo
  42978. */
  42979. export class AxisDragGizmo extends Gizmo {
  42980. /**
  42981. * Drag behavior responsible for the gizmos dragging interactions
  42982. */
  42983. dragBehavior: PointerDragBehavior;
  42984. private _pointerObserver;
  42985. /**
  42986. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42987. */
  42988. snapDistance: number;
  42989. /**
  42990. * Event that fires each time the gizmo snaps to a new location.
  42991. * * snapDistance is the the change in distance
  42992. */
  42993. onSnapObservable: Observable<{
  42994. snapDistance: number;
  42995. }>;
  42996. private _isEnabled;
  42997. private _parent;
  42998. private _arrow;
  42999. private _coloredMaterial;
  43000. private _hoverMaterial;
  43001. /** @hidden */
  43002. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43003. /** @hidden */
  43004. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43005. /**
  43006. * Creates an AxisDragGizmo
  43007. * @param gizmoLayer The utility layer the gizmo will be added to
  43008. * @param dragAxis The axis which the gizmo will be able to drag on
  43009. * @param color The color of the gizmo
  43010. */
  43011. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43012. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43013. /**
  43014. * If the gizmo is enabled
  43015. */
  43016. isEnabled: boolean;
  43017. /**
  43018. * Disposes of the gizmo
  43019. */
  43020. dispose(): void;
  43021. }
  43022. }
  43023. declare module BABYLON.Debug {
  43024. /**
  43025. * The Axes viewer will show 3 axes in a specific point in space
  43026. */
  43027. export class AxesViewer {
  43028. private _xAxis;
  43029. private _yAxis;
  43030. private _zAxis;
  43031. private _scaleLinesFactor;
  43032. private _instanced;
  43033. /**
  43034. * Gets the hosting scene
  43035. */
  43036. scene: Scene;
  43037. /**
  43038. * Gets or sets a number used to scale line length
  43039. */
  43040. scaleLines: number;
  43041. /** Gets the node hierarchy used to render x-axis */
  43042. readonly xAxis: TransformNode;
  43043. /** Gets the node hierarchy used to render y-axis */
  43044. readonly yAxis: TransformNode;
  43045. /** Gets the node hierarchy used to render z-axis */
  43046. readonly zAxis: TransformNode;
  43047. /**
  43048. * Creates a new AxesViewer
  43049. * @param scene defines the hosting scene
  43050. * @param scaleLines defines a number used to scale line length (1 by default)
  43051. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43052. * @param xAxis defines the node hierarchy used to render the x-axis
  43053. * @param yAxis defines the node hierarchy used to render the y-axis
  43054. * @param zAxis defines the node hierarchy used to render the z-axis
  43055. */
  43056. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43057. /**
  43058. * Force the viewer to update
  43059. * @param position defines the position of the viewer
  43060. * @param xaxis defines the x axis of the viewer
  43061. * @param yaxis defines the y axis of the viewer
  43062. * @param zaxis defines the z axis of the viewer
  43063. */
  43064. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43065. /**
  43066. * Creates an instance of this axes viewer.
  43067. * @returns a new axes viewer with instanced meshes
  43068. */
  43069. createInstance(): AxesViewer;
  43070. /** Releases resources */
  43071. dispose(): void;
  43072. private static _SetRenderingGroupId;
  43073. }
  43074. }
  43075. declare module BABYLON.Debug {
  43076. /**
  43077. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43078. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43079. */
  43080. export class BoneAxesViewer extends AxesViewer {
  43081. /**
  43082. * Gets or sets the target mesh where to display the axes viewer
  43083. */
  43084. mesh: Nullable<Mesh>;
  43085. /**
  43086. * Gets or sets the target bone where to display the axes viewer
  43087. */
  43088. bone: Nullable<Bone>;
  43089. /** Gets current position */
  43090. pos: Vector3;
  43091. /** Gets direction of X axis */
  43092. xaxis: Vector3;
  43093. /** Gets direction of Y axis */
  43094. yaxis: Vector3;
  43095. /** Gets direction of Z axis */
  43096. zaxis: Vector3;
  43097. /**
  43098. * Creates a new BoneAxesViewer
  43099. * @param scene defines the hosting scene
  43100. * @param bone defines the target bone
  43101. * @param mesh defines the target mesh
  43102. * @param scaleLines defines a scaling factor for line length (1 by default)
  43103. */
  43104. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43105. /**
  43106. * Force the viewer to update
  43107. */
  43108. update(): void;
  43109. /** Releases resources */
  43110. dispose(): void;
  43111. }
  43112. }
  43113. declare module BABYLON {
  43114. /**
  43115. * Interface used to define scene explorer extensibility option
  43116. */
  43117. export interface IExplorerExtensibilityOption {
  43118. /**
  43119. * Define the option label
  43120. */
  43121. label: string;
  43122. /**
  43123. * Defines the action to execute on click
  43124. */
  43125. action: (entity: any) => void;
  43126. }
  43127. /**
  43128. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43129. */
  43130. export interface IExplorerExtensibilityGroup {
  43131. /**
  43132. * Defines a predicate to test if a given type mut be extended
  43133. */
  43134. predicate: (entity: any) => boolean;
  43135. /**
  43136. * Gets the list of options added to a type
  43137. */
  43138. entries: IExplorerExtensibilityOption[];
  43139. }
  43140. /**
  43141. * Interface used to define the options to use to create the Inspector
  43142. */
  43143. export interface IInspectorOptions {
  43144. /**
  43145. * Display in overlay mode (default: false)
  43146. */
  43147. overlay?: boolean;
  43148. /**
  43149. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43150. */
  43151. globalRoot?: HTMLElement;
  43152. /**
  43153. * Display the Scene explorer
  43154. */
  43155. showExplorer?: boolean;
  43156. /**
  43157. * Display the property inspector
  43158. */
  43159. showInspector?: boolean;
  43160. /**
  43161. * Display in embed mode (both panes on the right)
  43162. */
  43163. embedMode?: boolean;
  43164. /**
  43165. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43166. */
  43167. handleResize?: boolean;
  43168. /**
  43169. * Allow the panes to popup (default: true)
  43170. */
  43171. enablePopup?: boolean;
  43172. /**
  43173. * Allow the panes to be closed by users (default: true)
  43174. */
  43175. enableClose?: boolean;
  43176. /**
  43177. * Optional list of extensibility entries
  43178. */
  43179. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43180. /**
  43181. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43182. */
  43183. inspectorURL?: string;
  43184. }
  43185. interface Scene {
  43186. /**
  43187. * @hidden
  43188. * Backing field
  43189. */
  43190. _debugLayer: DebugLayer;
  43191. /**
  43192. * Gets the debug layer (aka Inspector) associated with the scene
  43193. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43194. */
  43195. debugLayer: DebugLayer;
  43196. }
  43197. /**
  43198. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43199. * what is happening in your scene
  43200. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43201. */
  43202. export class DebugLayer {
  43203. /**
  43204. * Define the url to get the inspector script from.
  43205. * By default it uses the babylonjs CDN.
  43206. * @ignoreNaming
  43207. */
  43208. static InspectorURL: string;
  43209. private _scene;
  43210. private BJSINSPECTOR;
  43211. private _onPropertyChangedObservable?;
  43212. /**
  43213. * Observable triggered when a property is changed through the inspector.
  43214. */
  43215. readonly onPropertyChangedObservable: any;
  43216. /**
  43217. * Instantiates a new debug layer.
  43218. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43219. * what is happening in your scene
  43220. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43221. * @param scene Defines the scene to inspect
  43222. */
  43223. constructor(scene: Scene);
  43224. /** Creates the inspector window. */
  43225. private _createInspector;
  43226. /**
  43227. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43228. * @param entity defines the entity to select
  43229. * @param lineContainerTitle defines the specific block to highlight
  43230. */
  43231. select(entity: any, lineContainerTitle?: string): void;
  43232. /** Get the inspector from bundle or global */
  43233. private _getGlobalInspector;
  43234. /**
  43235. * Get if the inspector is visible or not.
  43236. * @returns true if visible otherwise, false
  43237. */
  43238. isVisible(): boolean;
  43239. /**
  43240. * Hide the inspector and close its window.
  43241. */
  43242. hide(): void;
  43243. /**
  43244. * Launch the debugLayer.
  43245. * @param config Define the configuration of the inspector
  43246. * @return a promise fulfilled when the debug layer is visible
  43247. */
  43248. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43249. }
  43250. }
  43251. declare module BABYLON {
  43252. /**
  43253. * Class containing static functions to help procedurally build meshes
  43254. */
  43255. export class BoxBuilder {
  43256. /**
  43257. * Creates a box mesh
  43258. * * The parameter `size` sets the size (float) of each box side (default 1)
  43259. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43260. * * 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)
  43261. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43263. * * 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
  43264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43265. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43266. * @param name defines the name of the mesh
  43267. * @param options defines the options used to create the mesh
  43268. * @param scene defines the hosting scene
  43269. * @returns the box mesh
  43270. */
  43271. static CreateBox(name: string, options: {
  43272. size?: number;
  43273. width?: number;
  43274. height?: number;
  43275. depth?: number;
  43276. faceUV?: Vector4[];
  43277. faceColors?: Color4[];
  43278. sideOrientation?: number;
  43279. frontUVs?: Vector4;
  43280. backUVs?: Vector4;
  43281. wrap?: boolean;
  43282. topBaseAt?: number;
  43283. bottomBaseAt?: number;
  43284. updatable?: boolean;
  43285. }, scene?: Nullable<Scene>): Mesh;
  43286. }
  43287. }
  43288. declare module BABYLON {
  43289. /**
  43290. * Class containing static functions to help procedurally build meshes
  43291. */
  43292. export class SphereBuilder {
  43293. /**
  43294. * Creates a sphere mesh
  43295. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43296. * * 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`)
  43297. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43298. * * 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
  43299. * * 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)
  43300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43301. * * 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
  43302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43303. * @param name defines the name of the mesh
  43304. * @param options defines the options used to create the mesh
  43305. * @param scene defines the hosting scene
  43306. * @returns the sphere mesh
  43307. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43308. */
  43309. static CreateSphere(name: string, options: {
  43310. segments?: number;
  43311. diameter?: number;
  43312. diameterX?: number;
  43313. diameterY?: number;
  43314. diameterZ?: number;
  43315. arc?: number;
  43316. slice?: number;
  43317. sideOrientation?: number;
  43318. frontUVs?: Vector4;
  43319. backUVs?: Vector4;
  43320. updatable?: boolean;
  43321. }, scene?: Nullable<Scene>): Mesh;
  43322. }
  43323. }
  43324. declare module BABYLON.Debug {
  43325. /**
  43326. * Used to show the physics impostor around the specific mesh
  43327. */
  43328. export class PhysicsViewer {
  43329. /** @hidden */
  43330. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43331. /** @hidden */
  43332. protected _meshes: Array<Nullable<AbstractMesh>>;
  43333. /** @hidden */
  43334. protected _scene: Nullable<Scene>;
  43335. /** @hidden */
  43336. protected _numMeshes: number;
  43337. /** @hidden */
  43338. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43339. private _renderFunction;
  43340. private _utilityLayer;
  43341. private _debugBoxMesh;
  43342. private _debugSphereMesh;
  43343. private _debugCylinderMesh;
  43344. private _debugMaterial;
  43345. private _debugMeshMeshes;
  43346. /**
  43347. * Creates a new PhysicsViewer
  43348. * @param scene defines the hosting scene
  43349. */
  43350. constructor(scene: Scene);
  43351. /** @hidden */
  43352. protected _updateDebugMeshes(): void;
  43353. /**
  43354. * Renders a specified physic impostor
  43355. * @param impostor defines the impostor to render
  43356. * @param targetMesh defines the mesh represented by the impostor
  43357. * @returns the new debug mesh used to render the impostor
  43358. */
  43359. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43360. /**
  43361. * Hides a specified physic impostor
  43362. * @param impostor defines the impostor to hide
  43363. */
  43364. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43365. private _getDebugMaterial;
  43366. private _getDebugBoxMesh;
  43367. private _getDebugSphereMesh;
  43368. private _getDebugCylinderMesh;
  43369. private _getDebugMeshMesh;
  43370. private _getDebugMesh;
  43371. /** Releases all resources */
  43372. dispose(): void;
  43373. }
  43374. }
  43375. declare module BABYLON {
  43376. /**
  43377. * Class containing static functions to help procedurally build meshes
  43378. */
  43379. export class LinesBuilder {
  43380. /**
  43381. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43382. * * 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
  43383. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43384. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43385. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43386. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43387. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43388. * * 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
  43389. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43392. * @param name defines the name of the new line system
  43393. * @param options defines the options used to create the line system
  43394. * @param scene defines the hosting scene
  43395. * @returns a new line system mesh
  43396. */
  43397. static CreateLineSystem(name: string, options: {
  43398. lines: Vector3[][];
  43399. updatable?: boolean;
  43400. instance?: Nullable<LinesMesh>;
  43401. colors?: Nullable<Color4[][]>;
  43402. useVertexAlpha?: boolean;
  43403. }, scene: Nullable<Scene>): LinesMesh;
  43404. /**
  43405. * Creates a line mesh
  43406. * 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
  43407. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43408. * * The parameter `points` is an array successive Vector3
  43409. * * 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
  43410. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43411. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43412. * * When updating an instance, remember that only point positions can change, not the number of points
  43413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43414. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43415. * @param name defines the name of the new line system
  43416. * @param options defines the options used to create the line system
  43417. * @param scene defines the hosting scene
  43418. * @returns a new line mesh
  43419. */
  43420. static CreateLines(name: string, options: {
  43421. points: Vector3[];
  43422. updatable?: boolean;
  43423. instance?: Nullable<LinesMesh>;
  43424. colors?: Color4[];
  43425. useVertexAlpha?: boolean;
  43426. }, scene?: Nullable<Scene>): LinesMesh;
  43427. /**
  43428. * Creates a dashed line mesh
  43429. * * 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
  43430. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43431. * * The parameter `points` is an array successive Vector3
  43432. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43433. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43434. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43435. * * 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
  43436. * * When updating an instance, remember that only point positions can change, not the number of points
  43437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43438. * @param name defines the name of the mesh
  43439. * @param options defines the options used to create the mesh
  43440. * @param scene defines the hosting scene
  43441. * @returns the dashed line mesh
  43442. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43443. */
  43444. static CreateDashedLines(name: string, options: {
  43445. points: Vector3[];
  43446. dashSize?: number;
  43447. gapSize?: number;
  43448. dashNb?: number;
  43449. updatable?: boolean;
  43450. instance?: LinesMesh;
  43451. }, scene?: Nullable<Scene>): LinesMesh;
  43452. }
  43453. }
  43454. declare module BABYLON {
  43455. /**
  43456. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43457. * in order to better appreciate the issue one might have.
  43458. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43459. */
  43460. export class RayHelper {
  43461. /**
  43462. * Defines the ray we are currently tryin to visualize.
  43463. */
  43464. ray: Nullable<Ray>;
  43465. private _renderPoints;
  43466. private _renderLine;
  43467. private _renderFunction;
  43468. private _scene;
  43469. private _updateToMeshFunction;
  43470. private _attachedToMesh;
  43471. private _meshSpaceDirection;
  43472. private _meshSpaceOrigin;
  43473. /**
  43474. * Helper function to create a colored helper in a scene in one line.
  43475. * @param ray Defines the ray we are currently tryin to visualize
  43476. * @param scene Defines the scene the ray is used in
  43477. * @param color Defines the color we want to see the ray in
  43478. * @returns The newly created ray helper.
  43479. */
  43480. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43481. /**
  43482. * Instantiate a new ray helper.
  43483. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43484. * in order to better appreciate the issue one might have.
  43485. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43486. * @param ray Defines the ray we are currently tryin to visualize
  43487. */
  43488. constructor(ray: Ray);
  43489. /**
  43490. * Shows the ray we are willing to debug.
  43491. * @param scene Defines the scene the ray needs to be rendered in
  43492. * @param color Defines the color the ray needs to be rendered in
  43493. */
  43494. show(scene: Scene, color?: Color3): void;
  43495. /**
  43496. * Hides the ray we are debugging.
  43497. */
  43498. hide(): void;
  43499. private _render;
  43500. /**
  43501. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43502. * @param mesh Defines the mesh we want the helper attached to
  43503. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43504. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43505. * @param length Defines the length of the ray
  43506. */
  43507. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43508. /**
  43509. * Detach the ray helper from the mesh it has previously been attached to.
  43510. */
  43511. detachFromMesh(): void;
  43512. private _updateToMesh;
  43513. /**
  43514. * Dispose the helper and release its associated resources.
  43515. */
  43516. dispose(): void;
  43517. }
  43518. }
  43519. declare module BABYLON.Debug {
  43520. /**
  43521. * Class used to render a debug view of a given skeleton
  43522. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43523. */
  43524. export class SkeletonViewer {
  43525. /** defines the skeleton to render */
  43526. skeleton: Skeleton;
  43527. /** defines the mesh attached to the skeleton */
  43528. mesh: AbstractMesh;
  43529. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43530. autoUpdateBonesMatrices: boolean;
  43531. /** defines the rendering group id to use with the viewer */
  43532. renderingGroupId: number;
  43533. /** Gets or sets the color used to render the skeleton */
  43534. color: Color3;
  43535. private _scene;
  43536. private _debugLines;
  43537. private _debugMesh;
  43538. private _isEnabled;
  43539. private _renderFunction;
  43540. private _utilityLayer;
  43541. /**
  43542. * Returns the mesh used to render the bones
  43543. */
  43544. readonly debugMesh: Nullable<LinesMesh>;
  43545. /**
  43546. * Creates a new SkeletonViewer
  43547. * @param skeleton defines the skeleton to render
  43548. * @param mesh defines the mesh attached to the skeleton
  43549. * @param scene defines the hosting scene
  43550. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43551. * @param renderingGroupId defines the rendering group id to use with the viewer
  43552. */
  43553. constructor(
  43554. /** defines the skeleton to render */
  43555. skeleton: Skeleton,
  43556. /** defines the mesh attached to the skeleton */
  43557. mesh: AbstractMesh, scene: Scene,
  43558. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43559. autoUpdateBonesMatrices?: boolean,
  43560. /** defines the rendering group id to use with the viewer */
  43561. renderingGroupId?: number);
  43562. /** Gets or sets a boolean indicating if the viewer is enabled */
  43563. isEnabled: boolean;
  43564. private _getBonePosition;
  43565. private _getLinesForBonesWithLength;
  43566. private _getLinesForBonesNoLength;
  43567. /** Update the viewer to sync with current skeleton state */
  43568. update(): void;
  43569. /** Release associated resources */
  43570. dispose(): void;
  43571. }
  43572. }
  43573. declare module BABYLON {
  43574. /**
  43575. * Options to create the null engine
  43576. */
  43577. export class NullEngineOptions {
  43578. /**
  43579. * Render width (Default: 512)
  43580. */
  43581. renderWidth: number;
  43582. /**
  43583. * Render height (Default: 256)
  43584. */
  43585. renderHeight: number;
  43586. /**
  43587. * Texture size (Default: 512)
  43588. */
  43589. textureSize: number;
  43590. /**
  43591. * If delta time between frames should be constant
  43592. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43593. */
  43594. deterministicLockstep: boolean;
  43595. /**
  43596. * Maximum about of steps between frames (Default: 4)
  43597. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43598. */
  43599. lockstepMaxSteps: number;
  43600. }
  43601. /**
  43602. * The null engine class provides support for headless version of babylon.js.
  43603. * This can be used in server side scenario or for testing purposes
  43604. */
  43605. export class NullEngine extends Engine {
  43606. private _options;
  43607. /**
  43608. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43609. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43610. * @returns true if engine is in deterministic lock step mode
  43611. */
  43612. isDeterministicLockStep(): boolean;
  43613. /**
  43614. * Gets the max steps when engine is running in deterministic lock step
  43615. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43616. * @returns the max steps
  43617. */
  43618. getLockstepMaxSteps(): number;
  43619. /**
  43620. * Gets the current hardware scaling level.
  43621. * By default the hardware scaling level is computed from the window device ratio.
  43622. * 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.
  43623. * @returns a number indicating the current hardware scaling level
  43624. */
  43625. getHardwareScalingLevel(): number;
  43626. constructor(options?: NullEngineOptions);
  43627. /**
  43628. * Creates a vertex buffer
  43629. * @param vertices the data for the vertex buffer
  43630. * @returns the new WebGL static buffer
  43631. */
  43632. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43633. /**
  43634. * Creates a new index buffer
  43635. * @param indices defines the content of the index buffer
  43636. * @param updatable defines if the index buffer must be updatable
  43637. * @returns a new webGL buffer
  43638. */
  43639. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43640. /**
  43641. * Clear the current render buffer or the current render target (if any is set up)
  43642. * @param color defines the color to use
  43643. * @param backBuffer defines if the back buffer must be cleared
  43644. * @param depth defines if the depth buffer must be cleared
  43645. * @param stencil defines if the stencil buffer must be cleared
  43646. */
  43647. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43648. /**
  43649. * Gets the current render width
  43650. * @param useScreen defines if screen size must be used (or the current render target if any)
  43651. * @returns a number defining the current render width
  43652. */
  43653. getRenderWidth(useScreen?: boolean): number;
  43654. /**
  43655. * Gets the current render height
  43656. * @param useScreen defines if screen size must be used (or the current render target if any)
  43657. * @returns a number defining the current render height
  43658. */
  43659. getRenderHeight(useScreen?: boolean): number;
  43660. /**
  43661. * Set the WebGL's viewport
  43662. * @param viewport defines the viewport element to be used
  43663. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43664. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43665. */
  43666. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43667. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43668. /**
  43669. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43670. * @param pipelineContext defines the pipeline context to use
  43671. * @param uniformsNames defines the list of uniform names
  43672. * @returns an array of webGL uniform locations
  43673. */
  43674. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43675. /**
  43676. * Gets the lsit of active attributes for a given webGL program
  43677. * @param pipelineContext defines the pipeline context to use
  43678. * @param attributesNames defines the list of attribute names to get
  43679. * @returns an array of indices indicating the offset of each attribute
  43680. */
  43681. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43682. /**
  43683. * Binds an effect to the webGL context
  43684. * @param effect defines the effect to bind
  43685. */
  43686. bindSamplers(effect: Effect): void;
  43687. /**
  43688. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43689. * @param effect defines the effect to activate
  43690. */
  43691. enableEffect(effect: Effect): void;
  43692. /**
  43693. * Set various states to the webGL context
  43694. * @param culling defines backface culling state
  43695. * @param zOffset defines the value to apply to zOffset (0 by default)
  43696. * @param force defines if states must be applied even if cache is up to date
  43697. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43698. */
  43699. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43700. /**
  43701. * Set the value of an uniform to an array of int32
  43702. * @param uniform defines the webGL uniform location where to store the value
  43703. * @param array defines the array of int32 to store
  43704. */
  43705. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43706. /**
  43707. * Set the value of an uniform to an array of int32 (stored as vec2)
  43708. * @param uniform defines the webGL uniform location where to store the value
  43709. * @param array defines the array of int32 to store
  43710. */
  43711. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43712. /**
  43713. * Set the value of an uniform to an array of int32 (stored as vec3)
  43714. * @param uniform defines the webGL uniform location where to store the value
  43715. * @param array defines the array of int32 to store
  43716. */
  43717. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43718. /**
  43719. * Set the value of an uniform to an array of int32 (stored as vec4)
  43720. * @param uniform defines the webGL uniform location where to store the value
  43721. * @param array defines the array of int32 to store
  43722. */
  43723. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43724. /**
  43725. * Set the value of an uniform to an array of float32
  43726. * @param uniform defines the webGL uniform location where to store the value
  43727. * @param array defines the array of float32 to store
  43728. */
  43729. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43730. /**
  43731. * Set the value of an uniform to an array of float32 (stored as vec2)
  43732. * @param uniform defines the webGL uniform location where to store the value
  43733. * @param array defines the array of float32 to store
  43734. */
  43735. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43736. /**
  43737. * Set the value of an uniform to an array of float32 (stored as vec3)
  43738. * @param uniform defines the webGL uniform location where to store the value
  43739. * @param array defines the array of float32 to store
  43740. */
  43741. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43742. /**
  43743. * Set the value of an uniform to an array of float32 (stored as vec4)
  43744. * @param uniform defines the webGL uniform location where to store the value
  43745. * @param array defines the array of float32 to store
  43746. */
  43747. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43748. /**
  43749. * Set the value of an uniform to an array of number
  43750. * @param uniform defines the webGL uniform location where to store the value
  43751. * @param array defines the array of number to store
  43752. */
  43753. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43754. /**
  43755. * Set the value of an uniform to an array of number (stored as vec2)
  43756. * @param uniform defines the webGL uniform location where to store the value
  43757. * @param array defines the array of number to store
  43758. */
  43759. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43760. /**
  43761. * Set the value of an uniform to an array of number (stored as vec3)
  43762. * @param uniform defines the webGL uniform location where to store the value
  43763. * @param array defines the array of number to store
  43764. */
  43765. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43766. /**
  43767. * Set the value of an uniform to an array of number (stored as vec4)
  43768. * @param uniform defines the webGL uniform location where to store the value
  43769. * @param array defines the array of number to store
  43770. */
  43771. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43772. /**
  43773. * Set the value of an uniform to an array of float32 (stored as matrices)
  43774. * @param uniform defines the webGL uniform location where to store the value
  43775. * @param matrices defines the array of float32 to store
  43776. */
  43777. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43778. /**
  43779. * Set the value of an uniform to a matrix (3x3)
  43780. * @param uniform defines the webGL uniform location where to store the value
  43781. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43782. */
  43783. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43784. /**
  43785. * Set the value of an uniform to a matrix (2x2)
  43786. * @param uniform defines the webGL uniform location where to store the value
  43787. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43788. */
  43789. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43790. /**
  43791. * Set the value of an uniform to a number (float)
  43792. * @param uniform defines the webGL uniform location where to store the value
  43793. * @param value defines the float number to store
  43794. */
  43795. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43796. /**
  43797. * Set the value of an uniform to a vec2
  43798. * @param uniform defines the webGL uniform location where to store the value
  43799. * @param x defines the 1st component of the value
  43800. * @param y defines the 2nd component of the value
  43801. */
  43802. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43803. /**
  43804. * Set the value of an uniform to a vec3
  43805. * @param uniform defines the webGL uniform location where to store the value
  43806. * @param x defines the 1st component of the value
  43807. * @param y defines the 2nd component of the value
  43808. * @param z defines the 3rd component of the value
  43809. */
  43810. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43811. /**
  43812. * Set the value of an uniform to a boolean
  43813. * @param uniform defines the webGL uniform location where to store the value
  43814. * @param bool defines the boolean to store
  43815. */
  43816. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43817. /**
  43818. * Set the value of an uniform to a vec4
  43819. * @param uniform defines the webGL uniform location where to store the value
  43820. * @param x defines the 1st component of the value
  43821. * @param y defines the 2nd component of the value
  43822. * @param z defines the 3rd component of the value
  43823. * @param w defines the 4th component of the value
  43824. */
  43825. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43826. /**
  43827. * Sets the current alpha mode
  43828. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43829. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43830. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43831. */
  43832. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43833. /**
  43834. * Bind webGl buffers directly to the webGL context
  43835. * @param vertexBuffers defines the vertex buffer to bind
  43836. * @param indexBuffer defines the index buffer to bind
  43837. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43838. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43839. * @param effect defines the effect associated with the vertex buffer
  43840. */
  43841. bindBuffers(vertexBuffers: {
  43842. [key: string]: VertexBuffer;
  43843. }, indexBuffer: DataBuffer, effect: Effect): void;
  43844. /**
  43845. * Force the entire cache to be cleared
  43846. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43847. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43848. */
  43849. wipeCaches(bruteForce?: boolean): void;
  43850. /**
  43851. * Send a draw order
  43852. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43853. * @param indexStart defines the starting index
  43854. * @param indexCount defines the number of index to draw
  43855. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43856. */
  43857. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43858. /**
  43859. * Draw a list of indexed primitives
  43860. * @param fillMode defines the primitive to use
  43861. * @param indexStart defines the starting index
  43862. * @param indexCount defines the number of index to draw
  43863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43864. */
  43865. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43866. /**
  43867. * Draw a list of unindexed primitives
  43868. * @param fillMode defines the primitive to use
  43869. * @param verticesStart defines the index of first vertex to draw
  43870. * @param verticesCount defines the count of vertices to draw
  43871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43872. */
  43873. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43874. /** @hidden */
  43875. _createTexture(): WebGLTexture;
  43876. /** @hidden */
  43877. _releaseTexture(texture: InternalTexture): void;
  43878. /**
  43879. * Usually called from Texture.ts.
  43880. * Passed information to create a WebGLTexture
  43881. * @param urlArg defines a value which contains one of the following:
  43882. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43883. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43884. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43885. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43886. * @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)
  43887. * @param scene needed for loading to the correct scene
  43888. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43889. * @param onLoad optional callback to be called upon successful completion
  43890. * @param onError optional callback to be called upon failure
  43891. * @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
  43892. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43893. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43894. * @param forcedExtension defines the extension to use to pick the right loader
  43895. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43896. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43897. */
  43898. 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;
  43899. /**
  43900. * Creates a new render target texture
  43901. * @param size defines the size of the texture
  43902. * @param options defines the options used to create the texture
  43903. * @returns a new render target texture stored in an InternalTexture
  43904. */
  43905. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43906. /**
  43907. * Update the sampling mode of a given texture
  43908. * @param samplingMode defines the required sampling mode
  43909. * @param texture defines the texture to update
  43910. */
  43911. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43912. /**
  43913. * Binds the frame buffer to the specified texture.
  43914. * @param texture The texture to render to or null for the default canvas
  43915. * @param faceIndex The face of the texture to render to in case of cube texture
  43916. * @param requiredWidth The width of the target to render to
  43917. * @param requiredHeight The height of the target to render to
  43918. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43919. * @param depthStencilTexture The depth stencil texture to use to render
  43920. * @param lodLevel defines le lod level to bind to the frame buffer
  43921. */
  43922. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43923. /**
  43924. * Unbind the current render target texture from the webGL context
  43925. * @param texture defines the render target texture to unbind
  43926. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43927. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43928. */
  43929. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43930. /**
  43931. * Creates a dynamic vertex buffer
  43932. * @param vertices the data for the dynamic vertex buffer
  43933. * @returns the new WebGL dynamic buffer
  43934. */
  43935. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43936. /**
  43937. * Update the content of a dynamic texture
  43938. * @param texture defines the texture to update
  43939. * @param canvas defines the canvas containing the source
  43940. * @param invertY defines if data must be stored with Y axis inverted
  43941. * @param premulAlpha defines if alpha is stored as premultiplied
  43942. * @param format defines the format of the data
  43943. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43944. */
  43945. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43946. /**
  43947. * Gets a boolean indicating if all created effects are ready
  43948. * @returns true if all effects are ready
  43949. */
  43950. areAllEffectsReady(): boolean;
  43951. /**
  43952. * @hidden
  43953. * Get the current error code of the webGL context
  43954. * @returns the error code
  43955. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43956. */
  43957. getError(): number;
  43958. /** @hidden */
  43959. _getUnpackAlignement(): number;
  43960. /** @hidden */
  43961. _unpackFlipY(value: boolean): void;
  43962. /**
  43963. * Update a dynamic index buffer
  43964. * @param indexBuffer defines the target index buffer
  43965. * @param indices defines the data to update
  43966. * @param offset defines the offset in the target index buffer where update should start
  43967. */
  43968. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43969. /**
  43970. * Updates a dynamic vertex buffer.
  43971. * @param vertexBuffer the vertex buffer to update
  43972. * @param vertices the data used to update the vertex buffer
  43973. * @param byteOffset the byte offset of the data (optional)
  43974. * @param byteLength the byte length of the data (optional)
  43975. */
  43976. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43977. /** @hidden */
  43978. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43979. /** @hidden */
  43980. _bindTexture(channel: number, texture: InternalTexture): void;
  43981. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43982. /**
  43983. * 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
  43984. */
  43985. releaseEffects(): void;
  43986. displayLoadingUI(): void;
  43987. hideLoadingUI(): void;
  43988. /** @hidden */
  43989. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43990. /** @hidden */
  43991. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43992. /** @hidden */
  43993. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43994. /** @hidden */
  43995. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43996. }
  43997. }
  43998. declare module BABYLON {
  43999. /** @hidden */
  44000. export class _OcclusionDataStorage {
  44001. /** @hidden */
  44002. occlusionInternalRetryCounter: number;
  44003. /** @hidden */
  44004. isOcclusionQueryInProgress: boolean;
  44005. /** @hidden */
  44006. isOccluded: boolean;
  44007. /** @hidden */
  44008. occlusionRetryCount: number;
  44009. /** @hidden */
  44010. occlusionType: number;
  44011. /** @hidden */
  44012. occlusionQueryAlgorithmType: number;
  44013. }
  44014. interface Engine {
  44015. /**
  44016. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44017. * @return the new query
  44018. */
  44019. createQuery(): WebGLQuery;
  44020. /**
  44021. * Delete and release a webGL query
  44022. * @param query defines the query to delete
  44023. * @return the current engine
  44024. */
  44025. deleteQuery(query: WebGLQuery): Engine;
  44026. /**
  44027. * Check if a given query has resolved and got its value
  44028. * @param query defines the query to check
  44029. * @returns true if the query got its value
  44030. */
  44031. isQueryResultAvailable(query: WebGLQuery): boolean;
  44032. /**
  44033. * Gets the value of a given query
  44034. * @param query defines the query to check
  44035. * @returns the value of the query
  44036. */
  44037. getQueryResult(query: WebGLQuery): number;
  44038. /**
  44039. * Initiates an occlusion query
  44040. * @param algorithmType defines the algorithm to use
  44041. * @param query defines the query to use
  44042. * @returns the current engine
  44043. * @see http://doc.babylonjs.com/features/occlusionquery
  44044. */
  44045. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44046. /**
  44047. * Ends an occlusion query
  44048. * @see http://doc.babylonjs.com/features/occlusionquery
  44049. * @param algorithmType defines the algorithm to use
  44050. * @returns the current engine
  44051. */
  44052. endOcclusionQuery(algorithmType: number): Engine;
  44053. /**
  44054. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44055. * Please note that only one query can be issued at a time
  44056. * @returns a time token used to track the time span
  44057. */
  44058. startTimeQuery(): Nullable<_TimeToken>;
  44059. /**
  44060. * Ends a time query
  44061. * @param token defines the token used to measure the time span
  44062. * @returns the time spent (in ns)
  44063. */
  44064. endTimeQuery(token: _TimeToken): int;
  44065. /** @hidden */
  44066. _currentNonTimestampToken: Nullable<_TimeToken>;
  44067. /** @hidden */
  44068. _createTimeQuery(): WebGLQuery;
  44069. /** @hidden */
  44070. _deleteTimeQuery(query: WebGLQuery): void;
  44071. /** @hidden */
  44072. _getGlAlgorithmType(algorithmType: number): number;
  44073. /** @hidden */
  44074. _getTimeQueryResult(query: WebGLQuery): any;
  44075. /** @hidden */
  44076. _getTimeQueryAvailability(query: WebGLQuery): any;
  44077. }
  44078. interface AbstractMesh {
  44079. /**
  44080. * Backing filed
  44081. * @hidden
  44082. */
  44083. __occlusionDataStorage: _OcclusionDataStorage;
  44084. /**
  44085. * Access property
  44086. * @hidden
  44087. */
  44088. _occlusionDataStorage: _OcclusionDataStorage;
  44089. /**
  44090. * 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.
  44091. * The default value is -1 which means don't break the query and wait till the result
  44092. * @see http://doc.babylonjs.com/features/occlusionquery
  44093. */
  44094. occlusionRetryCount: number;
  44095. /**
  44096. * 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:
  44097. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44098. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44099. * * 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.
  44100. * @see http://doc.babylonjs.com/features/occlusionquery
  44101. */
  44102. occlusionType: number;
  44103. /**
  44104. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44105. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44106. * * 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.
  44107. * @see http://doc.babylonjs.com/features/occlusionquery
  44108. */
  44109. occlusionQueryAlgorithmType: number;
  44110. /**
  44111. * 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
  44112. * @see http://doc.babylonjs.com/features/occlusionquery
  44113. */
  44114. isOccluded: boolean;
  44115. /**
  44116. * Flag to check the progress status of the query
  44117. * @see http://doc.babylonjs.com/features/occlusionquery
  44118. */
  44119. isOcclusionQueryInProgress: boolean;
  44120. }
  44121. }
  44122. declare module BABYLON {
  44123. /** @hidden */
  44124. export var _forceTransformFeedbackToBundle: boolean;
  44125. interface Engine {
  44126. /**
  44127. * Creates a webGL transform feedback object
  44128. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44129. * @returns the webGL transform feedback object
  44130. */
  44131. createTransformFeedback(): WebGLTransformFeedback;
  44132. /**
  44133. * Delete a webGL transform feedback object
  44134. * @param value defines the webGL transform feedback object to delete
  44135. */
  44136. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44137. /**
  44138. * Bind a webGL transform feedback object to the webgl context
  44139. * @param value defines the webGL transform feedback object to bind
  44140. */
  44141. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44142. /**
  44143. * Begins a transform feedback operation
  44144. * @param usePoints defines if points or triangles must be used
  44145. */
  44146. beginTransformFeedback(usePoints: boolean): void;
  44147. /**
  44148. * Ends a transform feedback operation
  44149. */
  44150. endTransformFeedback(): void;
  44151. /**
  44152. * Specify the varyings to use with transform feedback
  44153. * @param program defines the associated webGL program
  44154. * @param value defines the list of strings representing the varying names
  44155. */
  44156. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44157. /**
  44158. * Bind a webGL buffer for a transform feedback operation
  44159. * @param value defines the webGL buffer to bind
  44160. */
  44161. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44162. }
  44163. }
  44164. declare module BABYLON {
  44165. /**
  44166. * Creation options of the multi render target texture.
  44167. */
  44168. export interface IMultiRenderTargetOptions {
  44169. /**
  44170. * Define if the texture needs to create mip maps after render.
  44171. */
  44172. generateMipMaps?: boolean;
  44173. /**
  44174. * Define the types of all the draw buffers we want to create
  44175. */
  44176. types?: number[];
  44177. /**
  44178. * Define the sampling modes of all the draw buffers we want to create
  44179. */
  44180. samplingModes?: number[];
  44181. /**
  44182. * Define if a depth buffer is required
  44183. */
  44184. generateDepthBuffer?: boolean;
  44185. /**
  44186. * Define if a stencil buffer is required
  44187. */
  44188. generateStencilBuffer?: boolean;
  44189. /**
  44190. * Define if a depth texture is required instead of a depth buffer
  44191. */
  44192. generateDepthTexture?: boolean;
  44193. /**
  44194. * Define the number of desired draw buffers
  44195. */
  44196. textureCount?: number;
  44197. /**
  44198. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44199. */
  44200. doNotChangeAspectRatio?: boolean;
  44201. /**
  44202. * Define the default type of the buffers we are creating
  44203. */
  44204. defaultType?: number;
  44205. }
  44206. /**
  44207. * A multi render target, like a render target provides the ability to render to a texture.
  44208. * Unlike the render target, it can render to several draw buffers in one draw.
  44209. * This is specially interesting in deferred rendering or for any effects requiring more than
  44210. * just one color from a single pass.
  44211. */
  44212. export class MultiRenderTarget extends RenderTargetTexture {
  44213. private _internalTextures;
  44214. private _textures;
  44215. private _multiRenderTargetOptions;
  44216. /**
  44217. * Get if draw buffers are currently supported by the used hardware and browser.
  44218. */
  44219. readonly isSupported: boolean;
  44220. /**
  44221. * Get the list of textures generated by the multi render target.
  44222. */
  44223. readonly textures: Texture[];
  44224. /**
  44225. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44226. */
  44227. readonly depthTexture: Texture;
  44228. /**
  44229. * Set the wrapping mode on U of all the textures we are rendering to.
  44230. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44231. */
  44232. wrapU: number;
  44233. /**
  44234. * Set the wrapping mode on V of all the textures we are rendering to.
  44235. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44236. */
  44237. wrapV: number;
  44238. /**
  44239. * Instantiate a new multi render target texture.
  44240. * A multi render target, like a render target provides the ability to render to a texture.
  44241. * Unlike the render target, it can render to several draw buffers in one draw.
  44242. * This is specially interesting in deferred rendering or for any effects requiring more than
  44243. * just one color from a single pass.
  44244. * @param name Define the name of the texture
  44245. * @param size Define the size of the buffers to render to
  44246. * @param count Define the number of target we are rendering into
  44247. * @param scene Define the scene the texture belongs to
  44248. * @param options Define the options used to create the multi render target
  44249. */
  44250. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44251. /** @hidden */
  44252. _rebuild(): void;
  44253. private _createInternalTextures;
  44254. private _createTextures;
  44255. /**
  44256. * Define the number of samples used if MSAA is enabled.
  44257. */
  44258. samples: number;
  44259. /**
  44260. * Resize all the textures in the multi render target.
  44261. * Be carrefull as it will recreate all the data in the new texture.
  44262. * @param size Define the new size
  44263. */
  44264. resize(size: any): void;
  44265. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44266. /**
  44267. * Dispose the render targets and their associated resources
  44268. */
  44269. dispose(): void;
  44270. /**
  44271. * Release all the underlying texture used as draw buffers.
  44272. */
  44273. releaseInternalTextures(): void;
  44274. }
  44275. }
  44276. declare module BABYLON {
  44277. interface ThinEngine {
  44278. /**
  44279. * Unbind a list of render target textures from the webGL context
  44280. * This is used only when drawBuffer extension or webGL2 are active
  44281. * @param textures defines the render target textures to unbind
  44282. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44283. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44284. */
  44285. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44286. /**
  44287. * Create a multi render target texture
  44288. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44289. * @param size defines the size of the texture
  44290. * @param options defines the creation options
  44291. * @returns the cube texture as an InternalTexture
  44292. */
  44293. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44294. /**
  44295. * Update the sample count for a given multiple render target texture
  44296. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44297. * @param textures defines the textures to update
  44298. * @param samples defines the sample count to set
  44299. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44300. */
  44301. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44302. }
  44303. }
  44304. declare module BABYLON {
  44305. /**
  44306. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44307. */
  44308. export interface CubeMapInfo {
  44309. /**
  44310. * The pixel array for the front face.
  44311. * This is stored in format, left to right, up to down format.
  44312. */
  44313. front: Nullable<ArrayBufferView>;
  44314. /**
  44315. * The pixel array for the back face.
  44316. * This is stored in format, left to right, up to down format.
  44317. */
  44318. back: Nullable<ArrayBufferView>;
  44319. /**
  44320. * The pixel array for the left face.
  44321. * This is stored in format, left to right, up to down format.
  44322. */
  44323. left: Nullable<ArrayBufferView>;
  44324. /**
  44325. * The pixel array for the right face.
  44326. * This is stored in format, left to right, up to down format.
  44327. */
  44328. right: Nullable<ArrayBufferView>;
  44329. /**
  44330. * The pixel array for the up face.
  44331. * This is stored in format, left to right, up to down format.
  44332. */
  44333. up: Nullable<ArrayBufferView>;
  44334. /**
  44335. * The pixel array for the down face.
  44336. * This is stored in format, left to right, up to down format.
  44337. */
  44338. down: Nullable<ArrayBufferView>;
  44339. /**
  44340. * The size of the cubemap stored.
  44341. *
  44342. * Each faces will be size * size pixels.
  44343. */
  44344. size: number;
  44345. /**
  44346. * The format of the texture.
  44347. *
  44348. * RGBA, RGB.
  44349. */
  44350. format: number;
  44351. /**
  44352. * The type of the texture data.
  44353. *
  44354. * UNSIGNED_INT, FLOAT.
  44355. */
  44356. type: number;
  44357. /**
  44358. * Specifies whether the texture is in gamma space.
  44359. */
  44360. gammaSpace: boolean;
  44361. }
  44362. /**
  44363. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44364. */
  44365. export class PanoramaToCubeMapTools {
  44366. private static FACE_FRONT;
  44367. private static FACE_BACK;
  44368. private static FACE_RIGHT;
  44369. private static FACE_LEFT;
  44370. private static FACE_DOWN;
  44371. private static FACE_UP;
  44372. /**
  44373. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44374. *
  44375. * @param float32Array The source data.
  44376. * @param inputWidth The width of the input panorama.
  44377. * @param inputHeight The height of the input panorama.
  44378. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44379. * @return The cubemap data
  44380. */
  44381. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44382. private static CreateCubemapTexture;
  44383. private static CalcProjectionSpherical;
  44384. }
  44385. }
  44386. declare module BABYLON {
  44387. /**
  44388. * Helper class dealing with the extraction of spherical polynomial dataArray
  44389. * from a cube map.
  44390. */
  44391. export class CubeMapToSphericalPolynomialTools {
  44392. private static FileFaces;
  44393. /**
  44394. * Converts a texture to the according Spherical Polynomial data.
  44395. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44396. *
  44397. * @param texture The texture to extract the information from.
  44398. * @return The Spherical Polynomial data.
  44399. */
  44400. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44401. /**
  44402. * Converts a cubemap to the according Spherical Polynomial data.
  44403. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44404. *
  44405. * @param cubeInfo The Cube map to extract the information from.
  44406. * @return The Spherical Polynomial data.
  44407. */
  44408. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44409. }
  44410. }
  44411. declare module BABYLON {
  44412. interface BaseTexture {
  44413. /**
  44414. * Get the polynomial representation of the texture data.
  44415. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44416. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44417. */
  44418. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44419. }
  44420. }
  44421. declare module BABYLON {
  44422. /** @hidden */
  44423. export var rgbdEncodePixelShader: {
  44424. name: string;
  44425. shader: string;
  44426. };
  44427. }
  44428. declare module BABYLON {
  44429. /** @hidden */
  44430. export var rgbdDecodePixelShader: {
  44431. name: string;
  44432. shader: string;
  44433. };
  44434. }
  44435. declare module BABYLON {
  44436. /**
  44437. * Raw texture data and descriptor sufficient for WebGL texture upload
  44438. */
  44439. export interface EnvironmentTextureInfo {
  44440. /**
  44441. * Version of the environment map
  44442. */
  44443. version: number;
  44444. /**
  44445. * Width of image
  44446. */
  44447. width: number;
  44448. /**
  44449. * Irradiance information stored in the file.
  44450. */
  44451. irradiance: any;
  44452. /**
  44453. * Specular information stored in the file.
  44454. */
  44455. specular: any;
  44456. }
  44457. /**
  44458. * Defines One Image in the file. It requires only the position in the file
  44459. * as well as the length.
  44460. */
  44461. interface BufferImageData {
  44462. /**
  44463. * Length of the image data.
  44464. */
  44465. length: number;
  44466. /**
  44467. * Position of the data from the null terminator delimiting the end of the JSON.
  44468. */
  44469. position: number;
  44470. }
  44471. /**
  44472. * Defines the specular data enclosed in the file.
  44473. * This corresponds to the version 1 of the data.
  44474. */
  44475. export interface EnvironmentTextureSpecularInfoV1 {
  44476. /**
  44477. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44478. */
  44479. specularDataPosition?: number;
  44480. /**
  44481. * This contains all the images data needed to reconstruct the cubemap.
  44482. */
  44483. mipmaps: Array<BufferImageData>;
  44484. /**
  44485. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44486. */
  44487. lodGenerationScale: number;
  44488. }
  44489. /**
  44490. * Sets of helpers addressing the serialization and deserialization of environment texture
  44491. * stored in a BabylonJS env file.
  44492. * Those files are usually stored as .env files.
  44493. */
  44494. export class EnvironmentTextureTools {
  44495. /**
  44496. * Magic number identifying the env file.
  44497. */
  44498. private static _MagicBytes;
  44499. /**
  44500. * Gets the environment info from an env file.
  44501. * @param data The array buffer containing the .env bytes.
  44502. * @returns the environment file info (the json header) if successfully parsed.
  44503. */
  44504. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44505. /**
  44506. * Creates an environment texture from a loaded cube texture.
  44507. * @param texture defines the cube texture to convert in env file
  44508. * @return a promise containing the environment data if succesfull.
  44509. */
  44510. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44511. /**
  44512. * Creates a JSON representation of the spherical data.
  44513. * @param texture defines the texture containing the polynomials
  44514. * @return the JSON representation of the spherical info
  44515. */
  44516. private static _CreateEnvTextureIrradiance;
  44517. /**
  44518. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44519. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44520. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44521. * @return the views described by info providing access to the underlying buffer
  44522. */
  44523. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44524. /**
  44525. * Uploads the texture info contained in the env file to the GPU.
  44526. * @param texture defines the internal texture to upload to
  44527. * @param arrayBuffer defines the buffer cotaining the data to load
  44528. * @param info defines the texture info retrieved through the GetEnvInfo method
  44529. * @returns a promise
  44530. */
  44531. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44532. private static _OnImageReadyAsync;
  44533. /**
  44534. * Uploads the levels of image data to the GPU.
  44535. * @param texture defines the internal texture to upload to
  44536. * @param imageData defines the array buffer views of image data [mipmap][face]
  44537. * @returns a promise
  44538. */
  44539. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44540. /**
  44541. * Uploads spherical polynomials information to the texture.
  44542. * @param texture defines the texture we are trying to upload the information to
  44543. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44544. */
  44545. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44546. /** @hidden */
  44547. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44548. }
  44549. }
  44550. declare module BABYLON {
  44551. /**
  44552. * Contains position and normal vectors for a vertex
  44553. */
  44554. export class PositionNormalVertex {
  44555. /** the position of the vertex (defaut: 0,0,0) */
  44556. position: Vector3;
  44557. /** the normal of the vertex (defaut: 0,1,0) */
  44558. normal: Vector3;
  44559. /**
  44560. * Creates a PositionNormalVertex
  44561. * @param position the position of the vertex (defaut: 0,0,0)
  44562. * @param normal the normal of the vertex (defaut: 0,1,0)
  44563. */
  44564. constructor(
  44565. /** the position of the vertex (defaut: 0,0,0) */
  44566. position?: Vector3,
  44567. /** the normal of the vertex (defaut: 0,1,0) */
  44568. normal?: Vector3);
  44569. /**
  44570. * Clones the PositionNormalVertex
  44571. * @returns the cloned PositionNormalVertex
  44572. */
  44573. clone(): PositionNormalVertex;
  44574. }
  44575. /**
  44576. * Contains position, normal and uv vectors for a vertex
  44577. */
  44578. export class PositionNormalTextureVertex {
  44579. /** the position of the vertex (defaut: 0,0,0) */
  44580. position: Vector3;
  44581. /** the normal of the vertex (defaut: 0,1,0) */
  44582. normal: Vector3;
  44583. /** the uv of the vertex (default: 0,0) */
  44584. uv: Vector2;
  44585. /**
  44586. * Creates a PositionNormalTextureVertex
  44587. * @param position the position of the vertex (defaut: 0,0,0)
  44588. * @param normal the normal of the vertex (defaut: 0,1,0)
  44589. * @param uv the uv of the vertex (default: 0,0)
  44590. */
  44591. constructor(
  44592. /** the position of the vertex (defaut: 0,0,0) */
  44593. position?: Vector3,
  44594. /** the normal of the vertex (defaut: 0,1,0) */
  44595. normal?: Vector3,
  44596. /** the uv of the vertex (default: 0,0) */
  44597. uv?: Vector2);
  44598. /**
  44599. * Clones the PositionNormalTextureVertex
  44600. * @returns the cloned PositionNormalTextureVertex
  44601. */
  44602. clone(): PositionNormalTextureVertex;
  44603. }
  44604. }
  44605. declare module BABYLON {
  44606. /** @hidden */
  44607. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44608. private _genericAttributeLocation;
  44609. private _varyingLocationCount;
  44610. private _varyingLocationMap;
  44611. private _replacements;
  44612. private _textureCount;
  44613. private _uniforms;
  44614. lineProcessor(line: string): string;
  44615. attributeProcessor(attribute: string): string;
  44616. varyingProcessor(varying: string, isFragment: boolean): string;
  44617. uniformProcessor(uniform: string): string;
  44618. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44619. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44620. }
  44621. }
  44622. declare module BABYLON {
  44623. /**
  44624. * Container for accessors for natively-stored mesh data buffers.
  44625. */
  44626. class NativeDataBuffer extends DataBuffer {
  44627. /**
  44628. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44629. */
  44630. nativeIndexBuffer?: any;
  44631. /**
  44632. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44633. */
  44634. nativeVertexBuffer?: any;
  44635. }
  44636. /** @hidden */
  44637. export class NativeEngine extends Engine {
  44638. private readonly _native;
  44639. getHardwareScalingLevel(): number;
  44640. constructor();
  44641. /**
  44642. * Can be used to override the current requestAnimationFrame requester.
  44643. * @hidden
  44644. */
  44645. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44646. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44647. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44648. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44649. recordVertexArrayObject(vertexBuffers: {
  44650. [key: string]: VertexBuffer;
  44651. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44652. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44653. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44654. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44655. /**
  44656. * Draw a list of indexed primitives
  44657. * @param fillMode defines the primitive to use
  44658. * @param indexStart defines the starting index
  44659. * @param indexCount defines the number of index to draw
  44660. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44661. */
  44662. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44663. /**
  44664. * Draw a list of unindexed primitives
  44665. * @param fillMode defines the primitive to use
  44666. * @param verticesStart defines the index of first vertex to draw
  44667. * @param verticesCount defines the count of vertices to draw
  44668. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44669. */
  44670. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44671. createPipelineContext(): IPipelineContext;
  44672. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44673. /** @hidden */
  44674. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44675. /** @hidden */
  44676. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44677. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44678. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44679. protected _setProgram(program: WebGLProgram): void;
  44680. _releaseEffect(effect: Effect): void;
  44681. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44682. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44683. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44684. bindSamplers(effect: Effect): void;
  44685. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44686. getRenderWidth(useScreen?: boolean): number;
  44687. getRenderHeight(useScreen?: boolean): number;
  44688. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44689. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44690. /**
  44691. * Set the z offset to apply to current rendering
  44692. * @param value defines the offset to apply
  44693. */
  44694. setZOffset(value: number): void;
  44695. /**
  44696. * Gets the current value of the zOffset
  44697. * @returns the current zOffset state
  44698. */
  44699. getZOffset(): number;
  44700. /**
  44701. * Enable or disable depth buffering
  44702. * @param enable defines the state to set
  44703. */
  44704. setDepthBuffer(enable: boolean): void;
  44705. /**
  44706. * Gets a boolean indicating if depth writing is enabled
  44707. * @returns the current depth writing state
  44708. */
  44709. getDepthWrite(): boolean;
  44710. /**
  44711. * Enable or disable depth writing
  44712. * @param enable defines the state to set
  44713. */
  44714. setDepthWrite(enable: boolean): void;
  44715. /**
  44716. * Enable or disable color writing
  44717. * @param enable defines the state to set
  44718. */
  44719. setColorWrite(enable: boolean): void;
  44720. /**
  44721. * Gets a boolean indicating if color writing is enabled
  44722. * @returns the current color writing state
  44723. */
  44724. getColorWrite(): boolean;
  44725. /**
  44726. * Sets alpha constants used by some alpha blending modes
  44727. * @param r defines the red component
  44728. * @param g defines the green component
  44729. * @param b defines the blue component
  44730. * @param a defines the alpha component
  44731. */
  44732. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44733. /**
  44734. * Sets the current alpha mode
  44735. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44736. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44737. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44738. */
  44739. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44740. /**
  44741. * Gets the current alpha mode
  44742. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44743. * @returns the current alpha mode
  44744. */
  44745. getAlphaMode(): number;
  44746. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44747. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44748. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44749. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44750. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44751. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44752. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44753. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44754. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44755. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44756. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44757. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44758. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44759. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44760. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44761. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44762. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44763. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44764. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44765. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44766. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44767. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44768. wipeCaches(bruteForce?: boolean): void;
  44769. _createTexture(): WebGLTexture;
  44770. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44771. /**
  44772. * Usually called from BABYLON.Texture.ts.
  44773. * Passed information to create a WebGLTexture
  44774. * @param urlArg defines a value which contains one of the following:
  44775. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44776. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44777. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44778. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44779. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44780. * @param scene needed for loading to the correct scene
  44781. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44782. * @param onLoad optional callback to be called upon successful completion
  44783. * @param onError optional callback to be called upon failure
  44784. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44785. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44786. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44787. * @param forcedExtension defines the extension to use to pick the right loader
  44788. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44789. */
  44790. 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;
  44791. /**
  44792. * Creates a cube texture
  44793. * @param rootUrl defines the url where the files to load is located
  44794. * @param scene defines the current scene
  44795. * @param files defines the list of files to load (1 per face)
  44796. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44797. * @param onLoad defines an optional callback raised when the texture is loaded
  44798. * @param onError defines an optional callback raised if there is an issue to load the texture
  44799. * @param format defines the format of the data
  44800. * @param forcedExtension defines the extension to use to pick the right loader
  44801. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44802. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44803. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44804. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44805. * @returns the cube texture as an InternalTexture
  44806. */
  44807. 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;
  44808. private _getSamplingFilter;
  44809. private static _GetNativeTextureFormat;
  44810. createRenderTargetTexture(size: number | {
  44811. width: number;
  44812. height: number;
  44813. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44814. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44815. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44816. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44817. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44818. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44819. /**
  44820. * Updates a dynamic vertex buffer.
  44821. * @param vertexBuffer the vertex buffer to update
  44822. * @param data the data used to update the vertex buffer
  44823. * @param byteOffset the byte offset of the data (optional)
  44824. * @param byteLength the byte length of the data (optional)
  44825. */
  44826. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44827. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44828. private _updateAnisotropicLevel;
  44829. private _getAddressMode;
  44830. /** @hidden */
  44831. _bindTexture(channel: number, texture: InternalTexture): void;
  44832. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44833. releaseEffects(): void;
  44834. /** @hidden */
  44835. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44836. /** @hidden */
  44837. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44838. /** @hidden */
  44839. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44840. /** @hidden */
  44841. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44842. }
  44843. }
  44844. declare module BABYLON {
  44845. /**
  44846. * Gather the list of clipboard event types as constants.
  44847. */
  44848. export class ClipboardEventTypes {
  44849. /**
  44850. * The clipboard event is fired when a copy command is active (pressed).
  44851. */
  44852. static readonly COPY: number;
  44853. /**
  44854. * The clipboard event is fired when a cut command is active (pressed).
  44855. */
  44856. static readonly CUT: number;
  44857. /**
  44858. * The clipboard event is fired when a paste command is active (pressed).
  44859. */
  44860. static readonly PASTE: number;
  44861. }
  44862. /**
  44863. * This class is used to store clipboard related info for the onClipboardObservable event.
  44864. */
  44865. export class ClipboardInfo {
  44866. /**
  44867. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44868. */
  44869. type: number;
  44870. /**
  44871. * Defines the related dom event
  44872. */
  44873. event: ClipboardEvent;
  44874. /**
  44875. *Creates an instance of ClipboardInfo.
  44876. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44877. * @param event Defines the related dom event
  44878. */
  44879. constructor(
  44880. /**
  44881. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44882. */
  44883. type: number,
  44884. /**
  44885. * Defines the related dom event
  44886. */
  44887. event: ClipboardEvent);
  44888. /**
  44889. * Get the clipboard event's type from the keycode.
  44890. * @param keyCode Defines the keyCode for the current keyboard event.
  44891. * @return {number}
  44892. */
  44893. static GetTypeFromCharacter(keyCode: number): number;
  44894. }
  44895. }
  44896. declare module BABYLON {
  44897. /**
  44898. * Google Daydream controller
  44899. */
  44900. export class DaydreamController extends WebVRController {
  44901. /**
  44902. * Base Url for the controller model.
  44903. */
  44904. static MODEL_BASE_URL: string;
  44905. /**
  44906. * File name for the controller model.
  44907. */
  44908. static MODEL_FILENAME: string;
  44909. /**
  44910. * Gamepad Id prefix used to identify Daydream Controller.
  44911. */
  44912. static readonly GAMEPAD_ID_PREFIX: string;
  44913. /**
  44914. * Creates a new DaydreamController from a gamepad
  44915. * @param vrGamepad the gamepad that the controller should be created from
  44916. */
  44917. constructor(vrGamepad: any);
  44918. /**
  44919. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44920. * @param scene scene in which to add meshes
  44921. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44922. */
  44923. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44924. /**
  44925. * Called once for each button that changed state since the last frame
  44926. * @param buttonIdx Which button index changed
  44927. * @param state New state of the button
  44928. * @param changes Which properties on the state changed since last frame
  44929. */
  44930. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44931. }
  44932. }
  44933. declare module BABYLON {
  44934. /**
  44935. * Gear VR Controller
  44936. */
  44937. export class GearVRController extends WebVRController {
  44938. /**
  44939. * Base Url for the controller model.
  44940. */
  44941. static MODEL_BASE_URL: string;
  44942. /**
  44943. * File name for the controller model.
  44944. */
  44945. static MODEL_FILENAME: string;
  44946. /**
  44947. * Gamepad Id prefix used to identify this controller.
  44948. */
  44949. static readonly GAMEPAD_ID_PREFIX: string;
  44950. private readonly _buttonIndexToObservableNameMap;
  44951. /**
  44952. * Creates a new GearVRController from a gamepad
  44953. * @param vrGamepad the gamepad that the controller should be created from
  44954. */
  44955. constructor(vrGamepad: any);
  44956. /**
  44957. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44958. * @param scene scene in which to add meshes
  44959. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44960. */
  44961. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44962. /**
  44963. * Called once for each button that changed state since the last frame
  44964. * @param buttonIdx Which button index changed
  44965. * @param state New state of the button
  44966. * @param changes Which properties on the state changed since last frame
  44967. */
  44968. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44969. }
  44970. }
  44971. declare module BABYLON {
  44972. /**
  44973. * Class containing static functions to help procedurally build meshes
  44974. */
  44975. export class PolyhedronBuilder {
  44976. /**
  44977. * Creates a polyhedron mesh
  44978. * * 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
  44979. * * The parameter `size` (positive float, default 1) sets the polygon size
  44980. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44981. * * 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`
  44982. * * 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
  44983. * * 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)`)
  44984. * * 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
  44985. * * 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
  44986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44987. * * 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
  44988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44989. * @param name defines the name of the mesh
  44990. * @param options defines the options used to create the mesh
  44991. * @param scene defines the hosting scene
  44992. * @returns the polyhedron mesh
  44993. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44994. */
  44995. static CreatePolyhedron(name: string, options: {
  44996. type?: number;
  44997. size?: number;
  44998. sizeX?: number;
  44999. sizeY?: number;
  45000. sizeZ?: number;
  45001. custom?: any;
  45002. faceUV?: Vector4[];
  45003. faceColors?: Color4[];
  45004. flat?: boolean;
  45005. updatable?: boolean;
  45006. sideOrientation?: number;
  45007. frontUVs?: Vector4;
  45008. backUVs?: Vector4;
  45009. }, scene?: Nullable<Scene>): Mesh;
  45010. }
  45011. }
  45012. declare module BABYLON {
  45013. /**
  45014. * Gizmo that enables scaling a mesh along 3 axis
  45015. */
  45016. export class ScaleGizmo extends Gizmo {
  45017. /**
  45018. * Internal gizmo used for interactions on the x axis
  45019. */
  45020. xGizmo: AxisScaleGizmo;
  45021. /**
  45022. * Internal gizmo used for interactions on the y axis
  45023. */
  45024. yGizmo: AxisScaleGizmo;
  45025. /**
  45026. * Internal gizmo used for interactions on the z axis
  45027. */
  45028. zGizmo: AxisScaleGizmo;
  45029. /**
  45030. * Internal gizmo used to scale all axis equally
  45031. */
  45032. uniformScaleGizmo: AxisScaleGizmo;
  45033. private _meshAttached;
  45034. private _updateGizmoRotationToMatchAttachedMesh;
  45035. private _snapDistance;
  45036. private _scaleRatio;
  45037. private _uniformScalingMesh;
  45038. private _octahedron;
  45039. /** Fires an event when any of it's sub gizmos are dragged */
  45040. onDragStartObservable: Observable<unknown>;
  45041. /** Fires an event when any of it's sub gizmos are released from dragging */
  45042. onDragEndObservable: Observable<unknown>;
  45043. attachedMesh: Nullable<AbstractMesh>;
  45044. /**
  45045. * Creates a ScaleGizmo
  45046. * @param gizmoLayer The utility layer the gizmo will be added to
  45047. */
  45048. constructor(gizmoLayer?: UtilityLayerRenderer);
  45049. updateGizmoRotationToMatchAttachedMesh: boolean;
  45050. /**
  45051. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45052. */
  45053. snapDistance: number;
  45054. /**
  45055. * Ratio for the scale of the gizmo (Default: 1)
  45056. */
  45057. scaleRatio: number;
  45058. /**
  45059. * Disposes of the gizmo
  45060. */
  45061. dispose(): void;
  45062. }
  45063. }
  45064. declare module BABYLON {
  45065. /**
  45066. * Single axis scale gizmo
  45067. */
  45068. export class AxisScaleGizmo extends Gizmo {
  45069. /**
  45070. * Drag behavior responsible for the gizmos dragging interactions
  45071. */
  45072. dragBehavior: PointerDragBehavior;
  45073. private _pointerObserver;
  45074. /**
  45075. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45076. */
  45077. snapDistance: number;
  45078. /**
  45079. * Event that fires each time the gizmo snaps to a new location.
  45080. * * snapDistance is the the change in distance
  45081. */
  45082. onSnapObservable: Observable<{
  45083. snapDistance: number;
  45084. }>;
  45085. /**
  45086. * If the scaling operation should be done on all axis (default: false)
  45087. */
  45088. uniformScaling: boolean;
  45089. private _isEnabled;
  45090. private _parent;
  45091. private _arrow;
  45092. private _coloredMaterial;
  45093. private _hoverMaterial;
  45094. /**
  45095. * Creates an AxisScaleGizmo
  45096. * @param gizmoLayer The utility layer the gizmo will be added to
  45097. * @param dragAxis The axis which the gizmo will be able to scale on
  45098. * @param color The color of the gizmo
  45099. */
  45100. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45101. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45102. /**
  45103. * If the gizmo is enabled
  45104. */
  45105. isEnabled: boolean;
  45106. /**
  45107. * Disposes of the gizmo
  45108. */
  45109. dispose(): void;
  45110. /**
  45111. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45112. * @param mesh The mesh to replace the default mesh of the gizmo
  45113. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45114. */
  45115. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45116. }
  45117. }
  45118. declare module BABYLON {
  45119. /**
  45120. * Bounding box gizmo
  45121. */
  45122. export class BoundingBoxGizmo extends Gizmo {
  45123. private _lineBoundingBox;
  45124. private _rotateSpheresParent;
  45125. private _scaleBoxesParent;
  45126. private _boundingDimensions;
  45127. private _renderObserver;
  45128. private _pointerObserver;
  45129. private _scaleDragSpeed;
  45130. private _tmpQuaternion;
  45131. private _tmpVector;
  45132. private _tmpRotationMatrix;
  45133. /**
  45134. * 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)
  45135. */
  45136. ignoreChildren: boolean;
  45137. /**
  45138. * 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)
  45139. */
  45140. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45141. /**
  45142. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45143. */
  45144. rotationSphereSize: number;
  45145. /**
  45146. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45147. */
  45148. scaleBoxSize: number;
  45149. /**
  45150. * 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)
  45151. */
  45152. fixedDragMeshScreenSize: boolean;
  45153. /**
  45154. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45155. */
  45156. fixedDragMeshScreenSizeDistanceFactor: number;
  45157. /**
  45158. * Fired when a rotation sphere or scale box is dragged
  45159. */
  45160. onDragStartObservable: Observable<{}>;
  45161. /**
  45162. * Fired when a scale box is dragged
  45163. */
  45164. onScaleBoxDragObservable: Observable<{}>;
  45165. /**
  45166. * Fired when a scale box drag is ended
  45167. */
  45168. onScaleBoxDragEndObservable: Observable<{}>;
  45169. /**
  45170. * Fired when a rotation sphere is dragged
  45171. */
  45172. onRotationSphereDragObservable: Observable<{}>;
  45173. /**
  45174. * Fired when a rotation sphere drag is ended
  45175. */
  45176. onRotationSphereDragEndObservable: Observable<{}>;
  45177. /**
  45178. * 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)
  45179. */
  45180. scalePivot: Nullable<Vector3>;
  45181. /**
  45182. * Mesh used as a pivot to rotate the attached mesh
  45183. */
  45184. private _anchorMesh;
  45185. private _existingMeshScale;
  45186. private _dragMesh;
  45187. private pointerDragBehavior;
  45188. private coloredMaterial;
  45189. private hoverColoredMaterial;
  45190. /**
  45191. * Sets the color of the bounding box gizmo
  45192. * @param color the color to set
  45193. */
  45194. setColor(color: Color3): void;
  45195. /**
  45196. * Creates an BoundingBoxGizmo
  45197. * @param gizmoLayer The utility layer the gizmo will be added to
  45198. * @param color The color of the gizmo
  45199. */
  45200. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45201. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45202. private _selectNode;
  45203. /**
  45204. * Updates the bounding box information for the Gizmo
  45205. */
  45206. updateBoundingBox(): void;
  45207. private _updateRotationSpheres;
  45208. private _updateScaleBoxes;
  45209. /**
  45210. * Enables rotation on the specified axis and disables rotation on the others
  45211. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45212. */
  45213. setEnabledRotationAxis(axis: string): void;
  45214. /**
  45215. * Enables/disables scaling
  45216. * @param enable if scaling should be enabled
  45217. */
  45218. setEnabledScaling(enable: boolean): void;
  45219. private _updateDummy;
  45220. /**
  45221. * Enables a pointer drag behavior on the bounding box of the gizmo
  45222. */
  45223. enableDragBehavior(): void;
  45224. /**
  45225. * Disposes of the gizmo
  45226. */
  45227. dispose(): void;
  45228. /**
  45229. * 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)
  45230. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45231. * @returns the bounding box mesh with the passed in mesh as a child
  45232. */
  45233. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45234. /**
  45235. * CustomMeshes are not supported by this gizmo
  45236. * @param mesh The mesh to replace the default mesh of the gizmo
  45237. */
  45238. setCustomMesh(mesh: Mesh): void;
  45239. }
  45240. }
  45241. declare module BABYLON {
  45242. /**
  45243. * Single plane rotation gizmo
  45244. */
  45245. export class PlaneRotationGizmo extends Gizmo {
  45246. /**
  45247. * Drag behavior responsible for the gizmos dragging interactions
  45248. */
  45249. dragBehavior: PointerDragBehavior;
  45250. private _pointerObserver;
  45251. /**
  45252. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45253. */
  45254. snapDistance: number;
  45255. /**
  45256. * Event that fires each time the gizmo snaps to a new location.
  45257. * * snapDistance is the the change in distance
  45258. */
  45259. onSnapObservable: Observable<{
  45260. snapDistance: number;
  45261. }>;
  45262. private _isEnabled;
  45263. private _parent;
  45264. /**
  45265. * Creates a PlaneRotationGizmo
  45266. * @param gizmoLayer The utility layer the gizmo will be added to
  45267. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45268. * @param color The color of the gizmo
  45269. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45270. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45271. */
  45272. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45273. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45274. /**
  45275. * If the gizmo is enabled
  45276. */
  45277. isEnabled: boolean;
  45278. /**
  45279. * Disposes of the gizmo
  45280. */
  45281. dispose(): void;
  45282. }
  45283. }
  45284. declare module BABYLON {
  45285. /**
  45286. * Gizmo that enables rotating a mesh along 3 axis
  45287. */
  45288. export class RotationGizmo extends Gizmo {
  45289. /**
  45290. * Internal gizmo used for interactions on the x axis
  45291. */
  45292. xGizmo: PlaneRotationGizmo;
  45293. /**
  45294. * Internal gizmo used for interactions on the y axis
  45295. */
  45296. yGizmo: PlaneRotationGizmo;
  45297. /**
  45298. * Internal gizmo used for interactions on the z axis
  45299. */
  45300. zGizmo: PlaneRotationGizmo;
  45301. /** Fires an event when any of it's sub gizmos are dragged */
  45302. onDragStartObservable: Observable<unknown>;
  45303. /** Fires an event when any of it's sub gizmos are released from dragging */
  45304. onDragEndObservable: Observable<unknown>;
  45305. private _meshAttached;
  45306. attachedMesh: Nullable<AbstractMesh>;
  45307. /**
  45308. * Creates a RotationGizmo
  45309. * @param gizmoLayer The utility layer the gizmo will be added to
  45310. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45311. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45312. */
  45313. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45314. updateGizmoRotationToMatchAttachedMesh: boolean;
  45315. /**
  45316. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45317. */
  45318. snapDistance: number;
  45319. /**
  45320. * Ratio for the scale of the gizmo (Default: 1)
  45321. */
  45322. scaleRatio: number;
  45323. /**
  45324. * Disposes of the gizmo
  45325. */
  45326. dispose(): void;
  45327. /**
  45328. * CustomMeshes are not supported by this gizmo
  45329. * @param mesh The mesh to replace the default mesh of the gizmo
  45330. */
  45331. setCustomMesh(mesh: Mesh): void;
  45332. }
  45333. }
  45334. declare module BABYLON {
  45335. /**
  45336. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45337. */
  45338. export class GizmoManager implements IDisposable {
  45339. private scene;
  45340. /**
  45341. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45342. */
  45343. gizmos: {
  45344. positionGizmo: Nullable<PositionGizmo>;
  45345. rotationGizmo: Nullable<RotationGizmo>;
  45346. scaleGizmo: Nullable<ScaleGizmo>;
  45347. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45348. };
  45349. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45350. clearGizmoOnEmptyPointerEvent: boolean;
  45351. /** Fires an event when the manager is attached to a mesh */
  45352. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45353. private _gizmosEnabled;
  45354. private _pointerObserver;
  45355. private _attachedMesh;
  45356. private _boundingBoxColor;
  45357. private _defaultUtilityLayer;
  45358. private _defaultKeepDepthUtilityLayer;
  45359. /**
  45360. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45361. */
  45362. boundingBoxDragBehavior: SixDofDragBehavior;
  45363. /**
  45364. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45365. */
  45366. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45367. /**
  45368. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45369. */
  45370. usePointerToAttachGizmos: boolean;
  45371. /**
  45372. * Utility layer that the bounding box gizmo belongs to
  45373. */
  45374. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45375. /**
  45376. * Utility layer that all gizmos besides bounding box belong to
  45377. */
  45378. readonly utilityLayer: UtilityLayerRenderer;
  45379. /**
  45380. * Instatiates a gizmo manager
  45381. * @param scene the scene to overlay the gizmos on top of
  45382. */
  45383. constructor(scene: Scene);
  45384. /**
  45385. * Attaches a set of gizmos to the specified mesh
  45386. * @param mesh The mesh the gizmo's should be attached to
  45387. */
  45388. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45389. /**
  45390. * If the position gizmo is enabled
  45391. */
  45392. positionGizmoEnabled: boolean;
  45393. /**
  45394. * If the rotation gizmo is enabled
  45395. */
  45396. rotationGizmoEnabled: boolean;
  45397. /**
  45398. * If the scale gizmo is enabled
  45399. */
  45400. scaleGizmoEnabled: boolean;
  45401. /**
  45402. * If the boundingBox gizmo is enabled
  45403. */
  45404. boundingBoxGizmoEnabled: boolean;
  45405. /**
  45406. * Disposes of the gizmo manager
  45407. */
  45408. dispose(): void;
  45409. }
  45410. }
  45411. declare module BABYLON {
  45412. /**
  45413. * A directional light is defined by a direction (what a surprise!).
  45414. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45415. * 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.
  45416. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45417. */
  45418. export class DirectionalLight extends ShadowLight {
  45419. private _shadowFrustumSize;
  45420. /**
  45421. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45422. */
  45423. /**
  45424. * Specifies a fix frustum size for the shadow generation.
  45425. */
  45426. shadowFrustumSize: number;
  45427. private _shadowOrthoScale;
  45428. /**
  45429. * Gets the shadow projection scale against the optimal computed one.
  45430. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45431. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45432. */
  45433. /**
  45434. * Sets the shadow projection scale against the optimal computed one.
  45435. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45436. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45437. */
  45438. shadowOrthoScale: number;
  45439. /**
  45440. * Automatically compute the projection matrix to best fit (including all the casters)
  45441. * on each frame.
  45442. */
  45443. autoUpdateExtends: boolean;
  45444. private _orthoLeft;
  45445. private _orthoRight;
  45446. private _orthoTop;
  45447. private _orthoBottom;
  45448. /**
  45449. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45450. * The directional light is emitted from everywhere in the given direction.
  45451. * It can cast shadows.
  45452. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45453. * @param name The friendly name of the light
  45454. * @param direction The direction of the light
  45455. * @param scene The scene the light belongs to
  45456. */
  45457. constructor(name: string, direction: Vector3, scene: Scene);
  45458. /**
  45459. * Returns the string "DirectionalLight".
  45460. * @return The class name
  45461. */
  45462. getClassName(): string;
  45463. /**
  45464. * Returns the integer 1.
  45465. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45466. */
  45467. getTypeID(): number;
  45468. /**
  45469. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45470. * Returns the DirectionalLight Shadow projection matrix.
  45471. */
  45472. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45473. /**
  45474. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45475. * Returns the DirectionalLight Shadow projection matrix.
  45476. */
  45477. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45478. /**
  45479. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45480. * Returns the DirectionalLight Shadow projection matrix.
  45481. */
  45482. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45483. protected _buildUniformLayout(): void;
  45484. /**
  45485. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45486. * @param effect The effect to update
  45487. * @param lightIndex The index of the light in the effect to update
  45488. * @returns The directional light
  45489. */
  45490. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45491. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45492. /**
  45493. * Gets the minZ used for shadow according to both the scene and the light.
  45494. *
  45495. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45496. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45497. * @param activeCamera The camera we are returning the min for
  45498. * @returns the depth min z
  45499. */
  45500. getDepthMinZ(activeCamera: Camera): number;
  45501. /**
  45502. * Gets the maxZ used for shadow according to both the scene and the light.
  45503. *
  45504. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45505. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45506. * @param activeCamera The camera we are returning the max for
  45507. * @returns the depth max z
  45508. */
  45509. getDepthMaxZ(activeCamera: Camera): number;
  45510. /**
  45511. * Prepares the list of defines specific to the light type.
  45512. * @param defines the list of defines
  45513. * @param lightIndex defines the index of the light for the effect
  45514. */
  45515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45516. }
  45517. }
  45518. declare module BABYLON {
  45519. /**
  45520. * Class containing static functions to help procedurally build meshes
  45521. */
  45522. export class HemisphereBuilder {
  45523. /**
  45524. * Creates a hemisphere mesh
  45525. * @param name defines the name of the mesh
  45526. * @param options defines the options used to create the mesh
  45527. * @param scene defines the hosting scene
  45528. * @returns the hemisphere mesh
  45529. */
  45530. static CreateHemisphere(name: string, options: {
  45531. segments?: number;
  45532. diameter?: number;
  45533. sideOrientation?: number;
  45534. }, scene: any): Mesh;
  45535. }
  45536. }
  45537. declare module BABYLON {
  45538. /**
  45539. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45540. * These values define a cone of light starting from the position, emitting toward the direction.
  45541. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45542. * and the exponent defines the speed of the decay of the light with distance (reach).
  45543. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45544. */
  45545. export class SpotLight extends ShadowLight {
  45546. private _angle;
  45547. private _innerAngle;
  45548. private _cosHalfAngle;
  45549. private _lightAngleScale;
  45550. private _lightAngleOffset;
  45551. /**
  45552. * Gets the cone angle of the spot light in Radians.
  45553. */
  45554. /**
  45555. * Sets the cone angle of the spot light in Radians.
  45556. */
  45557. angle: number;
  45558. /**
  45559. * Only used in gltf falloff mode, this defines the angle where
  45560. * the directional falloff will start before cutting at angle which could be seen
  45561. * as outer angle.
  45562. */
  45563. /**
  45564. * Only used in gltf falloff mode, this defines the angle where
  45565. * the directional falloff will start before cutting at angle which could be seen
  45566. * as outer angle.
  45567. */
  45568. innerAngle: number;
  45569. private _shadowAngleScale;
  45570. /**
  45571. * Allows scaling the angle of the light for shadow generation only.
  45572. */
  45573. /**
  45574. * Allows scaling the angle of the light for shadow generation only.
  45575. */
  45576. shadowAngleScale: number;
  45577. /**
  45578. * The light decay speed with the distance from the emission spot.
  45579. */
  45580. exponent: number;
  45581. private _projectionTextureMatrix;
  45582. /**
  45583. * Allows reading the projecton texture
  45584. */
  45585. readonly projectionTextureMatrix: Matrix;
  45586. protected _projectionTextureLightNear: number;
  45587. /**
  45588. * Gets the near clip of the Spotlight for texture projection.
  45589. */
  45590. /**
  45591. * Sets the near clip of the Spotlight for texture projection.
  45592. */
  45593. projectionTextureLightNear: number;
  45594. protected _projectionTextureLightFar: number;
  45595. /**
  45596. * Gets the far clip of the Spotlight for texture projection.
  45597. */
  45598. /**
  45599. * Sets the far clip of the Spotlight for texture projection.
  45600. */
  45601. projectionTextureLightFar: number;
  45602. protected _projectionTextureUpDirection: Vector3;
  45603. /**
  45604. * Gets the Up vector of the Spotlight for texture projection.
  45605. */
  45606. /**
  45607. * Sets the Up vector of the Spotlight for texture projection.
  45608. */
  45609. projectionTextureUpDirection: Vector3;
  45610. private _projectionTexture;
  45611. /**
  45612. * Gets the projection texture of the light.
  45613. */
  45614. /**
  45615. * Sets the projection texture of the light.
  45616. */
  45617. projectionTexture: Nullable<BaseTexture>;
  45618. private _projectionTextureViewLightDirty;
  45619. private _projectionTextureProjectionLightDirty;
  45620. private _projectionTextureDirty;
  45621. private _projectionTextureViewTargetVector;
  45622. private _projectionTextureViewLightMatrix;
  45623. private _projectionTextureProjectionLightMatrix;
  45624. private _projectionTextureScalingMatrix;
  45625. /**
  45626. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45627. * It can cast shadows.
  45628. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45629. * @param name The light friendly name
  45630. * @param position The position of the spot light in the scene
  45631. * @param direction The direction of the light in the scene
  45632. * @param angle The cone angle of the light in Radians
  45633. * @param exponent The light decay speed with the distance from the emission spot
  45634. * @param scene The scene the lights belongs to
  45635. */
  45636. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45637. /**
  45638. * Returns the string "SpotLight".
  45639. * @returns the class name
  45640. */
  45641. getClassName(): string;
  45642. /**
  45643. * Returns the integer 2.
  45644. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45645. */
  45646. getTypeID(): number;
  45647. /**
  45648. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45649. */
  45650. protected _setDirection(value: Vector3): void;
  45651. /**
  45652. * Overrides the position setter to recompute the projection texture view light Matrix.
  45653. */
  45654. protected _setPosition(value: Vector3): void;
  45655. /**
  45656. * 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.
  45657. * Returns the SpotLight.
  45658. */
  45659. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45660. protected _computeProjectionTextureViewLightMatrix(): void;
  45661. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45662. /**
  45663. * Main function for light texture projection matrix computing.
  45664. */
  45665. protected _computeProjectionTextureMatrix(): void;
  45666. protected _buildUniformLayout(): void;
  45667. private _computeAngleValues;
  45668. /**
  45669. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45670. * @param effect The effect to update
  45671. * @param lightIndex The index of the light in the effect to update
  45672. * @returns The spot light
  45673. */
  45674. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45675. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45676. /**
  45677. * Disposes the light and the associated resources.
  45678. */
  45679. dispose(): void;
  45680. /**
  45681. * Prepares the list of defines specific to the light type.
  45682. * @param defines the list of defines
  45683. * @param lightIndex defines the index of the light for the effect
  45684. */
  45685. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45686. }
  45687. }
  45688. declare module BABYLON {
  45689. /**
  45690. * Gizmo that enables viewing a light
  45691. */
  45692. export class LightGizmo extends Gizmo {
  45693. private _lightMesh;
  45694. private _material;
  45695. private cachedPosition;
  45696. private cachedForward;
  45697. /**
  45698. * Creates a LightGizmo
  45699. * @param gizmoLayer The utility layer the gizmo will be added to
  45700. */
  45701. constructor(gizmoLayer?: UtilityLayerRenderer);
  45702. private _light;
  45703. /**
  45704. * The light that the gizmo is attached to
  45705. */
  45706. light: Nullable<Light>;
  45707. /**
  45708. * Gets the material used to render the light gizmo
  45709. */
  45710. readonly material: StandardMaterial;
  45711. /**
  45712. * @hidden
  45713. * Updates the gizmo to match the attached mesh's position/rotation
  45714. */
  45715. protected _update(): void;
  45716. private static _Scale;
  45717. /**
  45718. * Creates the lines for a light mesh
  45719. */
  45720. private static _createLightLines;
  45721. /**
  45722. * Disposes of the light gizmo
  45723. */
  45724. dispose(): void;
  45725. private static _CreateHemisphericLightMesh;
  45726. private static _CreatePointLightMesh;
  45727. private static _CreateSpotLightMesh;
  45728. private static _CreateDirectionalLightMesh;
  45729. }
  45730. }
  45731. declare module BABYLON {
  45732. /** @hidden */
  45733. export var backgroundFragmentDeclaration: {
  45734. name: string;
  45735. shader: string;
  45736. };
  45737. }
  45738. declare module BABYLON {
  45739. /** @hidden */
  45740. export var backgroundUboDeclaration: {
  45741. name: string;
  45742. shader: string;
  45743. };
  45744. }
  45745. declare module BABYLON {
  45746. /** @hidden */
  45747. export var backgroundPixelShader: {
  45748. name: string;
  45749. shader: string;
  45750. };
  45751. }
  45752. declare module BABYLON {
  45753. /** @hidden */
  45754. export var backgroundVertexDeclaration: {
  45755. name: string;
  45756. shader: string;
  45757. };
  45758. }
  45759. declare module BABYLON {
  45760. /** @hidden */
  45761. export var backgroundVertexShader: {
  45762. name: string;
  45763. shader: string;
  45764. };
  45765. }
  45766. declare module BABYLON {
  45767. /**
  45768. * Background material used to create an efficient environement around your scene.
  45769. */
  45770. export class BackgroundMaterial extends PushMaterial {
  45771. /**
  45772. * Standard reflectance value at parallel view angle.
  45773. */
  45774. static StandardReflectance0: number;
  45775. /**
  45776. * Standard reflectance value at grazing angle.
  45777. */
  45778. static StandardReflectance90: number;
  45779. protected _primaryColor: Color3;
  45780. /**
  45781. * Key light Color (multiply against the environement texture)
  45782. */
  45783. primaryColor: Color3;
  45784. protected __perceptualColor: Nullable<Color3>;
  45785. /**
  45786. * Experimental Internal Use Only.
  45787. *
  45788. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45789. * This acts as a helper to set the primary color to a more "human friendly" value.
  45790. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45791. * output color as close as possible from the chosen value.
  45792. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45793. * part of lighting setup.)
  45794. */
  45795. _perceptualColor: Nullable<Color3>;
  45796. protected _primaryColorShadowLevel: float;
  45797. /**
  45798. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45799. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45800. */
  45801. primaryColorShadowLevel: float;
  45802. protected _primaryColorHighlightLevel: float;
  45803. /**
  45804. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45805. * The primary color is used at the level chosen to define what the white area would look.
  45806. */
  45807. primaryColorHighlightLevel: float;
  45808. protected _reflectionTexture: Nullable<BaseTexture>;
  45809. /**
  45810. * Reflection Texture used in the material.
  45811. * Should be author in a specific way for the best result (refer to the documentation).
  45812. */
  45813. reflectionTexture: Nullable<BaseTexture>;
  45814. protected _reflectionBlur: float;
  45815. /**
  45816. * Reflection Texture level of blur.
  45817. *
  45818. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45819. * texture twice.
  45820. */
  45821. reflectionBlur: float;
  45822. protected _diffuseTexture: Nullable<BaseTexture>;
  45823. /**
  45824. * Diffuse Texture used in the material.
  45825. * Should be author in a specific way for the best result (refer to the documentation).
  45826. */
  45827. diffuseTexture: Nullable<BaseTexture>;
  45828. protected _shadowLights: Nullable<IShadowLight[]>;
  45829. /**
  45830. * Specify the list of lights casting shadow on the material.
  45831. * All scene shadow lights will be included if null.
  45832. */
  45833. shadowLights: Nullable<IShadowLight[]>;
  45834. protected _shadowLevel: float;
  45835. /**
  45836. * Helps adjusting the shadow to a softer level if required.
  45837. * 0 means black shadows and 1 means no shadows.
  45838. */
  45839. shadowLevel: float;
  45840. protected _sceneCenter: Vector3;
  45841. /**
  45842. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45843. * It is usually zero but might be interesting to modify according to your setup.
  45844. */
  45845. sceneCenter: Vector3;
  45846. protected _opacityFresnel: boolean;
  45847. /**
  45848. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45849. * This helps ensuring a nice transition when the camera goes under the ground.
  45850. */
  45851. opacityFresnel: boolean;
  45852. protected _reflectionFresnel: boolean;
  45853. /**
  45854. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45855. * This helps adding a mirror texture on the ground.
  45856. */
  45857. reflectionFresnel: boolean;
  45858. protected _reflectionFalloffDistance: number;
  45859. /**
  45860. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45861. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45862. */
  45863. reflectionFalloffDistance: number;
  45864. protected _reflectionAmount: number;
  45865. /**
  45866. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45867. */
  45868. reflectionAmount: number;
  45869. protected _reflectionReflectance0: number;
  45870. /**
  45871. * This specifies the weight of the reflection at grazing angle.
  45872. */
  45873. reflectionReflectance0: number;
  45874. protected _reflectionReflectance90: number;
  45875. /**
  45876. * This specifies the weight of the reflection at a perpendicular point of view.
  45877. */
  45878. reflectionReflectance90: number;
  45879. /**
  45880. * Sets the reflection reflectance fresnel values according to the default standard
  45881. * empirically know to work well :-)
  45882. */
  45883. reflectionStandardFresnelWeight: number;
  45884. protected _useRGBColor: boolean;
  45885. /**
  45886. * Helps to directly use the maps channels instead of their level.
  45887. */
  45888. useRGBColor: boolean;
  45889. protected _enableNoise: boolean;
  45890. /**
  45891. * This helps reducing the banding effect that could occur on the background.
  45892. */
  45893. enableNoise: boolean;
  45894. /**
  45895. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45896. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45897. * Recommended to be keep at 1.0 except for special cases.
  45898. */
  45899. fovMultiplier: number;
  45900. private _fovMultiplier;
  45901. /**
  45902. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45903. */
  45904. useEquirectangularFOV: boolean;
  45905. private _maxSimultaneousLights;
  45906. /**
  45907. * Number of Simultaneous lights allowed on the material.
  45908. */
  45909. maxSimultaneousLights: int;
  45910. /**
  45911. * Default configuration related to image processing available in the Background Material.
  45912. */
  45913. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45914. /**
  45915. * Keep track of the image processing observer to allow dispose and replace.
  45916. */
  45917. private _imageProcessingObserver;
  45918. /**
  45919. * Attaches a new image processing configuration to the PBR Material.
  45920. * @param configuration (if null the scene configuration will be use)
  45921. */
  45922. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45923. /**
  45924. * Gets the image processing configuration used either in this material.
  45925. */
  45926. /**
  45927. * Sets the Default image processing configuration used either in the this material.
  45928. *
  45929. * If sets to null, the scene one is in use.
  45930. */
  45931. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45932. /**
  45933. * Gets wether the color curves effect is enabled.
  45934. */
  45935. /**
  45936. * Sets wether the color curves effect is enabled.
  45937. */
  45938. cameraColorCurvesEnabled: boolean;
  45939. /**
  45940. * Gets wether the color grading effect is enabled.
  45941. */
  45942. /**
  45943. * Gets wether the color grading effect is enabled.
  45944. */
  45945. cameraColorGradingEnabled: boolean;
  45946. /**
  45947. * Gets wether tonemapping is enabled or not.
  45948. */
  45949. /**
  45950. * Sets wether tonemapping is enabled or not
  45951. */
  45952. cameraToneMappingEnabled: boolean;
  45953. /**
  45954. * The camera exposure used on this material.
  45955. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45956. * This corresponds to a photographic exposure.
  45957. */
  45958. /**
  45959. * The camera exposure used on this material.
  45960. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45961. * This corresponds to a photographic exposure.
  45962. */
  45963. cameraExposure: float;
  45964. /**
  45965. * Gets The camera contrast used on this material.
  45966. */
  45967. /**
  45968. * Sets The camera contrast used on this material.
  45969. */
  45970. cameraContrast: float;
  45971. /**
  45972. * Gets the Color Grading 2D Lookup Texture.
  45973. */
  45974. /**
  45975. * Sets the Color Grading 2D Lookup Texture.
  45976. */
  45977. cameraColorGradingTexture: Nullable<BaseTexture>;
  45978. /**
  45979. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45980. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45981. * 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;
  45982. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45983. */
  45984. /**
  45985. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45986. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45987. * 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;
  45988. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45989. */
  45990. cameraColorCurves: Nullable<ColorCurves>;
  45991. /**
  45992. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45993. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45994. */
  45995. switchToBGR: boolean;
  45996. private _renderTargets;
  45997. private _reflectionControls;
  45998. private _white;
  45999. private _primaryShadowColor;
  46000. private _primaryHighlightColor;
  46001. /**
  46002. * Instantiates a Background Material in the given scene
  46003. * @param name The friendly name of the material
  46004. * @param scene The scene to add the material to
  46005. */
  46006. constructor(name: string, scene: Scene);
  46007. /**
  46008. * Gets a boolean indicating that current material needs to register RTT
  46009. */
  46010. readonly hasRenderTargetTextures: boolean;
  46011. /**
  46012. * The entire material has been created in order to prevent overdraw.
  46013. * @returns false
  46014. */
  46015. needAlphaTesting(): boolean;
  46016. /**
  46017. * The entire material has been created in order to prevent overdraw.
  46018. * @returns true if blending is enable
  46019. */
  46020. needAlphaBlending(): boolean;
  46021. /**
  46022. * Checks wether the material is ready to be rendered for a given mesh.
  46023. * @param mesh The mesh to render
  46024. * @param subMesh The submesh to check against
  46025. * @param useInstances Specify wether or not the material is used with instances
  46026. * @returns true if all the dependencies are ready (Textures, Effects...)
  46027. */
  46028. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46029. /**
  46030. * Compute the primary color according to the chosen perceptual color.
  46031. */
  46032. private _computePrimaryColorFromPerceptualColor;
  46033. /**
  46034. * Compute the highlights and shadow colors according to their chosen levels.
  46035. */
  46036. private _computePrimaryColors;
  46037. /**
  46038. * Build the uniform buffer used in the material.
  46039. */
  46040. buildUniformLayout(): void;
  46041. /**
  46042. * Unbind the material.
  46043. */
  46044. unbind(): void;
  46045. /**
  46046. * Bind only the world matrix to the material.
  46047. * @param world The world matrix to bind.
  46048. */
  46049. bindOnlyWorldMatrix(world: Matrix): void;
  46050. /**
  46051. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46052. * @param world The world matrix to bind.
  46053. * @param subMesh The submesh to bind for.
  46054. */
  46055. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46056. /**
  46057. * Checks to see if a texture is used in the material.
  46058. * @param texture - Base texture to use.
  46059. * @returns - Boolean specifying if a texture is used in the material.
  46060. */
  46061. hasTexture(texture: BaseTexture): boolean;
  46062. /**
  46063. * Dispose the material.
  46064. * @param forceDisposeEffect Force disposal of the associated effect.
  46065. * @param forceDisposeTextures Force disposal of the associated textures.
  46066. */
  46067. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46068. /**
  46069. * Clones the material.
  46070. * @param name The cloned name.
  46071. * @returns The cloned material.
  46072. */
  46073. clone(name: string): BackgroundMaterial;
  46074. /**
  46075. * Serializes the current material to its JSON representation.
  46076. * @returns The JSON representation.
  46077. */
  46078. serialize(): any;
  46079. /**
  46080. * Gets the class name of the material
  46081. * @returns "BackgroundMaterial"
  46082. */
  46083. getClassName(): string;
  46084. /**
  46085. * Parse a JSON input to create back a background material.
  46086. * @param source The JSON data to parse
  46087. * @param scene The scene to create the parsed material in
  46088. * @param rootUrl The root url of the assets the material depends upon
  46089. * @returns the instantiated BackgroundMaterial.
  46090. */
  46091. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46092. }
  46093. }
  46094. declare module BABYLON {
  46095. /**
  46096. * Represents the different options available during the creation of
  46097. * a Environment helper.
  46098. *
  46099. * This can control the default ground, skybox and image processing setup of your scene.
  46100. */
  46101. export interface IEnvironmentHelperOptions {
  46102. /**
  46103. * Specifies wether or not to create a ground.
  46104. * True by default.
  46105. */
  46106. createGround: boolean;
  46107. /**
  46108. * Specifies the ground size.
  46109. * 15 by default.
  46110. */
  46111. groundSize: number;
  46112. /**
  46113. * The texture used on the ground for the main color.
  46114. * Comes from the BabylonJS CDN by default.
  46115. *
  46116. * Remarks: Can be either a texture or a url.
  46117. */
  46118. groundTexture: string | BaseTexture;
  46119. /**
  46120. * The color mixed in the ground texture by default.
  46121. * BabylonJS clearColor by default.
  46122. */
  46123. groundColor: Color3;
  46124. /**
  46125. * Specifies the ground opacity.
  46126. * 1 by default.
  46127. */
  46128. groundOpacity: number;
  46129. /**
  46130. * Enables the ground to receive shadows.
  46131. * True by default.
  46132. */
  46133. enableGroundShadow: boolean;
  46134. /**
  46135. * Helps preventing the shadow to be fully black on the ground.
  46136. * 0.5 by default.
  46137. */
  46138. groundShadowLevel: number;
  46139. /**
  46140. * Creates a mirror texture attach to the ground.
  46141. * false by default.
  46142. */
  46143. enableGroundMirror: boolean;
  46144. /**
  46145. * Specifies the ground mirror size ratio.
  46146. * 0.3 by default as the default kernel is 64.
  46147. */
  46148. groundMirrorSizeRatio: number;
  46149. /**
  46150. * Specifies the ground mirror blur kernel size.
  46151. * 64 by default.
  46152. */
  46153. groundMirrorBlurKernel: number;
  46154. /**
  46155. * Specifies the ground mirror visibility amount.
  46156. * 1 by default
  46157. */
  46158. groundMirrorAmount: number;
  46159. /**
  46160. * Specifies the ground mirror reflectance weight.
  46161. * This uses the standard weight of the background material to setup the fresnel effect
  46162. * of the mirror.
  46163. * 1 by default.
  46164. */
  46165. groundMirrorFresnelWeight: number;
  46166. /**
  46167. * Specifies the ground mirror Falloff distance.
  46168. * This can helps reducing the size of the reflection.
  46169. * 0 by Default.
  46170. */
  46171. groundMirrorFallOffDistance: number;
  46172. /**
  46173. * Specifies the ground mirror texture type.
  46174. * Unsigned Int by Default.
  46175. */
  46176. groundMirrorTextureType: number;
  46177. /**
  46178. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46179. * the shown objects.
  46180. */
  46181. groundYBias: number;
  46182. /**
  46183. * Specifies wether or not to create a skybox.
  46184. * True by default.
  46185. */
  46186. createSkybox: boolean;
  46187. /**
  46188. * Specifies the skybox size.
  46189. * 20 by default.
  46190. */
  46191. skyboxSize: number;
  46192. /**
  46193. * The texture used on the skybox for the main color.
  46194. * Comes from the BabylonJS CDN by default.
  46195. *
  46196. * Remarks: Can be either a texture or a url.
  46197. */
  46198. skyboxTexture: string | BaseTexture;
  46199. /**
  46200. * The color mixed in the skybox texture by default.
  46201. * BabylonJS clearColor by default.
  46202. */
  46203. skyboxColor: Color3;
  46204. /**
  46205. * The background rotation around the Y axis of the scene.
  46206. * This helps aligning the key lights of your scene with the background.
  46207. * 0 by default.
  46208. */
  46209. backgroundYRotation: number;
  46210. /**
  46211. * Compute automatically the size of the elements to best fit with the scene.
  46212. */
  46213. sizeAuto: boolean;
  46214. /**
  46215. * Default position of the rootMesh if autoSize is not true.
  46216. */
  46217. rootPosition: Vector3;
  46218. /**
  46219. * Sets up the image processing in the scene.
  46220. * true by default.
  46221. */
  46222. setupImageProcessing: boolean;
  46223. /**
  46224. * The texture used as your environment texture in the scene.
  46225. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46226. *
  46227. * Remarks: Can be either a texture or a url.
  46228. */
  46229. environmentTexture: string | BaseTexture;
  46230. /**
  46231. * The value of the exposure to apply to the scene.
  46232. * 0.6 by default if setupImageProcessing is true.
  46233. */
  46234. cameraExposure: number;
  46235. /**
  46236. * The value of the contrast to apply to the scene.
  46237. * 1.6 by default if setupImageProcessing is true.
  46238. */
  46239. cameraContrast: number;
  46240. /**
  46241. * Specifies wether or not tonemapping should be enabled in the scene.
  46242. * true by default if setupImageProcessing is true.
  46243. */
  46244. toneMappingEnabled: boolean;
  46245. }
  46246. /**
  46247. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46248. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46249. * It also helps with the default setup of your imageProcessing configuration.
  46250. */
  46251. export class EnvironmentHelper {
  46252. /**
  46253. * Default ground texture URL.
  46254. */
  46255. private static _groundTextureCDNUrl;
  46256. /**
  46257. * Default skybox texture URL.
  46258. */
  46259. private static _skyboxTextureCDNUrl;
  46260. /**
  46261. * Default environment texture URL.
  46262. */
  46263. private static _environmentTextureCDNUrl;
  46264. /**
  46265. * Creates the default options for the helper.
  46266. */
  46267. private static _getDefaultOptions;
  46268. private _rootMesh;
  46269. /**
  46270. * Gets the root mesh created by the helper.
  46271. */
  46272. readonly rootMesh: Mesh;
  46273. private _skybox;
  46274. /**
  46275. * Gets the skybox created by the helper.
  46276. */
  46277. readonly skybox: Nullable<Mesh>;
  46278. private _skyboxTexture;
  46279. /**
  46280. * Gets the skybox texture created by the helper.
  46281. */
  46282. readonly skyboxTexture: Nullable<BaseTexture>;
  46283. private _skyboxMaterial;
  46284. /**
  46285. * Gets the skybox material created by the helper.
  46286. */
  46287. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46288. private _ground;
  46289. /**
  46290. * Gets the ground mesh created by the helper.
  46291. */
  46292. readonly ground: Nullable<Mesh>;
  46293. private _groundTexture;
  46294. /**
  46295. * Gets the ground texture created by the helper.
  46296. */
  46297. readonly groundTexture: Nullable<BaseTexture>;
  46298. private _groundMirror;
  46299. /**
  46300. * Gets the ground mirror created by the helper.
  46301. */
  46302. readonly groundMirror: Nullable<MirrorTexture>;
  46303. /**
  46304. * Gets the ground mirror render list to helps pushing the meshes
  46305. * you wish in the ground reflection.
  46306. */
  46307. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46308. private _groundMaterial;
  46309. /**
  46310. * Gets the ground material created by the helper.
  46311. */
  46312. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46313. /**
  46314. * Stores the creation options.
  46315. */
  46316. private readonly _scene;
  46317. private _options;
  46318. /**
  46319. * This observable will be notified with any error during the creation of the environment,
  46320. * mainly texture creation errors.
  46321. */
  46322. onErrorObservable: Observable<{
  46323. message?: string;
  46324. exception?: any;
  46325. }>;
  46326. /**
  46327. * constructor
  46328. * @param options Defines the options we want to customize the helper
  46329. * @param scene The scene to add the material to
  46330. */
  46331. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46332. /**
  46333. * Updates the background according to the new options
  46334. * @param options
  46335. */
  46336. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46337. /**
  46338. * Sets the primary color of all the available elements.
  46339. * @param color the main color to affect to the ground and the background
  46340. */
  46341. setMainColor(color: Color3): void;
  46342. /**
  46343. * Setup the image processing according to the specified options.
  46344. */
  46345. private _setupImageProcessing;
  46346. /**
  46347. * Setup the environment texture according to the specified options.
  46348. */
  46349. private _setupEnvironmentTexture;
  46350. /**
  46351. * Setup the background according to the specified options.
  46352. */
  46353. private _setupBackground;
  46354. /**
  46355. * Get the scene sizes according to the setup.
  46356. */
  46357. private _getSceneSize;
  46358. /**
  46359. * Setup the ground according to the specified options.
  46360. */
  46361. private _setupGround;
  46362. /**
  46363. * Setup the ground material according to the specified options.
  46364. */
  46365. private _setupGroundMaterial;
  46366. /**
  46367. * Setup the ground diffuse texture according to the specified options.
  46368. */
  46369. private _setupGroundDiffuseTexture;
  46370. /**
  46371. * Setup the ground mirror texture according to the specified options.
  46372. */
  46373. private _setupGroundMirrorTexture;
  46374. /**
  46375. * Setup the ground to receive the mirror texture.
  46376. */
  46377. private _setupMirrorInGroundMaterial;
  46378. /**
  46379. * Setup the skybox according to the specified options.
  46380. */
  46381. private _setupSkybox;
  46382. /**
  46383. * Setup the skybox material according to the specified options.
  46384. */
  46385. private _setupSkyboxMaterial;
  46386. /**
  46387. * Setup the skybox reflection texture according to the specified options.
  46388. */
  46389. private _setupSkyboxReflectionTexture;
  46390. private _errorHandler;
  46391. /**
  46392. * Dispose all the elements created by the Helper.
  46393. */
  46394. dispose(): void;
  46395. }
  46396. }
  46397. declare module BABYLON {
  46398. /**
  46399. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46400. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46401. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46402. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46403. */
  46404. export class PhotoDome extends TransformNode {
  46405. /**
  46406. * Define the image as a Monoscopic panoramic 360 image.
  46407. */
  46408. static readonly MODE_MONOSCOPIC: number;
  46409. /**
  46410. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46411. */
  46412. static readonly MODE_TOPBOTTOM: number;
  46413. /**
  46414. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46415. */
  46416. static readonly MODE_SIDEBYSIDE: number;
  46417. private _useDirectMapping;
  46418. /**
  46419. * The texture being displayed on the sphere
  46420. */
  46421. protected _photoTexture: Texture;
  46422. /**
  46423. * Gets or sets the texture being displayed on the sphere
  46424. */
  46425. photoTexture: Texture;
  46426. /**
  46427. * Observable raised when an error occured while loading the 360 image
  46428. */
  46429. onLoadErrorObservable: Observable<string>;
  46430. /**
  46431. * The skybox material
  46432. */
  46433. protected _material: BackgroundMaterial;
  46434. /**
  46435. * The surface used for the skybox
  46436. */
  46437. protected _mesh: Mesh;
  46438. /**
  46439. * Gets the mesh used for the skybox.
  46440. */
  46441. readonly mesh: Mesh;
  46442. /**
  46443. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46444. * Also see the options.resolution property.
  46445. */
  46446. fovMultiplier: number;
  46447. private _imageMode;
  46448. /**
  46449. * Gets or set the current video mode for the video. It can be:
  46450. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46451. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46452. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46453. */
  46454. imageMode: number;
  46455. /**
  46456. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46457. * @param name Element's name, child elements will append suffixes for their own names.
  46458. * @param urlsOfPhoto defines the url of the photo to display
  46459. * @param options defines an object containing optional or exposed sub element properties
  46460. * @param onError defines a callback called when an error occured while loading the texture
  46461. */
  46462. constructor(name: string, urlOfPhoto: string, options: {
  46463. resolution?: number;
  46464. size?: number;
  46465. useDirectMapping?: boolean;
  46466. faceForward?: boolean;
  46467. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46468. private _onBeforeCameraRenderObserver;
  46469. private _changeImageMode;
  46470. /**
  46471. * Releases resources associated with this node.
  46472. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46473. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46474. */
  46475. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46476. }
  46477. }
  46478. declare module BABYLON {
  46479. /**
  46480. * Class used to host RGBD texture specific utilities
  46481. */
  46482. export class RGBDTextureTools {
  46483. /**
  46484. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46485. * @param texture the texture to expand.
  46486. */
  46487. static ExpandRGBDTexture(texture: Texture): void;
  46488. }
  46489. }
  46490. declare module BABYLON {
  46491. /**
  46492. * Class used to host texture specific utilities
  46493. */
  46494. export class BRDFTextureTools {
  46495. /**
  46496. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46497. * @param scene defines the hosting scene
  46498. * @returns the environment BRDF texture
  46499. */
  46500. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46501. private static _environmentBRDFBase64Texture;
  46502. }
  46503. }
  46504. declare module BABYLON {
  46505. /**
  46506. * @hidden
  46507. */
  46508. export interface IMaterialClearCoatDefines {
  46509. CLEARCOAT: boolean;
  46510. CLEARCOAT_DEFAULTIOR: boolean;
  46511. CLEARCOAT_TEXTURE: boolean;
  46512. CLEARCOAT_TEXTUREDIRECTUV: number;
  46513. CLEARCOAT_BUMP: boolean;
  46514. CLEARCOAT_BUMPDIRECTUV: number;
  46515. CLEARCOAT_TINT: boolean;
  46516. CLEARCOAT_TINT_TEXTURE: boolean;
  46517. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46518. /** @hidden */
  46519. _areTexturesDirty: boolean;
  46520. }
  46521. /**
  46522. * Define the code related to the clear coat parameters of the pbr material.
  46523. */
  46524. export class PBRClearCoatConfiguration {
  46525. /**
  46526. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46527. * The default fits with a polyurethane material.
  46528. */
  46529. private static readonly _DefaultIndexOfRefraction;
  46530. private _isEnabled;
  46531. /**
  46532. * Defines if the clear coat is enabled in the material.
  46533. */
  46534. isEnabled: boolean;
  46535. /**
  46536. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46537. */
  46538. intensity: number;
  46539. /**
  46540. * Defines the clear coat layer roughness.
  46541. */
  46542. roughness: number;
  46543. private _indexOfRefraction;
  46544. /**
  46545. * Defines the index of refraction of the clear coat.
  46546. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46547. * The default fits with a polyurethane material.
  46548. * Changing the default value is more performance intensive.
  46549. */
  46550. indexOfRefraction: number;
  46551. private _texture;
  46552. /**
  46553. * Stores the clear coat values in a texture.
  46554. */
  46555. texture: Nullable<BaseTexture>;
  46556. private _bumpTexture;
  46557. /**
  46558. * Define the clear coat specific bump texture.
  46559. */
  46560. bumpTexture: Nullable<BaseTexture>;
  46561. private _isTintEnabled;
  46562. /**
  46563. * Defines if the clear coat tint is enabled in the material.
  46564. */
  46565. isTintEnabled: boolean;
  46566. /**
  46567. * Defines the clear coat tint of the material.
  46568. * This is only use if tint is enabled
  46569. */
  46570. tintColor: Color3;
  46571. /**
  46572. * Defines the distance at which the tint color should be found in the
  46573. * clear coat media.
  46574. * This is only use if tint is enabled
  46575. */
  46576. tintColorAtDistance: number;
  46577. /**
  46578. * Defines the clear coat layer thickness.
  46579. * This is only use if tint is enabled
  46580. */
  46581. tintThickness: number;
  46582. private _tintTexture;
  46583. /**
  46584. * Stores the clear tint values in a texture.
  46585. * rgb is tint
  46586. * a is a thickness factor
  46587. */
  46588. tintTexture: Nullable<BaseTexture>;
  46589. /** @hidden */
  46590. private _internalMarkAllSubMeshesAsTexturesDirty;
  46591. /** @hidden */
  46592. _markAllSubMeshesAsTexturesDirty(): void;
  46593. /**
  46594. * Instantiate a new istance of clear coat configuration.
  46595. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46596. */
  46597. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46598. /**
  46599. * Gets wehter the submesh is ready to be used or not.
  46600. * @param defines the list of "defines" to update.
  46601. * @param scene defines the scene the material belongs to.
  46602. * @param engine defines the engine the material belongs to.
  46603. * @param disableBumpMap defines wether the material disables bump or not.
  46604. * @returns - boolean indicating that the submesh is ready or not.
  46605. */
  46606. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46607. /**
  46608. * Checks to see if a texture is used in the material.
  46609. * @param defines the list of "defines" to update.
  46610. * @param scene defines the scene to the material belongs to.
  46611. */
  46612. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46613. /**
  46614. * Binds the material data.
  46615. * @param uniformBuffer defines the Uniform buffer to fill in.
  46616. * @param scene defines the scene the material belongs to.
  46617. * @param engine defines the engine the material belongs to.
  46618. * @param disableBumpMap defines wether the material disables bump or not.
  46619. * @param isFrozen defines wether the material is frozen or not.
  46620. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46621. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46622. */
  46623. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46624. /**
  46625. * Checks to see if a texture is used in the material.
  46626. * @param texture - Base texture to use.
  46627. * @returns - Boolean specifying if a texture is used in the material.
  46628. */
  46629. hasTexture(texture: BaseTexture): boolean;
  46630. /**
  46631. * Returns an array of the actively used textures.
  46632. * @param activeTextures Array of BaseTextures
  46633. */
  46634. getActiveTextures(activeTextures: BaseTexture[]): void;
  46635. /**
  46636. * Returns the animatable textures.
  46637. * @param animatables Array of animatable textures.
  46638. */
  46639. getAnimatables(animatables: IAnimatable[]): void;
  46640. /**
  46641. * Disposes the resources of the material.
  46642. * @param forceDisposeTextures - Forces the disposal of all textures.
  46643. */
  46644. dispose(forceDisposeTextures?: boolean): void;
  46645. /**
  46646. * Get the current class name of the texture useful for serialization or dynamic coding.
  46647. * @returns "PBRClearCoatConfiguration"
  46648. */
  46649. getClassName(): string;
  46650. /**
  46651. * Add fallbacks to the effect fallbacks list.
  46652. * @param defines defines the Base texture to use.
  46653. * @param fallbacks defines the current fallback list.
  46654. * @param currentRank defines the current fallback rank.
  46655. * @returns the new fallback rank.
  46656. */
  46657. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46658. /**
  46659. * Add the required uniforms to the current list.
  46660. * @param uniforms defines the current uniform list.
  46661. */
  46662. static AddUniforms(uniforms: string[]): void;
  46663. /**
  46664. * Add the required samplers to the current list.
  46665. * @param samplers defines the current sampler list.
  46666. */
  46667. static AddSamplers(samplers: string[]): void;
  46668. /**
  46669. * Add the required uniforms to the current buffer.
  46670. * @param uniformBuffer defines the current uniform buffer.
  46671. */
  46672. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46673. /**
  46674. * Makes a duplicate of the current configuration into another one.
  46675. * @param clearCoatConfiguration define the config where to copy the info
  46676. */
  46677. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46678. /**
  46679. * Serializes this clear coat configuration.
  46680. * @returns - An object with the serialized config.
  46681. */
  46682. serialize(): any;
  46683. /**
  46684. * Parses a anisotropy Configuration from a serialized object.
  46685. * @param source - Serialized object.
  46686. * @param scene Defines the scene we are parsing for
  46687. * @param rootUrl Defines the rootUrl to load from
  46688. */
  46689. parse(source: any, scene: Scene, rootUrl: string): void;
  46690. }
  46691. }
  46692. declare module BABYLON {
  46693. /**
  46694. * @hidden
  46695. */
  46696. export interface IMaterialAnisotropicDefines {
  46697. ANISOTROPIC: boolean;
  46698. ANISOTROPIC_TEXTURE: boolean;
  46699. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46700. MAINUV1: boolean;
  46701. _areTexturesDirty: boolean;
  46702. _needUVs: boolean;
  46703. }
  46704. /**
  46705. * Define the code related to the anisotropic parameters of the pbr material.
  46706. */
  46707. export class PBRAnisotropicConfiguration {
  46708. private _isEnabled;
  46709. /**
  46710. * Defines if the anisotropy is enabled in the material.
  46711. */
  46712. isEnabled: boolean;
  46713. /**
  46714. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46715. */
  46716. intensity: number;
  46717. /**
  46718. * Defines if the effect is along the tangents, bitangents or in between.
  46719. * By default, the effect is "strectching" the highlights along the tangents.
  46720. */
  46721. direction: Vector2;
  46722. private _texture;
  46723. /**
  46724. * Stores the anisotropy values in a texture.
  46725. * rg is direction (like normal from -1 to 1)
  46726. * b is a intensity
  46727. */
  46728. texture: Nullable<BaseTexture>;
  46729. /** @hidden */
  46730. private _internalMarkAllSubMeshesAsTexturesDirty;
  46731. /** @hidden */
  46732. _markAllSubMeshesAsTexturesDirty(): void;
  46733. /**
  46734. * Instantiate a new istance of anisotropy configuration.
  46735. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46736. */
  46737. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46738. /**
  46739. * Specifies that the submesh is ready to be used.
  46740. * @param defines the list of "defines" to update.
  46741. * @param scene defines the scene the material belongs to.
  46742. * @returns - boolean indicating that the submesh is ready or not.
  46743. */
  46744. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46745. /**
  46746. * Checks to see if a texture is used in the material.
  46747. * @param defines the list of "defines" to update.
  46748. * @param mesh the mesh we are preparing the defines for.
  46749. * @param scene defines the scene the material belongs to.
  46750. */
  46751. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46752. /**
  46753. * Binds the material data.
  46754. * @param uniformBuffer defines the Uniform buffer to fill in.
  46755. * @param scene defines the scene the material belongs to.
  46756. * @param isFrozen defines wether the material is frozen or not.
  46757. */
  46758. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46759. /**
  46760. * Checks to see if a texture is used in the material.
  46761. * @param texture - Base texture to use.
  46762. * @returns - Boolean specifying if a texture is used in the material.
  46763. */
  46764. hasTexture(texture: BaseTexture): boolean;
  46765. /**
  46766. * Returns an array of the actively used textures.
  46767. * @param activeTextures Array of BaseTextures
  46768. */
  46769. getActiveTextures(activeTextures: BaseTexture[]): void;
  46770. /**
  46771. * Returns the animatable textures.
  46772. * @param animatables Array of animatable textures.
  46773. */
  46774. getAnimatables(animatables: IAnimatable[]): void;
  46775. /**
  46776. * Disposes the resources of the material.
  46777. * @param forceDisposeTextures - Forces the disposal of all textures.
  46778. */
  46779. dispose(forceDisposeTextures?: boolean): void;
  46780. /**
  46781. * Get the current class name of the texture useful for serialization or dynamic coding.
  46782. * @returns "PBRAnisotropicConfiguration"
  46783. */
  46784. getClassName(): string;
  46785. /**
  46786. * Add fallbacks to the effect fallbacks list.
  46787. * @param defines defines the Base texture to use.
  46788. * @param fallbacks defines the current fallback list.
  46789. * @param currentRank defines the current fallback rank.
  46790. * @returns the new fallback rank.
  46791. */
  46792. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46793. /**
  46794. * Add the required uniforms to the current list.
  46795. * @param uniforms defines the current uniform list.
  46796. */
  46797. static AddUniforms(uniforms: string[]): void;
  46798. /**
  46799. * Add the required uniforms to the current buffer.
  46800. * @param uniformBuffer defines the current uniform buffer.
  46801. */
  46802. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46803. /**
  46804. * Add the required samplers to the current list.
  46805. * @param samplers defines the current sampler list.
  46806. */
  46807. static AddSamplers(samplers: string[]): void;
  46808. /**
  46809. * Makes a duplicate of the current configuration into another one.
  46810. * @param anisotropicConfiguration define the config where to copy the info
  46811. */
  46812. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46813. /**
  46814. * Serializes this anisotropy configuration.
  46815. * @returns - An object with the serialized config.
  46816. */
  46817. serialize(): any;
  46818. /**
  46819. * Parses a anisotropy Configuration from a serialized object.
  46820. * @param source - Serialized object.
  46821. * @param scene Defines the scene we are parsing for
  46822. * @param rootUrl Defines the rootUrl to load from
  46823. */
  46824. parse(source: any, scene: Scene, rootUrl: string): void;
  46825. }
  46826. }
  46827. declare module BABYLON {
  46828. /**
  46829. * @hidden
  46830. */
  46831. export interface IMaterialBRDFDefines {
  46832. BRDF_V_HEIGHT_CORRELATED: boolean;
  46833. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46834. SPHERICAL_HARMONICS: boolean;
  46835. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46836. /** @hidden */
  46837. _areMiscDirty: boolean;
  46838. }
  46839. /**
  46840. * Define the code related to the BRDF parameters of the pbr material.
  46841. */
  46842. export class PBRBRDFConfiguration {
  46843. /**
  46844. * Default value used for the energy conservation.
  46845. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46846. */
  46847. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46848. /**
  46849. * Default value used for the Smith Visibility Height Correlated mode.
  46850. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46851. */
  46852. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46853. /**
  46854. * Default value used for the IBL diffuse part.
  46855. * This can help switching back to the polynomials mode globally which is a tiny bit
  46856. * less GPU intensive at the drawback of a lower quality.
  46857. */
  46858. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46859. /**
  46860. * Default value used for activating energy conservation for the specular workflow.
  46861. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46862. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46863. */
  46864. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46865. private _useEnergyConservation;
  46866. /**
  46867. * Defines if the material uses energy conservation.
  46868. */
  46869. useEnergyConservation: boolean;
  46870. private _useSmithVisibilityHeightCorrelated;
  46871. /**
  46872. * LEGACY Mode set to false
  46873. * Defines if the material uses height smith correlated visibility term.
  46874. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46875. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46876. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46877. * Not relying on height correlated will also disable energy conservation.
  46878. */
  46879. useSmithVisibilityHeightCorrelated: boolean;
  46880. private _useSphericalHarmonics;
  46881. /**
  46882. * LEGACY Mode set to false
  46883. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46884. * diffuse part of the IBL.
  46885. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46886. * to the ground truth.
  46887. */
  46888. useSphericalHarmonics: boolean;
  46889. private _useSpecularGlossinessInputEnergyConservation;
  46890. /**
  46891. * Defines if the material uses energy conservation, when the specular workflow is active.
  46892. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46893. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46894. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46895. */
  46896. useSpecularGlossinessInputEnergyConservation: boolean;
  46897. /** @hidden */
  46898. private _internalMarkAllSubMeshesAsMiscDirty;
  46899. /** @hidden */
  46900. _markAllSubMeshesAsMiscDirty(): void;
  46901. /**
  46902. * Instantiate a new istance of clear coat configuration.
  46903. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46904. */
  46905. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46906. /**
  46907. * Checks to see if a texture is used in the material.
  46908. * @param defines the list of "defines" to update.
  46909. */
  46910. prepareDefines(defines: IMaterialBRDFDefines): void;
  46911. /**
  46912. * Get the current class name of the texture useful for serialization or dynamic coding.
  46913. * @returns "PBRClearCoatConfiguration"
  46914. */
  46915. getClassName(): string;
  46916. /**
  46917. * Makes a duplicate of the current configuration into another one.
  46918. * @param brdfConfiguration define the config where to copy the info
  46919. */
  46920. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46921. /**
  46922. * Serializes this BRDF configuration.
  46923. * @returns - An object with the serialized config.
  46924. */
  46925. serialize(): any;
  46926. /**
  46927. * Parses a anisotropy Configuration from a serialized object.
  46928. * @param source - Serialized object.
  46929. * @param scene Defines the scene we are parsing for
  46930. * @param rootUrl Defines the rootUrl to load from
  46931. */
  46932. parse(source: any, scene: Scene, rootUrl: string): void;
  46933. }
  46934. }
  46935. declare module BABYLON {
  46936. /**
  46937. * @hidden
  46938. */
  46939. export interface IMaterialSheenDefines {
  46940. SHEEN: boolean;
  46941. SHEEN_TEXTURE: boolean;
  46942. SHEEN_TEXTUREDIRECTUV: number;
  46943. SHEEN_LINKWITHALBEDO: boolean;
  46944. /** @hidden */
  46945. _areTexturesDirty: boolean;
  46946. }
  46947. /**
  46948. * Define the code related to the Sheen parameters of the pbr material.
  46949. */
  46950. export class PBRSheenConfiguration {
  46951. private _isEnabled;
  46952. /**
  46953. * Defines if the material uses sheen.
  46954. */
  46955. isEnabled: boolean;
  46956. private _linkSheenWithAlbedo;
  46957. /**
  46958. * Defines if the sheen is linked to the sheen color.
  46959. */
  46960. linkSheenWithAlbedo: boolean;
  46961. /**
  46962. * Defines the sheen intensity.
  46963. */
  46964. intensity: number;
  46965. /**
  46966. * Defines the sheen color.
  46967. */
  46968. color: Color3;
  46969. private _texture;
  46970. /**
  46971. * Stores the sheen tint values in a texture.
  46972. * rgb is tint
  46973. * a is a intensity
  46974. */
  46975. texture: Nullable<BaseTexture>;
  46976. /** @hidden */
  46977. private _internalMarkAllSubMeshesAsTexturesDirty;
  46978. /** @hidden */
  46979. _markAllSubMeshesAsTexturesDirty(): void;
  46980. /**
  46981. * Instantiate a new istance of clear coat configuration.
  46982. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46983. */
  46984. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46985. /**
  46986. * Specifies that the submesh is ready to be used.
  46987. * @param defines the list of "defines" to update.
  46988. * @param scene defines the scene the material belongs to.
  46989. * @returns - boolean indicating that the submesh is ready or not.
  46990. */
  46991. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46992. /**
  46993. * Checks to see if a texture is used in the material.
  46994. * @param defines the list of "defines" to update.
  46995. * @param scene defines the scene the material belongs to.
  46996. */
  46997. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46998. /**
  46999. * Binds the material data.
  47000. * @param uniformBuffer defines the Uniform buffer to fill in.
  47001. * @param scene defines the scene the material belongs to.
  47002. * @param isFrozen defines wether the material is frozen or not.
  47003. */
  47004. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47005. /**
  47006. * Checks to see if a texture is used in the material.
  47007. * @param texture - Base texture to use.
  47008. * @returns - Boolean specifying if a texture is used in the material.
  47009. */
  47010. hasTexture(texture: BaseTexture): boolean;
  47011. /**
  47012. * Returns an array of the actively used textures.
  47013. * @param activeTextures Array of BaseTextures
  47014. */
  47015. getActiveTextures(activeTextures: BaseTexture[]): void;
  47016. /**
  47017. * Returns the animatable textures.
  47018. * @param animatables Array of animatable textures.
  47019. */
  47020. getAnimatables(animatables: IAnimatable[]): void;
  47021. /**
  47022. * Disposes the resources of the material.
  47023. * @param forceDisposeTextures - Forces the disposal of all textures.
  47024. */
  47025. dispose(forceDisposeTextures?: boolean): void;
  47026. /**
  47027. * Get the current class name of the texture useful for serialization or dynamic coding.
  47028. * @returns "PBRSheenConfiguration"
  47029. */
  47030. getClassName(): string;
  47031. /**
  47032. * Add fallbacks to the effect fallbacks list.
  47033. * @param defines defines the Base texture to use.
  47034. * @param fallbacks defines the current fallback list.
  47035. * @param currentRank defines the current fallback rank.
  47036. * @returns the new fallback rank.
  47037. */
  47038. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47039. /**
  47040. * Add the required uniforms to the current list.
  47041. * @param uniforms defines the current uniform list.
  47042. */
  47043. static AddUniforms(uniforms: string[]): void;
  47044. /**
  47045. * Add the required uniforms to the current buffer.
  47046. * @param uniformBuffer defines the current uniform buffer.
  47047. */
  47048. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47049. /**
  47050. * Add the required samplers to the current list.
  47051. * @param samplers defines the current sampler list.
  47052. */
  47053. static AddSamplers(samplers: string[]): void;
  47054. /**
  47055. * Makes a duplicate of the current configuration into another one.
  47056. * @param sheenConfiguration define the config where to copy the info
  47057. */
  47058. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47059. /**
  47060. * Serializes this BRDF configuration.
  47061. * @returns - An object with the serialized config.
  47062. */
  47063. serialize(): any;
  47064. /**
  47065. * Parses a anisotropy Configuration from a serialized object.
  47066. * @param source - Serialized object.
  47067. * @param scene Defines the scene we are parsing for
  47068. * @param rootUrl Defines the rootUrl to load from
  47069. */
  47070. parse(source: any, scene: Scene, rootUrl: string): void;
  47071. }
  47072. }
  47073. declare module BABYLON {
  47074. /**
  47075. * @hidden
  47076. */
  47077. export interface IMaterialSubSurfaceDefines {
  47078. SUBSURFACE: boolean;
  47079. SS_REFRACTION: boolean;
  47080. SS_TRANSLUCENCY: boolean;
  47081. SS_SCATERRING: boolean;
  47082. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47083. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47084. SS_REFRACTIONMAP_3D: boolean;
  47085. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47086. SS_LODINREFRACTIONALPHA: boolean;
  47087. SS_GAMMAREFRACTION: boolean;
  47088. SS_RGBDREFRACTION: boolean;
  47089. SS_LINEARSPECULARREFRACTION: boolean;
  47090. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47091. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47092. /** @hidden */
  47093. _areTexturesDirty: boolean;
  47094. }
  47095. /**
  47096. * Define the code related to the sub surface parameters of the pbr material.
  47097. */
  47098. export class PBRSubSurfaceConfiguration {
  47099. private _isRefractionEnabled;
  47100. /**
  47101. * Defines if the refraction is enabled in the material.
  47102. */
  47103. isRefractionEnabled: boolean;
  47104. private _isTranslucencyEnabled;
  47105. /**
  47106. * Defines if the translucency is enabled in the material.
  47107. */
  47108. isTranslucencyEnabled: boolean;
  47109. private _isScatteringEnabled;
  47110. /**
  47111. * Defines the refraction intensity of the material.
  47112. * The refraction when enabled replaces the Diffuse part of the material.
  47113. * The intensity helps transitionning between diffuse and refraction.
  47114. */
  47115. refractionIntensity: number;
  47116. /**
  47117. * Defines the translucency intensity of the material.
  47118. * When translucency has been enabled, this defines how much of the "translucency"
  47119. * is addded to the diffuse part of the material.
  47120. */
  47121. translucencyIntensity: number;
  47122. /**
  47123. * Defines the scattering intensity of the material.
  47124. * When scattering has been enabled, this defines how much of the "scattered light"
  47125. * is addded to the diffuse part of the material.
  47126. */
  47127. scatteringIntensity: number;
  47128. private _thicknessTexture;
  47129. /**
  47130. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47131. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47132. * 0 would mean minimumThickness
  47133. * 1 would mean maximumThickness
  47134. * The other channels might be use as a mask to vary the different effects intensity.
  47135. */
  47136. thicknessTexture: Nullable<BaseTexture>;
  47137. private _refractionTexture;
  47138. /**
  47139. * Defines the texture to use for refraction.
  47140. */
  47141. refractionTexture: Nullable<BaseTexture>;
  47142. private _indexOfRefraction;
  47143. /**
  47144. * Defines the index of refraction used in the material.
  47145. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47146. */
  47147. indexOfRefraction: number;
  47148. private _invertRefractionY;
  47149. /**
  47150. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47151. */
  47152. invertRefractionY: boolean;
  47153. private _linkRefractionWithTransparency;
  47154. /**
  47155. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47156. * Materials half opaque for instance using refraction could benefit from this control.
  47157. */
  47158. linkRefractionWithTransparency: boolean;
  47159. /**
  47160. * Defines the minimum thickness stored in the thickness map.
  47161. * If no thickness map is defined, this value will be used to simulate thickness.
  47162. */
  47163. minimumThickness: number;
  47164. /**
  47165. * Defines the maximum thickness stored in the thickness map.
  47166. */
  47167. maximumThickness: number;
  47168. /**
  47169. * Defines the volume tint of the material.
  47170. * This is used for both translucency and scattering.
  47171. */
  47172. tintColor: Color3;
  47173. /**
  47174. * Defines the distance at which the tint color should be found in the media.
  47175. * This is used for refraction only.
  47176. */
  47177. tintColorAtDistance: number;
  47178. /**
  47179. * Defines how far each channel transmit through the media.
  47180. * It is defined as a color to simplify it selection.
  47181. */
  47182. diffusionDistance: Color3;
  47183. private _useMaskFromThicknessTexture;
  47184. /**
  47185. * Stores the intensity of the different subsurface effects in the thickness texture.
  47186. * * the green channel is the translucency intensity.
  47187. * * the blue channel is the scattering intensity.
  47188. * * the alpha channel is the refraction intensity.
  47189. */
  47190. useMaskFromThicknessTexture: boolean;
  47191. /** @hidden */
  47192. private _internalMarkAllSubMeshesAsTexturesDirty;
  47193. /** @hidden */
  47194. _markAllSubMeshesAsTexturesDirty(): void;
  47195. /**
  47196. * Instantiate a new istance of sub surface configuration.
  47197. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47198. */
  47199. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47200. /**
  47201. * Gets wehter the submesh is ready to be used or not.
  47202. * @param defines the list of "defines" to update.
  47203. * @param scene defines the scene the material belongs to.
  47204. * @returns - boolean indicating that the submesh is ready or not.
  47205. */
  47206. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47207. /**
  47208. * Checks to see if a texture is used in the material.
  47209. * @param defines the list of "defines" to update.
  47210. * @param scene defines the scene to the material belongs to.
  47211. */
  47212. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47213. /**
  47214. * Binds the material data.
  47215. * @param uniformBuffer defines the Uniform buffer to fill in.
  47216. * @param scene defines the scene the material belongs to.
  47217. * @param engine defines the engine the material belongs to.
  47218. * @param isFrozen defines wether the material is frozen or not.
  47219. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47220. */
  47221. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47222. /**
  47223. * Unbinds the material from the mesh.
  47224. * @param activeEffect defines the effect that should be unbound from.
  47225. * @returns true if unbound, otherwise false
  47226. */
  47227. unbind(activeEffect: Effect): boolean;
  47228. /**
  47229. * Returns the texture used for refraction or null if none is used.
  47230. * @param scene defines the scene the material belongs to.
  47231. * @returns - Refraction texture if present. If no refraction texture and refraction
  47232. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47233. */
  47234. private _getRefractionTexture;
  47235. /**
  47236. * Returns true if alpha blending should be disabled.
  47237. */
  47238. readonly disableAlphaBlending: boolean;
  47239. /**
  47240. * Fills the list of render target textures.
  47241. * @param renderTargets the list of render targets to update
  47242. */
  47243. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47244. /**
  47245. * Checks to see if a texture is used in the material.
  47246. * @param texture - Base texture to use.
  47247. * @returns - Boolean specifying if a texture is used in the material.
  47248. */
  47249. hasTexture(texture: BaseTexture): boolean;
  47250. /**
  47251. * Gets a boolean indicating that current material needs to register RTT
  47252. * @returns true if this uses a render target otherwise false.
  47253. */
  47254. hasRenderTargetTextures(): boolean;
  47255. /**
  47256. * Returns an array of the actively used textures.
  47257. * @param activeTextures Array of BaseTextures
  47258. */
  47259. getActiveTextures(activeTextures: BaseTexture[]): void;
  47260. /**
  47261. * Returns the animatable textures.
  47262. * @param animatables Array of animatable textures.
  47263. */
  47264. getAnimatables(animatables: IAnimatable[]): void;
  47265. /**
  47266. * Disposes the resources of the material.
  47267. * @param forceDisposeTextures - Forces the disposal of all textures.
  47268. */
  47269. dispose(forceDisposeTextures?: boolean): void;
  47270. /**
  47271. * Get the current class name of the texture useful for serialization or dynamic coding.
  47272. * @returns "PBRSubSurfaceConfiguration"
  47273. */
  47274. getClassName(): string;
  47275. /**
  47276. * Add fallbacks to the effect fallbacks list.
  47277. * @param defines defines the Base texture to use.
  47278. * @param fallbacks defines the current fallback list.
  47279. * @param currentRank defines the current fallback rank.
  47280. * @returns the new fallback rank.
  47281. */
  47282. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47283. /**
  47284. * Add the required uniforms to the current list.
  47285. * @param uniforms defines the current uniform list.
  47286. */
  47287. static AddUniforms(uniforms: string[]): void;
  47288. /**
  47289. * Add the required samplers to the current list.
  47290. * @param samplers defines the current sampler list.
  47291. */
  47292. static AddSamplers(samplers: string[]): void;
  47293. /**
  47294. * Add the required uniforms to the current buffer.
  47295. * @param uniformBuffer defines the current uniform buffer.
  47296. */
  47297. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47298. /**
  47299. * Makes a duplicate of the current configuration into another one.
  47300. * @param configuration define the config where to copy the info
  47301. */
  47302. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47303. /**
  47304. * Serializes this Sub Surface configuration.
  47305. * @returns - An object with the serialized config.
  47306. */
  47307. serialize(): any;
  47308. /**
  47309. * Parses a anisotropy Configuration from a serialized object.
  47310. * @param source - Serialized object.
  47311. * @param scene Defines the scene we are parsing for
  47312. * @param rootUrl Defines the rootUrl to load from
  47313. */
  47314. parse(source: any, scene: Scene, rootUrl: string): void;
  47315. }
  47316. }
  47317. declare module BABYLON {
  47318. /** @hidden */
  47319. export var pbrFragmentDeclaration: {
  47320. name: string;
  47321. shader: string;
  47322. };
  47323. }
  47324. declare module BABYLON {
  47325. /** @hidden */
  47326. export var pbrUboDeclaration: {
  47327. name: string;
  47328. shader: string;
  47329. };
  47330. }
  47331. declare module BABYLON {
  47332. /** @hidden */
  47333. export var pbrFragmentExtraDeclaration: {
  47334. name: string;
  47335. shader: string;
  47336. };
  47337. }
  47338. declare module BABYLON {
  47339. /** @hidden */
  47340. export var pbrFragmentSamplersDeclaration: {
  47341. name: string;
  47342. shader: string;
  47343. };
  47344. }
  47345. declare module BABYLON {
  47346. /** @hidden */
  47347. export var pbrHelperFunctions: {
  47348. name: string;
  47349. shader: string;
  47350. };
  47351. }
  47352. declare module BABYLON {
  47353. /** @hidden */
  47354. export var harmonicsFunctions: {
  47355. name: string;
  47356. shader: string;
  47357. };
  47358. }
  47359. declare module BABYLON {
  47360. /** @hidden */
  47361. export var pbrDirectLightingSetupFunctions: {
  47362. name: string;
  47363. shader: string;
  47364. };
  47365. }
  47366. declare module BABYLON {
  47367. /** @hidden */
  47368. export var pbrDirectLightingFalloffFunctions: {
  47369. name: string;
  47370. shader: string;
  47371. };
  47372. }
  47373. declare module BABYLON {
  47374. /** @hidden */
  47375. export var pbrBRDFFunctions: {
  47376. name: string;
  47377. shader: string;
  47378. };
  47379. }
  47380. declare module BABYLON {
  47381. /** @hidden */
  47382. export var pbrDirectLightingFunctions: {
  47383. name: string;
  47384. shader: string;
  47385. };
  47386. }
  47387. declare module BABYLON {
  47388. /** @hidden */
  47389. export var pbrIBLFunctions: {
  47390. name: string;
  47391. shader: string;
  47392. };
  47393. }
  47394. declare module BABYLON {
  47395. /** @hidden */
  47396. export var pbrDebug: {
  47397. name: string;
  47398. shader: string;
  47399. };
  47400. }
  47401. declare module BABYLON {
  47402. /** @hidden */
  47403. export var pbrPixelShader: {
  47404. name: string;
  47405. shader: string;
  47406. };
  47407. }
  47408. declare module BABYLON {
  47409. /** @hidden */
  47410. export var pbrVertexDeclaration: {
  47411. name: string;
  47412. shader: string;
  47413. };
  47414. }
  47415. declare module BABYLON {
  47416. /** @hidden */
  47417. export var pbrVertexShader: {
  47418. name: string;
  47419. shader: string;
  47420. };
  47421. }
  47422. declare module BABYLON {
  47423. /**
  47424. * Manages the defines for the PBR Material.
  47425. * @hidden
  47426. */
  47427. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47428. PBR: boolean;
  47429. MAINUV1: boolean;
  47430. MAINUV2: boolean;
  47431. UV1: boolean;
  47432. UV2: boolean;
  47433. ALBEDO: boolean;
  47434. ALBEDODIRECTUV: number;
  47435. VERTEXCOLOR: boolean;
  47436. AMBIENT: boolean;
  47437. AMBIENTDIRECTUV: number;
  47438. AMBIENTINGRAYSCALE: boolean;
  47439. OPACITY: boolean;
  47440. VERTEXALPHA: boolean;
  47441. OPACITYDIRECTUV: number;
  47442. OPACITYRGB: boolean;
  47443. ALPHATEST: boolean;
  47444. DEPTHPREPASS: boolean;
  47445. ALPHABLEND: boolean;
  47446. ALPHAFROMALBEDO: boolean;
  47447. ALPHATESTVALUE: string;
  47448. SPECULAROVERALPHA: boolean;
  47449. RADIANCEOVERALPHA: boolean;
  47450. ALPHAFRESNEL: boolean;
  47451. LINEARALPHAFRESNEL: boolean;
  47452. PREMULTIPLYALPHA: boolean;
  47453. EMISSIVE: boolean;
  47454. EMISSIVEDIRECTUV: number;
  47455. REFLECTIVITY: boolean;
  47456. REFLECTIVITYDIRECTUV: number;
  47457. SPECULARTERM: boolean;
  47458. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47459. MICROSURFACEAUTOMATIC: boolean;
  47460. LODBASEDMICROSFURACE: boolean;
  47461. MICROSURFACEMAP: boolean;
  47462. MICROSURFACEMAPDIRECTUV: number;
  47463. METALLICWORKFLOW: boolean;
  47464. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47465. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47466. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47467. AOSTOREINMETALMAPRED: boolean;
  47468. ENVIRONMENTBRDF: boolean;
  47469. ENVIRONMENTBRDF_RGBD: boolean;
  47470. NORMAL: boolean;
  47471. TANGENT: boolean;
  47472. BUMP: boolean;
  47473. BUMPDIRECTUV: number;
  47474. OBJECTSPACE_NORMALMAP: boolean;
  47475. PARALLAX: boolean;
  47476. PARALLAXOCCLUSION: boolean;
  47477. NORMALXYSCALE: boolean;
  47478. LIGHTMAP: boolean;
  47479. LIGHTMAPDIRECTUV: number;
  47480. USELIGHTMAPASSHADOWMAP: boolean;
  47481. GAMMALIGHTMAP: boolean;
  47482. RGBDLIGHTMAP: boolean;
  47483. REFLECTION: boolean;
  47484. REFLECTIONMAP_3D: boolean;
  47485. REFLECTIONMAP_SPHERICAL: boolean;
  47486. REFLECTIONMAP_PLANAR: boolean;
  47487. REFLECTIONMAP_CUBIC: boolean;
  47488. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47489. REFLECTIONMAP_PROJECTION: boolean;
  47490. REFLECTIONMAP_SKYBOX: boolean;
  47491. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47492. REFLECTIONMAP_EXPLICIT: boolean;
  47493. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47494. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47495. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47496. INVERTCUBICMAP: boolean;
  47497. USESPHERICALFROMREFLECTIONMAP: boolean;
  47498. USEIRRADIANCEMAP: boolean;
  47499. SPHERICAL_HARMONICS: boolean;
  47500. USESPHERICALINVERTEX: boolean;
  47501. REFLECTIONMAP_OPPOSITEZ: boolean;
  47502. LODINREFLECTIONALPHA: boolean;
  47503. GAMMAREFLECTION: boolean;
  47504. RGBDREFLECTION: boolean;
  47505. LINEARSPECULARREFLECTION: boolean;
  47506. RADIANCEOCCLUSION: boolean;
  47507. HORIZONOCCLUSION: boolean;
  47508. INSTANCES: boolean;
  47509. NUM_BONE_INFLUENCERS: number;
  47510. BonesPerMesh: number;
  47511. BONETEXTURE: boolean;
  47512. NONUNIFORMSCALING: boolean;
  47513. MORPHTARGETS: boolean;
  47514. MORPHTARGETS_NORMAL: boolean;
  47515. MORPHTARGETS_TANGENT: boolean;
  47516. MORPHTARGETS_UV: boolean;
  47517. NUM_MORPH_INFLUENCERS: number;
  47518. IMAGEPROCESSING: boolean;
  47519. VIGNETTE: boolean;
  47520. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47521. VIGNETTEBLENDMODEOPAQUE: boolean;
  47522. TONEMAPPING: boolean;
  47523. TONEMAPPING_ACES: boolean;
  47524. CONTRAST: boolean;
  47525. COLORCURVES: boolean;
  47526. COLORGRADING: boolean;
  47527. COLORGRADING3D: boolean;
  47528. SAMPLER3DGREENDEPTH: boolean;
  47529. SAMPLER3DBGRMAP: boolean;
  47530. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47531. EXPOSURE: boolean;
  47532. MULTIVIEW: boolean;
  47533. USEPHYSICALLIGHTFALLOFF: boolean;
  47534. USEGLTFLIGHTFALLOFF: boolean;
  47535. TWOSIDEDLIGHTING: boolean;
  47536. SHADOWFLOAT: boolean;
  47537. CLIPPLANE: boolean;
  47538. CLIPPLANE2: boolean;
  47539. CLIPPLANE3: boolean;
  47540. CLIPPLANE4: boolean;
  47541. POINTSIZE: boolean;
  47542. FOG: boolean;
  47543. LOGARITHMICDEPTH: boolean;
  47544. FORCENORMALFORWARD: boolean;
  47545. SPECULARAA: boolean;
  47546. CLEARCOAT: boolean;
  47547. CLEARCOAT_DEFAULTIOR: boolean;
  47548. CLEARCOAT_TEXTURE: boolean;
  47549. CLEARCOAT_TEXTUREDIRECTUV: number;
  47550. CLEARCOAT_BUMP: boolean;
  47551. CLEARCOAT_BUMPDIRECTUV: number;
  47552. CLEARCOAT_TINT: boolean;
  47553. CLEARCOAT_TINT_TEXTURE: boolean;
  47554. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47555. ANISOTROPIC: boolean;
  47556. ANISOTROPIC_TEXTURE: boolean;
  47557. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47558. BRDF_V_HEIGHT_CORRELATED: boolean;
  47559. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47560. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47561. SHEEN: boolean;
  47562. SHEEN_TEXTURE: boolean;
  47563. SHEEN_TEXTUREDIRECTUV: number;
  47564. SHEEN_LINKWITHALBEDO: boolean;
  47565. SUBSURFACE: boolean;
  47566. SS_REFRACTION: boolean;
  47567. SS_TRANSLUCENCY: boolean;
  47568. SS_SCATERRING: boolean;
  47569. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47570. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47571. SS_REFRACTIONMAP_3D: boolean;
  47572. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47573. SS_LODINREFRACTIONALPHA: boolean;
  47574. SS_GAMMAREFRACTION: boolean;
  47575. SS_RGBDREFRACTION: boolean;
  47576. SS_LINEARSPECULARREFRACTION: boolean;
  47577. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47578. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47579. UNLIT: boolean;
  47580. DEBUGMODE: number;
  47581. /**
  47582. * Initializes the PBR Material defines.
  47583. */
  47584. constructor();
  47585. /**
  47586. * Resets the PBR Material defines.
  47587. */
  47588. reset(): void;
  47589. }
  47590. /**
  47591. * The Physically based material base class of BJS.
  47592. *
  47593. * This offers the main features of a standard PBR material.
  47594. * For more information, please refer to the documentation :
  47595. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47596. */
  47597. export abstract class PBRBaseMaterial extends PushMaterial {
  47598. /**
  47599. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47600. */
  47601. static readonly PBRMATERIAL_OPAQUE: number;
  47602. /**
  47603. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47604. */
  47605. static readonly PBRMATERIAL_ALPHATEST: number;
  47606. /**
  47607. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47608. */
  47609. static readonly PBRMATERIAL_ALPHABLEND: number;
  47610. /**
  47611. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47612. * They are also discarded below the alpha cutoff threshold to improve performances.
  47613. */
  47614. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47615. /**
  47616. * Defines the default value of how much AO map is occluding the analytical lights
  47617. * (point spot...).
  47618. */
  47619. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47620. /**
  47621. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47622. */
  47623. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47624. /**
  47625. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47626. * to enhance interoperability with other engines.
  47627. */
  47628. static readonly LIGHTFALLOFF_GLTF: number;
  47629. /**
  47630. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47631. * to enhance interoperability with other materials.
  47632. */
  47633. static readonly LIGHTFALLOFF_STANDARD: number;
  47634. /**
  47635. * Intensity of the direct lights e.g. the four lights available in your scene.
  47636. * This impacts both the direct diffuse and specular highlights.
  47637. */
  47638. protected _directIntensity: number;
  47639. /**
  47640. * Intensity of the emissive part of the material.
  47641. * This helps controlling the emissive effect without modifying the emissive color.
  47642. */
  47643. protected _emissiveIntensity: number;
  47644. /**
  47645. * Intensity of the environment e.g. how much the environment will light the object
  47646. * either through harmonics for rough material or through the refelction for shiny ones.
  47647. */
  47648. protected _environmentIntensity: number;
  47649. /**
  47650. * This is a special control allowing the reduction of the specular highlights coming from the
  47651. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47652. */
  47653. protected _specularIntensity: number;
  47654. /**
  47655. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47656. */
  47657. private _lightingInfos;
  47658. /**
  47659. * Debug Control allowing disabling the bump map on this material.
  47660. */
  47661. protected _disableBumpMap: boolean;
  47662. /**
  47663. * AKA Diffuse Texture in standard nomenclature.
  47664. */
  47665. protected _albedoTexture: Nullable<BaseTexture>;
  47666. /**
  47667. * AKA Occlusion Texture in other nomenclature.
  47668. */
  47669. protected _ambientTexture: Nullable<BaseTexture>;
  47670. /**
  47671. * AKA Occlusion Texture Intensity in other nomenclature.
  47672. */
  47673. protected _ambientTextureStrength: number;
  47674. /**
  47675. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47676. * 1 means it completely occludes it
  47677. * 0 mean it has no impact
  47678. */
  47679. protected _ambientTextureImpactOnAnalyticalLights: number;
  47680. /**
  47681. * Stores the alpha values in a texture.
  47682. */
  47683. protected _opacityTexture: Nullable<BaseTexture>;
  47684. /**
  47685. * Stores the reflection values in a texture.
  47686. */
  47687. protected _reflectionTexture: Nullable<BaseTexture>;
  47688. /**
  47689. * Stores the emissive values in a texture.
  47690. */
  47691. protected _emissiveTexture: Nullable<BaseTexture>;
  47692. /**
  47693. * AKA Specular texture in other nomenclature.
  47694. */
  47695. protected _reflectivityTexture: Nullable<BaseTexture>;
  47696. /**
  47697. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47698. */
  47699. protected _metallicTexture: Nullable<BaseTexture>;
  47700. /**
  47701. * Specifies the metallic scalar of the metallic/roughness workflow.
  47702. * Can also be used to scale the metalness values of the metallic texture.
  47703. */
  47704. protected _metallic: Nullable<number>;
  47705. /**
  47706. * Specifies the roughness scalar of the metallic/roughness workflow.
  47707. * Can also be used to scale the roughness values of the metallic texture.
  47708. */
  47709. protected _roughness: Nullable<number>;
  47710. /**
  47711. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47712. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47713. */
  47714. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47715. /**
  47716. * Stores surface normal data used to displace a mesh in a texture.
  47717. */
  47718. protected _bumpTexture: Nullable<BaseTexture>;
  47719. /**
  47720. * Stores the pre-calculated light information of a mesh in a texture.
  47721. */
  47722. protected _lightmapTexture: Nullable<BaseTexture>;
  47723. /**
  47724. * The color of a material in ambient lighting.
  47725. */
  47726. protected _ambientColor: Color3;
  47727. /**
  47728. * AKA Diffuse Color in other nomenclature.
  47729. */
  47730. protected _albedoColor: Color3;
  47731. /**
  47732. * AKA Specular Color in other nomenclature.
  47733. */
  47734. protected _reflectivityColor: Color3;
  47735. /**
  47736. * The color applied when light is reflected from a material.
  47737. */
  47738. protected _reflectionColor: Color3;
  47739. /**
  47740. * The color applied when light is emitted from a material.
  47741. */
  47742. protected _emissiveColor: Color3;
  47743. /**
  47744. * AKA Glossiness in other nomenclature.
  47745. */
  47746. protected _microSurface: number;
  47747. /**
  47748. * Specifies that the material will use the light map as a show map.
  47749. */
  47750. protected _useLightmapAsShadowmap: boolean;
  47751. /**
  47752. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47753. * makes the reflect vector face the model (under horizon).
  47754. */
  47755. protected _useHorizonOcclusion: boolean;
  47756. /**
  47757. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47758. * too much the area relying on ambient texture to define their ambient occlusion.
  47759. */
  47760. protected _useRadianceOcclusion: boolean;
  47761. /**
  47762. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47763. */
  47764. protected _useAlphaFromAlbedoTexture: boolean;
  47765. /**
  47766. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47767. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47768. */
  47769. protected _useSpecularOverAlpha: boolean;
  47770. /**
  47771. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47772. */
  47773. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47774. /**
  47775. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47776. */
  47777. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47778. /**
  47779. * Specifies if the metallic texture contains the roughness information in its green channel.
  47780. */
  47781. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47782. /**
  47783. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47784. */
  47785. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47786. /**
  47787. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47788. */
  47789. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47790. /**
  47791. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47792. */
  47793. protected _useAmbientInGrayScale: boolean;
  47794. /**
  47795. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47796. * The material will try to infer what glossiness each pixel should be.
  47797. */
  47798. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47799. /**
  47800. * Defines the falloff type used in this material.
  47801. * It by default is Physical.
  47802. */
  47803. protected _lightFalloff: number;
  47804. /**
  47805. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47806. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47807. */
  47808. protected _useRadianceOverAlpha: boolean;
  47809. /**
  47810. * Allows using an object space normal map (instead of tangent space).
  47811. */
  47812. protected _useObjectSpaceNormalMap: boolean;
  47813. /**
  47814. * Allows using the bump map in parallax mode.
  47815. */
  47816. protected _useParallax: boolean;
  47817. /**
  47818. * Allows using the bump map in parallax occlusion mode.
  47819. */
  47820. protected _useParallaxOcclusion: boolean;
  47821. /**
  47822. * Controls the scale bias of the parallax mode.
  47823. */
  47824. protected _parallaxScaleBias: number;
  47825. /**
  47826. * If sets to true, disables all the lights affecting the material.
  47827. */
  47828. protected _disableLighting: boolean;
  47829. /**
  47830. * Number of Simultaneous lights allowed on the material.
  47831. */
  47832. protected _maxSimultaneousLights: number;
  47833. /**
  47834. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47835. */
  47836. protected _invertNormalMapX: boolean;
  47837. /**
  47838. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47839. */
  47840. protected _invertNormalMapY: boolean;
  47841. /**
  47842. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47843. */
  47844. protected _twoSidedLighting: boolean;
  47845. /**
  47846. * Defines the alpha limits in alpha test mode.
  47847. */
  47848. protected _alphaCutOff: number;
  47849. /**
  47850. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47851. */
  47852. protected _forceAlphaTest: boolean;
  47853. /**
  47854. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47855. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47856. */
  47857. protected _useAlphaFresnel: boolean;
  47858. /**
  47859. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47860. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47861. */
  47862. protected _useLinearAlphaFresnel: boolean;
  47863. /**
  47864. * The transparency mode of the material.
  47865. */
  47866. protected _transparencyMode: Nullable<number>;
  47867. /**
  47868. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47869. * from cos thetav and roughness:
  47870. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47871. */
  47872. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47873. /**
  47874. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47875. */
  47876. protected _forceIrradianceInFragment: boolean;
  47877. /**
  47878. * Force normal to face away from face.
  47879. */
  47880. protected _forceNormalForward: boolean;
  47881. /**
  47882. * Enables specular anti aliasing in the PBR shader.
  47883. * It will both interacts on the Geometry for analytical and IBL lighting.
  47884. * It also prefilter the roughness map based on the bump values.
  47885. */
  47886. protected _enableSpecularAntiAliasing: boolean;
  47887. /**
  47888. * Default configuration related to image processing available in the PBR Material.
  47889. */
  47890. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47891. /**
  47892. * Keep track of the image processing observer to allow dispose and replace.
  47893. */
  47894. private _imageProcessingObserver;
  47895. /**
  47896. * Attaches a new image processing configuration to the PBR Material.
  47897. * @param configuration
  47898. */
  47899. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47900. /**
  47901. * Stores the available render targets.
  47902. */
  47903. private _renderTargets;
  47904. /**
  47905. * Sets the global ambient color for the material used in lighting calculations.
  47906. */
  47907. private _globalAmbientColor;
  47908. /**
  47909. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47910. */
  47911. private _useLogarithmicDepth;
  47912. /**
  47913. * If set to true, no lighting calculations will be applied.
  47914. */
  47915. private _unlit;
  47916. private _debugMode;
  47917. /**
  47918. * @hidden
  47919. * This is reserved for the inspector.
  47920. * Defines the material debug mode.
  47921. * It helps seeing only some components of the material while troubleshooting.
  47922. */
  47923. debugMode: number;
  47924. /**
  47925. * @hidden
  47926. * This is reserved for the inspector.
  47927. * Specify from where on screen the debug mode should start.
  47928. * The value goes from -1 (full screen) to 1 (not visible)
  47929. * It helps with side by side comparison against the final render
  47930. * This defaults to -1
  47931. */
  47932. private debugLimit;
  47933. /**
  47934. * @hidden
  47935. * This is reserved for the inspector.
  47936. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47937. * You can use the factor to better multiply the final value.
  47938. */
  47939. private debugFactor;
  47940. /**
  47941. * Defines the clear coat layer parameters for the material.
  47942. */
  47943. readonly clearCoat: PBRClearCoatConfiguration;
  47944. /**
  47945. * Defines the anisotropic parameters for the material.
  47946. */
  47947. readonly anisotropy: PBRAnisotropicConfiguration;
  47948. /**
  47949. * Defines the BRDF parameters for the material.
  47950. */
  47951. readonly brdf: PBRBRDFConfiguration;
  47952. /**
  47953. * Defines the Sheen parameters for the material.
  47954. */
  47955. readonly sheen: PBRSheenConfiguration;
  47956. /**
  47957. * Defines the SubSurface parameters for the material.
  47958. */
  47959. readonly subSurface: PBRSubSurfaceConfiguration;
  47960. /**
  47961. * Custom callback helping to override the default shader used in the material.
  47962. */
  47963. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47964. protected _rebuildInParallel: boolean;
  47965. /**
  47966. * Instantiates a new PBRMaterial instance.
  47967. *
  47968. * @param name The material name
  47969. * @param scene The scene the material will be use in.
  47970. */
  47971. constructor(name: string, scene: Scene);
  47972. /**
  47973. * Gets a boolean indicating that current material needs to register RTT
  47974. */
  47975. readonly hasRenderTargetTextures: boolean;
  47976. /**
  47977. * Gets the name of the material class.
  47978. */
  47979. getClassName(): string;
  47980. /**
  47981. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47982. */
  47983. /**
  47984. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47985. */
  47986. useLogarithmicDepth: boolean;
  47987. /**
  47988. * Gets the current transparency mode.
  47989. */
  47990. /**
  47991. * Sets the transparency mode of the material.
  47992. *
  47993. * | Value | Type | Description |
  47994. * | ----- | ----------------------------------- | ----------- |
  47995. * | 0 | OPAQUE | |
  47996. * | 1 | ALPHATEST | |
  47997. * | 2 | ALPHABLEND | |
  47998. * | 3 | ALPHATESTANDBLEND | |
  47999. *
  48000. */
  48001. transparencyMode: Nullable<number>;
  48002. /**
  48003. * Returns true if alpha blending should be disabled.
  48004. */
  48005. private readonly _disableAlphaBlending;
  48006. /**
  48007. * Specifies whether or not this material should be rendered in alpha blend mode.
  48008. */
  48009. needAlphaBlending(): boolean;
  48010. /**
  48011. * Specifies if the mesh will require alpha blending.
  48012. * @param mesh - BJS mesh.
  48013. */
  48014. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48015. /**
  48016. * Specifies whether or not this material should be rendered in alpha test mode.
  48017. */
  48018. needAlphaTesting(): boolean;
  48019. /**
  48020. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48021. */
  48022. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48023. /**
  48024. * Gets the texture used for the alpha test.
  48025. */
  48026. getAlphaTestTexture(): Nullable<BaseTexture>;
  48027. /**
  48028. * Specifies that the submesh is ready to be used.
  48029. * @param mesh - BJS mesh.
  48030. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48031. * @param useInstances - Specifies that instances should be used.
  48032. * @returns - boolean indicating that the submesh is ready or not.
  48033. */
  48034. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48035. /**
  48036. * Specifies if the material uses metallic roughness workflow.
  48037. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48038. */
  48039. isMetallicWorkflow(): boolean;
  48040. private _prepareEffect;
  48041. private _prepareDefines;
  48042. /**
  48043. * Force shader compilation
  48044. */
  48045. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48046. clipPlane: boolean;
  48047. }>): void;
  48048. /**
  48049. * Initializes the uniform buffer layout for the shader.
  48050. */
  48051. buildUniformLayout(): void;
  48052. /**
  48053. * Unbinds the material from the mesh
  48054. */
  48055. unbind(): void;
  48056. /**
  48057. * Binds the submesh data.
  48058. * @param world - The world matrix.
  48059. * @param mesh - The BJS mesh.
  48060. * @param subMesh - A submesh of the BJS mesh.
  48061. */
  48062. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48063. /**
  48064. * Returns the animatable textures.
  48065. * @returns - Array of animatable textures.
  48066. */
  48067. getAnimatables(): IAnimatable[];
  48068. /**
  48069. * Returns the texture used for reflections.
  48070. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48071. */
  48072. private _getReflectionTexture;
  48073. /**
  48074. * Returns an array of the actively used textures.
  48075. * @returns - Array of BaseTextures
  48076. */
  48077. getActiveTextures(): BaseTexture[];
  48078. /**
  48079. * Checks to see if a texture is used in the material.
  48080. * @param texture - Base texture to use.
  48081. * @returns - Boolean specifying if a texture is used in the material.
  48082. */
  48083. hasTexture(texture: BaseTexture): boolean;
  48084. /**
  48085. * Disposes the resources of the material.
  48086. * @param forceDisposeEffect - Forces the disposal of effects.
  48087. * @param forceDisposeTextures - Forces the disposal of all textures.
  48088. */
  48089. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48090. }
  48091. }
  48092. declare module BABYLON {
  48093. /**
  48094. * The Physically based material of BJS.
  48095. *
  48096. * This offers the main features of a standard PBR material.
  48097. * For more information, please refer to the documentation :
  48098. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48099. */
  48100. export class PBRMaterial extends PBRBaseMaterial {
  48101. /**
  48102. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48103. */
  48104. static readonly PBRMATERIAL_OPAQUE: number;
  48105. /**
  48106. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48107. */
  48108. static readonly PBRMATERIAL_ALPHATEST: number;
  48109. /**
  48110. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48111. */
  48112. static readonly PBRMATERIAL_ALPHABLEND: number;
  48113. /**
  48114. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48115. * They are also discarded below the alpha cutoff threshold to improve performances.
  48116. */
  48117. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48118. /**
  48119. * Defines the default value of how much AO map is occluding the analytical lights
  48120. * (point spot...).
  48121. */
  48122. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48123. /**
  48124. * Intensity of the direct lights e.g. the four lights available in your scene.
  48125. * This impacts both the direct diffuse and specular highlights.
  48126. */
  48127. directIntensity: number;
  48128. /**
  48129. * Intensity of the emissive part of the material.
  48130. * This helps controlling the emissive effect without modifying the emissive color.
  48131. */
  48132. emissiveIntensity: number;
  48133. /**
  48134. * Intensity of the environment e.g. how much the environment will light the object
  48135. * either through harmonics for rough material or through the refelction for shiny ones.
  48136. */
  48137. environmentIntensity: number;
  48138. /**
  48139. * This is a special control allowing the reduction of the specular highlights coming from the
  48140. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48141. */
  48142. specularIntensity: number;
  48143. /**
  48144. * Debug Control allowing disabling the bump map on this material.
  48145. */
  48146. disableBumpMap: boolean;
  48147. /**
  48148. * AKA Diffuse Texture in standard nomenclature.
  48149. */
  48150. albedoTexture: BaseTexture;
  48151. /**
  48152. * AKA Occlusion Texture in other nomenclature.
  48153. */
  48154. ambientTexture: BaseTexture;
  48155. /**
  48156. * AKA Occlusion Texture Intensity in other nomenclature.
  48157. */
  48158. ambientTextureStrength: number;
  48159. /**
  48160. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48161. * 1 means it completely occludes it
  48162. * 0 mean it has no impact
  48163. */
  48164. ambientTextureImpactOnAnalyticalLights: number;
  48165. /**
  48166. * Stores the alpha values in a texture.
  48167. */
  48168. opacityTexture: BaseTexture;
  48169. /**
  48170. * Stores the reflection values in a texture.
  48171. */
  48172. reflectionTexture: Nullable<BaseTexture>;
  48173. /**
  48174. * Stores the emissive values in a texture.
  48175. */
  48176. emissiveTexture: BaseTexture;
  48177. /**
  48178. * AKA Specular texture in other nomenclature.
  48179. */
  48180. reflectivityTexture: BaseTexture;
  48181. /**
  48182. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48183. */
  48184. metallicTexture: BaseTexture;
  48185. /**
  48186. * Specifies the metallic scalar of the metallic/roughness workflow.
  48187. * Can also be used to scale the metalness values of the metallic texture.
  48188. */
  48189. metallic: Nullable<number>;
  48190. /**
  48191. * Specifies the roughness scalar of the metallic/roughness workflow.
  48192. * Can also be used to scale the roughness values of the metallic texture.
  48193. */
  48194. roughness: Nullable<number>;
  48195. /**
  48196. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48197. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48198. */
  48199. microSurfaceTexture: BaseTexture;
  48200. /**
  48201. * Stores surface normal data used to displace a mesh in a texture.
  48202. */
  48203. bumpTexture: BaseTexture;
  48204. /**
  48205. * Stores the pre-calculated light information of a mesh in a texture.
  48206. */
  48207. lightmapTexture: BaseTexture;
  48208. /**
  48209. * Stores the refracted light information in a texture.
  48210. */
  48211. refractionTexture: Nullable<BaseTexture>;
  48212. /**
  48213. * The color of a material in ambient lighting.
  48214. */
  48215. ambientColor: Color3;
  48216. /**
  48217. * AKA Diffuse Color in other nomenclature.
  48218. */
  48219. albedoColor: Color3;
  48220. /**
  48221. * AKA Specular Color in other nomenclature.
  48222. */
  48223. reflectivityColor: Color3;
  48224. /**
  48225. * The color reflected from the material.
  48226. */
  48227. reflectionColor: Color3;
  48228. /**
  48229. * The color emitted from the material.
  48230. */
  48231. emissiveColor: Color3;
  48232. /**
  48233. * AKA Glossiness in other nomenclature.
  48234. */
  48235. microSurface: number;
  48236. /**
  48237. * source material index of refraction (IOR)' / 'destination material IOR.
  48238. */
  48239. indexOfRefraction: number;
  48240. /**
  48241. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48242. */
  48243. invertRefractionY: boolean;
  48244. /**
  48245. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48246. * Materials half opaque for instance using refraction could benefit from this control.
  48247. */
  48248. linkRefractionWithTransparency: boolean;
  48249. /**
  48250. * If true, the light map contains occlusion information instead of lighting info.
  48251. */
  48252. useLightmapAsShadowmap: boolean;
  48253. /**
  48254. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48255. */
  48256. useAlphaFromAlbedoTexture: boolean;
  48257. /**
  48258. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48259. */
  48260. forceAlphaTest: boolean;
  48261. /**
  48262. * Defines the alpha limits in alpha test mode.
  48263. */
  48264. alphaCutOff: number;
  48265. /**
  48266. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48267. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48268. */
  48269. useSpecularOverAlpha: boolean;
  48270. /**
  48271. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48272. */
  48273. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48274. /**
  48275. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48276. */
  48277. useRoughnessFromMetallicTextureAlpha: boolean;
  48278. /**
  48279. * Specifies if the metallic texture contains the roughness information in its green channel.
  48280. */
  48281. useRoughnessFromMetallicTextureGreen: boolean;
  48282. /**
  48283. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48284. */
  48285. useMetallnessFromMetallicTextureBlue: boolean;
  48286. /**
  48287. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48288. */
  48289. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48290. /**
  48291. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48292. */
  48293. useAmbientInGrayScale: boolean;
  48294. /**
  48295. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48296. * The material will try to infer what glossiness each pixel should be.
  48297. */
  48298. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48299. /**
  48300. * BJS is using an harcoded light falloff based on a manually sets up range.
  48301. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48302. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48303. */
  48304. /**
  48305. * BJS is using an harcoded light falloff based on a manually sets up range.
  48306. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48307. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48308. */
  48309. usePhysicalLightFalloff: boolean;
  48310. /**
  48311. * In order to support the falloff compatibility with gltf, a special mode has been added
  48312. * to reproduce the gltf light falloff.
  48313. */
  48314. /**
  48315. * In order to support the falloff compatibility with gltf, a special mode has been added
  48316. * to reproduce the gltf light falloff.
  48317. */
  48318. useGLTFLightFalloff: boolean;
  48319. /**
  48320. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48321. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48322. */
  48323. useRadianceOverAlpha: boolean;
  48324. /**
  48325. * Allows using an object space normal map (instead of tangent space).
  48326. */
  48327. useObjectSpaceNormalMap: boolean;
  48328. /**
  48329. * Allows using the bump map in parallax mode.
  48330. */
  48331. useParallax: boolean;
  48332. /**
  48333. * Allows using the bump map in parallax occlusion mode.
  48334. */
  48335. useParallaxOcclusion: boolean;
  48336. /**
  48337. * Controls the scale bias of the parallax mode.
  48338. */
  48339. parallaxScaleBias: number;
  48340. /**
  48341. * If sets to true, disables all the lights affecting the material.
  48342. */
  48343. disableLighting: boolean;
  48344. /**
  48345. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48346. */
  48347. forceIrradianceInFragment: boolean;
  48348. /**
  48349. * Number of Simultaneous lights allowed on the material.
  48350. */
  48351. maxSimultaneousLights: number;
  48352. /**
  48353. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48354. */
  48355. invertNormalMapX: boolean;
  48356. /**
  48357. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48358. */
  48359. invertNormalMapY: boolean;
  48360. /**
  48361. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48362. */
  48363. twoSidedLighting: boolean;
  48364. /**
  48365. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48366. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48367. */
  48368. useAlphaFresnel: boolean;
  48369. /**
  48370. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48371. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48372. */
  48373. useLinearAlphaFresnel: boolean;
  48374. /**
  48375. * Let user defines the brdf lookup texture used for IBL.
  48376. * A default 8bit version is embedded but you could point at :
  48377. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48378. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48379. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48380. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48381. */
  48382. environmentBRDFTexture: Nullable<BaseTexture>;
  48383. /**
  48384. * Force normal to face away from face.
  48385. */
  48386. forceNormalForward: boolean;
  48387. /**
  48388. * Enables specular anti aliasing in the PBR shader.
  48389. * It will both interacts on the Geometry for analytical and IBL lighting.
  48390. * It also prefilter the roughness map based on the bump values.
  48391. */
  48392. enableSpecularAntiAliasing: boolean;
  48393. /**
  48394. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48395. * makes the reflect vector face the model (under horizon).
  48396. */
  48397. useHorizonOcclusion: boolean;
  48398. /**
  48399. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48400. * too much the area relying on ambient texture to define their ambient occlusion.
  48401. */
  48402. useRadianceOcclusion: boolean;
  48403. /**
  48404. * If set to true, no lighting calculations will be applied.
  48405. */
  48406. unlit: boolean;
  48407. /**
  48408. * Gets the image processing configuration used either in this material.
  48409. */
  48410. /**
  48411. * Sets the Default image processing configuration used either in the this material.
  48412. *
  48413. * If sets to null, the scene one is in use.
  48414. */
  48415. imageProcessingConfiguration: ImageProcessingConfiguration;
  48416. /**
  48417. * Gets wether the color curves effect is enabled.
  48418. */
  48419. /**
  48420. * Sets wether the color curves effect is enabled.
  48421. */
  48422. cameraColorCurvesEnabled: boolean;
  48423. /**
  48424. * Gets wether the color grading effect is enabled.
  48425. */
  48426. /**
  48427. * Gets wether the color grading effect is enabled.
  48428. */
  48429. cameraColorGradingEnabled: boolean;
  48430. /**
  48431. * Gets wether tonemapping is enabled or not.
  48432. */
  48433. /**
  48434. * Sets wether tonemapping is enabled or not
  48435. */
  48436. cameraToneMappingEnabled: boolean;
  48437. /**
  48438. * The camera exposure used on this material.
  48439. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48440. * This corresponds to a photographic exposure.
  48441. */
  48442. /**
  48443. * The camera exposure used on this material.
  48444. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48445. * This corresponds to a photographic exposure.
  48446. */
  48447. cameraExposure: number;
  48448. /**
  48449. * Gets The camera contrast used on this material.
  48450. */
  48451. /**
  48452. * Sets The camera contrast used on this material.
  48453. */
  48454. cameraContrast: number;
  48455. /**
  48456. * Gets the Color Grading 2D Lookup Texture.
  48457. */
  48458. /**
  48459. * Sets the Color Grading 2D Lookup Texture.
  48460. */
  48461. cameraColorGradingTexture: Nullable<BaseTexture>;
  48462. /**
  48463. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48464. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48465. * 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;
  48466. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48467. */
  48468. /**
  48469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48471. * 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;
  48472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48473. */
  48474. cameraColorCurves: Nullable<ColorCurves>;
  48475. /**
  48476. * Instantiates a new PBRMaterial instance.
  48477. *
  48478. * @param name The material name
  48479. * @param scene The scene the material will be use in.
  48480. */
  48481. constructor(name: string, scene: Scene);
  48482. /**
  48483. * Returns the name of this material class.
  48484. */
  48485. getClassName(): string;
  48486. /**
  48487. * Makes a duplicate of the current material.
  48488. * @param name - name to use for the new material.
  48489. */
  48490. clone(name: string): PBRMaterial;
  48491. /**
  48492. * Serializes this PBR Material.
  48493. * @returns - An object with the serialized material.
  48494. */
  48495. serialize(): any;
  48496. /**
  48497. * Parses a PBR Material from a serialized object.
  48498. * @param source - Serialized object.
  48499. * @param scene - BJS scene instance.
  48500. * @param rootUrl - url for the scene object
  48501. * @returns - PBRMaterial
  48502. */
  48503. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48504. }
  48505. }
  48506. declare module BABYLON {
  48507. /**
  48508. * Direct draw surface info
  48509. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48510. */
  48511. export interface DDSInfo {
  48512. /**
  48513. * Width of the texture
  48514. */
  48515. width: number;
  48516. /**
  48517. * Width of the texture
  48518. */
  48519. height: number;
  48520. /**
  48521. * Number of Mipmaps for the texture
  48522. * @see https://en.wikipedia.org/wiki/Mipmap
  48523. */
  48524. mipmapCount: number;
  48525. /**
  48526. * If the textures format is a known fourCC format
  48527. * @see https://www.fourcc.org/
  48528. */
  48529. isFourCC: boolean;
  48530. /**
  48531. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48532. */
  48533. isRGB: boolean;
  48534. /**
  48535. * If the texture is a lumincance format
  48536. */
  48537. isLuminance: boolean;
  48538. /**
  48539. * If this is a cube texture
  48540. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48541. */
  48542. isCube: boolean;
  48543. /**
  48544. * If the texture is a compressed format eg. FOURCC_DXT1
  48545. */
  48546. isCompressed: boolean;
  48547. /**
  48548. * The dxgiFormat of the texture
  48549. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48550. */
  48551. dxgiFormat: number;
  48552. /**
  48553. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48554. */
  48555. textureType: number;
  48556. /**
  48557. * Sphericle polynomial created for the dds texture
  48558. */
  48559. sphericalPolynomial?: SphericalPolynomial;
  48560. }
  48561. /**
  48562. * Class used to provide DDS decompression tools
  48563. */
  48564. export class DDSTools {
  48565. /**
  48566. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48567. */
  48568. static StoreLODInAlphaChannel: boolean;
  48569. /**
  48570. * Gets DDS information from an array buffer
  48571. * @param arrayBuffer defines the array buffer to read data from
  48572. * @returns the DDS information
  48573. */
  48574. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48575. private static _FloatView;
  48576. private static _Int32View;
  48577. private static _ToHalfFloat;
  48578. private static _FromHalfFloat;
  48579. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48580. private static _GetHalfFloatRGBAArrayBuffer;
  48581. private static _GetFloatRGBAArrayBuffer;
  48582. private static _GetFloatAsUIntRGBAArrayBuffer;
  48583. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48584. private static _GetRGBAArrayBuffer;
  48585. private static _ExtractLongWordOrder;
  48586. private static _GetRGBArrayBuffer;
  48587. private static _GetLuminanceArrayBuffer;
  48588. /**
  48589. * Uploads DDS Levels to a Babylon Texture
  48590. * @hidden
  48591. */
  48592. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48593. }
  48594. interface ThinEngine {
  48595. /**
  48596. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48597. * @param rootUrl defines the url where the file to load is located
  48598. * @param scene defines the current scene
  48599. * @param lodScale defines scale to apply to the mip map selection
  48600. * @param lodOffset defines offset to apply to the mip map selection
  48601. * @param onLoad defines an optional callback raised when the texture is loaded
  48602. * @param onError defines an optional callback raised if there is an issue to load the texture
  48603. * @param format defines the format of the data
  48604. * @param forcedExtension defines the extension to use to pick the right loader
  48605. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48606. * @returns the cube texture as an InternalTexture
  48607. */
  48608. 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;
  48609. }
  48610. }
  48611. declare module BABYLON {
  48612. /**
  48613. * Implementation of the DDS Texture Loader.
  48614. * @hidden
  48615. */
  48616. export class _DDSTextureLoader implements IInternalTextureLoader {
  48617. /**
  48618. * Defines wether the loader supports cascade loading the different faces.
  48619. */
  48620. readonly supportCascades: boolean;
  48621. /**
  48622. * This returns if the loader support the current file information.
  48623. * @param extension defines the file extension of the file being loaded
  48624. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48625. * @param fallback defines the fallback internal texture if any
  48626. * @param isBase64 defines whether the texture is encoded as a base64
  48627. * @param isBuffer defines whether the texture data are stored as a buffer
  48628. * @returns true if the loader can load the specified file
  48629. */
  48630. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48631. /**
  48632. * Transform the url before loading if required.
  48633. * @param rootUrl the url of the texture
  48634. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48635. * @returns the transformed texture
  48636. */
  48637. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48638. /**
  48639. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48640. * @param rootUrl the url of the texture
  48641. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48642. * @returns the fallback texture
  48643. */
  48644. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48645. /**
  48646. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48647. * @param data contains the texture data
  48648. * @param texture defines the BabylonJS internal texture
  48649. * @param createPolynomials will be true if polynomials have been requested
  48650. * @param onLoad defines the callback to trigger once the texture is ready
  48651. * @param onError defines the callback to trigger in case of error
  48652. */
  48653. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48654. /**
  48655. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48656. * @param data contains the texture data
  48657. * @param texture defines the BabylonJS internal texture
  48658. * @param callback defines the method to call once ready to upload
  48659. */
  48660. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48661. }
  48662. }
  48663. declare module BABYLON {
  48664. /**
  48665. * Implementation of the ENV Texture Loader.
  48666. * @hidden
  48667. */
  48668. export class _ENVTextureLoader implements IInternalTextureLoader {
  48669. /**
  48670. * Defines wether the loader supports cascade loading the different faces.
  48671. */
  48672. readonly supportCascades: boolean;
  48673. /**
  48674. * This returns if the loader support the current file information.
  48675. * @param extension defines the file extension of the file being loaded
  48676. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48677. * @param fallback defines the fallback internal texture if any
  48678. * @param isBase64 defines whether the texture is encoded as a base64
  48679. * @param isBuffer defines whether the texture data are stored as a buffer
  48680. * @returns true if the loader can load the specified file
  48681. */
  48682. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48683. /**
  48684. * Transform the url before loading if required.
  48685. * @param rootUrl the url of the texture
  48686. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48687. * @returns the transformed texture
  48688. */
  48689. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48690. /**
  48691. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48692. * @param rootUrl the url of the texture
  48693. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48694. * @returns the fallback texture
  48695. */
  48696. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48697. /**
  48698. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48699. * @param data contains the texture data
  48700. * @param texture defines the BabylonJS internal texture
  48701. * @param createPolynomials will be true if polynomials have been requested
  48702. * @param onLoad defines the callback to trigger once the texture is ready
  48703. * @param onError defines the callback to trigger in case of error
  48704. */
  48705. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48706. /**
  48707. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48708. * @param data contains the texture data
  48709. * @param texture defines the BabylonJS internal texture
  48710. * @param callback defines the method to call once ready to upload
  48711. */
  48712. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48713. }
  48714. }
  48715. declare module BABYLON {
  48716. /**
  48717. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48718. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48719. */
  48720. export class KhronosTextureContainer {
  48721. /** contents of the KTX container file */
  48722. arrayBuffer: any;
  48723. private static HEADER_LEN;
  48724. private static COMPRESSED_2D;
  48725. private static COMPRESSED_3D;
  48726. private static TEX_2D;
  48727. private static TEX_3D;
  48728. /**
  48729. * Gets the openGL type
  48730. */
  48731. glType: number;
  48732. /**
  48733. * Gets the openGL type size
  48734. */
  48735. glTypeSize: number;
  48736. /**
  48737. * Gets the openGL format
  48738. */
  48739. glFormat: number;
  48740. /**
  48741. * Gets the openGL internal format
  48742. */
  48743. glInternalFormat: number;
  48744. /**
  48745. * Gets the base internal format
  48746. */
  48747. glBaseInternalFormat: number;
  48748. /**
  48749. * Gets image width in pixel
  48750. */
  48751. pixelWidth: number;
  48752. /**
  48753. * Gets image height in pixel
  48754. */
  48755. pixelHeight: number;
  48756. /**
  48757. * Gets image depth in pixels
  48758. */
  48759. pixelDepth: number;
  48760. /**
  48761. * Gets the number of array elements
  48762. */
  48763. numberOfArrayElements: number;
  48764. /**
  48765. * Gets the number of faces
  48766. */
  48767. numberOfFaces: number;
  48768. /**
  48769. * Gets the number of mipmap levels
  48770. */
  48771. numberOfMipmapLevels: number;
  48772. /**
  48773. * Gets the bytes of key value data
  48774. */
  48775. bytesOfKeyValueData: number;
  48776. /**
  48777. * Gets the load type
  48778. */
  48779. loadType: number;
  48780. /**
  48781. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48782. */
  48783. isInvalid: boolean;
  48784. /**
  48785. * Creates a new KhronosTextureContainer
  48786. * @param arrayBuffer contents of the KTX container file
  48787. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48788. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48789. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48790. */
  48791. constructor(
  48792. /** contents of the KTX container file */
  48793. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48794. /**
  48795. * Uploads KTX content to a Babylon Texture.
  48796. * It is assumed that the texture has already been created & is currently bound
  48797. * @hidden
  48798. */
  48799. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48800. private _upload2DCompressedLevels;
  48801. }
  48802. }
  48803. declare module BABYLON {
  48804. /**
  48805. * Implementation of the KTX Texture Loader.
  48806. * @hidden
  48807. */
  48808. export class _KTXTextureLoader implements IInternalTextureLoader {
  48809. /**
  48810. * Defines wether the loader supports cascade loading the different faces.
  48811. */
  48812. readonly supportCascades: boolean;
  48813. /**
  48814. * This returns if the loader support the current file information.
  48815. * @param extension defines the file extension of the file being loaded
  48816. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48817. * @param fallback defines the fallback internal texture if any
  48818. * @param isBase64 defines whether the texture is encoded as a base64
  48819. * @param isBuffer defines whether the texture data are stored as a buffer
  48820. * @returns true if the loader can load the specified file
  48821. */
  48822. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48823. /**
  48824. * Transform the url before loading if required.
  48825. * @param rootUrl the url of the texture
  48826. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48827. * @returns the transformed texture
  48828. */
  48829. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48830. /**
  48831. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48832. * @param rootUrl the url of the texture
  48833. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48834. * @returns the fallback texture
  48835. */
  48836. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48837. /**
  48838. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48839. * @param data contains the texture data
  48840. * @param texture defines the BabylonJS internal texture
  48841. * @param createPolynomials will be true if polynomials have been requested
  48842. * @param onLoad defines the callback to trigger once the texture is ready
  48843. * @param onError defines the callback to trigger in case of error
  48844. */
  48845. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48846. /**
  48847. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48848. * @param data contains the texture data
  48849. * @param texture defines the BabylonJS internal texture
  48850. * @param callback defines the method to call once ready to upload
  48851. */
  48852. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48853. }
  48854. }
  48855. declare module BABYLON {
  48856. /**
  48857. * Options for the default xr helper
  48858. */
  48859. export class WebXRDefaultExperienceOptions {
  48860. /**
  48861. * Floor meshes that should be used for teleporting
  48862. */
  48863. floorMeshes: Array<AbstractMesh>;
  48864. }
  48865. /**
  48866. * Default experience which provides a similar setup to the previous webVRExperience
  48867. */
  48868. export class WebXRDefaultExperience {
  48869. /**
  48870. * Base experience
  48871. */
  48872. baseExperience: WebXRExperienceHelper;
  48873. /**
  48874. * Input experience extension
  48875. */
  48876. input: WebXRInput;
  48877. /**
  48878. * Loads the controller models
  48879. */
  48880. controllerModelLoader: WebXRControllerModelLoader;
  48881. /**
  48882. * Enables laser pointer and selection
  48883. */
  48884. pointerSelection: WebXRControllerPointerSelection;
  48885. /**
  48886. * Enables teleportation
  48887. */
  48888. teleportation: WebXRControllerTeleportation;
  48889. /**
  48890. * Enables ui for enetering/exiting xr
  48891. */
  48892. enterExitUI: WebXREnterExitUI;
  48893. /**
  48894. * Default output canvas xr should render to
  48895. */
  48896. outputCanvas: WebXRManagedOutputCanvas;
  48897. /**
  48898. * Creates the default xr experience
  48899. * @param scene scene
  48900. * @param options options for basic configuration
  48901. * @returns resulting WebXRDefaultExperience
  48902. */
  48903. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48904. private constructor();
  48905. /**
  48906. * DIsposes of the experience helper
  48907. */
  48908. dispose(): void;
  48909. }
  48910. }
  48911. declare module BABYLON {
  48912. /** @hidden */
  48913. export var _forceSceneHelpersToBundle: boolean;
  48914. interface Scene {
  48915. /**
  48916. * Creates a default light for the scene.
  48917. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48918. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48919. */
  48920. createDefaultLight(replace?: boolean): void;
  48921. /**
  48922. * Creates a default camera for the scene.
  48923. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48924. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48925. * @param replace has default false, when true replaces the active camera in the scene
  48926. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48927. */
  48928. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48929. /**
  48930. * Creates a default camera and a default light.
  48931. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48932. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48933. * @param replace has the default false, when true replaces the active camera/light in the scene
  48934. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48935. */
  48936. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48937. /**
  48938. * Creates a new sky box
  48939. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48940. * @param environmentTexture defines the texture to use as environment texture
  48941. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48942. * @param scale defines the overall scale of the skybox
  48943. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48944. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48945. * @returns a new mesh holding the sky box
  48946. */
  48947. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48948. /**
  48949. * Creates a new environment
  48950. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48951. * @param options defines the options you can use to configure the environment
  48952. * @returns the new EnvironmentHelper
  48953. */
  48954. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48955. /**
  48956. * Creates a new VREXperienceHelper
  48957. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48958. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48959. * @returns a new VREXperienceHelper
  48960. */
  48961. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48962. /**
  48963. * Creates a new WebXRDefaultExperience
  48964. * @see http://doc.babylonjs.com/how_to/webxr
  48965. * @param options experience options
  48966. * @returns a promise for a new WebXRDefaultExperience
  48967. */
  48968. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48969. }
  48970. }
  48971. declare module BABYLON {
  48972. /**
  48973. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48974. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48975. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48976. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48977. */
  48978. export class VideoDome extends TransformNode {
  48979. /**
  48980. * Define the video source as a Monoscopic panoramic 360 video.
  48981. */
  48982. static readonly MODE_MONOSCOPIC: number;
  48983. /**
  48984. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48985. */
  48986. static readonly MODE_TOPBOTTOM: number;
  48987. /**
  48988. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48989. */
  48990. static readonly MODE_SIDEBYSIDE: number;
  48991. private _halfDome;
  48992. private _useDirectMapping;
  48993. /**
  48994. * The video texture being displayed on the sphere
  48995. */
  48996. protected _videoTexture: VideoTexture;
  48997. /**
  48998. * Gets the video texture being displayed on the sphere
  48999. */
  49000. readonly videoTexture: VideoTexture;
  49001. /**
  49002. * The skybox material
  49003. */
  49004. protected _material: BackgroundMaterial;
  49005. /**
  49006. * The surface used for the skybox
  49007. */
  49008. protected _mesh: Mesh;
  49009. /**
  49010. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49011. */
  49012. private _halfDomeMask;
  49013. /**
  49014. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49015. * Also see the options.resolution property.
  49016. */
  49017. fovMultiplier: number;
  49018. private _videoMode;
  49019. /**
  49020. * Gets or set the current video mode for the video. It can be:
  49021. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49022. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49023. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49024. */
  49025. videoMode: number;
  49026. /**
  49027. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49028. *
  49029. */
  49030. /**
  49031. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49032. */
  49033. halfDome: boolean;
  49034. /**
  49035. * Oberserver used in Stereoscopic VR Mode.
  49036. */
  49037. private _onBeforeCameraRenderObserver;
  49038. /**
  49039. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49040. * @param name Element's name, child elements will append suffixes for their own names.
  49041. * @param urlsOrVideo defines the url(s) or the video element to use
  49042. * @param options An object containing optional or exposed sub element properties
  49043. */
  49044. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49045. resolution?: number;
  49046. clickToPlay?: boolean;
  49047. autoPlay?: boolean;
  49048. loop?: boolean;
  49049. size?: number;
  49050. poster?: string;
  49051. faceForward?: boolean;
  49052. useDirectMapping?: boolean;
  49053. halfDomeMode?: boolean;
  49054. }, scene: Scene);
  49055. private _changeVideoMode;
  49056. /**
  49057. * Releases resources associated with this node.
  49058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49060. */
  49061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49062. }
  49063. }
  49064. declare module BABYLON {
  49065. /**
  49066. * This class can be used to get instrumentation data from a Babylon engine
  49067. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49068. */
  49069. export class EngineInstrumentation implements IDisposable {
  49070. /**
  49071. * Define the instrumented engine.
  49072. */
  49073. engine: Engine;
  49074. private _captureGPUFrameTime;
  49075. private _gpuFrameTimeToken;
  49076. private _gpuFrameTime;
  49077. private _captureShaderCompilationTime;
  49078. private _shaderCompilationTime;
  49079. private _onBeginFrameObserver;
  49080. private _onEndFrameObserver;
  49081. private _onBeforeShaderCompilationObserver;
  49082. private _onAfterShaderCompilationObserver;
  49083. /**
  49084. * Gets the perf counter used for GPU frame time
  49085. */
  49086. readonly gpuFrameTimeCounter: PerfCounter;
  49087. /**
  49088. * Gets the GPU frame time capture status
  49089. */
  49090. /**
  49091. * Enable or disable the GPU frame time capture
  49092. */
  49093. captureGPUFrameTime: boolean;
  49094. /**
  49095. * Gets the perf counter used for shader compilation time
  49096. */
  49097. readonly shaderCompilationTimeCounter: PerfCounter;
  49098. /**
  49099. * Gets the shader compilation time capture status
  49100. */
  49101. /**
  49102. * Enable or disable the shader compilation time capture
  49103. */
  49104. captureShaderCompilationTime: boolean;
  49105. /**
  49106. * Instantiates a new engine instrumentation.
  49107. * This class can be used to get instrumentation data from a Babylon engine
  49108. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49109. * @param engine Defines the engine to instrument
  49110. */
  49111. constructor(
  49112. /**
  49113. * Define the instrumented engine.
  49114. */
  49115. engine: Engine);
  49116. /**
  49117. * Dispose and release associated resources.
  49118. */
  49119. dispose(): void;
  49120. }
  49121. }
  49122. declare module BABYLON {
  49123. /**
  49124. * This class can be used to get instrumentation data from a Babylon engine
  49125. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49126. */
  49127. export class SceneInstrumentation implements IDisposable {
  49128. /**
  49129. * Defines the scene to instrument
  49130. */
  49131. scene: Scene;
  49132. private _captureActiveMeshesEvaluationTime;
  49133. private _activeMeshesEvaluationTime;
  49134. private _captureRenderTargetsRenderTime;
  49135. private _renderTargetsRenderTime;
  49136. private _captureFrameTime;
  49137. private _frameTime;
  49138. private _captureRenderTime;
  49139. private _renderTime;
  49140. private _captureInterFrameTime;
  49141. private _interFrameTime;
  49142. private _captureParticlesRenderTime;
  49143. private _particlesRenderTime;
  49144. private _captureSpritesRenderTime;
  49145. private _spritesRenderTime;
  49146. private _capturePhysicsTime;
  49147. private _physicsTime;
  49148. private _captureAnimationsTime;
  49149. private _animationsTime;
  49150. private _captureCameraRenderTime;
  49151. private _cameraRenderTime;
  49152. private _onBeforeActiveMeshesEvaluationObserver;
  49153. private _onAfterActiveMeshesEvaluationObserver;
  49154. private _onBeforeRenderTargetsRenderObserver;
  49155. private _onAfterRenderTargetsRenderObserver;
  49156. private _onAfterRenderObserver;
  49157. private _onBeforeDrawPhaseObserver;
  49158. private _onAfterDrawPhaseObserver;
  49159. private _onBeforeAnimationsObserver;
  49160. private _onBeforeParticlesRenderingObserver;
  49161. private _onAfterParticlesRenderingObserver;
  49162. private _onBeforeSpritesRenderingObserver;
  49163. private _onAfterSpritesRenderingObserver;
  49164. private _onBeforePhysicsObserver;
  49165. private _onAfterPhysicsObserver;
  49166. private _onAfterAnimationsObserver;
  49167. private _onBeforeCameraRenderObserver;
  49168. private _onAfterCameraRenderObserver;
  49169. /**
  49170. * Gets the perf counter used for active meshes evaluation time
  49171. */
  49172. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49173. /**
  49174. * Gets the active meshes evaluation time capture status
  49175. */
  49176. /**
  49177. * Enable or disable the active meshes evaluation time capture
  49178. */
  49179. captureActiveMeshesEvaluationTime: boolean;
  49180. /**
  49181. * Gets the perf counter used for render targets render time
  49182. */
  49183. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49184. /**
  49185. * Gets the render targets render time capture status
  49186. */
  49187. /**
  49188. * Enable or disable the render targets render time capture
  49189. */
  49190. captureRenderTargetsRenderTime: boolean;
  49191. /**
  49192. * Gets the perf counter used for particles render time
  49193. */
  49194. readonly particlesRenderTimeCounter: PerfCounter;
  49195. /**
  49196. * Gets the particles render time capture status
  49197. */
  49198. /**
  49199. * Enable or disable the particles render time capture
  49200. */
  49201. captureParticlesRenderTime: boolean;
  49202. /**
  49203. * Gets the perf counter used for sprites render time
  49204. */
  49205. readonly spritesRenderTimeCounter: PerfCounter;
  49206. /**
  49207. * Gets the sprites render time capture status
  49208. */
  49209. /**
  49210. * Enable or disable the sprites render time capture
  49211. */
  49212. captureSpritesRenderTime: boolean;
  49213. /**
  49214. * Gets the perf counter used for physics time
  49215. */
  49216. readonly physicsTimeCounter: PerfCounter;
  49217. /**
  49218. * Gets the physics time capture status
  49219. */
  49220. /**
  49221. * Enable or disable the physics time capture
  49222. */
  49223. capturePhysicsTime: boolean;
  49224. /**
  49225. * Gets the perf counter used for animations time
  49226. */
  49227. readonly animationsTimeCounter: PerfCounter;
  49228. /**
  49229. * Gets the animations time capture status
  49230. */
  49231. /**
  49232. * Enable or disable the animations time capture
  49233. */
  49234. captureAnimationsTime: boolean;
  49235. /**
  49236. * Gets the perf counter used for frame time capture
  49237. */
  49238. readonly frameTimeCounter: PerfCounter;
  49239. /**
  49240. * Gets the frame time capture status
  49241. */
  49242. /**
  49243. * Enable or disable the frame time capture
  49244. */
  49245. captureFrameTime: boolean;
  49246. /**
  49247. * Gets the perf counter used for inter-frames time capture
  49248. */
  49249. readonly interFrameTimeCounter: PerfCounter;
  49250. /**
  49251. * Gets the inter-frames time capture status
  49252. */
  49253. /**
  49254. * Enable or disable the inter-frames time capture
  49255. */
  49256. captureInterFrameTime: boolean;
  49257. /**
  49258. * Gets the perf counter used for render time capture
  49259. */
  49260. readonly renderTimeCounter: PerfCounter;
  49261. /**
  49262. * Gets the render time capture status
  49263. */
  49264. /**
  49265. * Enable or disable the render time capture
  49266. */
  49267. captureRenderTime: boolean;
  49268. /**
  49269. * Gets the perf counter used for camera render time capture
  49270. */
  49271. readonly cameraRenderTimeCounter: PerfCounter;
  49272. /**
  49273. * Gets the camera render time capture status
  49274. */
  49275. /**
  49276. * Enable or disable the camera render time capture
  49277. */
  49278. captureCameraRenderTime: boolean;
  49279. /**
  49280. * Gets the perf counter used for draw calls
  49281. */
  49282. readonly drawCallsCounter: PerfCounter;
  49283. /**
  49284. * Instantiates a new scene instrumentation.
  49285. * This class can be used to get instrumentation data from a Babylon engine
  49286. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49287. * @param scene Defines the scene to instrument
  49288. */
  49289. constructor(
  49290. /**
  49291. * Defines the scene to instrument
  49292. */
  49293. scene: Scene);
  49294. /**
  49295. * Dispose and release associated resources.
  49296. */
  49297. dispose(): void;
  49298. }
  49299. }
  49300. declare module BABYLON {
  49301. /** @hidden */
  49302. export var glowMapGenerationPixelShader: {
  49303. name: string;
  49304. shader: string;
  49305. };
  49306. }
  49307. declare module BABYLON {
  49308. /** @hidden */
  49309. export var glowMapGenerationVertexShader: {
  49310. name: string;
  49311. shader: string;
  49312. };
  49313. }
  49314. declare module BABYLON {
  49315. /**
  49316. * Effect layer options. This helps customizing the behaviour
  49317. * of the effect layer.
  49318. */
  49319. export interface IEffectLayerOptions {
  49320. /**
  49321. * Multiplication factor apply to the canvas size to compute the render target size
  49322. * used to generated the objects (the smaller the faster).
  49323. */
  49324. mainTextureRatio: number;
  49325. /**
  49326. * Enforces a fixed size texture to ensure effect stability across devices.
  49327. */
  49328. mainTextureFixedSize?: number;
  49329. /**
  49330. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49331. */
  49332. alphaBlendingMode: number;
  49333. /**
  49334. * The camera attached to the layer.
  49335. */
  49336. camera: Nullable<Camera>;
  49337. /**
  49338. * The rendering group to draw the layer in.
  49339. */
  49340. renderingGroupId: number;
  49341. }
  49342. /**
  49343. * The effect layer Helps adding post process effect blended with the main pass.
  49344. *
  49345. * This can be for instance use to generate glow or higlight effects on the scene.
  49346. *
  49347. * The effect layer class can not be used directly and is intented to inherited from to be
  49348. * customized per effects.
  49349. */
  49350. export abstract class EffectLayer {
  49351. private _vertexBuffers;
  49352. private _indexBuffer;
  49353. private _cachedDefines;
  49354. private _effectLayerMapGenerationEffect;
  49355. private _effectLayerOptions;
  49356. private _mergeEffect;
  49357. protected _scene: Scene;
  49358. protected _engine: Engine;
  49359. protected _maxSize: number;
  49360. protected _mainTextureDesiredSize: ISize;
  49361. protected _mainTexture: RenderTargetTexture;
  49362. protected _shouldRender: boolean;
  49363. protected _postProcesses: PostProcess[];
  49364. protected _textures: BaseTexture[];
  49365. protected _emissiveTextureAndColor: {
  49366. texture: Nullable<BaseTexture>;
  49367. color: Color4;
  49368. };
  49369. /**
  49370. * The name of the layer
  49371. */
  49372. name: string;
  49373. /**
  49374. * The clear color of the texture used to generate the glow map.
  49375. */
  49376. neutralColor: Color4;
  49377. /**
  49378. * Specifies wether the highlight layer is enabled or not.
  49379. */
  49380. isEnabled: boolean;
  49381. /**
  49382. * Gets the camera attached to the layer.
  49383. */
  49384. readonly camera: Nullable<Camera>;
  49385. /**
  49386. * Gets the rendering group id the layer should render in.
  49387. */
  49388. renderingGroupId: number;
  49389. /**
  49390. * An event triggered when the effect layer has been disposed.
  49391. */
  49392. onDisposeObservable: Observable<EffectLayer>;
  49393. /**
  49394. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49395. */
  49396. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49397. /**
  49398. * An event triggered when the generated texture is being merged in the scene.
  49399. */
  49400. onBeforeComposeObservable: Observable<EffectLayer>;
  49401. /**
  49402. * An event triggered when the generated texture has been merged in the scene.
  49403. */
  49404. onAfterComposeObservable: Observable<EffectLayer>;
  49405. /**
  49406. * An event triggered when the efffect layer changes its size.
  49407. */
  49408. onSizeChangedObservable: Observable<EffectLayer>;
  49409. /** @hidden */
  49410. static _SceneComponentInitialization: (scene: Scene) => void;
  49411. /**
  49412. * Instantiates a new effect Layer and references it in the scene.
  49413. * @param name The name of the layer
  49414. * @param scene The scene to use the layer in
  49415. */
  49416. constructor(
  49417. /** The Friendly of the effect in the scene */
  49418. name: string, scene: Scene);
  49419. /**
  49420. * Get the effect name of the layer.
  49421. * @return The effect name
  49422. */
  49423. abstract getEffectName(): string;
  49424. /**
  49425. * Checks for the readiness of the element composing the layer.
  49426. * @param subMesh the mesh to check for
  49427. * @param useInstances specify wether or not to use instances to render the mesh
  49428. * @return true if ready otherwise, false
  49429. */
  49430. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49431. /**
  49432. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49433. * @returns true if the effect requires stencil during the main canvas render pass.
  49434. */
  49435. abstract needStencil(): boolean;
  49436. /**
  49437. * Create the merge effect. This is the shader use to blit the information back
  49438. * to the main canvas at the end of the scene rendering.
  49439. * @returns The effect containing the shader used to merge the effect on the main canvas
  49440. */
  49441. protected abstract _createMergeEffect(): Effect;
  49442. /**
  49443. * Creates the render target textures and post processes used in the effect layer.
  49444. */
  49445. protected abstract _createTextureAndPostProcesses(): void;
  49446. /**
  49447. * Implementation specific of rendering the generating effect on the main canvas.
  49448. * @param effect The effect used to render through
  49449. */
  49450. protected abstract _internalRender(effect: Effect): void;
  49451. /**
  49452. * Sets the required values for both the emissive texture and and the main color.
  49453. */
  49454. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49455. /**
  49456. * Free any resources and references associated to a mesh.
  49457. * Internal use
  49458. * @param mesh The mesh to free.
  49459. */
  49460. abstract _disposeMesh(mesh: Mesh): void;
  49461. /**
  49462. * Serializes this layer (Glow or Highlight for example)
  49463. * @returns a serialized layer object
  49464. */
  49465. abstract serialize?(): any;
  49466. /**
  49467. * Initializes the effect layer with the required options.
  49468. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49469. */
  49470. protected _init(options: Partial<IEffectLayerOptions>): void;
  49471. /**
  49472. * Generates the index buffer of the full screen quad blending to the main canvas.
  49473. */
  49474. private _generateIndexBuffer;
  49475. /**
  49476. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49477. */
  49478. private _generateVertexBuffer;
  49479. /**
  49480. * Sets the main texture desired size which is the closest power of two
  49481. * of the engine canvas size.
  49482. */
  49483. private _setMainTextureSize;
  49484. /**
  49485. * Creates the main texture for the effect layer.
  49486. */
  49487. protected _createMainTexture(): void;
  49488. /**
  49489. * Adds specific effects defines.
  49490. * @param defines The defines to add specifics to.
  49491. */
  49492. protected _addCustomEffectDefines(defines: string[]): void;
  49493. /**
  49494. * Checks for the readiness of the element composing the layer.
  49495. * @param subMesh the mesh to check for
  49496. * @param useInstances specify wether or not to use instances to render the mesh
  49497. * @param emissiveTexture the associated emissive texture used to generate the glow
  49498. * @return true if ready otherwise, false
  49499. */
  49500. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49501. /**
  49502. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49503. */
  49504. render(): void;
  49505. /**
  49506. * Determine if a given mesh will be used in the current effect.
  49507. * @param mesh mesh to test
  49508. * @returns true if the mesh will be used
  49509. */
  49510. hasMesh(mesh: AbstractMesh): boolean;
  49511. /**
  49512. * Returns true if the layer contains information to display, otherwise false.
  49513. * @returns true if the glow layer should be rendered
  49514. */
  49515. shouldRender(): boolean;
  49516. /**
  49517. * Returns true if the mesh should render, otherwise false.
  49518. * @param mesh The mesh to render
  49519. * @returns true if it should render otherwise false
  49520. */
  49521. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49522. /**
  49523. * Returns true if the mesh can be rendered, otherwise false.
  49524. * @param mesh The mesh to render
  49525. * @param material The material used on the mesh
  49526. * @returns true if it can be rendered otherwise false
  49527. */
  49528. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49529. /**
  49530. * Returns true if the mesh should render, otherwise false.
  49531. * @param mesh The mesh to render
  49532. * @returns true if it should render otherwise false
  49533. */
  49534. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49535. /**
  49536. * Renders the submesh passed in parameter to the generation map.
  49537. */
  49538. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49539. /**
  49540. * Rebuild the required buffers.
  49541. * @hidden Internal use only.
  49542. */
  49543. _rebuild(): void;
  49544. /**
  49545. * Dispose only the render target textures and post process.
  49546. */
  49547. private _disposeTextureAndPostProcesses;
  49548. /**
  49549. * Dispose the highlight layer and free resources.
  49550. */
  49551. dispose(): void;
  49552. /**
  49553. * Gets the class name of the effect layer
  49554. * @returns the string with the class name of the effect layer
  49555. */
  49556. getClassName(): string;
  49557. /**
  49558. * Creates an effect layer from parsed effect layer data
  49559. * @param parsedEffectLayer defines effect layer data
  49560. * @param scene defines the current scene
  49561. * @param rootUrl defines the root URL containing the effect layer information
  49562. * @returns a parsed effect Layer
  49563. */
  49564. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49565. }
  49566. }
  49567. declare module BABYLON {
  49568. interface AbstractScene {
  49569. /**
  49570. * The list of effect layers (highlights/glow) added to the scene
  49571. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49572. * @see http://doc.babylonjs.com/how_to/glow_layer
  49573. */
  49574. effectLayers: Array<EffectLayer>;
  49575. /**
  49576. * Removes the given effect layer from this scene.
  49577. * @param toRemove defines the effect layer to remove
  49578. * @returns the index of the removed effect layer
  49579. */
  49580. removeEffectLayer(toRemove: EffectLayer): number;
  49581. /**
  49582. * Adds the given effect layer to this scene
  49583. * @param newEffectLayer defines the effect layer to add
  49584. */
  49585. addEffectLayer(newEffectLayer: EffectLayer): void;
  49586. }
  49587. /**
  49588. * Defines the layer scene component responsible to manage any effect layers
  49589. * in a given scene.
  49590. */
  49591. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49592. /**
  49593. * The component name helpfull to identify the component in the list of scene components.
  49594. */
  49595. readonly name: string;
  49596. /**
  49597. * The scene the component belongs to.
  49598. */
  49599. scene: Scene;
  49600. private _engine;
  49601. private _renderEffects;
  49602. private _needStencil;
  49603. private _previousStencilState;
  49604. /**
  49605. * Creates a new instance of the component for the given scene
  49606. * @param scene Defines the scene to register the component in
  49607. */
  49608. constructor(scene: Scene);
  49609. /**
  49610. * Registers the component in a given scene
  49611. */
  49612. register(): void;
  49613. /**
  49614. * Rebuilds the elements related to this component in case of
  49615. * context lost for instance.
  49616. */
  49617. rebuild(): void;
  49618. /**
  49619. * Serializes the component data to the specified json object
  49620. * @param serializationObject The object to serialize to
  49621. */
  49622. serialize(serializationObject: any): void;
  49623. /**
  49624. * Adds all the elements from the container to the scene
  49625. * @param container the container holding the elements
  49626. */
  49627. addFromContainer(container: AbstractScene): void;
  49628. /**
  49629. * Removes all the elements in the container from the scene
  49630. * @param container contains the elements to remove
  49631. * @param dispose if the removed element should be disposed (default: false)
  49632. */
  49633. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49634. /**
  49635. * Disposes the component and the associated ressources.
  49636. */
  49637. dispose(): void;
  49638. private _isReadyForMesh;
  49639. private _renderMainTexture;
  49640. private _setStencil;
  49641. private _setStencilBack;
  49642. private _draw;
  49643. private _drawCamera;
  49644. private _drawRenderingGroup;
  49645. }
  49646. }
  49647. declare module BABYLON {
  49648. /** @hidden */
  49649. export var glowMapMergePixelShader: {
  49650. name: string;
  49651. shader: string;
  49652. };
  49653. }
  49654. declare module BABYLON {
  49655. /** @hidden */
  49656. export var glowMapMergeVertexShader: {
  49657. name: string;
  49658. shader: string;
  49659. };
  49660. }
  49661. declare module BABYLON {
  49662. interface AbstractScene {
  49663. /**
  49664. * Return a the first highlight layer of the scene with a given name.
  49665. * @param name The name of the highlight layer to look for.
  49666. * @return The highlight layer if found otherwise null.
  49667. */
  49668. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49669. }
  49670. /**
  49671. * Glow layer options. This helps customizing the behaviour
  49672. * of the glow layer.
  49673. */
  49674. export interface IGlowLayerOptions {
  49675. /**
  49676. * Multiplication factor apply to the canvas size to compute the render target size
  49677. * used to generated the glowing objects (the smaller the faster).
  49678. */
  49679. mainTextureRatio: number;
  49680. /**
  49681. * Enforces a fixed size texture to ensure resize independant blur.
  49682. */
  49683. mainTextureFixedSize?: number;
  49684. /**
  49685. * How big is the kernel of the blur texture.
  49686. */
  49687. blurKernelSize: number;
  49688. /**
  49689. * The camera attached to the layer.
  49690. */
  49691. camera: Nullable<Camera>;
  49692. /**
  49693. * Enable MSAA by chosing the number of samples.
  49694. */
  49695. mainTextureSamples?: number;
  49696. /**
  49697. * The rendering group to draw the layer in.
  49698. */
  49699. renderingGroupId: number;
  49700. }
  49701. /**
  49702. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49703. *
  49704. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49705. * glowy meshes to your scene.
  49706. *
  49707. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49708. */
  49709. export class GlowLayer extends EffectLayer {
  49710. /**
  49711. * Effect Name of the layer.
  49712. */
  49713. static readonly EffectName: string;
  49714. /**
  49715. * The default blur kernel size used for the glow.
  49716. */
  49717. static DefaultBlurKernelSize: number;
  49718. /**
  49719. * The default texture size ratio used for the glow.
  49720. */
  49721. static DefaultTextureRatio: number;
  49722. /**
  49723. * Sets the kernel size of the blur.
  49724. */
  49725. /**
  49726. * Gets the kernel size of the blur.
  49727. */
  49728. blurKernelSize: number;
  49729. /**
  49730. * Sets the glow intensity.
  49731. */
  49732. /**
  49733. * Gets the glow intensity.
  49734. */
  49735. intensity: number;
  49736. private _options;
  49737. private _intensity;
  49738. private _horizontalBlurPostprocess1;
  49739. private _verticalBlurPostprocess1;
  49740. private _horizontalBlurPostprocess2;
  49741. private _verticalBlurPostprocess2;
  49742. private _blurTexture1;
  49743. private _blurTexture2;
  49744. private _postProcesses1;
  49745. private _postProcesses2;
  49746. private _includedOnlyMeshes;
  49747. private _excludedMeshes;
  49748. /**
  49749. * Callback used to let the user override the color selection on a per mesh basis
  49750. */
  49751. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49752. /**
  49753. * Callback used to let the user override the texture selection on a per mesh basis
  49754. */
  49755. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49756. /**
  49757. * Instantiates a new glow Layer and references it to the scene.
  49758. * @param name The name of the layer
  49759. * @param scene The scene to use the layer in
  49760. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49761. */
  49762. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49763. /**
  49764. * Get the effect name of the layer.
  49765. * @return The effect name
  49766. */
  49767. getEffectName(): string;
  49768. /**
  49769. * Create the merge effect. This is the shader use to blit the information back
  49770. * to the main canvas at the end of the scene rendering.
  49771. */
  49772. protected _createMergeEffect(): Effect;
  49773. /**
  49774. * Creates the render target textures and post processes used in the glow layer.
  49775. */
  49776. protected _createTextureAndPostProcesses(): void;
  49777. /**
  49778. * Checks for the readiness of the element composing the layer.
  49779. * @param subMesh the mesh to check for
  49780. * @param useInstances specify wether or not to use instances to render the mesh
  49781. * @param emissiveTexture the associated emissive texture used to generate the glow
  49782. * @return true if ready otherwise, false
  49783. */
  49784. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49785. /**
  49786. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49787. */
  49788. needStencil(): boolean;
  49789. /**
  49790. * Returns true if the mesh can be rendered, otherwise false.
  49791. * @param mesh The mesh to render
  49792. * @param material The material used on the mesh
  49793. * @returns true if it can be rendered otherwise false
  49794. */
  49795. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49796. /**
  49797. * Implementation specific of rendering the generating effect on the main canvas.
  49798. * @param effect The effect used to render through
  49799. */
  49800. protected _internalRender(effect: Effect): void;
  49801. /**
  49802. * Sets the required values for both the emissive texture and and the main color.
  49803. */
  49804. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49805. /**
  49806. * Returns true if the mesh should render, otherwise false.
  49807. * @param mesh The mesh to render
  49808. * @returns true if it should render otherwise false
  49809. */
  49810. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49811. /**
  49812. * Adds specific effects defines.
  49813. * @param defines The defines to add specifics to.
  49814. */
  49815. protected _addCustomEffectDefines(defines: string[]): void;
  49816. /**
  49817. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49818. * @param mesh The mesh to exclude from the glow layer
  49819. */
  49820. addExcludedMesh(mesh: Mesh): void;
  49821. /**
  49822. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49823. * @param mesh The mesh to remove
  49824. */
  49825. removeExcludedMesh(mesh: Mesh): void;
  49826. /**
  49827. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49828. * @param mesh The mesh to include in the glow layer
  49829. */
  49830. addIncludedOnlyMesh(mesh: Mesh): void;
  49831. /**
  49832. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49833. * @param mesh The mesh to remove
  49834. */
  49835. removeIncludedOnlyMesh(mesh: Mesh): void;
  49836. /**
  49837. * Determine if a given mesh will be used in the glow layer
  49838. * @param mesh The mesh to test
  49839. * @returns true if the mesh will be highlighted by the current glow layer
  49840. */
  49841. hasMesh(mesh: AbstractMesh): boolean;
  49842. /**
  49843. * Free any resources and references associated to a mesh.
  49844. * Internal use
  49845. * @param mesh The mesh to free.
  49846. * @hidden
  49847. */
  49848. _disposeMesh(mesh: Mesh): void;
  49849. /**
  49850. * Gets the class name of the effect layer
  49851. * @returns the string with the class name of the effect layer
  49852. */
  49853. getClassName(): string;
  49854. /**
  49855. * Serializes this glow layer
  49856. * @returns a serialized glow layer object
  49857. */
  49858. serialize(): any;
  49859. /**
  49860. * Creates a Glow Layer from parsed glow layer data
  49861. * @param parsedGlowLayer defines glow layer data
  49862. * @param scene defines the current scene
  49863. * @param rootUrl defines the root URL containing the glow layer information
  49864. * @returns a parsed Glow Layer
  49865. */
  49866. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49867. }
  49868. }
  49869. declare module BABYLON {
  49870. /** @hidden */
  49871. export var glowBlurPostProcessPixelShader: {
  49872. name: string;
  49873. shader: string;
  49874. };
  49875. }
  49876. declare module BABYLON {
  49877. interface AbstractScene {
  49878. /**
  49879. * Return a the first highlight layer of the scene with a given name.
  49880. * @param name The name of the highlight layer to look for.
  49881. * @return The highlight layer if found otherwise null.
  49882. */
  49883. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49884. }
  49885. /**
  49886. * Highlight layer options. This helps customizing the behaviour
  49887. * of the highlight layer.
  49888. */
  49889. export interface IHighlightLayerOptions {
  49890. /**
  49891. * Multiplication factor apply to the canvas size to compute the render target size
  49892. * used to generated the glowing objects (the smaller the faster).
  49893. */
  49894. mainTextureRatio: number;
  49895. /**
  49896. * Enforces a fixed size texture to ensure resize independant blur.
  49897. */
  49898. mainTextureFixedSize?: number;
  49899. /**
  49900. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49901. * of the picture to blur (the smaller the faster).
  49902. */
  49903. blurTextureSizeRatio: number;
  49904. /**
  49905. * How big in texel of the blur texture is the vertical blur.
  49906. */
  49907. blurVerticalSize: number;
  49908. /**
  49909. * How big in texel of the blur texture is the horizontal blur.
  49910. */
  49911. blurHorizontalSize: number;
  49912. /**
  49913. * Alpha blending mode used to apply the blur. Default is combine.
  49914. */
  49915. alphaBlendingMode: number;
  49916. /**
  49917. * The camera attached to the layer.
  49918. */
  49919. camera: Nullable<Camera>;
  49920. /**
  49921. * Should we display highlight as a solid stroke?
  49922. */
  49923. isStroke?: boolean;
  49924. /**
  49925. * The rendering group to draw the layer in.
  49926. */
  49927. renderingGroupId: number;
  49928. }
  49929. /**
  49930. * The highlight layer Helps adding a glow effect around a mesh.
  49931. *
  49932. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49933. * glowy meshes to your scene.
  49934. *
  49935. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49936. */
  49937. export class HighlightLayer extends EffectLayer {
  49938. name: string;
  49939. /**
  49940. * Effect Name of the highlight layer.
  49941. */
  49942. static readonly EffectName: string;
  49943. /**
  49944. * The neutral color used during the preparation of the glow effect.
  49945. * This is black by default as the blend operation is a blend operation.
  49946. */
  49947. static NeutralColor: Color4;
  49948. /**
  49949. * Stencil value used for glowing meshes.
  49950. */
  49951. static GlowingMeshStencilReference: number;
  49952. /**
  49953. * Stencil value used for the other meshes in the scene.
  49954. */
  49955. static NormalMeshStencilReference: number;
  49956. /**
  49957. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49958. */
  49959. innerGlow: boolean;
  49960. /**
  49961. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49962. */
  49963. outerGlow: boolean;
  49964. /**
  49965. * Specifies the horizontal size of the blur.
  49966. */
  49967. /**
  49968. * Gets the horizontal size of the blur.
  49969. */
  49970. blurHorizontalSize: number;
  49971. /**
  49972. * Specifies the vertical size of the blur.
  49973. */
  49974. /**
  49975. * Gets the vertical size of the blur.
  49976. */
  49977. blurVerticalSize: number;
  49978. /**
  49979. * An event triggered when the highlight layer is being blurred.
  49980. */
  49981. onBeforeBlurObservable: Observable<HighlightLayer>;
  49982. /**
  49983. * An event triggered when the highlight layer has been blurred.
  49984. */
  49985. onAfterBlurObservable: Observable<HighlightLayer>;
  49986. private _instanceGlowingMeshStencilReference;
  49987. private _options;
  49988. private _downSamplePostprocess;
  49989. private _horizontalBlurPostprocess;
  49990. private _verticalBlurPostprocess;
  49991. private _blurTexture;
  49992. private _meshes;
  49993. private _excludedMeshes;
  49994. /**
  49995. * Instantiates a new highlight Layer and references it to the scene..
  49996. * @param name The name of the layer
  49997. * @param scene The scene to use the layer in
  49998. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49999. */
  50000. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50001. /**
  50002. * Get the effect name of the layer.
  50003. * @return The effect name
  50004. */
  50005. getEffectName(): string;
  50006. /**
  50007. * Create the merge effect. This is the shader use to blit the information back
  50008. * to the main canvas at the end of the scene rendering.
  50009. */
  50010. protected _createMergeEffect(): Effect;
  50011. /**
  50012. * Creates the render target textures and post processes used in the highlight layer.
  50013. */
  50014. protected _createTextureAndPostProcesses(): void;
  50015. /**
  50016. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50017. */
  50018. needStencil(): boolean;
  50019. /**
  50020. * Checks for the readiness of the element composing the layer.
  50021. * @param subMesh the mesh to check for
  50022. * @param useInstances specify wether or not to use instances to render the mesh
  50023. * @param emissiveTexture the associated emissive texture used to generate the glow
  50024. * @return true if ready otherwise, false
  50025. */
  50026. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50027. /**
  50028. * Implementation specific of rendering the generating effect on the main canvas.
  50029. * @param effect The effect used to render through
  50030. */
  50031. protected _internalRender(effect: Effect): void;
  50032. /**
  50033. * Returns true if the layer contains information to display, otherwise false.
  50034. */
  50035. shouldRender(): boolean;
  50036. /**
  50037. * Returns true if the mesh should render, otherwise false.
  50038. * @param mesh The mesh to render
  50039. * @returns true if it should render otherwise false
  50040. */
  50041. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50042. /**
  50043. * Sets the required values for both the emissive texture and and the main color.
  50044. */
  50045. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50046. /**
  50047. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50048. * @param mesh The mesh to exclude from the highlight layer
  50049. */
  50050. addExcludedMesh(mesh: Mesh): void;
  50051. /**
  50052. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50053. * @param mesh The mesh to highlight
  50054. */
  50055. removeExcludedMesh(mesh: Mesh): void;
  50056. /**
  50057. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50058. * @param mesh mesh to test
  50059. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50060. */
  50061. hasMesh(mesh: AbstractMesh): boolean;
  50062. /**
  50063. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50064. * @param mesh The mesh to highlight
  50065. * @param color The color of the highlight
  50066. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50067. */
  50068. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50069. /**
  50070. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50071. * @param mesh The mesh to highlight
  50072. */
  50073. removeMesh(mesh: Mesh): void;
  50074. /**
  50075. * Force the stencil to the normal expected value for none glowing parts
  50076. */
  50077. private _defaultStencilReference;
  50078. /**
  50079. * Free any resources and references associated to a mesh.
  50080. * Internal use
  50081. * @param mesh The mesh to free.
  50082. * @hidden
  50083. */
  50084. _disposeMesh(mesh: Mesh): void;
  50085. /**
  50086. * Dispose the highlight layer and free resources.
  50087. */
  50088. dispose(): void;
  50089. /**
  50090. * Gets the class name of the effect layer
  50091. * @returns the string with the class name of the effect layer
  50092. */
  50093. getClassName(): string;
  50094. /**
  50095. * Serializes this Highlight layer
  50096. * @returns a serialized Highlight layer object
  50097. */
  50098. serialize(): any;
  50099. /**
  50100. * Creates a Highlight layer from parsed Highlight layer data
  50101. * @param parsedHightlightLayer defines the Highlight layer data
  50102. * @param scene defines the current scene
  50103. * @param rootUrl defines the root URL containing the Highlight layer information
  50104. * @returns a parsed Highlight layer
  50105. */
  50106. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50107. }
  50108. }
  50109. declare module BABYLON {
  50110. interface AbstractScene {
  50111. /**
  50112. * The list of layers (background and foreground) of the scene
  50113. */
  50114. layers: Array<Layer>;
  50115. }
  50116. /**
  50117. * Defines the layer scene component responsible to manage any layers
  50118. * in a given scene.
  50119. */
  50120. export class LayerSceneComponent implements ISceneComponent {
  50121. /**
  50122. * The component name helpfull to identify the component in the list of scene components.
  50123. */
  50124. readonly name: string;
  50125. /**
  50126. * The scene the component belongs to.
  50127. */
  50128. scene: Scene;
  50129. private _engine;
  50130. /**
  50131. * Creates a new instance of the component for the given scene
  50132. * @param scene Defines the scene to register the component in
  50133. */
  50134. constructor(scene: Scene);
  50135. /**
  50136. * Registers the component in a given scene
  50137. */
  50138. register(): void;
  50139. /**
  50140. * Rebuilds the elements related to this component in case of
  50141. * context lost for instance.
  50142. */
  50143. rebuild(): void;
  50144. /**
  50145. * Disposes the component and the associated ressources.
  50146. */
  50147. dispose(): void;
  50148. private _draw;
  50149. private _drawCameraPredicate;
  50150. private _drawCameraBackground;
  50151. private _drawCameraForeground;
  50152. private _drawRenderTargetPredicate;
  50153. private _drawRenderTargetBackground;
  50154. private _drawRenderTargetForeground;
  50155. /**
  50156. * Adds all the elements from the container to the scene
  50157. * @param container the container holding the elements
  50158. */
  50159. addFromContainer(container: AbstractScene): void;
  50160. /**
  50161. * Removes all the elements in the container from the scene
  50162. * @param container contains the elements to remove
  50163. * @param dispose if the removed element should be disposed (default: false)
  50164. */
  50165. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50166. }
  50167. }
  50168. declare module BABYLON {
  50169. /** @hidden */
  50170. export var layerPixelShader: {
  50171. name: string;
  50172. shader: string;
  50173. };
  50174. }
  50175. declare module BABYLON {
  50176. /** @hidden */
  50177. export var layerVertexShader: {
  50178. name: string;
  50179. shader: string;
  50180. };
  50181. }
  50182. declare module BABYLON {
  50183. /**
  50184. * This represents a full screen 2d layer.
  50185. * This can be useful to display a picture in the background of your scene for instance.
  50186. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50187. */
  50188. export class Layer {
  50189. /**
  50190. * Define the name of the layer.
  50191. */
  50192. name: string;
  50193. /**
  50194. * Define the texture the layer should display.
  50195. */
  50196. texture: Nullable<Texture>;
  50197. /**
  50198. * Is the layer in background or foreground.
  50199. */
  50200. isBackground: boolean;
  50201. /**
  50202. * Define the color of the layer (instead of texture).
  50203. */
  50204. color: Color4;
  50205. /**
  50206. * Define the scale of the layer in order to zoom in out of the texture.
  50207. */
  50208. scale: Vector2;
  50209. /**
  50210. * Define an offset for the layer in order to shift the texture.
  50211. */
  50212. offset: Vector2;
  50213. /**
  50214. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50215. */
  50216. alphaBlendingMode: number;
  50217. /**
  50218. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50219. * Alpha test will not mix with the background color in case of transparency.
  50220. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50221. */
  50222. alphaTest: boolean;
  50223. /**
  50224. * Define a mask to restrict the layer to only some of the scene cameras.
  50225. */
  50226. layerMask: number;
  50227. /**
  50228. * Define the list of render target the layer is visible into.
  50229. */
  50230. renderTargetTextures: RenderTargetTexture[];
  50231. /**
  50232. * Define if the layer is only used in renderTarget or if it also
  50233. * renders in the main frame buffer of the canvas.
  50234. */
  50235. renderOnlyInRenderTargetTextures: boolean;
  50236. private _scene;
  50237. private _vertexBuffers;
  50238. private _indexBuffer;
  50239. private _effect;
  50240. private _alphaTestEffect;
  50241. /**
  50242. * An event triggered when the layer is disposed.
  50243. */
  50244. onDisposeObservable: Observable<Layer>;
  50245. private _onDisposeObserver;
  50246. /**
  50247. * Back compatibility with callback before the onDisposeObservable existed.
  50248. * The set callback will be triggered when the layer has been disposed.
  50249. */
  50250. onDispose: () => void;
  50251. /**
  50252. * An event triggered before rendering the scene
  50253. */
  50254. onBeforeRenderObservable: Observable<Layer>;
  50255. private _onBeforeRenderObserver;
  50256. /**
  50257. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50258. * The set callback will be triggered just before rendering the layer.
  50259. */
  50260. onBeforeRender: () => void;
  50261. /**
  50262. * An event triggered after rendering the scene
  50263. */
  50264. onAfterRenderObservable: Observable<Layer>;
  50265. private _onAfterRenderObserver;
  50266. /**
  50267. * Back compatibility with callback before the onAfterRenderObservable existed.
  50268. * The set callback will be triggered just after rendering the layer.
  50269. */
  50270. onAfterRender: () => void;
  50271. /**
  50272. * Instantiates a new layer.
  50273. * This represents a full screen 2d layer.
  50274. * This can be useful to display a picture in the background of your scene for instance.
  50275. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50276. * @param name Define the name of the layer in the scene
  50277. * @param imgUrl Define the url of the texture to display in the layer
  50278. * @param scene Define the scene the layer belongs to
  50279. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50280. * @param color Defines a color for the layer
  50281. */
  50282. constructor(
  50283. /**
  50284. * Define the name of the layer.
  50285. */
  50286. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50287. private _createIndexBuffer;
  50288. /** @hidden */
  50289. _rebuild(): void;
  50290. /**
  50291. * Renders the layer in the scene.
  50292. */
  50293. render(): void;
  50294. /**
  50295. * Disposes and releases the associated ressources.
  50296. */
  50297. dispose(): void;
  50298. }
  50299. }
  50300. declare module BABYLON {
  50301. /** @hidden */
  50302. export var lensFlarePixelShader: {
  50303. name: string;
  50304. shader: string;
  50305. };
  50306. }
  50307. declare module BABYLON {
  50308. /** @hidden */
  50309. export var lensFlareVertexShader: {
  50310. name: string;
  50311. shader: string;
  50312. };
  50313. }
  50314. declare module BABYLON {
  50315. /**
  50316. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50317. * It is usually composed of several `lensFlare`.
  50318. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50319. */
  50320. export class LensFlareSystem {
  50321. /**
  50322. * Define the name of the lens flare system
  50323. */
  50324. name: string;
  50325. /**
  50326. * List of lens flares used in this system.
  50327. */
  50328. lensFlares: LensFlare[];
  50329. /**
  50330. * Define a limit from the border the lens flare can be visible.
  50331. */
  50332. borderLimit: number;
  50333. /**
  50334. * Define a viewport border we do not want to see the lens flare in.
  50335. */
  50336. viewportBorder: number;
  50337. /**
  50338. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50339. */
  50340. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50341. /**
  50342. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50343. */
  50344. layerMask: number;
  50345. /**
  50346. * Define the id of the lens flare system in the scene.
  50347. * (equal to name by default)
  50348. */
  50349. id: string;
  50350. private _scene;
  50351. private _emitter;
  50352. private _vertexBuffers;
  50353. private _indexBuffer;
  50354. private _effect;
  50355. private _positionX;
  50356. private _positionY;
  50357. private _isEnabled;
  50358. /** @hidden */
  50359. static _SceneComponentInitialization: (scene: Scene) => void;
  50360. /**
  50361. * Instantiates a lens flare system.
  50362. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50363. * It is usually composed of several `lensFlare`.
  50364. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50365. * @param name Define the name of the lens flare system in the scene
  50366. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50367. * @param scene Define the scene the lens flare system belongs to
  50368. */
  50369. constructor(
  50370. /**
  50371. * Define the name of the lens flare system
  50372. */
  50373. name: string, emitter: any, scene: Scene);
  50374. /**
  50375. * Define if the lens flare system is enabled.
  50376. */
  50377. isEnabled: boolean;
  50378. /**
  50379. * Get the scene the effects belongs to.
  50380. * @returns the scene holding the lens flare system
  50381. */
  50382. getScene(): Scene;
  50383. /**
  50384. * Get the emitter of the lens flare system.
  50385. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50386. * @returns the emitter of the lens flare system
  50387. */
  50388. getEmitter(): any;
  50389. /**
  50390. * Set the emitter of the lens flare system.
  50391. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50392. * @param newEmitter Define the new emitter of the system
  50393. */
  50394. setEmitter(newEmitter: any): void;
  50395. /**
  50396. * Get the lens flare system emitter position.
  50397. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50398. * @returns the position
  50399. */
  50400. getEmitterPosition(): Vector3;
  50401. /**
  50402. * @hidden
  50403. */
  50404. computeEffectivePosition(globalViewport: Viewport): boolean;
  50405. /** @hidden */
  50406. _isVisible(): boolean;
  50407. /**
  50408. * @hidden
  50409. */
  50410. render(): boolean;
  50411. /**
  50412. * Dispose and release the lens flare with its associated resources.
  50413. */
  50414. dispose(): void;
  50415. /**
  50416. * Parse a lens flare system from a JSON repressentation
  50417. * @param parsedLensFlareSystem Define the JSON to parse
  50418. * @param scene Define the scene the parsed system should be instantiated in
  50419. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50420. * @returns the parsed system
  50421. */
  50422. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50423. /**
  50424. * Serialize the current Lens Flare System into a JSON representation.
  50425. * @returns the serialized JSON
  50426. */
  50427. serialize(): any;
  50428. }
  50429. }
  50430. declare module BABYLON {
  50431. /**
  50432. * This represents one of the lens effect in a `lensFlareSystem`.
  50433. * It controls one of the indiviual texture used in the effect.
  50434. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50435. */
  50436. export class LensFlare {
  50437. /**
  50438. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50439. */
  50440. size: number;
  50441. /**
  50442. * 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.
  50443. */
  50444. position: number;
  50445. /**
  50446. * Define the lens color.
  50447. */
  50448. color: Color3;
  50449. /**
  50450. * Define the lens texture.
  50451. */
  50452. texture: Nullable<Texture>;
  50453. /**
  50454. * Define the alpha mode to render this particular lens.
  50455. */
  50456. alphaMode: number;
  50457. private _system;
  50458. /**
  50459. * Creates a new Lens Flare.
  50460. * This represents one of the lens effect in a `lensFlareSystem`.
  50461. * It controls one of the indiviual texture used in the effect.
  50462. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50463. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50464. * @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.
  50465. * @param color Define the lens color
  50466. * @param imgUrl Define the lens texture url
  50467. * @param system Define the `lensFlareSystem` this flare is part of
  50468. * @returns The newly created Lens Flare
  50469. */
  50470. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50471. /**
  50472. * Instantiates a new Lens Flare.
  50473. * This represents one of the lens effect in a `lensFlareSystem`.
  50474. * It controls one of the indiviual texture used in the effect.
  50475. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50476. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50477. * @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.
  50478. * @param color Define the lens color
  50479. * @param imgUrl Define the lens texture url
  50480. * @param system Define the `lensFlareSystem` this flare is part of
  50481. */
  50482. constructor(
  50483. /**
  50484. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50485. */
  50486. size: number,
  50487. /**
  50488. * 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.
  50489. */
  50490. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50491. /**
  50492. * Dispose and release the lens flare with its associated resources.
  50493. */
  50494. dispose(): void;
  50495. }
  50496. }
  50497. declare module BABYLON {
  50498. interface AbstractScene {
  50499. /**
  50500. * The list of lens flare system added to the scene
  50501. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50502. */
  50503. lensFlareSystems: Array<LensFlareSystem>;
  50504. /**
  50505. * Removes the given lens flare system from this scene.
  50506. * @param toRemove The lens flare system to remove
  50507. * @returns The index of the removed lens flare system
  50508. */
  50509. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50510. /**
  50511. * Adds the given lens flare system to this scene
  50512. * @param newLensFlareSystem The lens flare system to add
  50513. */
  50514. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50515. /**
  50516. * Gets a lens flare system using its name
  50517. * @param name defines the name to look for
  50518. * @returns the lens flare system or null if not found
  50519. */
  50520. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50521. /**
  50522. * Gets a lens flare system using its id
  50523. * @param id defines the id to look for
  50524. * @returns the lens flare system or null if not found
  50525. */
  50526. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50527. }
  50528. /**
  50529. * Defines the lens flare scene component responsible to manage any lens flares
  50530. * in a given scene.
  50531. */
  50532. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50533. /**
  50534. * The component name helpfull to identify the component in the list of scene components.
  50535. */
  50536. readonly name: string;
  50537. /**
  50538. * The scene the component belongs to.
  50539. */
  50540. scene: Scene;
  50541. /**
  50542. * Creates a new instance of the component for the given scene
  50543. * @param scene Defines the scene to register the component in
  50544. */
  50545. constructor(scene: Scene);
  50546. /**
  50547. * Registers the component in a given scene
  50548. */
  50549. register(): void;
  50550. /**
  50551. * Rebuilds the elements related to this component in case of
  50552. * context lost for instance.
  50553. */
  50554. rebuild(): void;
  50555. /**
  50556. * Adds all the elements from the container to the scene
  50557. * @param container the container holding the elements
  50558. */
  50559. addFromContainer(container: AbstractScene): void;
  50560. /**
  50561. * Removes all the elements in the container from the scene
  50562. * @param container contains the elements to remove
  50563. * @param dispose if the removed element should be disposed (default: false)
  50564. */
  50565. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50566. /**
  50567. * Serializes the component data to the specified json object
  50568. * @param serializationObject The object to serialize to
  50569. */
  50570. serialize(serializationObject: any): void;
  50571. /**
  50572. * Disposes the component and the associated ressources.
  50573. */
  50574. dispose(): void;
  50575. private _draw;
  50576. }
  50577. }
  50578. declare module BABYLON {
  50579. /**
  50580. * Defines the shadow generator component responsible to manage any shadow generators
  50581. * in a given scene.
  50582. */
  50583. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50584. /**
  50585. * The component name helpfull to identify the component in the list of scene components.
  50586. */
  50587. readonly name: string;
  50588. /**
  50589. * The scene the component belongs to.
  50590. */
  50591. scene: Scene;
  50592. /**
  50593. * Creates a new instance of the component for the given scene
  50594. * @param scene Defines the scene to register the component in
  50595. */
  50596. constructor(scene: Scene);
  50597. /**
  50598. * Registers the component in a given scene
  50599. */
  50600. register(): void;
  50601. /**
  50602. * Rebuilds the elements related to this component in case of
  50603. * context lost for instance.
  50604. */
  50605. rebuild(): void;
  50606. /**
  50607. * Serializes the component data to the specified json object
  50608. * @param serializationObject The object to serialize to
  50609. */
  50610. serialize(serializationObject: any): void;
  50611. /**
  50612. * Adds all the elements from the container to the scene
  50613. * @param container the container holding the elements
  50614. */
  50615. addFromContainer(container: AbstractScene): void;
  50616. /**
  50617. * Removes all the elements in the container from the scene
  50618. * @param container contains the elements to remove
  50619. * @param dispose if the removed element should be disposed (default: false)
  50620. */
  50621. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50622. /**
  50623. * Rebuilds the elements related to this component in case of
  50624. * context lost for instance.
  50625. */
  50626. dispose(): void;
  50627. private _gatherRenderTargets;
  50628. }
  50629. }
  50630. declare module BABYLON {
  50631. /**
  50632. * A point light is a light defined by an unique point in world space.
  50633. * The light is emitted in every direction from this point.
  50634. * A good example of a point light is a standard light bulb.
  50635. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50636. */
  50637. export class PointLight extends ShadowLight {
  50638. private _shadowAngle;
  50639. /**
  50640. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50641. * This specifies what angle the shadow will use to be created.
  50642. *
  50643. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50644. */
  50645. /**
  50646. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50647. * This specifies what angle the shadow will use to be created.
  50648. *
  50649. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50650. */
  50651. shadowAngle: number;
  50652. /**
  50653. * Gets the direction if it has been set.
  50654. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50655. */
  50656. /**
  50657. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50658. */
  50659. direction: Vector3;
  50660. /**
  50661. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50662. * A PointLight emits the light in every direction.
  50663. * It can cast shadows.
  50664. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50665. * ```javascript
  50666. * var pointLight = new PointLight("pl", camera.position, scene);
  50667. * ```
  50668. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50669. * @param name The light friendly name
  50670. * @param position The position of the point light in the scene
  50671. * @param scene The scene the lights belongs to
  50672. */
  50673. constructor(name: string, position: Vector3, scene: Scene);
  50674. /**
  50675. * Returns the string "PointLight"
  50676. * @returns the class name
  50677. */
  50678. getClassName(): string;
  50679. /**
  50680. * Returns the integer 0.
  50681. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50682. */
  50683. getTypeID(): number;
  50684. /**
  50685. * Specifies wether or not the shadowmap should be a cube texture.
  50686. * @returns true if the shadowmap needs to be a cube texture.
  50687. */
  50688. needCube(): boolean;
  50689. /**
  50690. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50691. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50692. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50693. */
  50694. getShadowDirection(faceIndex?: number): Vector3;
  50695. /**
  50696. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50697. * - fov = PI / 2
  50698. * - aspect ratio : 1.0
  50699. * - z-near and far equal to the active camera minZ and maxZ.
  50700. * Returns the PointLight.
  50701. */
  50702. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50703. protected _buildUniformLayout(): void;
  50704. /**
  50705. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50706. * @param effect The effect to update
  50707. * @param lightIndex The index of the light in the effect to update
  50708. * @returns The point light
  50709. */
  50710. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50711. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50712. /**
  50713. * Prepares the list of defines specific to the light type.
  50714. * @param defines the list of defines
  50715. * @param lightIndex defines the index of the light for the effect
  50716. */
  50717. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50718. }
  50719. }
  50720. declare module BABYLON {
  50721. /**
  50722. * Header information of HDR texture files.
  50723. */
  50724. export interface HDRInfo {
  50725. /**
  50726. * The height of the texture in pixels.
  50727. */
  50728. height: number;
  50729. /**
  50730. * The width of the texture in pixels.
  50731. */
  50732. width: number;
  50733. /**
  50734. * The index of the beginning of the data in the binary file.
  50735. */
  50736. dataPosition: number;
  50737. }
  50738. /**
  50739. * This groups tools to convert HDR texture to native colors array.
  50740. */
  50741. export class HDRTools {
  50742. private static Ldexp;
  50743. private static Rgbe2float;
  50744. private static readStringLine;
  50745. /**
  50746. * Reads header information from an RGBE texture stored in a native array.
  50747. * More information on this format are available here:
  50748. * https://en.wikipedia.org/wiki/RGBE_image_format
  50749. *
  50750. * @param uint8array The binary file stored in native array.
  50751. * @return The header information.
  50752. */
  50753. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50754. /**
  50755. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50756. * This RGBE texture needs to store the information as a panorama.
  50757. *
  50758. * More information on this format are available here:
  50759. * https://en.wikipedia.org/wiki/RGBE_image_format
  50760. *
  50761. * @param buffer The binary file stored in an array buffer.
  50762. * @param size The expected size of the extracted cubemap.
  50763. * @return The Cube Map information.
  50764. */
  50765. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50766. /**
  50767. * Returns the pixels data extracted from an RGBE texture.
  50768. * This pixels will be stored left to right up to down in the R G B order in one array.
  50769. *
  50770. * More information on this format are available here:
  50771. * https://en.wikipedia.org/wiki/RGBE_image_format
  50772. *
  50773. * @param uint8array The binary file stored in an array buffer.
  50774. * @param hdrInfo The header information of the file.
  50775. * @return The pixels data in RGB right to left up to down order.
  50776. */
  50777. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50778. private static RGBE_ReadPixels_RLE;
  50779. }
  50780. }
  50781. declare module BABYLON {
  50782. /**
  50783. * This represents a texture coming from an HDR input.
  50784. *
  50785. * The only supported format is currently panorama picture stored in RGBE format.
  50786. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50787. */
  50788. export class HDRCubeTexture extends BaseTexture {
  50789. private static _facesMapping;
  50790. private _generateHarmonics;
  50791. private _noMipmap;
  50792. private _textureMatrix;
  50793. private _size;
  50794. private _onLoad;
  50795. private _onError;
  50796. /**
  50797. * The texture URL.
  50798. */
  50799. url: string;
  50800. /**
  50801. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50802. */
  50803. coordinatesMode: number;
  50804. protected _isBlocking: boolean;
  50805. /**
  50806. * Sets wether or not the texture is blocking during loading.
  50807. */
  50808. /**
  50809. * Gets wether or not the texture is blocking during loading.
  50810. */
  50811. isBlocking: boolean;
  50812. protected _rotationY: number;
  50813. /**
  50814. * Sets texture matrix rotation angle around Y axis in radians.
  50815. */
  50816. /**
  50817. * Gets texture matrix rotation angle around Y axis radians.
  50818. */
  50819. rotationY: number;
  50820. /**
  50821. * Gets or sets the center of the bounding box associated with the cube texture
  50822. * It must define where the camera used to render the texture was set
  50823. */
  50824. boundingBoxPosition: Vector3;
  50825. private _boundingBoxSize;
  50826. /**
  50827. * Gets or sets the size of the bounding box associated with the cube texture
  50828. * When defined, the cubemap will switch to local mode
  50829. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50830. * @example https://www.babylonjs-playground.com/#RNASML
  50831. */
  50832. boundingBoxSize: Vector3;
  50833. /**
  50834. * Instantiates an HDRTexture from the following parameters.
  50835. *
  50836. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50837. * @param scene The scene the texture will be used in
  50838. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50839. * @param noMipmap Forces to not generate the mipmap if true
  50840. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50841. * @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)
  50842. * @param reserved Reserved flag for internal use.
  50843. */
  50844. 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>);
  50845. /**
  50846. * Get the current class name of the texture useful for serialization or dynamic coding.
  50847. * @returns "HDRCubeTexture"
  50848. */
  50849. getClassName(): string;
  50850. /**
  50851. * Occurs when the file is raw .hdr file.
  50852. */
  50853. private loadTexture;
  50854. clone(): HDRCubeTexture;
  50855. delayLoad(): void;
  50856. /**
  50857. * Get the texture reflection matrix used to rotate/transform the reflection.
  50858. * @returns the reflection matrix
  50859. */
  50860. getReflectionTextureMatrix(): Matrix;
  50861. /**
  50862. * Set the texture reflection matrix used to rotate/transform the reflection.
  50863. * @param value Define the reflection matrix to set
  50864. */
  50865. setReflectionTextureMatrix(value: Matrix): void;
  50866. /**
  50867. * Parses a JSON representation of an HDR Texture in order to create the texture
  50868. * @param parsedTexture Define the JSON representation
  50869. * @param scene Define the scene the texture should be created in
  50870. * @param rootUrl Define the root url in case we need to load relative dependencies
  50871. * @returns the newly created texture after parsing
  50872. */
  50873. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50874. serialize(): any;
  50875. }
  50876. }
  50877. declare module BABYLON {
  50878. /**
  50879. * Class used to control physics engine
  50880. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50881. */
  50882. export class PhysicsEngine implements IPhysicsEngine {
  50883. private _physicsPlugin;
  50884. /**
  50885. * Global value used to control the smallest number supported by the simulation
  50886. */
  50887. static Epsilon: number;
  50888. private _impostors;
  50889. private _joints;
  50890. /**
  50891. * Gets the gravity vector used by the simulation
  50892. */
  50893. gravity: Vector3;
  50894. /**
  50895. * Factory used to create the default physics plugin.
  50896. * @returns The default physics plugin
  50897. */
  50898. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50899. /**
  50900. * Creates a new Physics Engine
  50901. * @param gravity defines the gravity vector used by the simulation
  50902. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50903. */
  50904. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50905. /**
  50906. * Sets the gravity vector used by the simulation
  50907. * @param gravity defines the gravity vector to use
  50908. */
  50909. setGravity(gravity: Vector3): void;
  50910. /**
  50911. * Set the time step of the physics engine.
  50912. * Default is 1/60.
  50913. * To slow it down, enter 1/600 for example.
  50914. * To speed it up, 1/30
  50915. * @param newTimeStep defines the new timestep to apply to this world.
  50916. */
  50917. setTimeStep(newTimeStep?: number): void;
  50918. /**
  50919. * Get the time step of the physics engine.
  50920. * @returns the current time step
  50921. */
  50922. getTimeStep(): number;
  50923. /**
  50924. * Release all resources
  50925. */
  50926. dispose(): void;
  50927. /**
  50928. * Gets the name of the current physics plugin
  50929. * @returns the name of the plugin
  50930. */
  50931. getPhysicsPluginName(): string;
  50932. /**
  50933. * Adding a new impostor for the impostor tracking.
  50934. * This will be done by the impostor itself.
  50935. * @param impostor the impostor to add
  50936. */
  50937. addImpostor(impostor: PhysicsImpostor): void;
  50938. /**
  50939. * Remove an impostor from the engine.
  50940. * This impostor and its mesh will not longer be updated by the physics engine.
  50941. * @param impostor the impostor to remove
  50942. */
  50943. removeImpostor(impostor: PhysicsImpostor): void;
  50944. /**
  50945. * Add a joint to the physics engine
  50946. * @param mainImpostor defines the main impostor to which the joint is added.
  50947. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50948. * @param joint defines the joint that will connect both impostors.
  50949. */
  50950. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50951. /**
  50952. * Removes a joint from the simulation
  50953. * @param mainImpostor defines the impostor used with the joint
  50954. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50955. * @param joint defines the joint to remove
  50956. */
  50957. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50958. /**
  50959. * Called by the scene. No need to call it.
  50960. * @param delta defines the timespam between frames
  50961. */
  50962. _step(delta: number): void;
  50963. /**
  50964. * Gets the current plugin used to run the simulation
  50965. * @returns current plugin
  50966. */
  50967. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50968. /**
  50969. * Gets the list of physic impostors
  50970. * @returns an array of PhysicsImpostor
  50971. */
  50972. getImpostors(): Array<PhysicsImpostor>;
  50973. /**
  50974. * Gets the impostor for a physics enabled object
  50975. * @param object defines the object impersonated by the impostor
  50976. * @returns the PhysicsImpostor or null if not found
  50977. */
  50978. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50979. /**
  50980. * Gets the impostor for a physics body object
  50981. * @param body defines physics body used by the impostor
  50982. * @returns the PhysicsImpostor or null if not found
  50983. */
  50984. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50985. /**
  50986. * Does a raycast in the physics world
  50987. * @param from when should the ray start?
  50988. * @param to when should the ray end?
  50989. * @returns PhysicsRaycastResult
  50990. */
  50991. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50992. }
  50993. }
  50994. declare module BABYLON {
  50995. /** @hidden */
  50996. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50997. private _useDeltaForWorldStep;
  50998. world: any;
  50999. name: string;
  51000. private _physicsMaterials;
  51001. private _fixedTimeStep;
  51002. private _cannonRaycastResult;
  51003. private _raycastResult;
  51004. private _physicsBodysToRemoveAfterStep;
  51005. BJSCANNON: any;
  51006. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51007. setGravity(gravity: Vector3): void;
  51008. setTimeStep(timeStep: number): void;
  51009. getTimeStep(): number;
  51010. executeStep(delta: number): void;
  51011. private _removeMarkedPhysicsBodiesFromWorld;
  51012. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51013. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51014. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51015. private _processChildMeshes;
  51016. removePhysicsBody(impostor: PhysicsImpostor): void;
  51017. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51018. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51019. private _addMaterial;
  51020. private _checkWithEpsilon;
  51021. private _createShape;
  51022. private _createHeightmap;
  51023. private _minus90X;
  51024. private _plus90X;
  51025. private _tmpPosition;
  51026. private _tmpDeltaPosition;
  51027. private _tmpUnityRotation;
  51028. private _updatePhysicsBodyTransformation;
  51029. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51030. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51031. isSupported(): boolean;
  51032. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51033. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51034. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51035. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51036. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51037. getBodyMass(impostor: PhysicsImpostor): number;
  51038. getBodyFriction(impostor: PhysicsImpostor): number;
  51039. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51040. getBodyRestitution(impostor: PhysicsImpostor): number;
  51041. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51042. sleepBody(impostor: PhysicsImpostor): void;
  51043. wakeUpBody(impostor: PhysicsImpostor): void;
  51044. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51045. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51046. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51047. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51048. getRadius(impostor: PhysicsImpostor): number;
  51049. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51050. dispose(): void;
  51051. private _extendNamespace;
  51052. /**
  51053. * Does a raycast in the physics world
  51054. * @param from when should the ray start?
  51055. * @param to when should the ray end?
  51056. * @returns PhysicsRaycastResult
  51057. */
  51058. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51059. }
  51060. }
  51061. declare module BABYLON {
  51062. /** @hidden */
  51063. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51064. world: any;
  51065. name: string;
  51066. BJSOIMO: any;
  51067. private _raycastResult;
  51068. constructor(iterations?: number, oimoInjection?: any);
  51069. setGravity(gravity: Vector3): void;
  51070. setTimeStep(timeStep: number): void;
  51071. getTimeStep(): number;
  51072. private _tmpImpostorsArray;
  51073. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51074. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51075. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51076. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51077. private _tmpPositionVector;
  51078. removePhysicsBody(impostor: PhysicsImpostor): void;
  51079. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51080. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51081. isSupported(): boolean;
  51082. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51083. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51084. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51085. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51086. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51087. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51088. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51089. getBodyMass(impostor: PhysicsImpostor): number;
  51090. getBodyFriction(impostor: PhysicsImpostor): number;
  51091. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51092. getBodyRestitution(impostor: PhysicsImpostor): number;
  51093. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51094. sleepBody(impostor: PhysicsImpostor): void;
  51095. wakeUpBody(impostor: PhysicsImpostor): void;
  51096. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51097. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51098. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51099. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51100. getRadius(impostor: PhysicsImpostor): number;
  51101. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51102. dispose(): void;
  51103. /**
  51104. * Does a raycast in the physics world
  51105. * @param from when should the ray start?
  51106. * @param to when should the ray end?
  51107. * @returns PhysicsRaycastResult
  51108. */
  51109. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51110. }
  51111. }
  51112. declare module BABYLON {
  51113. /**
  51114. * Class containing static functions to help procedurally build meshes
  51115. */
  51116. export class RibbonBuilder {
  51117. /**
  51118. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51119. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51120. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51121. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51122. * * 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
  51123. * * 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
  51124. * * 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
  51125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51126. * * 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
  51127. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51128. * * 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
  51129. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51130. * * 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
  51131. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51133. * @param name defines the name of the mesh
  51134. * @param options defines the options used to create the mesh
  51135. * @param scene defines the hosting scene
  51136. * @returns the ribbon mesh
  51137. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51138. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51139. */
  51140. static CreateRibbon(name: string, options: {
  51141. pathArray: Vector3[][];
  51142. closeArray?: boolean;
  51143. closePath?: boolean;
  51144. offset?: number;
  51145. updatable?: boolean;
  51146. sideOrientation?: number;
  51147. frontUVs?: Vector4;
  51148. backUVs?: Vector4;
  51149. instance?: Mesh;
  51150. invertUV?: boolean;
  51151. uvs?: Vector2[];
  51152. colors?: Color4[];
  51153. }, scene?: Nullable<Scene>): Mesh;
  51154. }
  51155. }
  51156. declare module BABYLON {
  51157. /**
  51158. * Class containing static functions to help procedurally build meshes
  51159. */
  51160. export class ShapeBuilder {
  51161. /**
  51162. * 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.
  51163. * * 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.
  51164. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51165. * * 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.
  51166. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51167. * * 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
  51168. * * 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
  51169. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51171. * * 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
  51172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51174. * @param name defines the name of the mesh
  51175. * @param options defines the options used to create the mesh
  51176. * @param scene defines the hosting scene
  51177. * @returns the extruded shape mesh
  51178. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51180. */
  51181. static ExtrudeShape(name: string, options: {
  51182. shape: Vector3[];
  51183. path: Vector3[];
  51184. scale?: number;
  51185. rotation?: number;
  51186. cap?: number;
  51187. updatable?: boolean;
  51188. sideOrientation?: number;
  51189. frontUVs?: Vector4;
  51190. backUVs?: Vector4;
  51191. instance?: Mesh;
  51192. invertUV?: boolean;
  51193. }, scene?: Nullable<Scene>): Mesh;
  51194. /**
  51195. * Creates an custom extruded shape mesh.
  51196. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51197. * * 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.
  51198. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51199. * * 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
  51200. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51201. * * 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
  51202. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51203. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51204. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51205. * * 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
  51206. * * 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
  51207. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51209. * * 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
  51210. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51212. * @param name defines the name of the mesh
  51213. * @param options defines the options used to create the mesh
  51214. * @param scene defines the hosting scene
  51215. * @returns the custom extruded shape mesh
  51216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51217. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51218. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51219. */
  51220. static ExtrudeShapeCustom(name: string, options: {
  51221. shape: Vector3[];
  51222. path: Vector3[];
  51223. scaleFunction?: any;
  51224. rotationFunction?: any;
  51225. ribbonCloseArray?: boolean;
  51226. ribbonClosePath?: boolean;
  51227. cap?: number;
  51228. updatable?: boolean;
  51229. sideOrientation?: number;
  51230. frontUVs?: Vector4;
  51231. backUVs?: Vector4;
  51232. instance?: Mesh;
  51233. invertUV?: boolean;
  51234. }, scene?: Nullable<Scene>): Mesh;
  51235. private static _ExtrudeShapeGeneric;
  51236. }
  51237. }
  51238. declare module BABYLON {
  51239. /**
  51240. * AmmoJS Physics plugin
  51241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51242. * @see https://github.com/kripken/ammo.js/
  51243. */
  51244. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51245. private _useDeltaForWorldStep;
  51246. /**
  51247. * Reference to the Ammo library
  51248. */
  51249. bjsAMMO: any;
  51250. /**
  51251. * Created ammoJS world which physics bodies are added to
  51252. */
  51253. world: any;
  51254. /**
  51255. * Name of the plugin
  51256. */
  51257. name: string;
  51258. private _timeStep;
  51259. private _fixedTimeStep;
  51260. private _maxSteps;
  51261. private _tmpQuaternion;
  51262. private _tmpAmmoTransform;
  51263. private _tmpAmmoQuaternion;
  51264. private _tmpAmmoConcreteContactResultCallback;
  51265. private _collisionConfiguration;
  51266. private _dispatcher;
  51267. private _overlappingPairCache;
  51268. private _solver;
  51269. private _softBodySolver;
  51270. private _tmpAmmoVectorA;
  51271. private _tmpAmmoVectorB;
  51272. private _tmpAmmoVectorC;
  51273. private _tmpAmmoVectorD;
  51274. private _tmpContactCallbackResult;
  51275. private _tmpAmmoVectorRCA;
  51276. private _tmpAmmoVectorRCB;
  51277. private _raycastResult;
  51278. private static readonly DISABLE_COLLISION_FLAG;
  51279. private static readonly KINEMATIC_FLAG;
  51280. private static readonly DISABLE_DEACTIVATION_FLAG;
  51281. /**
  51282. * Initializes the ammoJS plugin
  51283. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51284. * @param ammoInjection can be used to inject your own ammo reference
  51285. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51286. */
  51287. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51288. /**
  51289. * Sets the gravity of the physics world (m/(s^2))
  51290. * @param gravity Gravity to set
  51291. */
  51292. setGravity(gravity: Vector3): void;
  51293. /**
  51294. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51295. * @param timeStep timestep to use in seconds
  51296. */
  51297. setTimeStep(timeStep: number): void;
  51298. /**
  51299. * 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)
  51300. * @param fixedTimeStep fixedTimeStep to use in seconds
  51301. */
  51302. setFixedTimeStep(fixedTimeStep: number): void;
  51303. /**
  51304. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51305. * @param maxSteps the maximum number of steps by the physics engine per frame
  51306. */
  51307. setMaxSteps(maxSteps: number): void;
  51308. /**
  51309. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51310. * @returns the current timestep in seconds
  51311. */
  51312. getTimeStep(): number;
  51313. private _isImpostorInContact;
  51314. private _isImpostorPairInContact;
  51315. private _stepSimulation;
  51316. /**
  51317. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51318. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51319. * After the step the babylon meshes are set to the position of the physics imposters
  51320. * @param delta amount of time to step forward
  51321. * @param impostors array of imposters to update before/after the step
  51322. */
  51323. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51324. /**
  51325. * Update babylon mesh to match physics world object
  51326. * @param impostor imposter to match
  51327. */
  51328. private _afterSoftStep;
  51329. /**
  51330. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51331. * @param impostor imposter to match
  51332. */
  51333. private _ropeStep;
  51334. /**
  51335. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51336. * @param impostor imposter to match
  51337. */
  51338. private _softbodyOrClothStep;
  51339. private _tmpVector;
  51340. private _tmpMatrix;
  51341. /**
  51342. * Applies an impulse on the imposter
  51343. * @param impostor imposter to apply impulse to
  51344. * @param force amount of force to be applied to the imposter
  51345. * @param contactPoint the location to apply the impulse on the imposter
  51346. */
  51347. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51348. /**
  51349. * Applies a force on the imposter
  51350. * @param impostor imposter to apply force
  51351. * @param force amount of force to be applied to the imposter
  51352. * @param contactPoint the location to apply the force on the imposter
  51353. */
  51354. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51355. /**
  51356. * Creates a physics body using the plugin
  51357. * @param impostor the imposter to create the physics body on
  51358. */
  51359. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51360. /**
  51361. * Removes the physics body from the imposter and disposes of the body's memory
  51362. * @param impostor imposter to remove the physics body from
  51363. */
  51364. removePhysicsBody(impostor: PhysicsImpostor): void;
  51365. /**
  51366. * Generates a joint
  51367. * @param impostorJoint the imposter joint to create the joint with
  51368. */
  51369. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51370. /**
  51371. * Removes a joint
  51372. * @param impostorJoint the imposter joint to remove the joint from
  51373. */
  51374. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51375. private _addMeshVerts;
  51376. /**
  51377. * Initialise the soft body vertices to match its object's (mesh) vertices
  51378. * Softbody vertices (nodes) are in world space and to match this
  51379. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51380. * @param impostor to create the softbody for
  51381. */
  51382. private _softVertexData;
  51383. /**
  51384. * Create an impostor's soft body
  51385. * @param impostor to create the softbody for
  51386. */
  51387. private _createSoftbody;
  51388. /**
  51389. * Create cloth for an impostor
  51390. * @param impostor to create the softbody for
  51391. */
  51392. private _createCloth;
  51393. /**
  51394. * Create rope for an impostor
  51395. * @param impostor to create the softbody for
  51396. */
  51397. private _createRope;
  51398. private _addHullVerts;
  51399. private _createShape;
  51400. /**
  51401. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51402. * @param impostor imposter containing the physics body and babylon object
  51403. */
  51404. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51405. /**
  51406. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51407. * @param impostor imposter containing the physics body and babylon object
  51408. * @param newPosition new position
  51409. * @param newRotation new rotation
  51410. */
  51411. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51412. /**
  51413. * If this plugin is supported
  51414. * @returns true if its supported
  51415. */
  51416. isSupported(): boolean;
  51417. /**
  51418. * Sets the linear velocity of the physics body
  51419. * @param impostor imposter to set the velocity on
  51420. * @param velocity velocity to set
  51421. */
  51422. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51423. /**
  51424. * Sets the angular velocity of the physics body
  51425. * @param impostor imposter to set the velocity on
  51426. * @param velocity velocity to set
  51427. */
  51428. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51429. /**
  51430. * gets the linear velocity
  51431. * @param impostor imposter to get linear velocity from
  51432. * @returns linear velocity
  51433. */
  51434. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51435. /**
  51436. * gets the angular velocity
  51437. * @param impostor imposter to get angular velocity from
  51438. * @returns angular velocity
  51439. */
  51440. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51441. /**
  51442. * Sets the mass of physics body
  51443. * @param impostor imposter to set the mass on
  51444. * @param mass mass to set
  51445. */
  51446. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51447. /**
  51448. * Gets the mass of the physics body
  51449. * @param impostor imposter to get the mass from
  51450. * @returns mass
  51451. */
  51452. getBodyMass(impostor: PhysicsImpostor): number;
  51453. /**
  51454. * Gets friction of the impostor
  51455. * @param impostor impostor to get friction from
  51456. * @returns friction value
  51457. */
  51458. getBodyFriction(impostor: PhysicsImpostor): number;
  51459. /**
  51460. * Sets friction of the impostor
  51461. * @param impostor impostor to set friction on
  51462. * @param friction friction value
  51463. */
  51464. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51465. /**
  51466. * Gets restitution of the impostor
  51467. * @param impostor impostor to get restitution from
  51468. * @returns restitution value
  51469. */
  51470. getBodyRestitution(impostor: PhysicsImpostor): number;
  51471. /**
  51472. * Sets resitution of the impostor
  51473. * @param impostor impostor to set resitution on
  51474. * @param restitution resitution value
  51475. */
  51476. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51477. /**
  51478. * Gets pressure inside the impostor
  51479. * @param impostor impostor to get pressure from
  51480. * @returns pressure value
  51481. */
  51482. getBodyPressure(impostor: PhysicsImpostor): number;
  51483. /**
  51484. * Sets pressure inside a soft body impostor
  51485. * Cloth and rope must remain 0 pressure
  51486. * @param impostor impostor to set pressure on
  51487. * @param pressure pressure value
  51488. */
  51489. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51490. /**
  51491. * Gets stiffness of the impostor
  51492. * @param impostor impostor to get stiffness from
  51493. * @returns pressure value
  51494. */
  51495. getBodyStiffness(impostor: PhysicsImpostor): number;
  51496. /**
  51497. * Sets stiffness of the impostor
  51498. * @param impostor impostor to set stiffness on
  51499. * @param stiffness stiffness value from 0 to 1
  51500. */
  51501. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51502. /**
  51503. * Gets velocityIterations of the impostor
  51504. * @param impostor impostor to get velocity iterations from
  51505. * @returns velocityIterations value
  51506. */
  51507. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51508. /**
  51509. * Sets velocityIterations of the impostor
  51510. * @param impostor impostor to set velocity iterations on
  51511. * @param velocityIterations velocityIterations value
  51512. */
  51513. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51514. /**
  51515. * Gets positionIterations of the impostor
  51516. * @param impostor impostor to get position iterations from
  51517. * @returns positionIterations value
  51518. */
  51519. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51520. /**
  51521. * Sets positionIterations of the impostor
  51522. * @param impostor impostor to set position on
  51523. * @param positionIterations positionIterations value
  51524. */
  51525. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51526. /**
  51527. * Append an anchor to a cloth object
  51528. * @param impostor is the cloth impostor to add anchor to
  51529. * @param otherImpostor is the rigid impostor to anchor to
  51530. * @param width ratio across width from 0 to 1
  51531. * @param height ratio up height from 0 to 1
  51532. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51533. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51534. */
  51535. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51536. /**
  51537. * Append an hook to a rope object
  51538. * @param impostor is the rope impostor to add hook to
  51539. * @param otherImpostor is the rigid impostor to hook to
  51540. * @param length ratio along the rope from 0 to 1
  51541. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51542. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51543. */
  51544. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51545. /**
  51546. * Sleeps the physics body and stops it from being active
  51547. * @param impostor impostor to sleep
  51548. */
  51549. sleepBody(impostor: PhysicsImpostor): void;
  51550. /**
  51551. * Activates the physics body
  51552. * @param impostor impostor to activate
  51553. */
  51554. wakeUpBody(impostor: PhysicsImpostor): void;
  51555. /**
  51556. * Updates the distance parameters of the joint
  51557. * @param joint joint to update
  51558. * @param maxDistance maximum distance of the joint
  51559. * @param minDistance minimum distance of the joint
  51560. */
  51561. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51562. /**
  51563. * Sets a motor on the joint
  51564. * @param joint joint to set motor on
  51565. * @param speed speed of the motor
  51566. * @param maxForce maximum force of the motor
  51567. * @param motorIndex index of the motor
  51568. */
  51569. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51570. /**
  51571. * Sets the motors limit
  51572. * @param joint joint to set limit on
  51573. * @param upperLimit upper limit
  51574. * @param lowerLimit lower limit
  51575. */
  51576. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51577. /**
  51578. * Syncs the position and rotation of a mesh with the impostor
  51579. * @param mesh mesh to sync
  51580. * @param impostor impostor to update the mesh with
  51581. */
  51582. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51583. /**
  51584. * Gets the radius of the impostor
  51585. * @param impostor impostor to get radius from
  51586. * @returns the radius
  51587. */
  51588. getRadius(impostor: PhysicsImpostor): number;
  51589. /**
  51590. * Gets the box size of the impostor
  51591. * @param impostor impostor to get box size from
  51592. * @param result the resulting box size
  51593. */
  51594. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51595. /**
  51596. * Disposes of the impostor
  51597. */
  51598. dispose(): void;
  51599. /**
  51600. * Does a raycast in the physics world
  51601. * @param from when should the ray start?
  51602. * @param to when should the ray end?
  51603. * @returns PhysicsRaycastResult
  51604. */
  51605. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51606. }
  51607. }
  51608. declare module BABYLON {
  51609. interface AbstractScene {
  51610. /**
  51611. * The list of reflection probes added to the scene
  51612. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51613. */
  51614. reflectionProbes: Array<ReflectionProbe>;
  51615. /**
  51616. * Removes the given reflection probe from this scene.
  51617. * @param toRemove The reflection probe to remove
  51618. * @returns The index of the removed reflection probe
  51619. */
  51620. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51621. /**
  51622. * Adds the given reflection probe to this scene.
  51623. * @param newReflectionProbe The reflection probe to add
  51624. */
  51625. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51626. }
  51627. /**
  51628. * Class used to generate realtime reflection / refraction cube textures
  51629. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51630. */
  51631. export class ReflectionProbe {
  51632. /** defines the name of the probe */
  51633. name: string;
  51634. private _scene;
  51635. private _renderTargetTexture;
  51636. private _projectionMatrix;
  51637. private _viewMatrix;
  51638. private _target;
  51639. private _add;
  51640. private _attachedMesh;
  51641. private _invertYAxis;
  51642. /** Gets or sets probe position (center of the cube map) */
  51643. position: Vector3;
  51644. /**
  51645. * Creates a new reflection probe
  51646. * @param name defines the name of the probe
  51647. * @param size defines the texture resolution (for each face)
  51648. * @param scene defines the hosting scene
  51649. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51650. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51651. */
  51652. constructor(
  51653. /** defines the name of the probe */
  51654. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51655. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51656. samples: number;
  51657. /** Gets or sets the refresh rate to use (on every frame by default) */
  51658. refreshRate: number;
  51659. /**
  51660. * Gets the hosting scene
  51661. * @returns a Scene
  51662. */
  51663. getScene(): Scene;
  51664. /** Gets the internal CubeTexture used to render to */
  51665. readonly cubeTexture: RenderTargetTexture;
  51666. /** Gets the list of meshes to render */
  51667. readonly renderList: Nullable<AbstractMesh[]>;
  51668. /**
  51669. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51670. * @param mesh defines the mesh to attach to
  51671. */
  51672. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51673. /**
  51674. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51675. * @param renderingGroupId The rendering group id corresponding to its index
  51676. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51677. */
  51678. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51679. /**
  51680. * Clean all associated resources
  51681. */
  51682. dispose(): void;
  51683. /**
  51684. * Converts the reflection probe information to a readable string for debug purpose.
  51685. * @param fullDetails Supports for multiple levels of logging within scene loading
  51686. * @returns the human readable reflection probe info
  51687. */
  51688. toString(fullDetails?: boolean): string;
  51689. /**
  51690. * Get the class name of the relfection probe.
  51691. * @returns "ReflectionProbe"
  51692. */
  51693. getClassName(): string;
  51694. /**
  51695. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51696. * @returns The JSON representation of the texture
  51697. */
  51698. serialize(): any;
  51699. /**
  51700. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51701. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51702. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51703. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51704. * @returns The parsed reflection probe if successful
  51705. */
  51706. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51707. }
  51708. }
  51709. declare module BABYLON {
  51710. /** @hidden */
  51711. export var _BabylonLoaderRegistered: boolean;
  51712. }
  51713. declare module BABYLON {
  51714. /**
  51715. * The Physically based simple base material of BJS.
  51716. *
  51717. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51718. * It is used as the base class for both the specGloss and metalRough conventions.
  51719. */
  51720. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51721. /**
  51722. * Number of Simultaneous lights allowed on the material.
  51723. */
  51724. maxSimultaneousLights: number;
  51725. /**
  51726. * If sets to true, disables all the lights affecting the material.
  51727. */
  51728. disableLighting: boolean;
  51729. /**
  51730. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51731. */
  51732. environmentTexture: BaseTexture;
  51733. /**
  51734. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51735. */
  51736. invertNormalMapX: boolean;
  51737. /**
  51738. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51739. */
  51740. invertNormalMapY: boolean;
  51741. /**
  51742. * Normal map used in the model.
  51743. */
  51744. normalTexture: BaseTexture;
  51745. /**
  51746. * Emissivie color used to self-illuminate the model.
  51747. */
  51748. emissiveColor: Color3;
  51749. /**
  51750. * Emissivie texture used to self-illuminate the model.
  51751. */
  51752. emissiveTexture: BaseTexture;
  51753. /**
  51754. * Occlusion Channel Strenght.
  51755. */
  51756. occlusionStrength: number;
  51757. /**
  51758. * Occlusion Texture of the material (adding extra occlusion effects).
  51759. */
  51760. occlusionTexture: BaseTexture;
  51761. /**
  51762. * Defines the alpha limits in alpha test mode.
  51763. */
  51764. alphaCutOff: number;
  51765. /**
  51766. * Gets the current double sided mode.
  51767. */
  51768. /**
  51769. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51770. */
  51771. doubleSided: boolean;
  51772. /**
  51773. * Stores the pre-calculated light information of a mesh in a texture.
  51774. */
  51775. lightmapTexture: BaseTexture;
  51776. /**
  51777. * If true, the light map contains occlusion information instead of lighting info.
  51778. */
  51779. useLightmapAsShadowmap: boolean;
  51780. /**
  51781. * Instantiates a new PBRMaterial instance.
  51782. *
  51783. * @param name The material name
  51784. * @param scene The scene the material will be use in.
  51785. */
  51786. constructor(name: string, scene: Scene);
  51787. getClassName(): string;
  51788. }
  51789. }
  51790. declare module BABYLON {
  51791. /**
  51792. * The PBR material of BJS following the metal roughness convention.
  51793. *
  51794. * This fits to the PBR convention in the GLTF definition:
  51795. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51796. */
  51797. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51798. /**
  51799. * The base color has two different interpretations depending on the value of metalness.
  51800. * When the material is a metal, the base color is the specific measured reflectance value
  51801. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51802. * of the material.
  51803. */
  51804. baseColor: Color3;
  51805. /**
  51806. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51807. * well as opacity information in the alpha channel.
  51808. */
  51809. baseTexture: BaseTexture;
  51810. /**
  51811. * Specifies the metallic scalar value of the material.
  51812. * Can also be used to scale the metalness values of the metallic texture.
  51813. */
  51814. metallic: number;
  51815. /**
  51816. * Specifies the roughness scalar value of the material.
  51817. * Can also be used to scale the roughness values of the metallic texture.
  51818. */
  51819. roughness: number;
  51820. /**
  51821. * Texture containing both the metallic value in the B channel and the
  51822. * roughness value in the G channel to keep better precision.
  51823. */
  51824. metallicRoughnessTexture: BaseTexture;
  51825. /**
  51826. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51827. *
  51828. * @param name The material name
  51829. * @param scene The scene the material will be use in.
  51830. */
  51831. constructor(name: string, scene: Scene);
  51832. /**
  51833. * Return the currrent class name of the material.
  51834. */
  51835. getClassName(): string;
  51836. /**
  51837. * Makes a duplicate of the current material.
  51838. * @param name - name to use for the new material.
  51839. */
  51840. clone(name: string): PBRMetallicRoughnessMaterial;
  51841. /**
  51842. * Serialize the material to a parsable JSON object.
  51843. */
  51844. serialize(): any;
  51845. /**
  51846. * Parses a JSON object correponding to the serialize function.
  51847. */
  51848. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51849. }
  51850. }
  51851. declare module BABYLON {
  51852. /**
  51853. * The PBR material of BJS following the specular glossiness convention.
  51854. *
  51855. * This fits to the PBR convention in the GLTF definition:
  51856. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51857. */
  51858. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51859. /**
  51860. * Specifies the diffuse color of the material.
  51861. */
  51862. diffuseColor: Color3;
  51863. /**
  51864. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51865. * channel.
  51866. */
  51867. diffuseTexture: BaseTexture;
  51868. /**
  51869. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51870. */
  51871. specularColor: Color3;
  51872. /**
  51873. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51874. */
  51875. glossiness: number;
  51876. /**
  51877. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51878. */
  51879. specularGlossinessTexture: BaseTexture;
  51880. /**
  51881. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51882. *
  51883. * @param name The material name
  51884. * @param scene The scene the material will be use in.
  51885. */
  51886. constructor(name: string, scene: Scene);
  51887. /**
  51888. * Return the currrent class name of the material.
  51889. */
  51890. getClassName(): string;
  51891. /**
  51892. * Makes a duplicate of the current material.
  51893. * @param name - name to use for the new material.
  51894. */
  51895. clone(name: string): PBRSpecularGlossinessMaterial;
  51896. /**
  51897. * Serialize the material to a parsable JSON object.
  51898. */
  51899. serialize(): any;
  51900. /**
  51901. * Parses a JSON object correponding to the serialize function.
  51902. */
  51903. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51904. }
  51905. }
  51906. declare module BABYLON {
  51907. /**
  51908. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51909. * It can help converting any input color in a desired output one. This can then be used to create effects
  51910. * from sepia, black and white to sixties or futuristic rendering...
  51911. *
  51912. * The only supported format is currently 3dl.
  51913. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51914. */
  51915. export class ColorGradingTexture extends BaseTexture {
  51916. /**
  51917. * The current texture matrix. (will always be identity in color grading texture)
  51918. */
  51919. private _textureMatrix;
  51920. /**
  51921. * The texture URL.
  51922. */
  51923. url: string;
  51924. /**
  51925. * Empty line regex stored for GC.
  51926. */
  51927. private static _noneEmptyLineRegex;
  51928. private _engine;
  51929. /**
  51930. * Instantiates a ColorGradingTexture from the following parameters.
  51931. *
  51932. * @param url The location of the color gradind data (currently only supporting 3dl)
  51933. * @param scene The scene the texture will be used in
  51934. */
  51935. constructor(url: string, scene: Scene);
  51936. /**
  51937. * Returns the texture matrix used in most of the material.
  51938. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51939. */
  51940. getTextureMatrix(): Matrix;
  51941. /**
  51942. * Occurs when the file being loaded is a .3dl LUT file.
  51943. */
  51944. private load3dlTexture;
  51945. /**
  51946. * Starts the loading process of the texture.
  51947. */
  51948. private loadTexture;
  51949. /**
  51950. * Clones the color gradind texture.
  51951. */
  51952. clone(): ColorGradingTexture;
  51953. /**
  51954. * Called during delayed load for textures.
  51955. */
  51956. delayLoad(): void;
  51957. /**
  51958. * Parses a color grading texture serialized by Babylon.
  51959. * @param parsedTexture The texture information being parsedTexture
  51960. * @param scene The scene to load the texture in
  51961. * @param rootUrl The root url of the data assets to load
  51962. * @return A color gradind texture
  51963. */
  51964. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51965. /**
  51966. * Serializes the LUT texture to json format.
  51967. */
  51968. serialize(): any;
  51969. }
  51970. }
  51971. declare module BABYLON {
  51972. /**
  51973. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51974. */
  51975. export class EquiRectangularCubeTexture extends BaseTexture {
  51976. /** The six faces of the cube. */
  51977. private static _FacesMapping;
  51978. private _noMipmap;
  51979. private _onLoad;
  51980. private _onError;
  51981. /** The size of the cubemap. */
  51982. private _size;
  51983. /** The buffer of the image. */
  51984. private _buffer;
  51985. /** The width of the input image. */
  51986. private _width;
  51987. /** The height of the input image. */
  51988. private _height;
  51989. /** The URL to the image. */
  51990. url: string;
  51991. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51992. coordinatesMode: number;
  51993. /**
  51994. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51995. * @param url The location of the image
  51996. * @param scene The scene the texture will be used in
  51997. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51998. * @param noMipmap Forces to not generate the mipmap if true
  51999. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52000. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52001. * @param onLoad — defines a callback called when texture is loaded
  52002. * @param onError — defines a callback called if there is an error
  52003. */
  52004. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52005. /**
  52006. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52007. */
  52008. private loadImage;
  52009. /**
  52010. * Convert the image buffer into a cubemap and create a CubeTexture.
  52011. */
  52012. private loadTexture;
  52013. /**
  52014. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52015. * @param buffer The ArrayBuffer that should be converted.
  52016. * @returns The buffer as Float32Array.
  52017. */
  52018. private getFloat32ArrayFromArrayBuffer;
  52019. /**
  52020. * Get the current class name of the texture useful for serialization or dynamic coding.
  52021. * @returns "EquiRectangularCubeTexture"
  52022. */
  52023. getClassName(): string;
  52024. /**
  52025. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52026. * @returns A clone of the current EquiRectangularCubeTexture.
  52027. */
  52028. clone(): EquiRectangularCubeTexture;
  52029. }
  52030. }
  52031. declare module BABYLON {
  52032. /**
  52033. * Based on jsTGALoader - Javascript loader for TGA file
  52034. * By Vincent Thibault
  52035. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52036. */
  52037. export class TGATools {
  52038. private static _TYPE_INDEXED;
  52039. private static _TYPE_RGB;
  52040. private static _TYPE_GREY;
  52041. private static _TYPE_RLE_INDEXED;
  52042. private static _TYPE_RLE_RGB;
  52043. private static _TYPE_RLE_GREY;
  52044. private static _ORIGIN_MASK;
  52045. private static _ORIGIN_SHIFT;
  52046. private static _ORIGIN_BL;
  52047. private static _ORIGIN_BR;
  52048. private static _ORIGIN_UL;
  52049. private static _ORIGIN_UR;
  52050. /**
  52051. * Gets the header of a TGA file
  52052. * @param data defines the TGA data
  52053. * @returns the header
  52054. */
  52055. static GetTGAHeader(data: Uint8Array): any;
  52056. /**
  52057. * Uploads TGA content to a Babylon Texture
  52058. * @hidden
  52059. */
  52060. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52061. /** @hidden */
  52062. 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;
  52063. /** @hidden */
  52064. 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;
  52065. /** @hidden */
  52066. 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;
  52067. /** @hidden */
  52068. 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;
  52069. /** @hidden */
  52070. 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;
  52071. /** @hidden */
  52072. 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;
  52073. }
  52074. }
  52075. declare module BABYLON {
  52076. /**
  52077. * Implementation of the TGA Texture Loader.
  52078. * @hidden
  52079. */
  52080. export class _TGATextureLoader implements IInternalTextureLoader {
  52081. /**
  52082. * Defines wether the loader supports cascade loading the different faces.
  52083. */
  52084. readonly supportCascades: boolean;
  52085. /**
  52086. * This returns if the loader support the current file information.
  52087. * @param extension defines the file extension of the file being loaded
  52088. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52089. * @param fallback defines the fallback internal texture if any
  52090. * @param isBase64 defines whether the texture is encoded as a base64
  52091. * @param isBuffer defines whether the texture data are stored as a buffer
  52092. * @returns true if the loader can load the specified file
  52093. */
  52094. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52095. /**
  52096. * Transform the url before loading if required.
  52097. * @param rootUrl the url of the texture
  52098. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52099. * @returns the transformed texture
  52100. */
  52101. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52102. /**
  52103. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52104. * @param rootUrl the url of the texture
  52105. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52106. * @returns the fallback texture
  52107. */
  52108. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52109. /**
  52110. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52111. * @param data contains the texture data
  52112. * @param texture defines the BabylonJS internal texture
  52113. * @param createPolynomials will be true if polynomials have been requested
  52114. * @param onLoad defines the callback to trigger once the texture is ready
  52115. * @param onError defines the callback to trigger in case of error
  52116. */
  52117. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52118. /**
  52119. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52120. * @param data contains the texture data
  52121. * @param texture defines the BabylonJS internal texture
  52122. * @param callback defines the method to call once ready to upload
  52123. */
  52124. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52125. }
  52126. }
  52127. declare module BABYLON {
  52128. /**
  52129. * Info about the .basis files
  52130. */
  52131. class BasisFileInfo {
  52132. /**
  52133. * If the file has alpha
  52134. */
  52135. hasAlpha: boolean;
  52136. /**
  52137. * Info about each image of the basis file
  52138. */
  52139. images: Array<{
  52140. levels: Array<{
  52141. width: number;
  52142. height: number;
  52143. transcodedPixels: ArrayBufferView;
  52144. }>;
  52145. }>;
  52146. }
  52147. /**
  52148. * Result of transcoding a basis file
  52149. */
  52150. class TranscodeResult {
  52151. /**
  52152. * Info about the .basis file
  52153. */
  52154. fileInfo: BasisFileInfo;
  52155. /**
  52156. * Format to use when loading the file
  52157. */
  52158. format: number;
  52159. }
  52160. /**
  52161. * Configuration options for the Basis transcoder
  52162. */
  52163. export class BasisTranscodeConfiguration {
  52164. /**
  52165. * Supported compression formats used to determine the supported output format of the transcoder
  52166. */
  52167. supportedCompressionFormats?: {
  52168. /**
  52169. * etc1 compression format
  52170. */
  52171. etc1?: boolean;
  52172. /**
  52173. * s3tc compression format
  52174. */
  52175. s3tc?: boolean;
  52176. /**
  52177. * pvrtc compression format
  52178. */
  52179. pvrtc?: boolean;
  52180. /**
  52181. * etc2 compression format
  52182. */
  52183. etc2?: boolean;
  52184. };
  52185. /**
  52186. * If mipmap levels should be loaded for transcoded images (Default: true)
  52187. */
  52188. loadMipmapLevels?: boolean;
  52189. /**
  52190. * Index of a single image to load (Default: all images)
  52191. */
  52192. loadSingleImage?: number;
  52193. }
  52194. /**
  52195. * Used to load .Basis files
  52196. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52197. */
  52198. export class BasisTools {
  52199. private static _IgnoreSupportedFormats;
  52200. /**
  52201. * URL to use when loading the basis transcoder
  52202. */
  52203. static JSModuleURL: string;
  52204. /**
  52205. * URL to use when loading the wasm module for the transcoder
  52206. */
  52207. static WasmModuleURL: string;
  52208. /**
  52209. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52210. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52211. * @returns internal format corresponding to the Basis format
  52212. */
  52213. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52214. private static _WorkerPromise;
  52215. private static _Worker;
  52216. private static _actionId;
  52217. private static _CreateWorkerAsync;
  52218. /**
  52219. * Transcodes a loaded image file to compressed pixel data
  52220. * @param imageData image data to transcode
  52221. * @param config configuration options for the transcoding
  52222. * @returns a promise resulting in the transcoded image
  52223. */
  52224. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52225. /**
  52226. * Loads a texture from the transcode result
  52227. * @param texture texture load to
  52228. * @param transcodeResult the result of transcoding the basis file to load from
  52229. */
  52230. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52231. }
  52232. }
  52233. declare module BABYLON {
  52234. /**
  52235. * Loader for .basis file format
  52236. */
  52237. export class _BasisTextureLoader implements IInternalTextureLoader {
  52238. /**
  52239. * Defines whether the loader supports cascade loading the different faces.
  52240. */
  52241. readonly supportCascades: boolean;
  52242. /**
  52243. * This returns if the loader support the current file information.
  52244. * @param extension defines the file extension of the file being loaded
  52245. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52246. * @param fallback defines the fallback internal texture if any
  52247. * @param isBase64 defines whether the texture is encoded as a base64
  52248. * @param isBuffer defines whether the texture data are stored as a buffer
  52249. * @returns true if the loader can load the specified file
  52250. */
  52251. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52252. /**
  52253. * Transform the url before loading if required.
  52254. * @param rootUrl the url of the texture
  52255. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52256. * @returns the transformed texture
  52257. */
  52258. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52259. /**
  52260. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52261. * @param rootUrl the url of the texture
  52262. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52263. * @returns the fallback texture
  52264. */
  52265. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52266. /**
  52267. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52268. * @param data contains the texture data
  52269. * @param texture defines the BabylonJS internal texture
  52270. * @param createPolynomials will be true if polynomials have been requested
  52271. * @param onLoad defines the callback to trigger once the texture is ready
  52272. * @param onError defines the callback to trigger in case of error
  52273. */
  52274. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52275. /**
  52276. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52277. * @param data contains the texture data
  52278. * @param texture defines the BabylonJS internal texture
  52279. * @param callback defines the method to call once ready to upload
  52280. */
  52281. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52282. }
  52283. }
  52284. declare module BABYLON {
  52285. /**
  52286. * 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.
  52287. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52288. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52289. */
  52290. export class CustomProceduralTexture extends ProceduralTexture {
  52291. private _animate;
  52292. private _time;
  52293. private _config;
  52294. private _texturePath;
  52295. /**
  52296. * Instantiates a new Custom Procedural Texture.
  52297. * 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.
  52298. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52299. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52300. * @param name Define the name of the texture
  52301. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52302. * @param size Define the size of the texture to create
  52303. * @param scene Define the scene the texture belongs to
  52304. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52305. * @param generateMipMaps Define if the texture should creates mip maps or not
  52306. */
  52307. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52308. private _loadJson;
  52309. /**
  52310. * Is the texture ready to be used ? (rendered at least once)
  52311. * @returns true if ready, otherwise, false.
  52312. */
  52313. isReady(): boolean;
  52314. /**
  52315. * Render the texture to its associated render target.
  52316. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52317. */
  52318. render(useCameraPostProcess?: boolean): void;
  52319. /**
  52320. * Update the list of dependant textures samplers in the shader.
  52321. */
  52322. updateTextures(): void;
  52323. /**
  52324. * Update the uniform values of the procedural texture in the shader.
  52325. */
  52326. updateShaderUniforms(): void;
  52327. /**
  52328. * Define if the texture animates or not.
  52329. */
  52330. animate: boolean;
  52331. }
  52332. }
  52333. declare module BABYLON {
  52334. /** @hidden */
  52335. export var noisePixelShader: {
  52336. name: string;
  52337. shader: string;
  52338. };
  52339. }
  52340. declare module BABYLON {
  52341. /**
  52342. * Class used to generate noise procedural textures
  52343. */
  52344. export class NoiseProceduralTexture extends ProceduralTexture {
  52345. private _time;
  52346. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52347. brightness: number;
  52348. /** Defines the number of octaves to process */
  52349. octaves: number;
  52350. /** Defines the level of persistence (0.8 by default) */
  52351. persistence: number;
  52352. /** Gets or sets animation speed factor (default is 1) */
  52353. animationSpeedFactor: number;
  52354. /**
  52355. * Creates a new NoiseProceduralTexture
  52356. * @param name defines the name fo the texture
  52357. * @param size defines the size of the texture (default is 256)
  52358. * @param scene defines the hosting scene
  52359. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52360. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52361. */
  52362. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52363. private _updateShaderUniforms;
  52364. protected _getDefines(): string;
  52365. /** Generate the current state of the procedural texture */
  52366. render(useCameraPostProcess?: boolean): void;
  52367. /**
  52368. * Serializes this noise procedural texture
  52369. * @returns a serialized noise procedural texture object
  52370. */
  52371. serialize(): any;
  52372. /**
  52373. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52374. * @param parsedTexture defines parsed texture data
  52375. * @param scene defines the current scene
  52376. * @param rootUrl defines the root URL containing noise procedural texture information
  52377. * @returns a parsed NoiseProceduralTexture
  52378. */
  52379. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52380. }
  52381. }
  52382. declare module BABYLON {
  52383. /**
  52384. * Raw cube texture where the raw buffers are passed in
  52385. */
  52386. export class RawCubeTexture extends CubeTexture {
  52387. /**
  52388. * Creates a cube texture where the raw buffers are passed in.
  52389. * @param scene defines the scene the texture is attached to
  52390. * @param data defines the array of data to use to create each face
  52391. * @param size defines the size of the textures
  52392. * @param format defines the format of the data
  52393. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52394. * @param generateMipMaps defines if the engine should generate the mip levels
  52395. * @param invertY defines if data must be stored with Y axis inverted
  52396. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52397. * @param compression defines the compression used (null by default)
  52398. */
  52399. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52400. /**
  52401. * Updates the raw cube texture.
  52402. * @param data defines the data to store
  52403. * @param format defines the data format
  52404. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52405. * @param invertY defines if data must be stored with Y axis inverted
  52406. * @param compression defines the compression used (null by default)
  52407. * @param level defines which level of the texture to update
  52408. */
  52409. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52410. /**
  52411. * Updates a raw cube texture with RGBD encoded data.
  52412. * @param data defines the array of data [mipmap][face] to use to create each face
  52413. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52414. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52415. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52416. * @returns a promsie that resolves when the operation is complete
  52417. */
  52418. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52419. /**
  52420. * Clones the raw cube texture.
  52421. * @return a new cube texture
  52422. */
  52423. clone(): CubeTexture;
  52424. /** @hidden */
  52425. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52426. }
  52427. }
  52428. declare module BABYLON {
  52429. /**
  52430. * Class used to store 3D textures containing user data
  52431. */
  52432. export class RawTexture3D extends Texture {
  52433. /** Gets or sets the texture format to use */
  52434. format: number;
  52435. private _engine;
  52436. /**
  52437. * Create a new RawTexture3D
  52438. * @param data defines the data of the texture
  52439. * @param width defines the width of the texture
  52440. * @param height defines the height of the texture
  52441. * @param depth defines the depth of the texture
  52442. * @param format defines the texture format to use
  52443. * @param scene defines the hosting scene
  52444. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52445. * @param invertY defines if texture must be stored with Y axis inverted
  52446. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52447. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52448. */
  52449. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52450. /** Gets or sets the texture format to use */
  52451. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52452. /**
  52453. * Update the texture with new data
  52454. * @param data defines the data to store in the texture
  52455. */
  52456. update(data: ArrayBufferView): void;
  52457. }
  52458. }
  52459. declare module BABYLON {
  52460. /**
  52461. * Creates a refraction texture used by refraction channel of the standard material.
  52462. * It is like a mirror but to see through a material.
  52463. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52464. */
  52465. export class RefractionTexture extends RenderTargetTexture {
  52466. /**
  52467. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52468. * 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.
  52469. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52470. */
  52471. refractionPlane: Plane;
  52472. /**
  52473. * Define how deep under the surface we should see.
  52474. */
  52475. depth: number;
  52476. /**
  52477. * Creates a refraction texture used by refraction channel of the standard material.
  52478. * It is like a mirror but to see through a material.
  52479. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52480. * @param name Define the texture name
  52481. * @param size Define the size of the underlying texture
  52482. * @param scene Define the scene the refraction belongs to
  52483. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52484. */
  52485. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52486. /**
  52487. * Clone the refraction texture.
  52488. * @returns the cloned texture
  52489. */
  52490. clone(): RefractionTexture;
  52491. /**
  52492. * Serialize the texture to a JSON representation you could use in Parse later on
  52493. * @returns the serialized JSON representation
  52494. */
  52495. serialize(): any;
  52496. }
  52497. }
  52498. declare module BABYLON {
  52499. /**
  52500. * Defines the options related to the creation of an HtmlElementTexture
  52501. */
  52502. export interface IHtmlElementTextureOptions {
  52503. /**
  52504. * Defines wether mip maps should be created or not.
  52505. */
  52506. generateMipMaps?: boolean;
  52507. /**
  52508. * Defines the sampling mode of the texture.
  52509. */
  52510. samplingMode?: number;
  52511. /**
  52512. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52513. */
  52514. engine: Nullable<ThinEngine>;
  52515. /**
  52516. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52517. */
  52518. scene: Nullable<Scene>;
  52519. }
  52520. /**
  52521. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52522. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52523. * is automatically managed.
  52524. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52525. * in your application.
  52526. *
  52527. * As the update is not automatic, you need to call them manually.
  52528. */
  52529. export class HtmlElementTexture extends BaseTexture {
  52530. /**
  52531. * The texture URL.
  52532. */
  52533. element: HTMLVideoElement | HTMLCanvasElement;
  52534. private static readonly DefaultOptions;
  52535. private _textureMatrix;
  52536. private _engine;
  52537. private _isVideo;
  52538. private _generateMipMaps;
  52539. private _samplingMode;
  52540. /**
  52541. * Instantiates a HtmlElementTexture from the following parameters.
  52542. *
  52543. * @param name Defines the name of the texture
  52544. * @param element Defines the video or canvas the texture is filled with
  52545. * @param options Defines the other none mandatory texture creation options
  52546. */
  52547. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52548. private _createInternalTexture;
  52549. /**
  52550. * Returns the texture matrix used in most of the material.
  52551. */
  52552. getTextureMatrix(): Matrix;
  52553. /**
  52554. * Updates the content of the texture.
  52555. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52556. */
  52557. update(invertY?: Nullable<boolean>): void;
  52558. }
  52559. }
  52560. declare module BABYLON {
  52561. /**
  52562. * Enum used to define the target of a block
  52563. */
  52564. export enum NodeMaterialBlockTargets {
  52565. /** Vertex shader */
  52566. Vertex = 1,
  52567. /** Fragment shader */
  52568. Fragment = 2,
  52569. /** Neutral */
  52570. Neutral = 4,
  52571. /** Vertex and Fragment */
  52572. VertexAndFragment = 3
  52573. }
  52574. }
  52575. declare module BABYLON {
  52576. /**
  52577. * Defines the kind of connection point for node based material
  52578. */
  52579. export enum NodeMaterialBlockConnectionPointTypes {
  52580. /** Float */
  52581. Float = 1,
  52582. /** Int */
  52583. Int = 2,
  52584. /** Vector2 */
  52585. Vector2 = 4,
  52586. /** Vector3 */
  52587. Vector3 = 8,
  52588. /** Vector4 */
  52589. Vector4 = 16,
  52590. /** Color3 */
  52591. Color3 = 32,
  52592. /** Color4 */
  52593. Color4 = 64,
  52594. /** Matrix */
  52595. Matrix = 128,
  52596. /** Detect type based on connection */
  52597. AutoDetect = 1024,
  52598. /** Output type that will be defined by input type */
  52599. BasedOnInput = 2048
  52600. }
  52601. }
  52602. declare module BABYLON {
  52603. /**
  52604. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52605. */
  52606. export enum NodeMaterialBlockConnectionPointMode {
  52607. /** Value is an uniform */
  52608. Uniform = 0,
  52609. /** Value is a mesh attribute */
  52610. Attribute = 1,
  52611. /** Value is a varying between vertex and fragment shaders */
  52612. Varying = 2,
  52613. /** Mode is undefined */
  52614. Undefined = 3
  52615. }
  52616. }
  52617. declare module BABYLON {
  52618. /**
  52619. * Enum used to define system values e.g. values automatically provided by the system
  52620. */
  52621. export enum NodeMaterialSystemValues {
  52622. /** World */
  52623. World = 1,
  52624. /** View */
  52625. View = 2,
  52626. /** Projection */
  52627. Projection = 3,
  52628. /** ViewProjection */
  52629. ViewProjection = 4,
  52630. /** WorldView */
  52631. WorldView = 5,
  52632. /** WorldViewProjection */
  52633. WorldViewProjection = 6,
  52634. /** CameraPosition */
  52635. CameraPosition = 7,
  52636. /** Fog Color */
  52637. FogColor = 8,
  52638. /** Delta time */
  52639. DeltaTime = 9
  52640. }
  52641. }
  52642. declare module BABYLON {
  52643. /**
  52644. * Root class for all node material optimizers
  52645. */
  52646. export class NodeMaterialOptimizer {
  52647. /**
  52648. * Function used to optimize a NodeMaterial graph
  52649. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52650. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52651. */
  52652. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52653. }
  52654. }
  52655. declare module BABYLON {
  52656. /**
  52657. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52658. */
  52659. export class TransformBlock extends NodeMaterialBlock {
  52660. /**
  52661. * Defines the value to use to complement W value to transform it to a Vector4
  52662. */
  52663. complementW: number;
  52664. /**
  52665. * Defines the value to use to complement z value to transform it to a Vector4
  52666. */
  52667. complementZ: number;
  52668. /**
  52669. * Creates a new TransformBlock
  52670. * @param name defines the block name
  52671. */
  52672. constructor(name: string);
  52673. /**
  52674. * Gets the current class name
  52675. * @returns the class name
  52676. */
  52677. getClassName(): string;
  52678. /**
  52679. * Gets the vector input
  52680. */
  52681. readonly vector: NodeMaterialConnectionPoint;
  52682. /**
  52683. * Gets the output component
  52684. */
  52685. readonly output: NodeMaterialConnectionPoint;
  52686. /**
  52687. * Gets the matrix transform input
  52688. */
  52689. readonly transform: NodeMaterialConnectionPoint;
  52690. protected _buildBlock(state: NodeMaterialBuildState): this;
  52691. serialize(): any;
  52692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52693. protected _dumpPropertiesCode(): string;
  52694. }
  52695. }
  52696. declare module BABYLON {
  52697. /**
  52698. * Block used to output the vertex position
  52699. */
  52700. export class VertexOutputBlock extends NodeMaterialBlock {
  52701. /**
  52702. * Creates a new VertexOutputBlock
  52703. * @param name defines the block name
  52704. */
  52705. constructor(name: string);
  52706. /**
  52707. * Gets the current class name
  52708. * @returns the class name
  52709. */
  52710. getClassName(): string;
  52711. /**
  52712. * Gets the vector input component
  52713. */
  52714. readonly vector: NodeMaterialConnectionPoint;
  52715. protected _buildBlock(state: NodeMaterialBuildState): this;
  52716. }
  52717. }
  52718. declare module BABYLON {
  52719. /**
  52720. * Block used to output the final color
  52721. */
  52722. export class FragmentOutputBlock extends NodeMaterialBlock {
  52723. /**
  52724. * Create a new FragmentOutputBlock
  52725. * @param name defines the block name
  52726. */
  52727. constructor(name: string);
  52728. /**
  52729. * Gets the current class name
  52730. * @returns the class name
  52731. */
  52732. getClassName(): string;
  52733. /**
  52734. * Gets the rgba input component
  52735. */
  52736. readonly rgba: NodeMaterialConnectionPoint;
  52737. /**
  52738. * Gets the rgb input component
  52739. */
  52740. readonly rgb: NodeMaterialConnectionPoint;
  52741. /**
  52742. * Gets the a input component
  52743. */
  52744. readonly a: NodeMaterialConnectionPoint;
  52745. protected _buildBlock(state: NodeMaterialBuildState): this;
  52746. }
  52747. }
  52748. declare module BABYLON {
  52749. /**
  52750. * Block used to read a reflection texture from a sampler
  52751. */
  52752. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52753. private _define3DName;
  52754. private _defineCubicName;
  52755. private _defineExplicitName;
  52756. private _defineProjectionName;
  52757. private _defineLocalCubicName;
  52758. private _defineSphericalName;
  52759. private _definePlanarName;
  52760. private _defineEquirectangularName;
  52761. private _defineMirroredEquirectangularFixedName;
  52762. private _defineEquirectangularFixedName;
  52763. private _defineSkyboxName;
  52764. private _cubeSamplerName;
  52765. private _2DSamplerName;
  52766. private _positionUVWName;
  52767. private _directionWName;
  52768. private _reflectionCoordsName;
  52769. private _reflection2DCoordsName;
  52770. private _reflectionColorName;
  52771. private _reflectionMatrixName;
  52772. /**
  52773. * Gets or sets the texture associated with the node
  52774. */
  52775. texture: Nullable<BaseTexture>;
  52776. /**
  52777. * Create a new TextureBlock
  52778. * @param name defines the block name
  52779. */
  52780. constructor(name: string);
  52781. /**
  52782. * Gets the current class name
  52783. * @returns the class name
  52784. */
  52785. getClassName(): string;
  52786. /**
  52787. * Gets the world position input component
  52788. */
  52789. readonly position: NodeMaterialConnectionPoint;
  52790. /**
  52791. * Gets the world position input component
  52792. */
  52793. readonly worldPosition: NodeMaterialConnectionPoint;
  52794. /**
  52795. * Gets the world normal input component
  52796. */
  52797. readonly worldNormal: NodeMaterialConnectionPoint;
  52798. /**
  52799. * Gets the world input component
  52800. */
  52801. readonly world: NodeMaterialConnectionPoint;
  52802. /**
  52803. * Gets the camera (or eye) position component
  52804. */
  52805. readonly cameraPosition: NodeMaterialConnectionPoint;
  52806. /**
  52807. * Gets the view input component
  52808. */
  52809. readonly view: NodeMaterialConnectionPoint;
  52810. /**
  52811. * Gets the rgb output component
  52812. */
  52813. readonly rgb: NodeMaterialConnectionPoint;
  52814. /**
  52815. * Gets the r output component
  52816. */
  52817. readonly r: NodeMaterialConnectionPoint;
  52818. /**
  52819. * Gets the g output component
  52820. */
  52821. readonly g: NodeMaterialConnectionPoint;
  52822. /**
  52823. * Gets the b output component
  52824. */
  52825. readonly b: NodeMaterialConnectionPoint;
  52826. autoConfigure(material: NodeMaterial): void;
  52827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52828. isReady(): boolean;
  52829. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52830. private _injectVertexCode;
  52831. private _writeOutput;
  52832. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52833. serialize(): any;
  52834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52835. }
  52836. }
  52837. declare module BABYLON {
  52838. /**
  52839. * Interface used to configure the node material editor
  52840. */
  52841. export interface INodeMaterialEditorOptions {
  52842. /** Define the URl to load node editor script */
  52843. editorURL?: string;
  52844. }
  52845. /** @hidden */
  52846. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52847. /** BONES */
  52848. NUM_BONE_INFLUENCERS: number;
  52849. BonesPerMesh: number;
  52850. BONETEXTURE: boolean;
  52851. /** MORPH TARGETS */
  52852. MORPHTARGETS: boolean;
  52853. MORPHTARGETS_NORMAL: boolean;
  52854. MORPHTARGETS_TANGENT: boolean;
  52855. MORPHTARGETS_UV: boolean;
  52856. NUM_MORPH_INFLUENCERS: number;
  52857. /** IMAGE PROCESSING */
  52858. IMAGEPROCESSING: boolean;
  52859. VIGNETTE: boolean;
  52860. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52861. VIGNETTEBLENDMODEOPAQUE: boolean;
  52862. TONEMAPPING: boolean;
  52863. TONEMAPPING_ACES: boolean;
  52864. CONTRAST: boolean;
  52865. EXPOSURE: boolean;
  52866. COLORCURVES: boolean;
  52867. COLORGRADING: boolean;
  52868. COLORGRADING3D: boolean;
  52869. SAMPLER3DGREENDEPTH: boolean;
  52870. SAMPLER3DBGRMAP: boolean;
  52871. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52872. /** MISC. */
  52873. BUMPDIRECTUV: number;
  52874. constructor();
  52875. setValue(name: string, value: boolean): void;
  52876. }
  52877. /**
  52878. * Class used to configure NodeMaterial
  52879. */
  52880. export interface INodeMaterialOptions {
  52881. /**
  52882. * Defines if blocks should emit comments
  52883. */
  52884. emitComments: boolean;
  52885. }
  52886. /**
  52887. * Class used to create a node based material built by assembling shader blocks
  52888. */
  52889. export class NodeMaterial extends PushMaterial {
  52890. private static _BuildIdGenerator;
  52891. private _options;
  52892. private _vertexCompilationState;
  52893. private _fragmentCompilationState;
  52894. private _sharedData;
  52895. private _buildId;
  52896. private _buildWasSuccessful;
  52897. private _cachedWorldViewMatrix;
  52898. private _cachedWorldViewProjectionMatrix;
  52899. private _optimizers;
  52900. private _animationFrame;
  52901. /** Define the URl to load node editor script */
  52902. static EditorURL: string;
  52903. private BJSNODEMATERIALEDITOR;
  52904. /** Get the inspector from bundle or global */
  52905. private _getGlobalNodeMaterialEditor;
  52906. /**
  52907. * 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)
  52908. */
  52909. ignoreAlpha: boolean;
  52910. /**
  52911. * Defines the maximum number of lights that can be used in the material
  52912. */
  52913. maxSimultaneousLights: number;
  52914. /**
  52915. * Observable raised when the material is built
  52916. */
  52917. onBuildObservable: Observable<NodeMaterial>;
  52918. /**
  52919. * Gets or sets the root nodes of the material vertex shader
  52920. */
  52921. _vertexOutputNodes: NodeMaterialBlock[];
  52922. /**
  52923. * Gets or sets the root nodes of the material fragment (pixel) shader
  52924. */
  52925. _fragmentOutputNodes: NodeMaterialBlock[];
  52926. /** Gets or sets options to control the node material overall behavior */
  52927. options: INodeMaterialOptions;
  52928. /**
  52929. * Default configuration related to image processing available in the standard Material.
  52930. */
  52931. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52932. /**
  52933. * Gets the image processing configuration used either in this material.
  52934. */
  52935. /**
  52936. * Sets the Default image processing configuration used either in the this material.
  52937. *
  52938. * If sets to null, the scene one is in use.
  52939. */
  52940. imageProcessingConfiguration: ImageProcessingConfiguration;
  52941. /**
  52942. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52943. */
  52944. attachedBlocks: NodeMaterialBlock[];
  52945. /**
  52946. * Create a new node based material
  52947. * @param name defines the material name
  52948. * @param scene defines the hosting scene
  52949. * @param options defines creation option
  52950. */
  52951. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52952. /**
  52953. * Gets the current class name of the material e.g. "NodeMaterial"
  52954. * @returns the class name
  52955. */
  52956. getClassName(): string;
  52957. /**
  52958. * Keep track of the image processing observer to allow dispose and replace.
  52959. */
  52960. private _imageProcessingObserver;
  52961. /**
  52962. * Attaches a new image processing configuration to the Standard Material.
  52963. * @param configuration
  52964. */
  52965. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52966. /**
  52967. * Get a block by its name
  52968. * @param name defines the name of the block to retrieve
  52969. * @returns the required block or null if not found
  52970. */
  52971. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52972. /**
  52973. * Get a block by its name
  52974. * @param predicate defines the predicate used to find the good candidate
  52975. * @returns the required block or null if not found
  52976. */
  52977. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52978. /**
  52979. * Get an input block by its name
  52980. * @param predicate defines the predicate used to find the good candidate
  52981. * @returns the required input block or null if not found
  52982. */
  52983. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52984. /**
  52985. * Gets the list of input blocks attached to this material
  52986. * @returns an array of InputBlocks
  52987. */
  52988. getInputBlocks(): InputBlock[];
  52989. /**
  52990. * Adds a new optimizer to the list of optimizers
  52991. * @param optimizer defines the optimizers to add
  52992. * @returns the current material
  52993. */
  52994. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52995. /**
  52996. * Remove an optimizer from the list of optimizers
  52997. * @param optimizer defines the optimizers to remove
  52998. * @returns the current material
  52999. */
  53000. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53001. /**
  53002. * Add a new block to the list of output nodes
  53003. * @param node defines the node to add
  53004. * @returns the current material
  53005. */
  53006. addOutputNode(node: NodeMaterialBlock): this;
  53007. /**
  53008. * Remove a block from the list of root nodes
  53009. * @param node defines the node to remove
  53010. * @returns the current material
  53011. */
  53012. removeOutputNode(node: NodeMaterialBlock): this;
  53013. private _addVertexOutputNode;
  53014. private _removeVertexOutputNode;
  53015. private _addFragmentOutputNode;
  53016. private _removeFragmentOutputNode;
  53017. /**
  53018. * Specifies if the material will require alpha blending
  53019. * @returns a boolean specifying if alpha blending is needed
  53020. */
  53021. needAlphaBlending(): boolean;
  53022. /**
  53023. * Specifies if this material should be rendered in alpha test mode
  53024. * @returns a boolean specifying if an alpha test is needed.
  53025. */
  53026. needAlphaTesting(): boolean;
  53027. private _initializeBlock;
  53028. private _resetDualBlocks;
  53029. /**
  53030. * Build the material and generates the inner effect
  53031. * @param verbose defines if the build should log activity
  53032. */
  53033. build(verbose?: boolean): void;
  53034. /**
  53035. * Runs an otpimization phase to try to improve the shader code
  53036. */
  53037. optimize(): void;
  53038. private _prepareDefinesForAttributes;
  53039. /**
  53040. * Get if the submesh is ready to be used and all its information available.
  53041. * Child classes can use it to update shaders
  53042. * @param mesh defines the mesh to check
  53043. * @param subMesh defines which submesh to check
  53044. * @param useInstances specifies that instances should be used
  53045. * @returns a boolean indicating that the submesh is ready or not
  53046. */
  53047. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53048. /**
  53049. * Get a string representing the shaders built by the current node graph
  53050. */
  53051. readonly compiledShaders: string;
  53052. /**
  53053. * Binds the world matrix to the material
  53054. * @param world defines the world transformation matrix
  53055. */
  53056. bindOnlyWorldMatrix(world: Matrix): void;
  53057. /**
  53058. * Binds the submesh to this material by preparing the effect and shader to draw
  53059. * @param world defines the world transformation matrix
  53060. * @param mesh defines the mesh containing the submesh
  53061. * @param subMesh defines the submesh to bind the material to
  53062. */
  53063. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53064. /**
  53065. * Gets the active textures from the material
  53066. * @returns an array of textures
  53067. */
  53068. getActiveTextures(): BaseTexture[];
  53069. /**
  53070. * Gets the list of texture blocks
  53071. * @returns an array of texture blocks
  53072. */
  53073. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53074. /**
  53075. * Specifies if the material uses a texture
  53076. * @param texture defines the texture to check against the material
  53077. * @returns a boolean specifying if the material uses the texture
  53078. */
  53079. hasTexture(texture: BaseTexture): boolean;
  53080. /**
  53081. * Disposes the material
  53082. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53083. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53084. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53085. */
  53086. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53087. /** Creates the node editor window. */
  53088. private _createNodeEditor;
  53089. /**
  53090. * Launch the node material editor
  53091. * @param config Define the configuration of the editor
  53092. * @return a promise fulfilled when the node editor is visible
  53093. */
  53094. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53095. /**
  53096. * Clear the current material
  53097. */
  53098. clear(): void;
  53099. /**
  53100. * Clear the current material and set it to a default state
  53101. */
  53102. setToDefault(): void;
  53103. /**
  53104. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53105. * @param url defines the url to load from
  53106. * @returns a promise that will fullfil when the material is fully loaded
  53107. */
  53108. loadAsync(url: string): Promise<unknown>;
  53109. private _gatherBlocks;
  53110. /**
  53111. * Generate a string containing the code declaration required to create an equivalent of this material
  53112. * @returns a string
  53113. */
  53114. generateCode(): string;
  53115. /**
  53116. * Serializes this material in a JSON representation
  53117. * @returns the serialized material object
  53118. */
  53119. serialize(): any;
  53120. private _restoreConnections;
  53121. /**
  53122. * Clear the current graph and load a new one from a serialization object
  53123. * @param source defines the JSON representation of the material
  53124. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53125. */
  53126. loadFromSerialization(source: any, rootUrl?: string): void;
  53127. /**
  53128. * Creates a node material from parsed material data
  53129. * @param source defines the JSON representation of the material
  53130. * @param scene defines the hosting scene
  53131. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53132. * @returns a new node material
  53133. */
  53134. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53135. /**
  53136. * Creates a new node material set to default basic configuration
  53137. * @param name defines the name of the material
  53138. * @param scene defines the hosting scene
  53139. * @returns a new NodeMaterial
  53140. */
  53141. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53142. }
  53143. }
  53144. declare module BABYLON {
  53145. /**
  53146. * Block used to read a texture from a sampler
  53147. */
  53148. export class TextureBlock extends NodeMaterialBlock {
  53149. private _defineName;
  53150. private _linearDefineName;
  53151. private _samplerName;
  53152. private _transformedUVName;
  53153. private _textureTransformName;
  53154. private _textureInfoName;
  53155. private _mainUVName;
  53156. private _mainUVDefineName;
  53157. /**
  53158. * Gets or sets the texture associated with the node
  53159. */
  53160. texture: Nullable<Texture>;
  53161. /**
  53162. * Create a new TextureBlock
  53163. * @param name defines the block name
  53164. */
  53165. constructor(name: string);
  53166. /**
  53167. * Gets the current class name
  53168. * @returns the class name
  53169. */
  53170. getClassName(): string;
  53171. /**
  53172. * Gets the uv input component
  53173. */
  53174. readonly uv: NodeMaterialConnectionPoint;
  53175. /**
  53176. * Gets the rgba output component
  53177. */
  53178. readonly rgba: NodeMaterialConnectionPoint;
  53179. /**
  53180. * Gets the rgb output component
  53181. */
  53182. readonly rgb: NodeMaterialConnectionPoint;
  53183. /**
  53184. * Gets the r output component
  53185. */
  53186. readonly r: NodeMaterialConnectionPoint;
  53187. /**
  53188. * Gets the g output component
  53189. */
  53190. readonly g: NodeMaterialConnectionPoint;
  53191. /**
  53192. * Gets the b output component
  53193. */
  53194. readonly b: NodeMaterialConnectionPoint;
  53195. /**
  53196. * Gets the a output component
  53197. */
  53198. readonly a: NodeMaterialConnectionPoint;
  53199. readonly target: NodeMaterialBlockTargets;
  53200. autoConfigure(material: NodeMaterial): void;
  53201. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53203. isReady(): boolean;
  53204. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53205. private readonly _isMixed;
  53206. private _injectVertexCode;
  53207. private _writeOutput;
  53208. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53209. protected _dumpPropertiesCode(): string;
  53210. serialize(): any;
  53211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53212. }
  53213. }
  53214. declare module BABYLON {
  53215. /**
  53216. * Class used to store shared data between 2 NodeMaterialBuildState
  53217. */
  53218. export class NodeMaterialBuildStateSharedData {
  53219. /**
  53220. * Gets the list of emitted varyings
  53221. */
  53222. temps: string[];
  53223. /**
  53224. * Gets the list of emitted varyings
  53225. */
  53226. varyings: string[];
  53227. /**
  53228. * Gets the varying declaration string
  53229. */
  53230. varyingDeclaration: string;
  53231. /**
  53232. * Input blocks
  53233. */
  53234. inputBlocks: InputBlock[];
  53235. /**
  53236. * Input blocks
  53237. */
  53238. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53239. /**
  53240. * Bindable blocks (Blocks that need to set data to the effect)
  53241. */
  53242. bindableBlocks: NodeMaterialBlock[];
  53243. /**
  53244. * List of blocks that can provide a compilation fallback
  53245. */
  53246. blocksWithFallbacks: NodeMaterialBlock[];
  53247. /**
  53248. * List of blocks that can provide a define update
  53249. */
  53250. blocksWithDefines: NodeMaterialBlock[];
  53251. /**
  53252. * List of blocks that can provide a repeatable content
  53253. */
  53254. repeatableContentBlocks: NodeMaterialBlock[];
  53255. /**
  53256. * List of blocks that can provide a dynamic list of uniforms
  53257. */
  53258. dynamicUniformBlocks: NodeMaterialBlock[];
  53259. /**
  53260. * List of blocks that can block the isReady function for the material
  53261. */
  53262. blockingBlocks: NodeMaterialBlock[];
  53263. /**
  53264. * Gets the list of animated inputs
  53265. */
  53266. animatedInputs: InputBlock[];
  53267. /**
  53268. * Build Id used to avoid multiple recompilations
  53269. */
  53270. buildId: number;
  53271. /** List of emitted variables */
  53272. variableNames: {
  53273. [key: string]: number;
  53274. };
  53275. /** List of emitted defines */
  53276. defineNames: {
  53277. [key: string]: number;
  53278. };
  53279. /** Should emit comments? */
  53280. emitComments: boolean;
  53281. /** Emit build activity */
  53282. verbose: boolean;
  53283. /** Gets or sets the hosting scene */
  53284. scene: Scene;
  53285. /**
  53286. * Gets the compilation hints emitted at compilation time
  53287. */
  53288. hints: {
  53289. needWorldViewMatrix: boolean;
  53290. needWorldViewProjectionMatrix: boolean;
  53291. needAlphaBlending: boolean;
  53292. needAlphaTesting: boolean;
  53293. };
  53294. /**
  53295. * List of compilation checks
  53296. */
  53297. checks: {
  53298. emitVertex: boolean;
  53299. emitFragment: boolean;
  53300. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53301. };
  53302. /** Creates a new shared data */
  53303. constructor();
  53304. /**
  53305. * Emits console errors and exceptions if there is a failing check
  53306. */
  53307. emitErrors(): void;
  53308. }
  53309. }
  53310. declare module BABYLON {
  53311. /**
  53312. * Class used to store node based material build state
  53313. */
  53314. export class NodeMaterialBuildState {
  53315. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53316. supportUniformBuffers: boolean;
  53317. /**
  53318. * Gets the list of emitted attributes
  53319. */
  53320. attributes: string[];
  53321. /**
  53322. * Gets the list of emitted uniforms
  53323. */
  53324. uniforms: string[];
  53325. /**
  53326. * Gets the list of emitted constants
  53327. */
  53328. constants: string[];
  53329. /**
  53330. * Gets the list of emitted samplers
  53331. */
  53332. samplers: string[];
  53333. /**
  53334. * Gets the list of emitted functions
  53335. */
  53336. functions: {
  53337. [key: string]: string;
  53338. };
  53339. /**
  53340. * Gets the list of emitted extensions
  53341. */
  53342. extensions: {
  53343. [key: string]: string;
  53344. };
  53345. /**
  53346. * Gets the target of the compilation state
  53347. */
  53348. target: NodeMaterialBlockTargets;
  53349. /**
  53350. * Gets the list of emitted counters
  53351. */
  53352. counters: {
  53353. [key: string]: number;
  53354. };
  53355. /**
  53356. * Shared data between multiple NodeMaterialBuildState instances
  53357. */
  53358. sharedData: NodeMaterialBuildStateSharedData;
  53359. /** @hidden */
  53360. _vertexState: NodeMaterialBuildState;
  53361. /** @hidden */
  53362. _attributeDeclaration: string;
  53363. /** @hidden */
  53364. _uniformDeclaration: string;
  53365. /** @hidden */
  53366. _constantDeclaration: string;
  53367. /** @hidden */
  53368. _samplerDeclaration: string;
  53369. /** @hidden */
  53370. _varyingTransfer: string;
  53371. private _repeatableContentAnchorIndex;
  53372. /** @hidden */
  53373. _builtCompilationString: string;
  53374. /**
  53375. * Gets the emitted compilation strings
  53376. */
  53377. compilationString: string;
  53378. /**
  53379. * Finalize the compilation strings
  53380. * @param state defines the current compilation state
  53381. */
  53382. finalize(state: NodeMaterialBuildState): void;
  53383. /** @hidden */
  53384. readonly _repeatableContentAnchor: string;
  53385. /** @hidden */
  53386. _getFreeVariableName(prefix: string): string;
  53387. /** @hidden */
  53388. _getFreeDefineName(prefix: string): string;
  53389. /** @hidden */
  53390. _excludeVariableName(name: string): void;
  53391. /** @hidden */
  53392. _emit2DSampler(name: string): void;
  53393. /** @hidden */
  53394. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53395. /** @hidden */
  53396. _emitExtension(name: string, extension: string): void;
  53397. /** @hidden */
  53398. _emitFunction(name: string, code: string, comments: string): void;
  53399. /** @hidden */
  53400. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53401. replaceStrings?: {
  53402. search: RegExp;
  53403. replace: string;
  53404. }[];
  53405. repeatKey?: string;
  53406. }): string;
  53407. /** @hidden */
  53408. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53409. repeatKey?: string;
  53410. removeAttributes?: boolean;
  53411. removeUniforms?: boolean;
  53412. removeVaryings?: boolean;
  53413. removeIfDef?: boolean;
  53414. replaceStrings?: {
  53415. search: RegExp;
  53416. replace: string;
  53417. }[];
  53418. }, storeKey?: string): void;
  53419. /** @hidden */
  53420. _registerTempVariable(name: string): boolean;
  53421. /** @hidden */
  53422. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53423. /** @hidden */
  53424. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53425. /** @hidden */
  53426. _emitFloat(value: number): string;
  53427. }
  53428. }
  53429. declare module BABYLON {
  53430. /**
  53431. * Defines a block that can be used inside a node based material
  53432. */
  53433. export class NodeMaterialBlock {
  53434. private _buildId;
  53435. private _buildTarget;
  53436. private _target;
  53437. private _isFinalMerger;
  53438. private _isInput;
  53439. /** @hidden */
  53440. _codeVariableName: string;
  53441. /** @hidden */
  53442. _inputs: NodeMaterialConnectionPoint[];
  53443. /** @hidden */
  53444. _outputs: NodeMaterialConnectionPoint[];
  53445. /** @hidden */
  53446. _preparationId: number;
  53447. /**
  53448. * Gets or sets the name of the block
  53449. */
  53450. name: string;
  53451. /**
  53452. * Gets or sets the unique id of the node
  53453. */
  53454. uniqueId: number;
  53455. /**
  53456. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53457. */
  53458. readonly isFinalMerger: boolean;
  53459. /**
  53460. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53461. */
  53462. readonly isInput: boolean;
  53463. /**
  53464. * Gets or sets the build Id
  53465. */
  53466. buildId: number;
  53467. /**
  53468. * Gets or sets the target of the block
  53469. */
  53470. target: NodeMaterialBlockTargets;
  53471. /**
  53472. * Gets the list of input points
  53473. */
  53474. readonly inputs: NodeMaterialConnectionPoint[];
  53475. /** Gets the list of output points */
  53476. readonly outputs: NodeMaterialConnectionPoint[];
  53477. /**
  53478. * Find an input by its name
  53479. * @param name defines the name of the input to look for
  53480. * @returns the input or null if not found
  53481. */
  53482. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53483. /**
  53484. * Find an output by its name
  53485. * @param name defines the name of the outputto look for
  53486. * @returns the output or null if not found
  53487. */
  53488. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53489. /**
  53490. * Creates a new NodeMaterialBlock
  53491. * @param name defines the block name
  53492. * @param target defines the target of that block (Vertex by default)
  53493. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53494. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53495. */
  53496. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53497. /**
  53498. * Initialize the block and prepare the context for build
  53499. * @param state defines the state that will be used for the build
  53500. */
  53501. initialize(state: NodeMaterialBuildState): void;
  53502. /**
  53503. * Bind data to effect. Will only be called for blocks with isBindable === true
  53504. * @param effect defines the effect to bind data to
  53505. * @param nodeMaterial defines the hosting NodeMaterial
  53506. * @param mesh defines the mesh that will be rendered
  53507. */
  53508. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53509. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53510. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53511. protected _writeFloat(value: number): string;
  53512. /**
  53513. * Gets the current class name e.g. "NodeMaterialBlock"
  53514. * @returns the class name
  53515. */
  53516. getClassName(): string;
  53517. /**
  53518. * Register a new input. Must be called inside a block constructor
  53519. * @param name defines the connection point name
  53520. * @param type defines the connection point type
  53521. * @param isOptional defines a boolean indicating that this input can be omitted
  53522. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53523. * @returns the current block
  53524. */
  53525. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53526. /**
  53527. * Register a new output. Must be called inside a block constructor
  53528. * @param name defines the connection point name
  53529. * @param type defines the connection point type
  53530. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53531. * @returns the current block
  53532. */
  53533. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53534. /**
  53535. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53536. * @param forOutput defines an optional connection point to check compatibility with
  53537. * @returns the first available input or null
  53538. */
  53539. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53540. /**
  53541. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53542. * @param forBlock defines an optional block to check compatibility with
  53543. * @returns the first available input or null
  53544. */
  53545. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53546. /**
  53547. * Gets the sibling of the given output
  53548. * @param current defines the current output
  53549. * @returns the next output in the list or null
  53550. */
  53551. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53552. /**
  53553. * Connect current block with another block
  53554. * @param other defines the block to connect with
  53555. * @param options define the various options to help pick the right connections
  53556. * @returns the current block
  53557. */
  53558. connectTo(other: NodeMaterialBlock, options?: {
  53559. input?: string;
  53560. output?: string;
  53561. outputSwizzle?: string;
  53562. }): this | undefined;
  53563. protected _buildBlock(state: NodeMaterialBuildState): void;
  53564. /**
  53565. * Add uniforms, samplers and uniform buffers at compilation time
  53566. * @param state defines the state to update
  53567. * @param nodeMaterial defines the node material requesting the update
  53568. * @param defines defines the material defines to update
  53569. * @param uniformBuffers defines the list of uniform buffer names
  53570. */
  53571. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  53572. /**
  53573. * Add potential fallbacks if shader compilation fails
  53574. * @param mesh defines the mesh to be rendered
  53575. * @param fallbacks defines the current prioritized list of fallbacks
  53576. */
  53577. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53578. /**
  53579. * Initialize defines for shader compilation
  53580. * @param mesh defines the mesh to be rendered
  53581. * @param nodeMaterial defines the node material requesting the update
  53582. * @param defines defines the material defines to update
  53583. * @param useInstances specifies that instances should be used
  53584. */
  53585. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53586. /**
  53587. * Update defines for shader compilation
  53588. * @param mesh defines the mesh to be rendered
  53589. * @param nodeMaterial defines the node material requesting the update
  53590. * @param defines defines the material defines to update
  53591. * @param useInstances specifies that instances should be used
  53592. */
  53593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53594. /**
  53595. * Lets the block try to connect some inputs automatically
  53596. * @param material defines the hosting NodeMaterial
  53597. */
  53598. autoConfigure(material: NodeMaterial): void;
  53599. /**
  53600. * Function called when a block is declared as repeatable content generator
  53601. * @param vertexShaderState defines the current compilation state for the vertex shader
  53602. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53603. * @param mesh defines the mesh to be rendered
  53604. * @param defines defines the material defines to update
  53605. */
  53606. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53607. /**
  53608. * Checks if the block is ready
  53609. * @param mesh defines the mesh to be rendered
  53610. * @param nodeMaterial defines the node material requesting the update
  53611. * @param defines defines the material defines to update
  53612. * @param useInstances specifies that instances should be used
  53613. * @returns true if the block is ready
  53614. */
  53615. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53616. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53617. private _processBuild;
  53618. /**
  53619. * Compile the current node and generate the shader code
  53620. * @param state defines the current compilation state (uniforms, samplers, current string)
  53621. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53622. * @returns true if already built
  53623. */
  53624. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53625. protected _inputRename(name: string): string;
  53626. protected _outputRename(name: string): string;
  53627. protected _dumpPropertiesCode(): string;
  53628. /** @hidden */
  53629. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53630. /**
  53631. * Clone the current block to a new identical block
  53632. * @param scene defines the hosting scene
  53633. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53634. * @returns a copy of the current block
  53635. */
  53636. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53637. /**
  53638. * Serializes this block in a JSON representation
  53639. * @returns the serialized block object
  53640. */
  53641. serialize(): any;
  53642. /** @hidden */
  53643. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53644. }
  53645. }
  53646. declare module BABYLON {
  53647. /**
  53648. * Enum defining the type of animations supported by InputBlock
  53649. */
  53650. export enum AnimatedInputBlockTypes {
  53651. /** No animation */
  53652. None = 0,
  53653. /** Time based animation. Will only work for floats */
  53654. Time = 1
  53655. }
  53656. }
  53657. declare module BABYLON {
  53658. /**
  53659. * Block used to expose an input value
  53660. */
  53661. export class InputBlock extends NodeMaterialBlock {
  53662. private _mode;
  53663. private _associatedVariableName;
  53664. private _storedValue;
  53665. private _valueCallback;
  53666. private _type;
  53667. private _animationType;
  53668. /** Gets or set a value used to limit the range of float values */
  53669. min: number;
  53670. /** Gets or set a value used to limit the range of float values */
  53671. max: number;
  53672. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53673. matrixMode: number;
  53674. /** @hidden */
  53675. _systemValue: Nullable<NodeMaterialSystemValues>;
  53676. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53677. visibleInInspector: boolean;
  53678. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53679. isConstant: boolean;
  53680. /**
  53681. * Gets or sets the connection point type (default is float)
  53682. */
  53683. readonly type: NodeMaterialBlockConnectionPointTypes;
  53684. /**
  53685. * Creates a new InputBlock
  53686. * @param name defines the block name
  53687. * @param target defines the target of that block (Vertex by default)
  53688. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53689. */
  53690. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53691. /**
  53692. * Gets the output component
  53693. */
  53694. readonly output: NodeMaterialConnectionPoint;
  53695. /**
  53696. * Set the source of this connection point to a vertex attribute
  53697. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53698. * @returns the current connection point
  53699. */
  53700. setAsAttribute(attributeName?: string): InputBlock;
  53701. /**
  53702. * Set the source of this connection point to a system value
  53703. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53704. * @returns the current connection point
  53705. */
  53706. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53707. /**
  53708. * Gets or sets the value of that point.
  53709. * Please note that this value will be ignored if valueCallback is defined
  53710. */
  53711. value: any;
  53712. /**
  53713. * Gets or sets a callback used to get the value of that point.
  53714. * Please note that setting this value will force the connection point to ignore the value property
  53715. */
  53716. valueCallback: () => any;
  53717. /**
  53718. * Gets or sets the associated variable name in the shader
  53719. */
  53720. associatedVariableName: string;
  53721. /** Gets or sets the type of animation applied to the input */
  53722. animationType: AnimatedInputBlockTypes;
  53723. /**
  53724. * Gets a boolean indicating that this connection point not defined yet
  53725. */
  53726. readonly isUndefined: boolean;
  53727. /**
  53728. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53729. * In this case the connection point name must be the name of the uniform to use.
  53730. * Can only be set on inputs
  53731. */
  53732. isUniform: boolean;
  53733. /**
  53734. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53735. * In this case the connection point name must be the name of the attribute to use
  53736. * Can only be set on inputs
  53737. */
  53738. isAttribute: boolean;
  53739. /**
  53740. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53741. * Can only be set on exit points
  53742. */
  53743. isVarying: boolean;
  53744. /**
  53745. * Gets a boolean indicating that the current connection point is a system value
  53746. */
  53747. readonly isSystemValue: boolean;
  53748. /**
  53749. * Gets or sets the current well known value or null if not defined as a system value
  53750. */
  53751. systemValue: Nullable<NodeMaterialSystemValues>;
  53752. /**
  53753. * Gets the current class name
  53754. * @returns the class name
  53755. */
  53756. getClassName(): string;
  53757. /**
  53758. * Animate the input if animationType !== None
  53759. * @param scene defines the rendering scene
  53760. */
  53761. animate(scene: Scene): void;
  53762. private _emitDefine;
  53763. initialize(state: NodeMaterialBuildState): void;
  53764. /**
  53765. * Set the input block to its default value (based on its type)
  53766. */
  53767. setDefaultValue(): void;
  53768. private _emitConstant;
  53769. private _emit;
  53770. /** @hidden */
  53771. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53772. /** @hidden */
  53773. _transmit(effect: Effect, scene: Scene): void;
  53774. protected _buildBlock(state: NodeMaterialBuildState): void;
  53775. protected _dumpPropertiesCode(): string;
  53776. serialize(): any;
  53777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53778. }
  53779. }
  53780. declare module BABYLON {
  53781. /**
  53782. * Defines a connection point for a block
  53783. */
  53784. export class NodeMaterialConnectionPoint {
  53785. /** @hidden */
  53786. _ownerBlock: NodeMaterialBlock;
  53787. /** @hidden */
  53788. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53789. private _endpoints;
  53790. private _associatedVariableName;
  53791. /** @hidden */
  53792. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53793. /** @hidden */
  53794. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53795. private _type;
  53796. /** @hidden */
  53797. _enforceAssociatedVariableName: boolean;
  53798. /**
  53799. * Gets or sets the additional types supported by this connection point
  53800. */
  53801. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53802. /**
  53803. * Gets or sets the additional types excluded by this connection point
  53804. */
  53805. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53806. /**
  53807. * Gets or sets the associated variable name in the shader
  53808. */
  53809. associatedVariableName: string;
  53810. /**
  53811. * Gets or sets the connection point type (default is float)
  53812. */
  53813. type: NodeMaterialBlockConnectionPointTypes;
  53814. /**
  53815. * Gets or sets the connection point name
  53816. */
  53817. name: string;
  53818. /**
  53819. * Gets or sets a boolean indicating that this connection point can be omitted
  53820. */
  53821. isOptional: boolean;
  53822. /**
  53823. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53824. */
  53825. define: string;
  53826. /** Gets or sets the target of that connection point */
  53827. target: NodeMaterialBlockTargets;
  53828. /**
  53829. * Gets a boolean indicating that the current point is connected
  53830. */
  53831. readonly isConnected: boolean;
  53832. /**
  53833. * Gets a boolean indicating that the current point is connected to an input block
  53834. */
  53835. readonly isConnectedToInputBlock: boolean;
  53836. /**
  53837. * Gets a the connected input block (if any)
  53838. */
  53839. readonly connectInputBlock: Nullable<InputBlock>;
  53840. /** Get the other side of the connection (if any) */
  53841. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53842. /** Get the block that owns this connection point */
  53843. readonly ownerBlock: NodeMaterialBlock;
  53844. /** Get the block connected on the other side of this connection (if any) */
  53845. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53846. /** Get the block connected on the endpoints of this connection (if any) */
  53847. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53848. /** Gets the list of connected endpoints */
  53849. readonly endpoints: NodeMaterialConnectionPoint[];
  53850. /** Gets a boolean indicating if that output point is connected to at least one input */
  53851. readonly hasEndpoints: boolean;
  53852. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  53853. readonly isConnectedInVertexShader: boolean;
  53854. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  53855. readonly isConnectedInFragmentShader: boolean;
  53856. /**
  53857. * Creates a new connection point
  53858. * @param name defines the connection point name
  53859. * @param ownerBlock defines the block hosting this connection point
  53860. */
  53861. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53862. /**
  53863. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53864. * @returns the class name
  53865. */
  53866. getClassName(): string;
  53867. /**
  53868. * Gets an boolean indicating if the current point can be connected to another point
  53869. * @param connectionPoint defines the other connection point
  53870. * @returns true if the connection is possible
  53871. */
  53872. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53873. /**
  53874. * Connect this point to another connection point
  53875. * @param connectionPoint defines the other connection point
  53876. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53877. * @returns the current connection point
  53878. */
  53879. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53880. /**
  53881. * Disconnect this point from one of his endpoint
  53882. * @param endpoint defines the other connection point
  53883. * @returns the current connection point
  53884. */
  53885. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53886. /**
  53887. * Serializes this point in a JSON representation
  53888. * @returns the serialized point object
  53889. */
  53890. serialize(): any;
  53891. }
  53892. }
  53893. declare module BABYLON {
  53894. /**
  53895. * Block used to add support for vertex skinning (bones)
  53896. */
  53897. export class BonesBlock extends NodeMaterialBlock {
  53898. /**
  53899. * Creates a new BonesBlock
  53900. * @param name defines the block name
  53901. */
  53902. constructor(name: string);
  53903. /**
  53904. * Initialize the block and prepare the context for build
  53905. * @param state defines the state that will be used for the build
  53906. */
  53907. initialize(state: NodeMaterialBuildState): void;
  53908. /**
  53909. * Gets the current class name
  53910. * @returns the class name
  53911. */
  53912. getClassName(): string;
  53913. /**
  53914. * Gets the matrix indices input component
  53915. */
  53916. readonly matricesIndices: NodeMaterialConnectionPoint;
  53917. /**
  53918. * Gets the matrix weights input component
  53919. */
  53920. readonly matricesWeights: NodeMaterialConnectionPoint;
  53921. /**
  53922. * Gets the extra matrix indices input component
  53923. */
  53924. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53925. /**
  53926. * Gets the extra matrix weights input component
  53927. */
  53928. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53929. /**
  53930. * Gets the world input component
  53931. */
  53932. readonly world: NodeMaterialConnectionPoint;
  53933. /**
  53934. * Gets the output component
  53935. */
  53936. readonly output: NodeMaterialConnectionPoint;
  53937. autoConfigure(material: NodeMaterial): void;
  53938. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53939. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53941. protected _buildBlock(state: NodeMaterialBuildState): this;
  53942. }
  53943. }
  53944. declare module BABYLON {
  53945. /**
  53946. * Block used to add support for instances
  53947. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53948. */
  53949. export class InstancesBlock extends NodeMaterialBlock {
  53950. /**
  53951. * Creates a new InstancesBlock
  53952. * @param name defines the block name
  53953. */
  53954. constructor(name: string);
  53955. /**
  53956. * Gets the current class name
  53957. * @returns the class name
  53958. */
  53959. getClassName(): string;
  53960. /**
  53961. * Gets the first world row input component
  53962. */
  53963. readonly world0: NodeMaterialConnectionPoint;
  53964. /**
  53965. * Gets the second world row input component
  53966. */
  53967. readonly world1: NodeMaterialConnectionPoint;
  53968. /**
  53969. * Gets the third world row input component
  53970. */
  53971. readonly world2: NodeMaterialConnectionPoint;
  53972. /**
  53973. * Gets the forth world row input component
  53974. */
  53975. readonly world3: NodeMaterialConnectionPoint;
  53976. /**
  53977. * Gets the world input component
  53978. */
  53979. readonly world: NodeMaterialConnectionPoint;
  53980. /**
  53981. * Gets the output component
  53982. */
  53983. readonly output: NodeMaterialConnectionPoint;
  53984. autoConfigure(material: NodeMaterial): void;
  53985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53986. protected _buildBlock(state: NodeMaterialBuildState): this;
  53987. }
  53988. }
  53989. declare module BABYLON {
  53990. /**
  53991. * Block used to add morph targets support to vertex shader
  53992. */
  53993. export class MorphTargetsBlock extends NodeMaterialBlock {
  53994. private _repeatableContentAnchor;
  53995. private _repeatebleContentGenerated;
  53996. /**
  53997. * Create a new MorphTargetsBlock
  53998. * @param name defines the block name
  53999. */
  54000. constructor(name: string);
  54001. /**
  54002. * Gets the current class name
  54003. * @returns the class name
  54004. */
  54005. getClassName(): string;
  54006. /**
  54007. * Gets the position input component
  54008. */
  54009. readonly position: NodeMaterialConnectionPoint;
  54010. /**
  54011. * Gets the normal input component
  54012. */
  54013. readonly normal: NodeMaterialConnectionPoint;
  54014. /**
  54015. * Gets the tangent input component
  54016. */
  54017. readonly tangent: NodeMaterialConnectionPoint;
  54018. /**
  54019. * Gets the tangent input component
  54020. */
  54021. readonly uv: NodeMaterialConnectionPoint;
  54022. /**
  54023. * Gets the position output component
  54024. */
  54025. readonly positionOutput: NodeMaterialConnectionPoint;
  54026. /**
  54027. * Gets the normal output component
  54028. */
  54029. readonly normalOutput: NodeMaterialConnectionPoint;
  54030. /**
  54031. * Gets the tangent output component
  54032. */
  54033. readonly tangentOutput: NodeMaterialConnectionPoint;
  54034. /**
  54035. * Gets the tangent output component
  54036. */
  54037. readonly uvOutput: NodeMaterialConnectionPoint;
  54038. initialize(state: NodeMaterialBuildState): void;
  54039. autoConfigure(material: NodeMaterial): void;
  54040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54041. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54042. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54043. protected _buildBlock(state: NodeMaterialBuildState): this;
  54044. }
  54045. }
  54046. declare module BABYLON {
  54047. /**
  54048. * Block used to get data information from a light
  54049. */
  54050. export class LightInformationBlock extends NodeMaterialBlock {
  54051. private _lightDataUniformName;
  54052. private _lightColorUniformName;
  54053. private _lightTypeDefineName;
  54054. /**
  54055. * Gets or sets the light associated with this block
  54056. */
  54057. light: Nullable<Light>;
  54058. /**
  54059. * Creates a new LightInformationBlock
  54060. * @param name defines the block name
  54061. */
  54062. constructor(name: string);
  54063. /**
  54064. * Gets the current class name
  54065. * @returns the class name
  54066. */
  54067. getClassName(): string;
  54068. /**
  54069. * Gets the world position input component
  54070. */
  54071. readonly worldPosition: NodeMaterialConnectionPoint;
  54072. /**
  54073. * Gets the direction output component
  54074. */
  54075. readonly direction: NodeMaterialConnectionPoint;
  54076. /**
  54077. * Gets the direction output component
  54078. */
  54079. readonly color: NodeMaterialConnectionPoint;
  54080. /**
  54081. * Gets the direction output component
  54082. */
  54083. readonly intensity: NodeMaterialConnectionPoint;
  54084. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54086. protected _buildBlock(state: NodeMaterialBuildState): this;
  54087. serialize(): any;
  54088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54089. }
  54090. }
  54091. declare module BABYLON {
  54092. /**
  54093. * Block used to add image processing support to fragment shader
  54094. */
  54095. export class ImageProcessingBlock extends NodeMaterialBlock {
  54096. /**
  54097. * Create a new ImageProcessingBlock
  54098. * @param name defines the block name
  54099. */
  54100. constructor(name: string);
  54101. /**
  54102. * Gets the current class name
  54103. * @returns the class name
  54104. */
  54105. getClassName(): string;
  54106. /**
  54107. * Gets the color input component
  54108. */
  54109. readonly color: NodeMaterialConnectionPoint;
  54110. /**
  54111. * Gets the output component
  54112. */
  54113. readonly output: NodeMaterialConnectionPoint;
  54114. /**
  54115. * Initialize the block and prepare the context for build
  54116. * @param state defines the state that will be used for the build
  54117. */
  54118. initialize(state: NodeMaterialBuildState): void;
  54119. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54120. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54121. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54122. protected _buildBlock(state: NodeMaterialBuildState): this;
  54123. }
  54124. }
  54125. declare module BABYLON {
  54126. /**
  54127. * Block used to pertub normals based on a normal map
  54128. */
  54129. export class PerturbNormalBlock extends NodeMaterialBlock {
  54130. private _tangentSpaceParameterName;
  54131. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54132. invertX: boolean;
  54133. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54134. invertY: boolean;
  54135. /**
  54136. * Create a new PerturbNormalBlock
  54137. * @param name defines the block name
  54138. */
  54139. constructor(name: string);
  54140. /**
  54141. * Gets the current class name
  54142. * @returns the class name
  54143. */
  54144. getClassName(): string;
  54145. /**
  54146. * Gets the world position input component
  54147. */
  54148. readonly worldPosition: NodeMaterialConnectionPoint;
  54149. /**
  54150. * Gets the world normal input component
  54151. */
  54152. readonly worldNormal: NodeMaterialConnectionPoint;
  54153. /**
  54154. * Gets the uv input component
  54155. */
  54156. readonly uv: NodeMaterialConnectionPoint;
  54157. /**
  54158. * Gets the normal map color input component
  54159. */
  54160. readonly normalMapColor: NodeMaterialConnectionPoint;
  54161. /**
  54162. * Gets the strength input component
  54163. */
  54164. readonly strength: NodeMaterialConnectionPoint;
  54165. /**
  54166. * Gets the output component
  54167. */
  54168. readonly output: NodeMaterialConnectionPoint;
  54169. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54171. autoConfigure(material: NodeMaterial): void;
  54172. protected _buildBlock(state: NodeMaterialBuildState): this;
  54173. protected _dumpPropertiesCode(): string;
  54174. serialize(): any;
  54175. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54176. }
  54177. }
  54178. declare module BABYLON {
  54179. /**
  54180. * Block used to discard a pixel if a value is smaller than a cutoff
  54181. */
  54182. export class DiscardBlock extends NodeMaterialBlock {
  54183. /**
  54184. * Create a new DiscardBlock
  54185. * @param name defines the block name
  54186. */
  54187. constructor(name: string);
  54188. /**
  54189. * Gets the current class name
  54190. * @returns the class name
  54191. */
  54192. getClassName(): string;
  54193. /**
  54194. * Gets the color input component
  54195. */
  54196. readonly value: NodeMaterialConnectionPoint;
  54197. /**
  54198. * Gets the cutoff input component
  54199. */
  54200. readonly cutoff: NodeMaterialConnectionPoint;
  54201. protected _buildBlock(state: NodeMaterialBuildState): this;
  54202. }
  54203. }
  54204. declare module BABYLON {
  54205. /**
  54206. * Block used to add support for scene fog
  54207. */
  54208. export class FogBlock extends NodeMaterialBlock {
  54209. private _fogDistanceName;
  54210. private _fogParameters;
  54211. /**
  54212. * Create a new FogBlock
  54213. * @param name defines the block name
  54214. */
  54215. constructor(name: string);
  54216. /**
  54217. * Gets the current class name
  54218. * @returns the class name
  54219. */
  54220. getClassName(): string;
  54221. /**
  54222. * Gets the world position input component
  54223. */
  54224. readonly worldPosition: NodeMaterialConnectionPoint;
  54225. /**
  54226. * Gets the view input component
  54227. */
  54228. readonly view: NodeMaterialConnectionPoint;
  54229. /**
  54230. * Gets the color input component
  54231. */
  54232. readonly input: NodeMaterialConnectionPoint;
  54233. /**
  54234. * Gets the fog color input component
  54235. */
  54236. readonly fogColor: NodeMaterialConnectionPoint;
  54237. /**
  54238. * Gets the output component
  54239. */
  54240. readonly output: NodeMaterialConnectionPoint;
  54241. autoConfigure(material: NodeMaterial): void;
  54242. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54243. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54244. protected _buildBlock(state: NodeMaterialBuildState): this;
  54245. }
  54246. }
  54247. declare module BABYLON {
  54248. /**
  54249. * Block used to add light in the fragment shader
  54250. */
  54251. export class LightBlock extends NodeMaterialBlock {
  54252. private _lightId;
  54253. /**
  54254. * Gets or sets the light associated with this block
  54255. */
  54256. light: Nullable<Light>;
  54257. /**
  54258. * Create a new LightBlock
  54259. * @param name defines the block name
  54260. */
  54261. constructor(name: string);
  54262. /**
  54263. * Gets the current class name
  54264. * @returns the class name
  54265. */
  54266. getClassName(): string;
  54267. /**
  54268. * Gets the world position input component
  54269. */
  54270. readonly worldPosition: NodeMaterialConnectionPoint;
  54271. /**
  54272. * Gets the world normal input component
  54273. */
  54274. readonly worldNormal: NodeMaterialConnectionPoint;
  54275. /**
  54276. * Gets the camera (or eye) position component
  54277. */
  54278. readonly cameraPosition: NodeMaterialConnectionPoint;
  54279. /**
  54280. * Gets the glossiness component
  54281. */
  54282. readonly glossiness: NodeMaterialConnectionPoint;
  54283. /**
  54284. * Gets the glossinness power component
  54285. */
  54286. readonly glossPower: NodeMaterialConnectionPoint;
  54287. /**
  54288. * Gets the diffuse color component
  54289. */
  54290. readonly diffuseColor: NodeMaterialConnectionPoint;
  54291. /**
  54292. * Gets the specular color component
  54293. */
  54294. readonly specularColor: NodeMaterialConnectionPoint;
  54295. /**
  54296. * Gets the diffuse output component
  54297. */
  54298. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54299. /**
  54300. * Gets the specular output component
  54301. */
  54302. readonly specularOutput: NodeMaterialConnectionPoint;
  54303. autoConfigure(material: NodeMaterial): void;
  54304. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54305. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54306. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54307. private _injectVertexCode;
  54308. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54309. serialize(): any;
  54310. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54311. }
  54312. }
  54313. declare module BABYLON {
  54314. /**
  54315. * Block used to multiply 2 values
  54316. */
  54317. export class MultiplyBlock extends NodeMaterialBlock {
  54318. /**
  54319. * Creates a new MultiplyBlock
  54320. * @param name defines the block name
  54321. */
  54322. constructor(name: string);
  54323. /**
  54324. * Gets the current class name
  54325. * @returns the class name
  54326. */
  54327. getClassName(): string;
  54328. /**
  54329. * Gets the left operand input component
  54330. */
  54331. readonly left: NodeMaterialConnectionPoint;
  54332. /**
  54333. * Gets the right operand input component
  54334. */
  54335. readonly right: NodeMaterialConnectionPoint;
  54336. /**
  54337. * Gets the output component
  54338. */
  54339. readonly output: NodeMaterialConnectionPoint;
  54340. protected _buildBlock(state: NodeMaterialBuildState): this;
  54341. }
  54342. }
  54343. declare module BABYLON {
  54344. /**
  54345. * Block used to add 2 vectors
  54346. */
  54347. export class AddBlock extends NodeMaterialBlock {
  54348. /**
  54349. * Creates a new AddBlock
  54350. * @param name defines the block name
  54351. */
  54352. constructor(name: string);
  54353. /**
  54354. * Gets the current class name
  54355. * @returns the class name
  54356. */
  54357. getClassName(): string;
  54358. /**
  54359. * Gets the left operand input component
  54360. */
  54361. readonly left: NodeMaterialConnectionPoint;
  54362. /**
  54363. * Gets the right operand input component
  54364. */
  54365. readonly right: NodeMaterialConnectionPoint;
  54366. /**
  54367. * Gets the output component
  54368. */
  54369. readonly output: NodeMaterialConnectionPoint;
  54370. protected _buildBlock(state: NodeMaterialBuildState): this;
  54371. }
  54372. }
  54373. declare module BABYLON {
  54374. /**
  54375. * Block used to scale a vector by a float
  54376. */
  54377. export class ScaleBlock extends NodeMaterialBlock {
  54378. /**
  54379. * Creates a new ScaleBlock
  54380. * @param name defines the block name
  54381. */
  54382. constructor(name: string);
  54383. /**
  54384. * Gets the current class name
  54385. * @returns the class name
  54386. */
  54387. getClassName(): string;
  54388. /**
  54389. * Gets the input component
  54390. */
  54391. readonly input: NodeMaterialConnectionPoint;
  54392. /**
  54393. * Gets the factor input component
  54394. */
  54395. readonly factor: NodeMaterialConnectionPoint;
  54396. /**
  54397. * Gets the output component
  54398. */
  54399. readonly output: NodeMaterialConnectionPoint;
  54400. protected _buildBlock(state: NodeMaterialBuildState): this;
  54401. }
  54402. }
  54403. declare module BABYLON {
  54404. /**
  54405. * Block used to clamp a float
  54406. */
  54407. export class ClampBlock extends NodeMaterialBlock {
  54408. /** Gets or sets the minimum range */
  54409. minimum: number;
  54410. /** Gets or sets the maximum range */
  54411. maximum: number;
  54412. /**
  54413. * Creates a new ClampBlock
  54414. * @param name defines the block name
  54415. */
  54416. constructor(name: string);
  54417. /**
  54418. * Gets the current class name
  54419. * @returns the class name
  54420. */
  54421. getClassName(): string;
  54422. /**
  54423. * Gets the value input component
  54424. */
  54425. readonly value: NodeMaterialConnectionPoint;
  54426. /**
  54427. * Gets the output component
  54428. */
  54429. readonly output: NodeMaterialConnectionPoint;
  54430. protected _buildBlock(state: NodeMaterialBuildState): this;
  54431. protected _dumpPropertiesCode(): string;
  54432. serialize(): any;
  54433. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54434. }
  54435. }
  54436. declare module BABYLON {
  54437. /**
  54438. * Block used to apply a cross product between 2 vectors
  54439. */
  54440. export class CrossBlock extends NodeMaterialBlock {
  54441. /**
  54442. * Creates a new CrossBlock
  54443. * @param name defines the block name
  54444. */
  54445. constructor(name: string);
  54446. /**
  54447. * Gets the current class name
  54448. * @returns the class name
  54449. */
  54450. getClassName(): string;
  54451. /**
  54452. * Gets the left operand input component
  54453. */
  54454. readonly left: NodeMaterialConnectionPoint;
  54455. /**
  54456. * Gets the right operand input component
  54457. */
  54458. readonly right: NodeMaterialConnectionPoint;
  54459. /**
  54460. * Gets the output component
  54461. */
  54462. readonly output: NodeMaterialConnectionPoint;
  54463. protected _buildBlock(state: NodeMaterialBuildState): this;
  54464. }
  54465. }
  54466. declare module BABYLON {
  54467. /**
  54468. * Block used to apply a dot product between 2 vectors
  54469. */
  54470. export class DotBlock extends NodeMaterialBlock {
  54471. /**
  54472. * Creates a new DotBlock
  54473. * @param name defines the block name
  54474. */
  54475. constructor(name: string);
  54476. /**
  54477. * Gets the current class name
  54478. * @returns the class name
  54479. */
  54480. getClassName(): string;
  54481. /**
  54482. * Gets the left operand input component
  54483. */
  54484. readonly left: NodeMaterialConnectionPoint;
  54485. /**
  54486. * Gets the right operand input component
  54487. */
  54488. readonly right: NodeMaterialConnectionPoint;
  54489. /**
  54490. * Gets the output component
  54491. */
  54492. readonly output: NodeMaterialConnectionPoint;
  54493. protected _buildBlock(state: NodeMaterialBuildState): this;
  54494. }
  54495. }
  54496. declare module BABYLON {
  54497. /**
  54498. * Block used to remap a float from a range to a new one
  54499. */
  54500. export class RemapBlock extends NodeMaterialBlock {
  54501. /**
  54502. * Gets or sets the source range
  54503. */
  54504. sourceRange: Vector2;
  54505. /**
  54506. * Gets or sets the target range
  54507. */
  54508. targetRange: Vector2;
  54509. /**
  54510. * Creates a new RemapBlock
  54511. * @param name defines the block name
  54512. */
  54513. constructor(name: string);
  54514. /**
  54515. * Gets the current class name
  54516. * @returns the class name
  54517. */
  54518. getClassName(): string;
  54519. /**
  54520. * Gets the input component
  54521. */
  54522. readonly input: NodeMaterialConnectionPoint;
  54523. /**
  54524. * Gets the source min input component
  54525. */
  54526. readonly sourceMin: NodeMaterialConnectionPoint;
  54527. /**
  54528. * Gets the source max input component
  54529. */
  54530. readonly sourceMax: NodeMaterialConnectionPoint;
  54531. /**
  54532. * Gets the target min input component
  54533. */
  54534. readonly targetMin: NodeMaterialConnectionPoint;
  54535. /**
  54536. * Gets the target max input component
  54537. */
  54538. readonly targetMax: NodeMaterialConnectionPoint;
  54539. /**
  54540. * Gets the output component
  54541. */
  54542. readonly output: NodeMaterialConnectionPoint;
  54543. protected _buildBlock(state: NodeMaterialBuildState): this;
  54544. protected _dumpPropertiesCode(): string;
  54545. serialize(): any;
  54546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54547. }
  54548. }
  54549. declare module BABYLON {
  54550. /**
  54551. * Block used to normalize a vector
  54552. */
  54553. export class NormalizeBlock extends NodeMaterialBlock {
  54554. /**
  54555. * Creates a new NormalizeBlock
  54556. * @param name defines the block name
  54557. */
  54558. constructor(name: string);
  54559. /**
  54560. * Gets the current class name
  54561. * @returns the class name
  54562. */
  54563. getClassName(): string;
  54564. /**
  54565. * Gets the input component
  54566. */
  54567. readonly input: NodeMaterialConnectionPoint;
  54568. /**
  54569. * Gets the output component
  54570. */
  54571. readonly output: NodeMaterialConnectionPoint;
  54572. protected _buildBlock(state: NodeMaterialBuildState): this;
  54573. }
  54574. }
  54575. declare module BABYLON {
  54576. /**
  54577. * Operations supported by the Trigonometry block
  54578. */
  54579. export enum TrigonometryBlockOperations {
  54580. /** Cos */
  54581. Cos = 0,
  54582. /** Sin */
  54583. Sin = 1,
  54584. /** Abs */
  54585. Abs = 2,
  54586. /** Exp */
  54587. Exp = 3,
  54588. /** Exp2 */
  54589. Exp2 = 4,
  54590. /** Round */
  54591. Round = 5,
  54592. /** Floor */
  54593. Floor = 6,
  54594. /** Ceiling */
  54595. Ceiling = 7,
  54596. /** Square root */
  54597. Sqrt = 8,
  54598. /** Log */
  54599. Log = 9,
  54600. /** Tangent */
  54601. Tan = 10,
  54602. /** Arc tangent */
  54603. ArcTan = 11,
  54604. /** Arc cosinus */
  54605. ArcCos = 12,
  54606. /** Arc sinus */
  54607. ArcSin = 13,
  54608. /** Fraction */
  54609. Fract = 14,
  54610. /** Sign */
  54611. Sign = 15,
  54612. /** To radians (from degrees) */
  54613. Radians = 16,
  54614. /** To degrees (from radians) */
  54615. Degrees = 17
  54616. }
  54617. /**
  54618. * Block used to apply trigonometry operation to floats
  54619. */
  54620. export class TrigonometryBlock extends NodeMaterialBlock {
  54621. /**
  54622. * Gets or sets the operation applied by the block
  54623. */
  54624. operation: TrigonometryBlockOperations;
  54625. /**
  54626. * Creates a new TrigonometryBlock
  54627. * @param name defines the block name
  54628. */
  54629. constructor(name: string);
  54630. /**
  54631. * Gets the current class name
  54632. * @returns the class name
  54633. */
  54634. getClassName(): string;
  54635. /**
  54636. * Gets the input component
  54637. */
  54638. readonly input: NodeMaterialConnectionPoint;
  54639. /**
  54640. * Gets the output component
  54641. */
  54642. readonly output: NodeMaterialConnectionPoint;
  54643. protected _buildBlock(state: NodeMaterialBuildState): this;
  54644. serialize(): any;
  54645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54646. }
  54647. }
  54648. declare module BABYLON {
  54649. /**
  54650. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54651. */
  54652. export class ColorMergerBlock extends NodeMaterialBlock {
  54653. /**
  54654. * Create a new ColorMergerBlock
  54655. * @param name defines the block name
  54656. */
  54657. constructor(name: string);
  54658. /**
  54659. * Gets the current class name
  54660. * @returns the class name
  54661. */
  54662. getClassName(): string;
  54663. /**
  54664. * Gets the r component (input)
  54665. */
  54666. readonly r: NodeMaterialConnectionPoint;
  54667. /**
  54668. * Gets the g component (input)
  54669. */
  54670. readonly g: NodeMaterialConnectionPoint;
  54671. /**
  54672. * Gets the b component (input)
  54673. */
  54674. readonly b: NodeMaterialConnectionPoint;
  54675. /**
  54676. * Gets the a component (input)
  54677. */
  54678. readonly a: NodeMaterialConnectionPoint;
  54679. /**
  54680. * Gets the rgba component (output)
  54681. */
  54682. readonly rgba: NodeMaterialConnectionPoint;
  54683. /**
  54684. * Gets the rgb component (output)
  54685. */
  54686. readonly rgb: NodeMaterialConnectionPoint;
  54687. protected _buildBlock(state: NodeMaterialBuildState): this;
  54688. }
  54689. }
  54690. declare module BABYLON {
  54691. /**
  54692. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54693. */
  54694. export class VectorMergerBlock extends NodeMaterialBlock {
  54695. /**
  54696. * Create a new VectorMergerBlock
  54697. * @param name defines the block name
  54698. */
  54699. constructor(name: string);
  54700. /**
  54701. * Gets the current class name
  54702. * @returns the class name
  54703. */
  54704. getClassName(): string;
  54705. /**
  54706. * Gets the x component (input)
  54707. */
  54708. readonly x: NodeMaterialConnectionPoint;
  54709. /**
  54710. * Gets the y component (input)
  54711. */
  54712. readonly y: NodeMaterialConnectionPoint;
  54713. /**
  54714. * Gets the z component (input)
  54715. */
  54716. readonly z: NodeMaterialConnectionPoint;
  54717. /**
  54718. * Gets the w component (input)
  54719. */
  54720. readonly w: NodeMaterialConnectionPoint;
  54721. /**
  54722. * Gets the xyzw component (output)
  54723. */
  54724. readonly xyzw: NodeMaterialConnectionPoint;
  54725. /**
  54726. * Gets the xyz component (output)
  54727. */
  54728. readonly xyz: NodeMaterialConnectionPoint;
  54729. /**
  54730. * Gets the xy component (output)
  54731. */
  54732. readonly xy: NodeMaterialConnectionPoint;
  54733. protected _buildBlock(state: NodeMaterialBuildState): this;
  54734. }
  54735. }
  54736. declare module BABYLON {
  54737. /**
  54738. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54739. */
  54740. export class ColorSplitterBlock extends NodeMaterialBlock {
  54741. /**
  54742. * Create a new ColorSplitterBlock
  54743. * @param name defines the block name
  54744. */
  54745. constructor(name: string);
  54746. /**
  54747. * Gets the current class name
  54748. * @returns the class name
  54749. */
  54750. getClassName(): string;
  54751. /**
  54752. * Gets the rgba component (input)
  54753. */
  54754. readonly rgba: NodeMaterialConnectionPoint;
  54755. /**
  54756. * Gets the rgb component (input)
  54757. */
  54758. readonly rgbIn: NodeMaterialConnectionPoint;
  54759. /**
  54760. * Gets the rgb component (output)
  54761. */
  54762. readonly rgbOut: NodeMaterialConnectionPoint;
  54763. /**
  54764. * Gets the r component (output)
  54765. */
  54766. readonly r: NodeMaterialConnectionPoint;
  54767. /**
  54768. * Gets the g component (output)
  54769. */
  54770. readonly g: NodeMaterialConnectionPoint;
  54771. /**
  54772. * Gets the b component (output)
  54773. */
  54774. readonly b: NodeMaterialConnectionPoint;
  54775. /**
  54776. * Gets the a component (output)
  54777. */
  54778. readonly a: NodeMaterialConnectionPoint;
  54779. protected _inputRename(name: string): string;
  54780. protected _outputRename(name: string): string;
  54781. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54782. }
  54783. }
  54784. declare module BABYLON {
  54785. /**
  54786. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54787. */
  54788. export class VectorSplitterBlock extends NodeMaterialBlock {
  54789. /**
  54790. * Create a new VectorSplitterBlock
  54791. * @param name defines the block name
  54792. */
  54793. constructor(name: string);
  54794. /**
  54795. * Gets the current class name
  54796. * @returns the class name
  54797. */
  54798. getClassName(): string;
  54799. /**
  54800. * Gets the xyzw component (input)
  54801. */
  54802. readonly xyzw: NodeMaterialConnectionPoint;
  54803. /**
  54804. * Gets the xyz component (input)
  54805. */
  54806. readonly xyzIn: NodeMaterialConnectionPoint;
  54807. /**
  54808. * Gets the xy component (input)
  54809. */
  54810. readonly xyIn: NodeMaterialConnectionPoint;
  54811. /**
  54812. * Gets the xyz component (output)
  54813. */
  54814. readonly xyzOut: NodeMaterialConnectionPoint;
  54815. /**
  54816. * Gets the xy component (output)
  54817. */
  54818. readonly xyOut: NodeMaterialConnectionPoint;
  54819. /**
  54820. * Gets the x component (output)
  54821. */
  54822. readonly x: NodeMaterialConnectionPoint;
  54823. /**
  54824. * Gets the y component (output)
  54825. */
  54826. readonly y: NodeMaterialConnectionPoint;
  54827. /**
  54828. * Gets the z component (output)
  54829. */
  54830. readonly z: NodeMaterialConnectionPoint;
  54831. /**
  54832. * Gets the w component (output)
  54833. */
  54834. readonly w: NodeMaterialConnectionPoint;
  54835. protected _inputRename(name: string): string;
  54836. protected _outputRename(name: string): string;
  54837. protected _buildBlock(state: NodeMaterialBuildState): this;
  54838. }
  54839. }
  54840. declare module BABYLON {
  54841. /**
  54842. * Block used to lerp between 2 values
  54843. */
  54844. export class LerpBlock extends NodeMaterialBlock {
  54845. /**
  54846. * Creates a new LerpBlock
  54847. * @param name defines the block name
  54848. */
  54849. constructor(name: string);
  54850. /**
  54851. * Gets the current class name
  54852. * @returns the class name
  54853. */
  54854. getClassName(): string;
  54855. /**
  54856. * Gets the left operand input component
  54857. */
  54858. readonly left: NodeMaterialConnectionPoint;
  54859. /**
  54860. * Gets the right operand input component
  54861. */
  54862. readonly right: NodeMaterialConnectionPoint;
  54863. /**
  54864. * Gets the gradient operand input component
  54865. */
  54866. readonly gradient: NodeMaterialConnectionPoint;
  54867. /**
  54868. * Gets the output component
  54869. */
  54870. readonly output: NodeMaterialConnectionPoint;
  54871. protected _buildBlock(state: NodeMaterialBuildState): this;
  54872. }
  54873. }
  54874. declare module BABYLON {
  54875. /**
  54876. * Block used to divide 2 vectors
  54877. */
  54878. export class DivideBlock extends NodeMaterialBlock {
  54879. /**
  54880. * Creates a new DivideBlock
  54881. * @param name defines the block name
  54882. */
  54883. constructor(name: string);
  54884. /**
  54885. * Gets the current class name
  54886. * @returns the class name
  54887. */
  54888. getClassName(): string;
  54889. /**
  54890. * Gets the left operand input component
  54891. */
  54892. readonly left: NodeMaterialConnectionPoint;
  54893. /**
  54894. * Gets the right operand input component
  54895. */
  54896. readonly right: NodeMaterialConnectionPoint;
  54897. /**
  54898. * Gets the output component
  54899. */
  54900. readonly output: NodeMaterialConnectionPoint;
  54901. protected _buildBlock(state: NodeMaterialBuildState): this;
  54902. }
  54903. }
  54904. declare module BABYLON {
  54905. /**
  54906. * Block used to subtract 2 vectors
  54907. */
  54908. export class SubtractBlock extends NodeMaterialBlock {
  54909. /**
  54910. * Creates a new SubtractBlock
  54911. * @param name defines the block name
  54912. */
  54913. constructor(name: string);
  54914. /**
  54915. * Gets the current class name
  54916. * @returns the class name
  54917. */
  54918. getClassName(): string;
  54919. /**
  54920. * Gets the left operand input component
  54921. */
  54922. readonly left: NodeMaterialConnectionPoint;
  54923. /**
  54924. * Gets the right operand input component
  54925. */
  54926. readonly right: NodeMaterialConnectionPoint;
  54927. /**
  54928. * Gets the output component
  54929. */
  54930. readonly output: NodeMaterialConnectionPoint;
  54931. protected _buildBlock(state: NodeMaterialBuildState): this;
  54932. }
  54933. }
  54934. declare module BABYLON {
  54935. /**
  54936. * Block used to step a value
  54937. */
  54938. export class StepBlock extends NodeMaterialBlock {
  54939. /**
  54940. * Creates a new StepBlock
  54941. * @param name defines the block name
  54942. */
  54943. constructor(name: string);
  54944. /**
  54945. * Gets the current class name
  54946. * @returns the class name
  54947. */
  54948. getClassName(): string;
  54949. /**
  54950. * Gets the value operand input component
  54951. */
  54952. readonly value: NodeMaterialConnectionPoint;
  54953. /**
  54954. * Gets the edge operand input component
  54955. */
  54956. readonly edge: NodeMaterialConnectionPoint;
  54957. /**
  54958. * Gets the output component
  54959. */
  54960. readonly output: NodeMaterialConnectionPoint;
  54961. protected _buildBlock(state: NodeMaterialBuildState): this;
  54962. }
  54963. }
  54964. declare module BABYLON {
  54965. /**
  54966. * Block used to get the opposite (1 - x) of a value
  54967. */
  54968. export class OneMinusBlock extends NodeMaterialBlock {
  54969. /**
  54970. * Creates a new OneMinusBlock
  54971. * @param name defines the block name
  54972. */
  54973. constructor(name: string);
  54974. /**
  54975. * Gets the current class name
  54976. * @returns the class name
  54977. */
  54978. getClassName(): string;
  54979. /**
  54980. * Gets the input component
  54981. */
  54982. readonly input: NodeMaterialConnectionPoint;
  54983. /**
  54984. * Gets the output component
  54985. */
  54986. readonly output: NodeMaterialConnectionPoint;
  54987. protected _buildBlock(state: NodeMaterialBuildState): this;
  54988. }
  54989. }
  54990. declare module BABYLON {
  54991. /**
  54992. * Block used to get the view direction
  54993. */
  54994. export class ViewDirectionBlock extends NodeMaterialBlock {
  54995. /**
  54996. * Creates a new ViewDirectionBlock
  54997. * @param name defines the block name
  54998. */
  54999. constructor(name: string);
  55000. /**
  55001. * Gets the current class name
  55002. * @returns the class name
  55003. */
  55004. getClassName(): string;
  55005. /**
  55006. * Gets the world position component
  55007. */
  55008. readonly worldPosition: NodeMaterialConnectionPoint;
  55009. /**
  55010. * Gets the camera position component
  55011. */
  55012. readonly cameraPosition: NodeMaterialConnectionPoint;
  55013. /**
  55014. * Gets the output component
  55015. */
  55016. readonly output: NodeMaterialConnectionPoint;
  55017. autoConfigure(material: NodeMaterial): void;
  55018. protected _buildBlock(state: NodeMaterialBuildState): this;
  55019. }
  55020. }
  55021. declare module BABYLON {
  55022. /**
  55023. * Block used to compute fresnel value
  55024. */
  55025. export class FresnelBlock extends NodeMaterialBlock {
  55026. /**
  55027. * Create a new FresnelBlock
  55028. * @param name defines the block name
  55029. */
  55030. constructor(name: string);
  55031. /**
  55032. * Gets the current class name
  55033. * @returns the class name
  55034. */
  55035. getClassName(): string;
  55036. /**
  55037. * Gets the world normal input component
  55038. */
  55039. readonly worldNormal: NodeMaterialConnectionPoint;
  55040. /**
  55041. * Gets the view direction input component
  55042. */
  55043. readonly viewDirection: NodeMaterialConnectionPoint;
  55044. /**
  55045. * Gets the bias input component
  55046. */
  55047. readonly bias: NodeMaterialConnectionPoint;
  55048. /**
  55049. * Gets the camera (or eye) position component
  55050. */
  55051. readonly power: NodeMaterialConnectionPoint;
  55052. /**
  55053. * Gets the fresnel output component
  55054. */
  55055. readonly fresnel: NodeMaterialConnectionPoint;
  55056. autoConfigure(material: NodeMaterial): void;
  55057. protected _buildBlock(state: NodeMaterialBuildState): this;
  55058. }
  55059. }
  55060. declare module BABYLON {
  55061. /**
  55062. * Block used to get the max of 2 values
  55063. */
  55064. export class MaxBlock extends NodeMaterialBlock {
  55065. /**
  55066. * Creates a new MaxBlock
  55067. * @param name defines the block name
  55068. */
  55069. constructor(name: string);
  55070. /**
  55071. * Gets the current class name
  55072. * @returns the class name
  55073. */
  55074. getClassName(): string;
  55075. /**
  55076. * Gets the left operand input component
  55077. */
  55078. readonly left: NodeMaterialConnectionPoint;
  55079. /**
  55080. * Gets the right operand input component
  55081. */
  55082. readonly right: NodeMaterialConnectionPoint;
  55083. /**
  55084. * Gets the output component
  55085. */
  55086. readonly output: NodeMaterialConnectionPoint;
  55087. protected _buildBlock(state: NodeMaterialBuildState): this;
  55088. }
  55089. }
  55090. declare module BABYLON {
  55091. /**
  55092. * Block used to get the min of 2 values
  55093. */
  55094. export class MinBlock extends NodeMaterialBlock {
  55095. /**
  55096. * Creates a new MinBlock
  55097. * @param name defines the block name
  55098. */
  55099. constructor(name: string);
  55100. /**
  55101. * Gets the current class name
  55102. * @returns the class name
  55103. */
  55104. getClassName(): string;
  55105. /**
  55106. * Gets the left operand input component
  55107. */
  55108. readonly left: NodeMaterialConnectionPoint;
  55109. /**
  55110. * Gets the right operand input component
  55111. */
  55112. readonly right: NodeMaterialConnectionPoint;
  55113. /**
  55114. * Gets the output component
  55115. */
  55116. readonly output: NodeMaterialConnectionPoint;
  55117. protected _buildBlock(state: NodeMaterialBuildState): this;
  55118. }
  55119. }
  55120. declare module BABYLON {
  55121. /**
  55122. * Block used to get the distance between 2 values
  55123. */
  55124. export class DistanceBlock extends NodeMaterialBlock {
  55125. /**
  55126. * Creates a new DistanceBlock
  55127. * @param name defines the block name
  55128. */
  55129. constructor(name: string);
  55130. /**
  55131. * Gets the current class name
  55132. * @returns the class name
  55133. */
  55134. getClassName(): string;
  55135. /**
  55136. * Gets the left operand input component
  55137. */
  55138. readonly left: NodeMaterialConnectionPoint;
  55139. /**
  55140. * Gets the right operand input component
  55141. */
  55142. readonly right: NodeMaterialConnectionPoint;
  55143. /**
  55144. * Gets the output component
  55145. */
  55146. readonly output: NodeMaterialConnectionPoint;
  55147. protected _buildBlock(state: NodeMaterialBuildState): this;
  55148. }
  55149. }
  55150. declare module BABYLON {
  55151. /**
  55152. * Block used to get the length of a vector
  55153. */
  55154. export class LengthBlock extends NodeMaterialBlock {
  55155. /**
  55156. * Creates a new LengthBlock
  55157. * @param name defines the block name
  55158. */
  55159. constructor(name: string);
  55160. /**
  55161. * Gets the current class name
  55162. * @returns the class name
  55163. */
  55164. getClassName(): string;
  55165. /**
  55166. * Gets the value input component
  55167. */
  55168. readonly value: NodeMaterialConnectionPoint;
  55169. /**
  55170. * Gets the output component
  55171. */
  55172. readonly output: NodeMaterialConnectionPoint;
  55173. protected _buildBlock(state: NodeMaterialBuildState): this;
  55174. }
  55175. }
  55176. declare module BABYLON {
  55177. /**
  55178. * Block used to get negative version of a value (i.e. x * -1)
  55179. */
  55180. export class NegateBlock extends NodeMaterialBlock {
  55181. /**
  55182. * Creates a new NegateBlock
  55183. * @param name defines the block name
  55184. */
  55185. constructor(name: string);
  55186. /**
  55187. * Gets the current class name
  55188. * @returns the class name
  55189. */
  55190. getClassName(): string;
  55191. /**
  55192. * Gets the value input component
  55193. */
  55194. readonly value: NodeMaterialConnectionPoint;
  55195. /**
  55196. * Gets the output component
  55197. */
  55198. readonly output: NodeMaterialConnectionPoint;
  55199. protected _buildBlock(state: NodeMaterialBuildState): this;
  55200. }
  55201. }
  55202. declare module BABYLON {
  55203. /**
  55204. * Block used to get the value of the first parameter raised to the power of the second
  55205. */
  55206. export class PowBlock extends NodeMaterialBlock {
  55207. /**
  55208. * Creates a new PowBlock
  55209. * @param name defines the block name
  55210. */
  55211. constructor(name: string);
  55212. /**
  55213. * Gets the current class name
  55214. * @returns the class name
  55215. */
  55216. getClassName(): string;
  55217. /**
  55218. * Gets the value operand input component
  55219. */
  55220. readonly value: NodeMaterialConnectionPoint;
  55221. /**
  55222. * Gets the power operand input component
  55223. */
  55224. readonly power: NodeMaterialConnectionPoint;
  55225. /**
  55226. * Gets the output component
  55227. */
  55228. readonly output: NodeMaterialConnectionPoint;
  55229. protected _buildBlock(state: NodeMaterialBuildState): this;
  55230. }
  55231. }
  55232. declare module BABYLON {
  55233. /**
  55234. * Block used to get a random number
  55235. */
  55236. export class RandomNumberBlock extends NodeMaterialBlock {
  55237. /**
  55238. * Creates a new RandomNumberBlock
  55239. * @param name defines the block name
  55240. */
  55241. constructor(name: string);
  55242. /**
  55243. * Gets the current class name
  55244. * @returns the class name
  55245. */
  55246. getClassName(): string;
  55247. /**
  55248. * Gets the seed input component
  55249. */
  55250. readonly seed: NodeMaterialConnectionPoint;
  55251. /**
  55252. * Gets the output component
  55253. */
  55254. readonly output: NodeMaterialConnectionPoint;
  55255. protected _buildBlock(state: NodeMaterialBuildState): this;
  55256. }
  55257. }
  55258. declare module BABYLON {
  55259. /**
  55260. * Block used to compute arc tangent of 2 values
  55261. */
  55262. export class ArcTan2Block extends NodeMaterialBlock {
  55263. /**
  55264. * Creates a new ArcTan2Block
  55265. * @param name defines the block name
  55266. */
  55267. constructor(name: string);
  55268. /**
  55269. * Gets the current class name
  55270. * @returns the class name
  55271. */
  55272. getClassName(): string;
  55273. /**
  55274. * Gets the x operand input component
  55275. */
  55276. readonly x: NodeMaterialConnectionPoint;
  55277. /**
  55278. * Gets the y operand input component
  55279. */
  55280. readonly y: NodeMaterialConnectionPoint;
  55281. /**
  55282. * Gets the output component
  55283. */
  55284. readonly output: NodeMaterialConnectionPoint;
  55285. protected _buildBlock(state: NodeMaterialBuildState): this;
  55286. }
  55287. }
  55288. declare module BABYLON {
  55289. /**
  55290. * Block used to smooth step a value
  55291. */
  55292. export class SmoothStepBlock extends NodeMaterialBlock {
  55293. /**
  55294. * Creates a new SmoothStepBlock
  55295. * @param name defines the block name
  55296. */
  55297. constructor(name: string);
  55298. /**
  55299. * Gets the current class name
  55300. * @returns the class name
  55301. */
  55302. getClassName(): string;
  55303. /**
  55304. * Gets the value operand input component
  55305. */
  55306. readonly value: NodeMaterialConnectionPoint;
  55307. /**
  55308. * Gets the first edge operand input component
  55309. */
  55310. readonly edge0: NodeMaterialConnectionPoint;
  55311. /**
  55312. * Gets the second edge operand input component
  55313. */
  55314. readonly edge1: NodeMaterialConnectionPoint;
  55315. /**
  55316. * Gets the output component
  55317. */
  55318. readonly output: NodeMaterialConnectionPoint;
  55319. protected _buildBlock(state: NodeMaterialBuildState): this;
  55320. }
  55321. }
  55322. declare module BABYLON {
  55323. /**
  55324. * Block used to get the reciprocal (1 / x) of a value
  55325. */
  55326. export class ReciprocalBlock extends NodeMaterialBlock {
  55327. /**
  55328. * Creates a new ReciprocalBlock
  55329. * @param name defines the block name
  55330. */
  55331. constructor(name: string);
  55332. /**
  55333. * Gets the current class name
  55334. * @returns the class name
  55335. */
  55336. getClassName(): string;
  55337. /**
  55338. * Gets the input component
  55339. */
  55340. readonly input: NodeMaterialConnectionPoint;
  55341. /**
  55342. * Gets the output component
  55343. */
  55344. readonly output: NodeMaterialConnectionPoint;
  55345. protected _buildBlock(state: NodeMaterialBuildState): this;
  55346. }
  55347. }
  55348. declare module BABYLON {
  55349. /**
  55350. * Block used to replace a color by another one
  55351. */
  55352. export class ReplaceColorBlock extends NodeMaterialBlock {
  55353. /**
  55354. * Creates a new ReplaceColorBlock
  55355. * @param name defines the block name
  55356. */
  55357. constructor(name: string);
  55358. /**
  55359. * Gets the current class name
  55360. * @returns the class name
  55361. */
  55362. getClassName(): string;
  55363. /**
  55364. * Gets the value input component
  55365. */
  55366. readonly value: NodeMaterialConnectionPoint;
  55367. /**
  55368. * Gets the reference input component
  55369. */
  55370. readonly reference: NodeMaterialConnectionPoint;
  55371. /**
  55372. * Gets the distance input component
  55373. */
  55374. readonly distance: NodeMaterialConnectionPoint;
  55375. /**
  55376. * Gets the replacement input component
  55377. */
  55378. readonly replacement: NodeMaterialConnectionPoint;
  55379. /**
  55380. * Gets the output component
  55381. */
  55382. readonly output: NodeMaterialConnectionPoint;
  55383. protected _buildBlock(state: NodeMaterialBuildState): this;
  55384. }
  55385. }
  55386. declare module BABYLON {
  55387. /**
  55388. * Block used to posterize a value
  55389. * @see https://en.wikipedia.org/wiki/Posterization
  55390. */
  55391. export class PosterizeBlock extends NodeMaterialBlock {
  55392. /**
  55393. * Creates a new PosterizeBlock
  55394. * @param name defines the block name
  55395. */
  55396. constructor(name: string);
  55397. /**
  55398. * Gets the current class name
  55399. * @returns the class name
  55400. */
  55401. getClassName(): string;
  55402. /**
  55403. * Gets the value input component
  55404. */
  55405. readonly value: NodeMaterialConnectionPoint;
  55406. /**
  55407. * Gets the steps input component
  55408. */
  55409. readonly steps: NodeMaterialConnectionPoint;
  55410. /**
  55411. * Gets the output component
  55412. */
  55413. readonly output: NodeMaterialConnectionPoint;
  55414. protected _buildBlock(state: NodeMaterialBuildState): this;
  55415. }
  55416. }
  55417. declare module BABYLON {
  55418. /**
  55419. * Operations supported by the Wave block
  55420. */
  55421. export enum WaveBlockKind {
  55422. /** SawTooth */
  55423. SawTooth = 0,
  55424. /** Square */
  55425. Square = 1,
  55426. /** Triangle */
  55427. Triangle = 2
  55428. }
  55429. /**
  55430. * Block used to apply wave operation to floats
  55431. */
  55432. export class WaveBlock extends NodeMaterialBlock {
  55433. /**
  55434. * Gets or sets the kibnd of wave to be applied by the block
  55435. */
  55436. kind: WaveBlockKind;
  55437. /**
  55438. * Creates a new WaveBlock
  55439. * @param name defines the block name
  55440. */
  55441. constructor(name: string);
  55442. /**
  55443. * Gets the current class name
  55444. * @returns the class name
  55445. */
  55446. getClassName(): string;
  55447. /**
  55448. * Gets the input component
  55449. */
  55450. readonly input: NodeMaterialConnectionPoint;
  55451. /**
  55452. * Gets the output component
  55453. */
  55454. readonly output: NodeMaterialConnectionPoint;
  55455. protected _buildBlock(state: NodeMaterialBuildState): this;
  55456. serialize(): any;
  55457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55458. }
  55459. }
  55460. declare module BABYLON {
  55461. /**
  55462. * Class used to store a color step for the GradientBlock
  55463. */
  55464. export class GradientBlockColorStep {
  55465. /**
  55466. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55467. */
  55468. step: number;
  55469. /**
  55470. * Gets or sets the color associated with this step
  55471. */
  55472. color: Color3;
  55473. /**
  55474. * Creates a new GradientBlockColorStep
  55475. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55476. * @param color defines the color associated with this step
  55477. */
  55478. constructor(
  55479. /**
  55480. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55481. */
  55482. step: number,
  55483. /**
  55484. * Gets or sets the color associated with this step
  55485. */
  55486. color: Color3);
  55487. }
  55488. /**
  55489. * Block used to return a color from a gradient based on an input value between 0 and 1
  55490. */
  55491. export class GradientBlock extends NodeMaterialBlock {
  55492. /**
  55493. * Gets or sets the list of color steps
  55494. */
  55495. colorSteps: GradientBlockColorStep[];
  55496. /**
  55497. * Creates a new GradientBlock
  55498. * @param name defines the block name
  55499. */
  55500. constructor(name: string);
  55501. /**
  55502. * Gets the current class name
  55503. * @returns the class name
  55504. */
  55505. getClassName(): string;
  55506. /**
  55507. * Gets the gradient input component
  55508. */
  55509. readonly gradient: NodeMaterialConnectionPoint;
  55510. /**
  55511. * Gets the output component
  55512. */
  55513. readonly output: NodeMaterialConnectionPoint;
  55514. private _writeColorConstant;
  55515. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55516. serialize(): any;
  55517. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55518. protected _dumpPropertiesCode(): string;
  55519. }
  55520. }
  55521. declare module BABYLON {
  55522. /**
  55523. * Block used to normalize lerp between 2 values
  55524. */
  55525. export class NLerpBlock extends NodeMaterialBlock {
  55526. /**
  55527. * Creates a new NLerpBlock
  55528. * @param name defines the block name
  55529. */
  55530. constructor(name: string);
  55531. /**
  55532. * Gets the current class name
  55533. * @returns the class name
  55534. */
  55535. getClassName(): string;
  55536. /**
  55537. * Gets the left operand input component
  55538. */
  55539. readonly left: NodeMaterialConnectionPoint;
  55540. /**
  55541. * Gets the right operand input component
  55542. */
  55543. readonly right: NodeMaterialConnectionPoint;
  55544. /**
  55545. * Gets the gradient operand input component
  55546. */
  55547. readonly gradient: NodeMaterialConnectionPoint;
  55548. /**
  55549. * Gets the output component
  55550. */
  55551. readonly output: NodeMaterialConnectionPoint;
  55552. protected _buildBlock(state: NodeMaterialBuildState): this;
  55553. }
  55554. }
  55555. declare module BABYLON {
  55556. /**
  55557. * Effect Render Options
  55558. */
  55559. export interface IEffectRendererOptions {
  55560. /**
  55561. * Defines the vertices positions.
  55562. */
  55563. positions?: number[];
  55564. /**
  55565. * Defines the indices.
  55566. */
  55567. indices?: number[];
  55568. }
  55569. /**
  55570. * Helper class to render one or more effects
  55571. */
  55572. export class EffectRenderer {
  55573. private engine;
  55574. private static _DefaultOptions;
  55575. private _vertexBuffers;
  55576. private _indexBuffer;
  55577. private _ringBufferIndex;
  55578. private _ringScreenBuffer;
  55579. private _fullscreenViewport;
  55580. private _getNextFrameBuffer;
  55581. /**
  55582. * Creates an effect renderer
  55583. * @param engine the engine to use for rendering
  55584. * @param options defines the options of the effect renderer
  55585. */
  55586. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  55587. /**
  55588. * Sets the current viewport in normalized coordinates 0-1
  55589. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55590. */
  55591. setViewport(viewport?: Viewport): void;
  55592. /**
  55593. * Binds the embedded attributes buffer to the effect.
  55594. * @param effect Defines the effect to bind the attributes for
  55595. */
  55596. bindBuffers(effect: Effect): void;
  55597. /**
  55598. * Sets the current effect wrapper to use during draw.
  55599. * The effect needs to be ready before calling this api.
  55600. * This also sets the default full screen position attribute.
  55601. * @param effectWrapper Defines the effect to draw with
  55602. */
  55603. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55604. /**
  55605. * Draws a full screen quad.
  55606. */
  55607. draw(): void;
  55608. /**
  55609. * renders one or more effects to a specified texture
  55610. * @param effectWrappers list of effects to renderer
  55611. * @param outputTexture texture to draw to, if null it will render to the screen
  55612. */
  55613. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55614. /**
  55615. * Disposes of the effect renderer
  55616. */
  55617. dispose(): void;
  55618. }
  55619. /**
  55620. * Options to create an EffectWrapper
  55621. */
  55622. interface EffectWrapperCreationOptions {
  55623. /**
  55624. * Engine to use to create the effect
  55625. */
  55626. engine: ThinEngine;
  55627. /**
  55628. * Fragment shader for the effect
  55629. */
  55630. fragmentShader: string;
  55631. /**
  55632. * Vertex shader for the effect
  55633. */
  55634. vertexShader?: string;
  55635. /**
  55636. * Attributes to use in the shader
  55637. */
  55638. attributeNames?: Array<string>;
  55639. /**
  55640. * Uniforms to use in the shader
  55641. */
  55642. uniformNames?: Array<string>;
  55643. /**
  55644. * Texture sampler names to use in the shader
  55645. */
  55646. samplerNames?: Array<string>;
  55647. /**
  55648. * The friendly name of the effect displayed in Spector.
  55649. */
  55650. name?: string;
  55651. }
  55652. /**
  55653. * Wraps an effect to be used for rendering
  55654. */
  55655. export class EffectWrapper {
  55656. /**
  55657. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55658. */
  55659. onApplyObservable: Observable<{}>;
  55660. /**
  55661. * The underlying effect
  55662. */
  55663. effect: Effect;
  55664. /**
  55665. * Creates an effect to be renderer
  55666. * @param creationOptions options to create the effect
  55667. */
  55668. constructor(creationOptions: EffectWrapperCreationOptions);
  55669. /**
  55670. * Disposes of the effect wrapper
  55671. */
  55672. dispose(): void;
  55673. }
  55674. }
  55675. declare module BABYLON {
  55676. /**
  55677. * Helper class to push actions to a pool of workers.
  55678. */
  55679. export class WorkerPool implements IDisposable {
  55680. private _workerInfos;
  55681. private _pendingActions;
  55682. /**
  55683. * Constructor
  55684. * @param workers Array of workers to use for actions
  55685. */
  55686. constructor(workers: Array<Worker>);
  55687. /**
  55688. * Terminates all workers and clears any pending actions.
  55689. */
  55690. dispose(): void;
  55691. /**
  55692. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55693. * pended until a worker has completed its action.
  55694. * @param action The action to perform. Call onComplete when the action is complete.
  55695. */
  55696. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55697. private _execute;
  55698. }
  55699. }
  55700. declare module BABYLON {
  55701. /**
  55702. * Configuration for Draco compression
  55703. */
  55704. export interface IDracoCompressionConfiguration {
  55705. /**
  55706. * Configuration for the decoder.
  55707. */
  55708. decoder: {
  55709. /**
  55710. * The url to the WebAssembly module.
  55711. */
  55712. wasmUrl?: string;
  55713. /**
  55714. * The url to the WebAssembly binary.
  55715. */
  55716. wasmBinaryUrl?: string;
  55717. /**
  55718. * The url to the fallback JavaScript module.
  55719. */
  55720. fallbackUrl?: string;
  55721. };
  55722. }
  55723. /**
  55724. * Draco compression (https://google.github.io/draco/)
  55725. *
  55726. * This class wraps the Draco module.
  55727. *
  55728. * **Encoder**
  55729. *
  55730. * The encoder is not currently implemented.
  55731. *
  55732. * **Decoder**
  55733. *
  55734. * 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.
  55735. *
  55736. * To update the configuration, use the following code:
  55737. * ```javascript
  55738. * DracoCompression.Configuration = {
  55739. * decoder: {
  55740. * wasmUrl: "<url to the WebAssembly library>",
  55741. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55742. * fallbackUrl: "<url to the fallback JavaScript library>",
  55743. * }
  55744. * };
  55745. * ```
  55746. *
  55747. * 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.
  55748. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55749. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55750. *
  55751. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55752. * ```javascript
  55753. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55754. * ```
  55755. *
  55756. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55757. */
  55758. export class DracoCompression implements IDisposable {
  55759. private _workerPoolPromise?;
  55760. private _decoderModulePromise?;
  55761. /**
  55762. * The configuration. Defaults to the following urls:
  55763. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55764. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55765. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55766. */
  55767. static Configuration: IDracoCompressionConfiguration;
  55768. /**
  55769. * Returns true if the decoder configuration is available.
  55770. */
  55771. static readonly DecoderAvailable: boolean;
  55772. /**
  55773. * Default number of workers to create when creating the draco compression object.
  55774. */
  55775. static DefaultNumWorkers: number;
  55776. private static GetDefaultNumWorkers;
  55777. private static _Default;
  55778. /**
  55779. * Default instance for the draco compression object.
  55780. */
  55781. static readonly Default: DracoCompression;
  55782. /**
  55783. * Constructor
  55784. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55785. */
  55786. constructor(numWorkers?: number);
  55787. /**
  55788. * Stop all async operations and release resources.
  55789. */
  55790. dispose(): void;
  55791. /**
  55792. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55793. * @returns a promise that resolves when ready
  55794. */
  55795. whenReadyAsync(): Promise<void>;
  55796. /**
  55797. * Decode Draco compressed mesh data to vertex data.
  55798. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55799. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55800. * @returns A promise that resolves with the decoded vertex data
  55801. */
  55802. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55803. [kind: string]: number;
  55804. }): Promise<VertexData>;
  55805. }
  55806. }
  55807. declare module BABYLON {
  55808. /**
  55809. * Class for building Constructive Solid Geometry
  55810. */
  55811. export class CSG {
  55812. private polygons;
  55813. /**
  55814. * The world matrix
  55815. */
  55816. matrix: Matrix;
  55817. /**
  55818. * Stores the position
  55819. */
  55820. position: Vector3;
  55821. /**
  55822. * Stores the rotation
  55823. */
  55824. rotation: Vector3;
  55825. /**
  55826. * Stores the rotation quaternion
  55827. */
  55828. rotationQuaternion: Nullable<Quaternion>;
  55829. /**
  55830. * Stores the scaling vector
  55831. */
  55832. scaling: Vector3;
  55833. /**
  55834. * Convert the Mesh to CSG
  55835. * @param mesh The Mesh to convert to CSG
  55836. * @returns A new CSG from the Mesh
  55837. */
  55838. static FromMesh(mesh: Mesh): CSG;
  55839. /**
  55840. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55841. * @param polygons Polygons used to construct a CSG solid
  55842. */
  55843. private static FromPolygons;
  55844. /**
  55845. * Clones, or makes a deep copy, of the CSG
  55846. * @returns A new CSG
  55847. */
  55848. clone(): CSG;
  55849. /**
  55850. * Unions this CSG with another CSG
  55851. * @param csg The CSG to union against this CSG
  55852. * @returns The unioned CSG
  55853. */
  55854. union(csg: CSG): CSG;
  55855. /**
  55856. * Unions this CSG with another CSG in place
  55857. * @param csg The CSG to union against this CSG
  55858. */
  55859. unionInPlace(csg: CSG): void;
  55860. /**
  55861. * Subtracts this CSG with another CSG
  55862. * @param csg The CSG to subtract against this CSG
  55863. * @returns A new CSG
  55864. */
  55865. subtract(csg: CSG): CSG;
  55866. /**
  55867. * Subtracts this CSG with another CSG in place
  55868. * @param csg The CSG to subtact against this CSG
  55869. */
  55870. subtractInPlace(csg: CSG): void;
  55871. /**
  55872. * Intersect this CSG with another CSG
  55873. * @param csg The CSG to intersect against this CSG
  55874. * @returns A new CSG
  55875. */
  55876. intersect(csg: CSG): CSG;
  55877. /**
  55878. * Intersects this CSG with another CSG in place
  55879. * @param csg The CSG to intersect against this CSG
  55880. */
  55881. intersectInPlace(csg: CSG): void;
  55882. /**
  55883. * Return a new CSG solid with solid and empty space switched. This solid is
  55884. * not modified.
  55885. * @returns A new CSG solid with solid and empty space switched
  55886. */
  55887. inverse(): CSG;
  55888. /**
  55889. * Inverses the CSG in place
  55890. */
  55891. inverseInPlace(): void;
  55892. /**
  55893. * This is used to keep meshes transformations so they can be restored
  55894. * when we build back a Babylon Mesh
  55895. * NB : All CSG operations are performed in world coordinates
  55896. * @param csg The CSG to copy the transform attributes from
  55897. * @returns This CSG
  55898. */
  55899. copyTransformAttributes(csg: CSG): CSG;
  55900. /**
  55901. * Build Raw mesh from CSG
  55902. * Coordinates here are in world space
  55903. * @param name The name of the mesh geometry
  55904. * @param scene The Scene
  55905. * @param keepSubMeshes Specifies if the submeshes should be kept
  55906. * @returns A new Mesh
  55907. */
  55908. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55909. /**
  55910. * Build Mesh from CSG taking material and transforms into account
  55911. * @param name The name of the Mesh
  55912. * @param material The material of the Mesh
  55913. * @param scene The Scene
  55914. * @param keepSubMeshes Specifies if submeshes should be kept
  55915. * @returns The new Mesh
  55916. */
  55917. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55918. }
  55919. }
  55920. declare module BABYLON {
  55921. /**
  55922. * Class used to create a trail following a mesh
  55923. */
  55924. export class TrailMesh extends Mesh {
  55925. private _generator;
  55926. private _autoStart;
  55927. private _running;
  55928. private _diameter;
  55929. private _length;
  55930. private _sectionPolygonPointsCount;
  55931. private _sectionVectors;
  55932. private _sectionNormalVectors;
  55933. private _beforeRenderObserver;
  55934. /**
  55935. * @constructor
  55936. * @param name The value used by scene.getMeshByName() to do a lookup.
  55937. * @param generator The mesh to generate a trail.
  55938. * @param scene The scene to add this mesh to.
  55939. * @param diameter Diameter of trailing mesh. Default is 1.
  55940. * @param length Length of trailing mesh. Default is 60.
  55941. * @param autoStart Automatically start trailing mesh. Default true.
  55942. */
  55943. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55944. /**
  55945. * "TrailMesh"
  55946. * @returns "TrailMesh"
  55947. */
  55948. getClassName(): string;
  55949. private _createMesh;
  55950. /**
  55951. * Start trailing mesh.
  55952. */
  55953. start(): void;
  55954. /**
  55955. * Stop trailing mesh.
  55956. */
  55957. stop(): void;
  55958. /**
  55959. * Update trailing mesh geometry.
  55960. */
  55961. update(): void;
  55962. /**
  55963. * Returns a new TrailMesh object.
  55964. * @param name is a string, the name given to the new mesh
  55965. * @param newGenerator use new generator object for cloned trail mesh
  55966. * @returns a new mesh
  55967. */
  55968. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55969. /**
  55970. * Serializes this trail mesh
  55971. * @param serializationObject object to write serialization to
  55972. */
  55973. serialize(serializationObject: any): void;
  55974. /**
  55975. * Parses a serialized trail mesh
  55976. * @param parsedMesh the serialized mesh
  55977. * @param scene the scene to create the trail mesh in
  55978. * @returns the created trail mesh
  55979. */
  55980. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55981. }
  55982. }
  55983. declare module BABYLON {
  55984. /**
  55985. * Class containing static functions to help procedurally build meshes
  55986. */
  55987. export class TiledBoxBuilder {
  55988. /**
  55989. * Creates a box mesh
  55990. * 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)
  55991. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55993. * * 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
  55994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55995. * @param name defines the name of the mesh
  55996. * @param options defines the options used to create the mesh
  55997. * @param scene defines the hosting scene
  55998. * @returns the box mesh
  55999. */
  56000. static CreateTiledBox(name: string, options: {
  56001. pattern?: number;
  56002. width?: number;
  56003. height?: number;
  56004. depth?: number;
  56005. tileSize?: number;
  56006. tileWidth?: number;
  56007. tileHeight?: number;
  56008. alignHorizontal?: number;
  56009. alignVertical?: number;
  56010. faceUV?: Vector4[];
  56011. faceColors?: Color4[];
  56012. sideOrientation?: number;
  56013. updatable?: boolean;
  56014. }, scene?: Nullable<Scene>): Mesh;
  56015. }
  56016. }
  56017. declare module BABYLON {
  56018. /**
  56019. * Class containing static functions to help procedurally build meshes
  56020. */
  56021. export class TorusKnotBuilder {
  56022. /**
  56023. * Creates a torus knot mesh
  56024. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56025. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56026. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56027. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56029. * * 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
  56030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56031. * @param name defines the name of the mesh
  56032. * @param options defines the options used to create the mesh
  56033. * @param scene defines the hosting scene
  56034. * @returns the torus knot mesh
  56035. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56036. */
  56037. static CreateTorusKnot(name: string, options: {
  56038. radius?: number;
  56039. tube?: number;
  56040. radialSegments?: number;
  56041. tubularSegments?: number;
  56042. p?: number;
  56043. q?: number;
  56044. updatable?: boolean;
  56045. sideOrientation?: number;
  56046. frontUVs?: Vector4;
  56047. backUVs?: Vector4;
  56048. }, scene: any): Mesh;
  56049. }
  56050. }
  56051. declare module BABYLON {
  56052. /**
  56053. * Polygon
  56054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56055. */
  56056. export class Polygon {
  56057. /**
  56058. * Creates a rectangle
  56059. * @param xmin bottom X coord
  56060. * @param ymin bottom Y coord
  56061. * @param xmax top X coord
  56062. * @param ymax top Y coord
  56063. * @returns points that make the resulting rectation
  56064. */
  56065. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56066. /**
  56067. * Creates a circle
  56068. * @param radius radius of circle
  56069. * @param cx scale in x
  56070. * @param cy scale in y
  56071. * @param numberOfSides number of sides that make up the circle
  56072. * @returns points that make the resulting circle
  56073. */
  56074. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56075. /**
  56076. * Creates a polygon from input string
  56077. * @param input Input polygon data
  56078. * @returns the parsed points
  56079. */
  56080. static Parse(input: string): Vector2[];
  56081. /**
  56082. * Starts building a polygon from x and y coordinates
  56083. * @param x x coordinate
  56084. * @param y y coordinate
  56085. * @returns the started path2
  56086. */
  56087. static StartingAt(x: number, y: number): Path2;
  56088. }
  56089. /**
  56090. * Builds a polygon
  56091. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56092. */
  56093. export class PolygonMeshBuilder {
  56094. private _points;
  56095. private _outlinepoints;
  56096. private _holes;
  56097. private _name;
  56098. private _scene;
  56099. private _epoints;
  56100. private _eholes;
  56101. private _addToepoint;
  56102. /**
  56103. * Babylon reference to the earcut plugin.
  56104. */
  56105. bjsEarcut: any;
  56106. /**
  56107. * Creates a PolygonMeshBuilder
  56108. * @param name name of the builder
  56109. * @param contours Path of the polygon
  56110. * @param scene scene to add to when creating the mesh
  56111. * @param earcutInjection can be used to inject your own earcut reference
  56112. */
  56113. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56114. /**
  56115. * Adds a whole within the polygon
  56116. * @param hole Array of points defining the hole
  56117. * @returns this
  56118. */
  56119. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56120. /**
  56121. * Creates the polygon
  56122. * @param updatable If the mesh should be updatable
  56123. * @param depth The depth of the mesh created
  56124. * @returns the created mesh
  56125. */
  56126. build(updatable?: boolean, depth?: number): Mesh;
  56127. /**
  56128. * Creates the polygon
  56129. * @param depth The depth of the mesh created
  56130. * @returns the created VertexData
  56131. */
  56132. buildVertexData(depth?: number): VertexData;
  56133. /**
  56134. * Adds a side to the polygon
  56135. * @param positions points that make the polygon
  56136. * @param normals normals of the polygon
  56137. * @param uvs uvs of the polygon
  56138. * @param indices indices of the polygon
  56139. * @param bounds bounds of the polygon
  56140. * @param points points of the polygon
  56141. * @param depth depth of the polygon
  56142. * @param flip flip of the polygon
  56143. */
  56144. private addSide;
  56145. }
  56146. }
  56147. declare module BABYLON {
  56148. /**
  56149. * Class containing static functions to help procedurally build meshes
  56150. */
  56151. export class PolygonBuilder {
  56152. /**
  56153. * Creates a polygon mesh
  56154. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56155. * * 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
  56156. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56158. * * 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)
  56159. * * Remember you can only change the shape positions, not their number when updating a polygon
  56160. * @param name defines the name of the mesh
  56161. * @param options defines the options used to create the mesh
  56162. * @param scene defines the hosting scene
  56163. * @param earcutInjection can be used to inject your own earcut reference
  56164. * @returns the polygon mesh
  56165. */
  56166. static CreatePolygon(name: string, options: {
  56167. shape: Vector3[];
  56168. holes?: Vector3[][];
  56169. depth?: number;
  56170. faceUV?: Vector4[];
  56171. faceColors?: Color4[];
  56172. updatable?: boolean;
  56173. sideOrientation?: number;
  56174. frontUVs?: Vector4;
  56175. backUVs?: Vector4;
  56176. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56177. /**
  56178. * Creates an extruded polygon mesh, with depth in the Y direction.
  56179. * * 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)
  56180. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56181. * @param name defines the name of the mesh
  56182. * @param options defines the options used to create the mesh
  56183. * @param scene defines the hosting scene
  56184. * @param earcutInjection can be used to inject your own earcut reference
  56185. * @returns the polygon mesh
  56186. */
  56187. static ExtrudePolygon(name: string, options: {
  56188. shape: Vector3[];
  56189. holes?: Vector3[][];
  56190. depth?: number;
  56191. faceUV?: Vector4[];
  56192. faceColors?: Color4[];
  56193. updatable?: boolean;
  56194. sideOrientation?: number;
  56195. frontUVs?: Vector4;
  56196. backUVs?: Vector4;
  56197. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56198. }
  56199. }
  56200. declare module BABYLON {
  56201. /**
  56202. * Class containing static functions to help procedurally build meshes
  56203. */
  56204. export class LatheBuilder {
  56205. /**
  56206. * Creates lathe mesh.
  56207. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56208. * * 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
  56209. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56210. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56211. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56212. * * 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
  56213. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56214. * * 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
  56215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56216. * * 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
  56217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56219. * @param name defines the name of the mesh
  56220. * @param options defines the options used to create the mesh
  56221. * @param scene defines the hosting scene
  56222. * @returns the lathe mesh
  56223. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56224. */
  56225. static CreateLathe(name: string, options: {
  56226. shape: Vector3[];
  56227. radius?: number;
  56228. tessellation?: number;
  56229. clip?: number;
  56230. arc?: number;
  56231. closed?: boolean;
  56232. updatable?: boolean;
  56233. sideOrientation?: number;
  56234. frontUVs?: Vector4;
  56235. backUVs?: Vector4;
  56236. cap?: number;
  56237. invertUV?: boolean;
  56238. }, scene?: Nullable<Scene>): Mesh;
  56239. }
  56240. }
  56241. declare module BABYLON {
  56242. /**
  56243. * Class containing static functions to help procedurally build meshes
  56244. */
  56245. export class TiledPlaneBuilder {
  56246. /**
  56247. * Creates a tiled plane mesh
  56248. * * The parameter `pattern` will, depending on value, do nothing or
  56249. * * * flip (reflect about central vertical) alternate tiles across and up
  56250. * * * flip every tile on alternate rows
  56251. * * * rotate (180 degs) alternate tiles across and up
  56252. * * * rotate every tile on alternate rows
  56253. * * * flip and rotate alternate tiles across and up
  56254. * * * flip and rotate every tile on alternate rows
  56255. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56256. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56257. * * 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
  56258. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56259. * * 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)
  56260. * * 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)
  56261. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56262. * @param name defines the name of the mesh
  56263. * @param options defines the options used to create the mesh
  56264. * @param scene defines the hosting scene
  56265. * @returns the box mesh
  56266. */
  56267. static CreateTiledPlane(name: string, options: {
  56268. pattern?: number;
  56269. tileSize?: number;
  56270. tileWidth?: number;
  56271. tileHeight?: number;
  56272. size?: number;
  56273. width?: number;
  56274. height?: number;
  56275. alignHorizontal?: number;
  56276. alignVertical?: number;
  56277. sideOrientation?: number;
  56278. frontUVs?: Vector4;
  56279. backUVs?: Vector4;
  56280. updatable?: boolean;
  56281. }, scene?: Nullable<Scene>): Mesh;
  56282. }
  56283. }
  56284. declare module BABYLON {
  56285. /**
  56286. * Class containing static functions to help procedurally build meshes
  56287. */
  56288. export class TubeBuilder {
  56289. /**
  56290. * Creates a tube mesh.
  56291. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56292. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56293. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56294. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56295. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56296. * * 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)
  56297. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56298. * * 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
  56299. * * 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
  56300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56301. * * 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
  56302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56304. * @param name defines the name of the mesh
  56305. * @param options defines the options used to create the mesh
  56306. * @param scene defines the hosting scene
  56307. * @returns the tube mesh
  56308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56309. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56310. */
  56311. static CreateTube(name: string, options: {
  56312. path: Vector3[];
  56313. radius?: number;
  56314. tessellation?: number;
  56315. radiusFunction?: {
  56316. (i: number, distance: number): number;
  56317. };
  56318. cap?: number;
  56319. arc?: number;
  56320. updatable?: boolean;
  56321. sideOrientation?: number;
  56322. frontUVs?: Vector4;
  56323. backUVs?: Vector4;
  56324. instance?: Mesh;
  56325. invertUV?: boolean;
  56326. }, scene?: Nullable<Scene>): Mesh;
  56327. }
  56328. }
  56329. declare module BABYLON {
  56330. /**
  56331. * Class containing static functions to help procedurally build meshes
  56332. */
  56333. export class IcoSphereBuilder {
  56334. /**
  56335. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56336. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56337. * * 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`)
  56338. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56339. * * 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
  56340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56341. * * 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
  56342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56343. * @param name defines the name of the mesh
  56344. * @param options defines the options used to create the mesh
  56345. * @param scene defines the hosting scene
  56346. * @returns the icosahedron mesh
  56347. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56348. */
  56349. static CreateIcoSphere(name: string, options: {
  56350. radius?: number;
  56351. radiusX?: number;
  56352. radiusY?: number;
  56353. radiusZ?: number;
  56354. flat?: boolean;
  56355. subdivisions?: number;
  56356. sideOrientation?: number;
  56357. frontUVs?: Vector4;
  56358. backUVs?: Vector4;
  56359. updatable?: boolean;
  56360. }, scene?: Nullable<Scene>): Mesh;
  56361. }
  56362. }
  56363. declare module BABYLON {
  56364. /**
  56365. * Class containing static functions to help procedurally build meshes
  56366. */
  56367. export class DecalBuilder {
  56368. /**
  56369. * Creates a decal mesh.
  56370. * 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
  56371. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56372. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56373. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56374. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56375. * @param name defines the name of the mesh
  56376. * @param sourceMesh defines the mesh where the decal must be applied
  56377. * @param options defines the options used to create the mesh
  56378. * @param scene defines the hosting scene
  56379. * @returns the decal mesh
  56380. * @see https://doc.babylonjs.com/how_to/decals
  56381. */
  56382. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56383. position?: Vector3;
  56384. normal?: Vector3;
  56385. size?: Vector3;
  56386. angle?: number;
  56387. }): Mesh;
  56388. }
  56389. }
  56390. declare module BABYLON {
  56391. /**
  56392. * Class containing static functions to help procedurally build meshes
  56393. */
  56394. export class MeshBuilder {
  56395. /**
  56396. * Creates a box mesh
  56397. * * The parameter `size` sets the size (float) of each box side (default 1)
  56398. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56399. * * 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)
  56400. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56402. * * 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
  56403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56404. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56405. * @param name defines the name of the mesh
  56406. * @param options defines the options used to create the mesh
  56407. * @param scene defines the hosting scene
  56408. * @returns the box mesh
  56409. */
  56410. static CreateBox(name: string, options: {
  56411. size?: number;
  56412. width?: number;
  56413. height?: number;
  56414. depth?: number;
  56415. faceUV?: Vector4[];
  56416. faceColors?: Color4[];
  56417. sideOrientation?: number;
  56418. frontUVs?: Vector4;
  56419. backUVs?: Vector4;
  56420. updatable?: boolean;
  56421. }, scene?: Nullable<Scene>): Mesh;
  56422. /**
  56423. * Creates a tiled box mesh
  56424. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56426. * @param name defines the name of the mesh
  56427. * @param options defines the options used to create the mesh
  56428. * @param scene defines the hosting scene
  56429. * @returns the tiled box mesh
  56430. */
  56431. static CreateTiledBox(name: string, options: {
  56432. pattern?: number;
  56433. size?: number;
  56434. width?: number;
  56435. height?: number;
  56436. depth: number;
  56437. tileSize?: number;
  56438. tileWidth?: number;
  56439. tileHeight?: number;
  56440. faceUV?: Vector4[];
  56441. faceColors?: Color4[];
  56442. alignHorizontal?: number;
  56443. alignVertical?: number;
  56444. sideOrientation?: number;
  56445. updatable?: boolean;
  56446. }, scene?: Nullable<Scene>): Mesh;
  56447. /**
  56448. * Creates a sphere mesh
  56449. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56450. * * 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`)
  56451. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56452. * * 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
  56453. * * 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)
  56454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56455. * * 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
  56456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56457. * @param name defines the name of the mesh
  56458. * @param options defines the options used to create the mesh
  56459. * @param scene defines the hosting scene
  56460. * @returns the sphere mesh
  56461. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56462. */
  56463. static CreateSphere(name: string, options: {
  56464. segments?: number;
  56465. diameter?: number;
  56466. diameterX?: number;
  56467. diameterY?: number;
  56468. diameterZ?: number;
  56469. arc?: number;
  56470. slice?: number;
  56471. sideOrientation?: number;
  56472. frontUVs?: Vector4;
  56473. backUVs?: Vector4;
  56474. updatable?: boolean;
  56475. }, scene?: Nullable<Scene>): Mesh;
  56476. /**
  56477. * Creates a plane polygonal mesh. By default, this is a disc
  56478. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56479. * * 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
  56480. * * 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
  56481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56482. * * 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
  56483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56484. * @param name defines the name of the mesh
  56485. * @param options defines the options used to create the mesh
  56486. * @param scene defines the hosting scene
  56487. * @returns the plane polygonal mesh
  56488. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56489. */
  56490. static CreateDisc(name: string, options: {
  56491. radius?: number;
  56492. tessellation?: number;
  56493. arc?: number;
  56494. updatable?: boolean;
  56495. sideOrientation?: number;
  56496. frontUVs?: Vector4;
  56497. backUVs?: Vector4;
  56498. }, scene?: Nullable<Scene>): Mesh;
  56499. /**
  56500. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56501. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56502. * * 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`)
  56503. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56504. * * 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
  56505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56506. * * 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
  56507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56508. * @param name defines the name of the mesh
  56509. * @param options defines the options used to create the mesh
  56510. * @param scene defines the hosting scene
  56511. * @returns the icosahedron mesh
  56512. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56513. */
  56514. static CreateIcoSphere(name: string, options: {
  56515. radius?: number;
  56516. radiusX?: number;
  56517. radiusY?: number;
  56518. radiusZ?: number;
  56519. flat?: boolean;
  56520. subdivisions?: number;
  56521. sideOrientation?: number;
  56522. frontUVs?: Vector4;
  56523. backUVs?: Vector4;
  56524. updatable?: boolean;
  56525. }, scene?: Nullable<Scene>): Mesh;
  56526. /**
  56527. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56528. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56529. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56530. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56531. * * 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
  56532. * * 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
  56533. * * 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
  56534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56535. * * 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
  56536. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56537. * * 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
  56538. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56539. * * 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
  56540. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56542. * @param name defines the name of the mesh
  56543. * @param options defines the options used to create the mesh
  56544. * @param scene defines the hosting scene
  56545. * @returns the ribbon mesh
  56546. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56548. */
  56549. static CreateRibbon(name: string, options: {
  56550. pathArray: Vector3[][];
  56551. closeArray?: boolean;
  56552. closePath?: boolean;
  56553. offset?: number;
  56554. updatable?: boolean;
  56555. sideOrientation?: number;
  56556. frontUVs?: Vector4;
  56557. backUVs?: Vector4;
  56558. instance?: Mesh;
  56559. invertUV?: boolean;
  56560. uvs?: Vector2[];
  56561. colors?: Color4[];
  56562. }, scene?: Nullable<Scene>): Mesh;
  56563. /**
  56564. * Creates a cylinder or a cone mesh
  56565. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56566. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56567. * * 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.
  56568. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56569. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56570. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56571. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56572. * * 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).
  56573. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56574. * * 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).
  56575. * * 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
  56576. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56577. * * 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
  56578. * * 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.
  56579. * * If `enclose` is false, a ring surface is one element.
  56580. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56581. * * 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
  56582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56583. * * 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
  56584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56585. * @param name defines the name of the mesh
  56586. * @param options defines the options used to create the mesh
  56587. * @param scene defines the hosting scene
  56588. * @returns the cylinder mesh
  56589. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56590. */
  56591. static CreateCylinder(name: string, options: {
  56592. height?: number;
  56593. diameterTop?: number;
  56594. diameterBottom?: number;
  56595. diameter?: number;
  56596. tessellation?: number;
  56597. subdivisions?: number;
  56598. arc?: number;
  56599. faceColors?: Color4[];
  56600. faceUV?: Vector4[];
  56601. updatable?: boolean;
  56602. hasRings?: boolean;
  56603. enclose?: boolean;
  56604. cap?: number;
  56605. sideOrientation?: number;
  56606. frontUVs?: Vector4;
  56607. backUVs?: Vector4;
  56608. }, scene?: Nullable<Scene>): Mesh;
  56609. /**
  56610. * Creates a torus mesh
  56611. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56612. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56613. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56615. * * 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
  56616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56617. * @param name defines the name of the mesh
  56618. * @param options defines the options used to create the mesh
  56619. * @param scene defines the hosting scene
  56620. * @returns the torus mesh
  56621. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56622. */
  56623. static CreateTorus(name: string, options: {
  56624. diameter?: number;
  56625. thickness?: number;
  56626. tessellation?: number;
  56627. updatable?: boolean;
  56628. sideOrientation?: number;
  56629. frontUVs?: Vector4;
  56630. backUVs?: Vector4;
  56631. }, scene?: Nullable<Scene>): Mesh;
  56632. /**
  56633. * Creates a torus knot mesh
  56634. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56635. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56636. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56637. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56639. * * 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
  56640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56641. * @param name defines the name of the mesh
  56642. * @param options defines the options used to create the mesh
  56643. * @param scene defines the hosting scene
  56644. * @returns the torus knot mesh
  56645. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56646. */
  56647. static CreateTorusKnot(name: string, options: {
  56648. radius?: number;
  56649. tube?: number;
  56650. radialSegments?: number;
  56651. tubularSegments?: number;
  56652. p?: number;
  56653. q?: number;
  56654. updatable?: boolean;
  56655. sideOrientation?: number;
  56656. frontUVs?: Vector4;
  56657. backUVs?: Vector4;
  56658. }, scene?: Nullable<Scene>): Mesh;
  56659. /**
  56660. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56661. * * 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
  56662. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56663. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56664. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56665. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56666. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56667. * * 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
  56668. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56671. * @param name defines the name of the new line system
  56672. * @param options defines the options used to create the line system
  56673. * @param scene defines the hosting scene
  56674. * @returns a new line system mesh
  56675. */
  56676. static CreateLineSystem(name: string, options: {
  56677. lines: Vector3[][];
  56678. updatable?: boolean;
  56679. instance?: Nullable<LinesMesh>;
  56680. colors?: Nullable<Color4[][]>;
  56681. useVertexAlpha?: boolean;
  56682. }, scene: Nullable<Scene>): LinesMesh;
  56683. /**
  56684. * Creates a line mesh
  56685. * 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
  56686. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56687. * * The parameter `points` is an array successive Vector3
  56688. * * 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
  56689. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56690. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56691. * * When updating an instance, remember that only point positions can change, not the number of points
  56692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56694. * @param name defines the name of the new line system
  56695. * @param options defines the options used to create the line system
  56696. * @param scene defines the hosting scene
  56697. * @returns a new line mesh
  56698. */
  56699. static CreateLines(name: string, options: {
  56700. points: Vector3[];
  56701. updatable?: boolean;
  56702. instance?: Nullable<LinesMesh>;
  56703. colors?: Color4[];
  56704. useVertexAlpha?: boolean;
  56705. }, scene?: Nullable<Scene>): LinesMesh;
  56706. /**
  56707. * Creates a dashed line mesh
  56708. * * 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
  56709. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56710. * * The parameter `points` is an array successive Vector3
  56711. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56712. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56713. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56714. * * 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
  56715. * * When updating an instance, remember that only point positions can change, not the number of points
  56716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56717. * @param name defines the name of the mesh
  56718. * @param options defines the options used to create the mesh
  56719. * @param scene defines the hosting scene
  56720. * @returns the dashed line mesh
  56721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56722. */
  56723. static CreateDashedLines(name: string, options: {
  56724. points: Vector3[];
  56725. dashSize?: number;
  56726. gapSize?: number;
  56727. dashNb?: number;
  56728. updatable?: boolean;
  56729. instance?: LinesMesh;
  56730. }, scene?: Nullable<Scene>): LinesMesh;
  56731. /**
  56732. * 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.
  56733. * * 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.
  56734. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56735. * * 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.
  56736. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56737. * * 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
  56738. * * 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
  56739. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56741. * * 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
  56742. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56744. * @param name defines the name of the mesh
  56745. * @param options defines the options used to create the mesh
  56746. * @param scene defines the hosting scene
  56747. * @returns the extruded shape mesh
  56748. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56749. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56750. */
  56751. static ExtrudeShape(name: string, options: {
  56752. shape: Vector3[];
  56753. path: Vector3[];
  56754. scale?: number;
  56755. rotation?: number;
  56756. cap?: number;
  56757. updatable?: boolean;
  56758. sideOrientation?: number;
  56759. frontUVs?: Vector4;
  56760. backUVs?: Vector4;
  56761. instance?: Mesh;
  56762. invertUV?: boolean;
  56763. }, scene?: Nullable<Scene>): Mesh;
  56764. /**
  56765. * Creates an custom extruded shape mesh.
  56766. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56767. * * 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.
  56768. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56769. * * 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
  56770. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56771. * * 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
  56772. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56773. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56774. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56775. * * 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
  56776. * * 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
  56777. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56779. * * 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
  56780. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56782. * @param name defines the name of the mesh
  56783. * @param options defines the options used to create the mesh
  56784. * @param scene defines the hosting scene
  56785. * @returns the custom extruded shape mesh
  56786. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56787. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56789. */
  56790. static ExtrudeShapeCustom(name: string, options: {
  56791. shape: Vector3[];
  56792. path: Vector3[];
  56793. scaleFunction?: any;
  56794. rotationFunction?: any;
  56795. ribbonCloseArray?: boolean;
  56796. ribbonClosePath?: boolean;
  56797. cap?: number;
  56798. updatable?: boolean;
  56799. sideOrientation?: number;
  56800. frontUVs?: Vector4;
  56801. backUVs?: Vector4;
  56802. instance?: Mesh;
  56803. invertUV?: boolean;
  56804. }, scene?: Nullable<Scene>): Mesh;
  56805. /**
  56806. * Creates lathe mesh.
  56807. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56808. * * 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
  56809. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56810. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56811. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56812. * * 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
  56813. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56814. * * 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
  56815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56816. * * 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
  56817. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56819. * @param name defines the name of the mesh
  56820. * @param options defines the options used to create the mesh
  56821. * @param scene defines the hosting scene
  56822. * @returns the lathe mesh
  56823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56824. */
  56825. static CreateLathe(name: string, options: {
  56826. shape: Vector3[];
  56827. radius?: number;
  56828. tessellation?: number;
  56829. clip?: number;
  56830. arc?: number;
  56831. closed?: boolean;
  56832. updatable?: boolean;
  56833. sideOrientation?: number;
  56834. frontUVs?: Vector4;
  56835. backUVs?: Vector4;
  56836. cap?: number;
  56837. invertUV?: boolean;
  56838. }, scene?: Nullable<Scene>): Mesh;
  56839. /**
  56840. * Creates a tiled plane mesh
  56841. * * You can set a limited pattern arrangement with the tiles
  56842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56843. * * 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
  56844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56845. * @param name defines the name of the mesh
  56846. * @param options defines the options used to create the mesh
  56847. * @param scene defines the hosting scene
  56848. * @returns the plane mesh
  56849. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56850. */
  56851. static CreateTiledPlane(name: string, options: {
  56852. pattern?: number;
  56853. tileSize?: number;
  56854. tileWidth?: number;
  56855. tileHeight?: number;
  56856. size?: number;
  56857. width?: number;
  56858. height?: number;
  56859. alignHorizontal?: number;
  56860. alignVertical?: number;
  56861. sideOrientation?: number;
  56862. frontUVs?: Vector4;
  56863. backUVs?: Vector4;
  56864. updatable?: boolean;
  56865. }, scene?: Nullable<Scene>): Mesh;
  56866. /**
  56867. * Creates a plane mesh
  56868. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56869. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56870. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56872. * * 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
  56873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56874. * @param name defines the name of the mesh
  56875. * @param options defines the options used to create the mesh
  56876. * @param scene defines the hosting scene
  56877. * @returns the plane mesh
  56878. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56879. */
  56880. static CreatePlane(name: string, options: {
  56881. size?: number;
  56882. width?: number;
  56883. height?: number;
  56884. sideOrientation?: number;
  56885. frontUVs?: Vector4;
  56886. backUVs?: Vector4;
  56887. updatable?: boolean;
  56888. sourcePlane?: Plane;
  56889. }, scene?: Nullable<Scene>): Mesh;
  56890. /**
  56891. * Creates a ground mesh
  56892. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56893. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56895. * @param name defines the name of the mesh
  56896. * @param options defines the options used to create the mesh
  56897. * @param scene defines the hosting scene
  56898. * @returns the ground mesh
  56899. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56900. */
  56901. static CreateGround(name: string, options: {
  56902. width?: number;
  56903. height?: number;
  56904. subdivisions?: number;
  56905. subdivisionsX?: number;
  56906. subdivisionsY?: number;
  56907. updatable?: boolean;
  56908. }, scene?: Nullable<Scene>): Mesh;
  56909. /**
  56910. * Creates a tiled ground mesh
  56911. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56912. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56913. * * 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
  56914. * * 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
  56915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56916. * @param name defines the name of the mesh
  56917. * @param options defines the options used to create the mesh
  56918. * @param scene defines the hosting scene
  56919. * @returns the tiled ground mesh
  56920. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56921. */
  56922. static CreateTiledGround(name: string, options: {
  56923. xmin: number;
  56924. zmin: number;
  56925. xmax: number;
  56926. zmax: number;
  56927. subdivisions?: {
  56928. w: number;
  56929. h: number;
  56930. };
  56931. precision?: {
  56932. w: number;
  56933. h: number;
  56934. };
  56935. updatable?: boolean;
  56936. }, scene?: Nullable<Scene>): Mesh;
  56937. /**
  56938. * Creates a ground mesh from a height map
  56939. * * The parameter `url` sets the URL of the height map image resource.
  56940. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56941. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56942. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56943. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56944. * * 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.
  56945. * * 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).
  56946. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56948. * @param name defines the name of the mesh
  56949. * @param url defines the url to the height map
  56950. * @param options defines the options used to create the mesh
  56951. * @param scene defines the hosting scene
  56952. * @returns the ground mesh
  56953. * @see https://doc.babylonjs.com/babylon101/height_map
  56954. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56955. */
  56956. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56957. width?: number;
  56958. height?: number;
  56959. subdivisions?: number;
  56960. minHeight?: number;
  56961. maxHeight?: number;
  56962. colorFilter?: Color3;
  56963. alphaFilter?: number;
  56964. updatable?: boolean;
  56965. onReady?: (mesh: GroundMesh) => void;
  56966. }, scene?: Nullable<Scene>): GroundMesh;
  56967. /**
  56968. * Creates a polygon mesh
  56969. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56970. * * 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
  56971. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56973. * * 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)
  56974. * * Remember you can only change the shape positions, not their number when updating a polygon
  56975. * @param name defines the name of the mesh
  56976. * @param options defines the options used to create the mesh
  56977. * @param scene defines the hosting scene
  56978. * @param earcutInjection can be used to inject your own earcut reference
  56979. * @returns the polygon mesh
  56980. */
  56981. static CreatePolygon(name: string, options: {
  56982. shape: Vector3[];
  56983. holes?: Vector3[][];
  56984. depth?: number;
  56985. faceUV?: Vector4[];
  56986. faceColors?: Color4[];
  56987. updatable?: boolean;
  56988. sideOrientation?: number;
  56989. frontUVs?: Vector4;
  56990. backUVs?: Vector4;
  56991. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56992. /**
  56993. * Creates an extruded polygon mesh, with depth in the Y direction.
  56994. * * 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)
  56995. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56996. * @param name defines the name of the mesh
  56997. * @param options defines the options used to create the mesh
  56998. * @param scene defines the hosting scene
  56999. * @param earcutInjection can be used to inject your own earcut reference
  57000. * @returns the polygon mesh
  57001. */
  57002. static ExtrudePolygon(name: string, options: {
  57003. shape: Vector3[];
  57004. holes?: Vector3[][];
  57005. depth?: number;
  57006. faceUV?: Vector4[];
  57007. faceColors?: Color4[];
  57008. updatable?: boolean;
  57009. sideOrientation?: number;
  57010. frontUVs?: Vector4;
  57011. backUVs?: Vector4;
  57012. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57013. /**
  57014. * Creates a tube mesh.
  57015. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57016. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57017. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57018. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57019. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57020. * * 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)
  57021. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57022. * * 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
  57023. * * 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
  57024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57025. * * 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
  57026. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57028. * @param name defines the name of the mesh
  57029. * @param options defines the options used to create the mesh
  57030. * @param scene defines the hosting scene
  57031. * @returns the tube mesh
  57032. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57033. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57034. */
  57035. static CreateTube(name: string, options: {
  57036. path: Vector3[];
  57037. radius?: number;
  57038. tessellation?: number;
  57039. radiusFunction?: {
  57040. (i: number, distance: number): number;
  57041. };
  57042. cap?: number;
  57043. arc?: number;
  57044. updatable?: boolean;
  57045. sideOrientation?: number;
  57046. frontUVs?: Vector4;
  57047. backUVs?: Vector4;
  57048. instance?: Mesh;
  57049. invertUV?: boolean;
  57050. }, scene?: Nullable<Scene>): Mesh;
  57051. /**
  57052. * Creates a polyhedron mesh
  57053. * * 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
  57054. * * The parameter `size` (positive float, default 1) sets the polygon size
  57055. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57056. * * 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`
  57057. * * 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
  57058. * * 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)`)
  57059. * * 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
  57060. * * 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
  57061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57062. * * 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
  57063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57064. * @param name defines the name of the mesh
  57065. * @param options defines the options used to create the mesh
  57066. * @param scene defines the hosting scene
  57067. * @returns the polyhedron mesh
  57068. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57069. */
  57070. static CreatePolyhedron(name: string, options: {
  57071. type?: number;
  57072. size?: number;
  57073. sizeX?: number;
  57074. sizeY?: number;
  57075. sizeZ?: number;
  57076. custom?: any;
  57077. faceUV?: Vector4[];
  57078. faceColors?: Color4[];
  57079. flat?: boolean;
  57080. updatable?: boolean;
  57081. sideOrientation?: number;
  57082. frontUVs?: Vector4;
  57083. backUVs?: Vector4;
  57084. }, scene?: Nullable<Scene>): Mesh;
  57085. /**
  57086. * Creates a decal mesh.
  57087. * 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
  57088. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57089. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57090. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57091. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57092. * @param name defines the name of the mesh
  57093. * @param sourceMesh defines the mesh where the decal must be applied
  57094. * @param options defines the options used to create the mesh
  57095. * @param scene defines the hosting scene
  57096. * @returns the decal mesh
  57097. * @see https://doc.babylonjs.com/how_to/decals
  57098. */
  57099. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57100. position?: Vector3;
  57101. normal?: Vector3;
  57102. size?: Vector3;
  57103. angle?: number;
  57104. }): Mesh;
  57105. }
  57106. }
  57107. declare module BABYLON {
  57108. /**
  57109. * A simplifier interface for future simplification implementations
  57110. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57111. */
  57112. export interface ISimplifier {
  57113. /**
  57114. * Simplification of a given mesh according to the given settings.
  57115. * Since this requires computation, it is assumed that the function runs async.
  57116. * @param settings The settings of the simplification, including quality and distance
  57117. * @param successCallback A callback that will be called after the mesh was simplified.
  57118. * @param errorCallback in case of an error, this callback will be called. optional.
  57119. */
  57120. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57121. }
  57122. /**
  57123. * Expected simplification settings.
  57124. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57125. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57126. */
  57127. export interface ISimplificationSettings {
  57128. /**
  57129. * Gets or sets the expected quality
  57130. */
  57131. quality: number;
  57132. /**
  57133. * Gets or sets the distance when this optimized version should be used
  57134. */
  57135. distance: number;
  57136. /**
  57137. * Gets an already optimized mesh
  57138. */
  57139. optimizeMesh?: boolean;
  57140. }
  57141. /**
  57142. * Class used to specify simplification options
  57143. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57144. */
  57145. export class SimplificationSettings implements ISimplificationSettings {
  57146. /** expected quality */
  57147. quality: number;
  57148. /** distance when this optimized version should be used */
  57149. distance: number;
  57150. /** already optimized mesh */
  57151. optimizeMesh?: boolean | undefined;
  57152. /**
  57153. * Creates a SimplificationSettings
  57154. * @param quality expected quality
  57155. * @param distance distance when this optimized version should be used
  57156. * @param optimizeMesh already optimized mesh
  57157. */
  57158. constructor(
  57159. /** expected quality */
  57160. quality: number,
  57161. /** distance when this optimized version should be used */
  57162. distance: number,
  57163. /** already optimized mesh */
  57164. optimizeMesh?: boolean | undefined);
  57165. }
  57166. /**
  57167. * Interface used to define a simplification task
  57168. */
  57169. export interface ISimplificationTask {
  57170. /**
  57171. * Array of settings
  57172. */
  57173. settings: Array<ISimplificationSettings>;
  57174. /**
  57175. * Simplification type
  57176. */
  57177. simplificationType: SimplificationType;
  57178. /**
  57179. * Mesh to simplify
  57180. */
  57181. mesh: Mesh;
  57182. /**
  57183. * Callback called on success
  57184. */
  57185. successCallback?: () => void;
  57186. /**
  57187. * Defines if parallel processing can be used
  57188. */
  57189. parallelProcessing: boolean;
  57190. }
  57191. /**
  57192. * Queue used to order the simplification tasks
  57193. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57194. */
  57195. export class SimplificationQueue {
  57196. private _simplificationArray;
  57197. /**
  57198. * Gets a boolean indicating that the process is still running
  57199. */
  57200. running: boolean;
  57201. /**
  57202. * Creates a new queue
  57203. */
  57204. constructor();
  57205. /**
  57206. * Adds a new simplification task
  57207. * @param task defines a task to add
  57208. */
  57209. addTask(task: ISimplificationTask): void;
  57210. /**
  57211. * Execute next task
  57212. */
  57213. executeNext(): void;
  57214. /**
  57215. * Execute a simplification task
  57216. * @param task defines the task to run
  57217. */
  57218. runSimplification(task: ISimplificationTask): void;
  57219. private getSimplifier;
  57220. }
  57221. /**
  57222. * The implemented types of simplification
  57223. * At the moment only Quadratic Error Decimation is implemented
  57224. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57225. */
  57226. export enum SimplificationType {
  57227. /** Quadratic error decimation */
  57228. QUADRATIC = 0
  57229. }
  57230. }
  57231. declare module BABYLON {
  57232. interface Scene {
  57233. /** @hidden (Backing field) */
  57234. _simplificationQueue: SimplificationQueue;
  57235. /**
  57236. * Gets or sets the simplification queue attached to the scene
  57237. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57238. */
  57239. simplificationQueue: SimplificationQueue;
  57240. }
  57241. interface Mesh {
  57242. /**
  57243. * Simplify the mesh according to the given array of settings.
  57244. * Function will return immediately and will simplify async
  57245. * @param settings a collection of simplification settings
  57246. * @param parallelProcessing should all levels calculate parallel or one after the other
  57247. * @param simplificationType the type of simplification to run
  57248. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57249. * @returns the current mesh
  57250. */
  57251. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57252. }
  57253. /**
  57254. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57255. * created in a scene
  57256. */
  57257. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57258. /**
  57259. * The component name helpfull to identify the component in the list of scene components.
  57260. */
  57261. readonly name: string;
  57262. /**
  57263. * The scene the component belongs to.
  57264. */
  57265. scene: Scene;
  57266. /**
  57267. * Creates a new instance of the component for the given scene
  57268. * @param scene Defines the scene to register the component in
  57269. */
  57270. constructor(scene: Scene);
  57271. /**
  57272. * Registers the component in a given scene
  57273. */
  57274. register(): void;
  57275. /**
  57276. * Rebuilds the elements related to this component in case of
  57277. * context lost for instance.
  57278. */
  57279. rebuild(): void;
  57280. /**
  57281. * Disposes the component and the associated ressources
  57282. */
  57283. dispose(): void;
  57284. private _beforeCameraUpdate;
  57285. }
  57286. }
  57287. declare module BABYLON {
  57288. /**
  57289. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57290. */
  57291. export interface INavigationEnginePlugin {
  57292. /**
  57293. * plugin name
  57294. */
  57295. name: string;
  57296. /**
  57297. * Creates a navigation mesh
  57298. * @param meshes array of all the geometry used to compute the navigatio mesh
  57299. * @param parameters bunch of parameters used to filter geometry
  57300. */
  57301. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57302. /**
  57303. * Create a navigation mesh debug mesh
  57304. * @param scene is where the mesh will be added
  57305. * @returns debug display mesh
  57306. */
  57307. createDebugNavMesh(scene: Scene): Mesh;
  57308. /**
  57309. * Get a navigation mesh constrained position, closest to the parameter position
  57310. * @param position world position
  57311. * @returns the closest point to position constrained by the navigation mesh
  57312. */
  57313. getClosestPoint(position: Vector3): Vector3;
  57314. /**
  57315. * Get a navigation mesh constrained position, within a particular radius
  57316. * @param position world position
  57317. * @param maxRadius the maximum distance to the constrained world position
  57318. * @returns the closest point to position constrained by the navigation mesh
  57319. */
  57320. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57321. /**
  57322. * Compute the final position from a segment made of destination-position
  57323. * @param position world position
  57324. * @param destination world position
  57325. * @returns the resulting point along the navmesh
  57326. */
  57327. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57328. /**
  57329. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57330. * @param start world position
  57331. * @param end world position
  57332. * @returns array containing world position composing the path
  57333. */
  57334. computePath(start: Vector3, end: Vector3): Vector3[];
  57335. /**
  57336. * If this plugin is supported
  57337. * @returns true if plugin is supported
  57338. */
  57339. isSupported(): boolean;
  57340. /**
  57341. * Create a new Crowd so you can add agents
  57342. * @param maxAgents the maximum agent count in the crowd
  57343. * @param maxAgentRadius the maximum radius an agent can have
  57344. * @param scene to attach the crowd to
  57345. * @returns the crowd you can add agents to
  57346. */
  57347. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57348. /**
  57349. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57350. * The queries will try to find a solution within those bounds
  57351. * default is (1,1,1)
  57352. * @param extent x,y,z value that define the extent around the queries point of reference
  57353. */
  57354. setDefaultQueryExtent(extent: Vector3): void;
  57355. /**
  57356. * Get the Bounding box extent specified by setDefaultQueryExtent
  57357. * @returns the box extent values
  57358. */
  57359. getDefaultQueryExtent(): Vector3;
  57360. /**
  57361. * Release all resources
  57362. */
  57363. dispose(): void;
  57364. }
  57365. /**
  57366. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57367. */
  57368. export interface ICrowd {
  57369. /**
  57370. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57371. * You can attach anything to that node. The node position is updated in the scene update tick.
  57372. * @param pos world position that will be constrained by the navigation mesh
  57373. * @param parameters agent parameters
  57374. * @param transform hooked to the agent that will be update by the scene
  57375. * @returns agent index
  57376. */
  57377. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57378. /**
  57379. * Returns the agent position in world space
  57380. * @param index agent index returned by addAgent
  57381. * @returns world space position
  57382. */
  57383. getAgentPosition(index: number): Vector3;
  57384. /**
  57385. * Gets the agent velocity in world space
  57386. * @param index agent index returned by addAgent
  57387. * @returns world space velocity
  57388. */
  57389. getAgentVelocity(index: number): Vector3;
  57390. /**
  57391. * remove a particular agent previously created
  57392. * @param index agent index returned by addAgent
  57393. */
  57394. removeAgent(index: number): void;
  57395. /**
  57396. * get the list of all agents attached to this crowd
  57397. * @returns list of agent indices
  57398. */
  57399. getAgents(): number[];
  57400. /**
  57401. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57402. * @param deltaTime in seconds
  57403. */
  57404. update(deltaTime: number): void;
  57405. /**
  57406. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57407. * @param index agent index returned by addAgent
  57408. * @param destination targeted world position
  57409. */
  57410. agentGoto(index: number, destination: Vector3): void;
  57411. /**
  57412. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57413. * The queries will try to find a solution within those bounds
  57414. * default is (1,1,1)
  57415. * @param extent x,y,z value that define the extent around the queries point of reference
  57416. */
  57417. setDefaultQueryExtent(extent: Vector3): void;
  57418. /**
  57419. * Get the Bounding box extent specified by setDefaultQueryExtent
  57420. * @returns the box extent values
  57421. */
  57422. getDefaultQueryExtent(): Vector3;
  57423. /**
  57424. * Release all resources
  57425. */
  57426. dispose(): void;
  57427. }
  57428. /**
  57429. * Configures an agent
  57430. */
  57431. export interface IAgentParameters {
  57432. /**
  57433. * Agent radius. [Limit: >= 0]
  57434. */
  57435. radius: number;
  57436. /**
  57437. * Agent height. [Limit: > 0]
  57438. */
  57439. height: number;
  57440. /**
  57441. * Maximum allowed acceleration. [Limit: >= 0]
  57442. */
  57443. maxAcceleration: number;
  57444. /**
  57445. * Maximum allowed speed. [Limit: >= 0]
  57446. */
  57447. maxSpeed: number;
  57448. /**
  57449. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57450. */
  57451. collisionQueryRange: number;
  57452. /**
  57453. * The path visibility optimization range. [Limit: > 0]
  57454. */
  57455. pathOptimizationRange: number;
  57456. /**
  57457. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57458. */
  57459. separationWeight: number;
  57460. }
  57461. /**
  57462. * Configures the navigation mesh creation
  57463. */
  57464. export interface INavMeshParameters {
  57465. /**
  57466. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57467. */
  57468. cs: number;
  57469. /**
  57470. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57471. */
  57472. ch: number;
  57473. /**
  57474. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57475. */
  57476. walkableSlopeAngle: number;
  57477. /**
  57478. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57479. * be considered walkable. [Limit: >= 3] [Units: vx]
  57480. */
  57481. walkableHeight: number;
  57482. /**
  57483. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57484. */
  57485. walkableClimb: number;
  57486. /**
  57487. * The distance to erode/shrink the walkable area of the heightfield away from
  57488. * obstructions. [Limit: >=0] [Units: vx]
  57489. */
  57490. walkableRadius: number;
  57491. /**
  57492. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57493. */
  57494. maxEdgeLen: number;
  57495. /**
  57496. * The maximum distance a simplfied contour's border edges should deviate
  57497. * the original raw contour. [Limit: >=0] [Units: vx]
  57498. */
  57499. maxSimplificationError: number;
  57500. /**
  57501. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57502. */
  57503. minRegionArea: number;
  57504. /**
  57505. * Any regions with a span count smaller than this value will, if possible,
  57506. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57507. */
  57508. mergeRegionArea: number;
  57509. /**
  57510. * The maximum number of vertices allowed for polygons generated during the
  57511. * contour to polygon conversion process. [Limit: >= 3]
  57512. */
  57513. maxVertsPerPoly: number;
  57514. /**
  57515. * Sets the sampling distance to use when generating the detail mesh.
  57516. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57517. */
  57518. detailSampleDist: number;
  57519. /**
  57520. * The maximum distance the detail mesh surface should deviate from heightfield
  57521. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57522. */
  57523. detailSampleMaxError: number;
  57524. }
  57525. }
  57526. declare module BABYLON {
  57527. /**
  57528. * RecastJS navigation plugin
  57529. */
  57530. export class RecastJSPlugin implements INavigationEnginePlugin {
  57531. /**
  57532. * Reference to the Recast library
  57533. */
  57534. bjsRECAST: any;
  57535. /**
  57536. * plugin name
  57537. */
  57538. name: string;
  57539. /**
  57540. * the first navmesh created. We might extend this to support multiple navmeshes
  57541. */
  57542. navMesh: any;
  57543. /**
  57544. * Initializes the recastJS plugin
  57545. * @param recastInjection can be used to inject your own recast reference
  57546. */
  57547. constructor(recastInjection?: any);
  57548. /**
  57549. * Creates a navigation mesh
  57550. * @param meshes array of all the geometry used to compute the navigatio mesh
  57551. * @param parameters bunch of parameters used to filter geometry
  57552. */
  57553. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57554. /**
  57555. * Create a navigation mesh debug mesh
  57556. * @param scene is where the mesh will be added
  57557. * @returns debug display mesh
  57558. */
  57559. createDebugNavMesh(scene: Scene): Mesh;
  57560. /**
  57561. * Get a navigation mesh constrained position, closest to the parameter position
  57562. * @param position world position
  57563. * @returns the closest point to position constrained by the navigation mesh
  57564. */
  57565. getClosestPoint(position: Vector3): Vector3;
  57566. /**
  57567. * Get a navigation mesh constrained position, within a particular radius
  57568. * @param position world position
  57569. * @param maxRadius the maximum distance to the constrained world position
  57570. * @returns the closest point to position constrained by the navigation mesh
  57571. */
  57572. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57573. /**
  57574. * Compute the final position from a segment made of destination-position
  57575. * @param position world position
  57576. * @param destination world position
  57577. * @returns the resulting point along the navmesh
  57578. */
  57579. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57580. /**
  57581. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57582. * @param start world position
  57583. * @param end world position
  57584. * @returns array containing world position composing the path
  57585. */
  57586. computePath(start: Vector3, end: Vector3): Vector3[];
  57587. /**
  57588. * Create a new Crowd so you can add agents
  57589. * @param maxAgents the maximum agent count in the crowd
  57590. * @param maxAgentRadius the maximum radius an agent can have
  57591. * @param scene to attach the crowd to
  57592. * @returns the crowd you can add agents to
  57593. */
  57594. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57595. /**
  57596. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57597. * The queries will try to find a solution within those bounds
  57598. * default is (1,1,1)
  57599. * @param extent x,y,z value that define the extent around the queries point of reference
  57600. */
  57601. setDefaultQueryExtent(extent: Vector3): void;
  57602. /**
  57603. * Get the Bounding box extent specified by setDefaultQueryExtent
  57604. * @returns the box extent values
  57605. */
  57606. getDefaultQueryExtent(): Vector3;
  57607. /**
  57608. * Disposes
  57609. */
  57610. dispose(): void;
  57611. /**
  57612. * If this plugin is supported
  57613. * @returns true if plugin is supported
  57614. */
  57615. isSupported(): boolean;
  57616. }
  57617. /**
  57618. * Recast detour crowd implementation
  57619. */
  57620. export class RecastJSCrowd implements ICrowd {
  57621. /**
  57622. * Recast/detour plugin
  57623. */
  57624. bjsRECASTPlugin: RecastJSPlugin;
  57625. /**
  57626. * Link to the detour crowd
  57627. */
  57628. recastCrowd: any;
  57629. /**
  57630. * One transform per agent
  57631. */
  57632. transforms: TransformNode[];
  57633. /**
  57634. * All agents created
  57635. */
  57636. agents: number[];
  57637. /**
  57638. * Link to the scene is kept to unregister the crowd from the scene
  57639. */
  57640. private _scene;
  57641. /**
  57642. * Observer for crowd updates
  57643. */
  57644. private _onBeforeAnimationsObserver;
  57645. /**
  57646. * Constructor
  57647. * @param plugin recastJS plugin
  57648. * @param maxAgents the maximum agent count in the crowd
  57649. * @param maxAgentRadius the maximum radius an agent can have
  57650. * @param scene to attach the crowd to
  57651. * @returns the crowd you can add agents to
  57652. */
  57653. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57654. /**
  57655. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57656. * You can attach anything to that node. The node position is updated in the scene update tick.
  57657. * @param pos world position that will be constrained by the navigation mesh
  57658. * @param parameters agent parameters
  57659. * @param transform hooked to the agent that will be update by the scene
  57660. * @returns agent index
  57661. */
  57662. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57663. /**
  57664. * Returns the agent position in world space
  57665. * @param index agent index returned by addAgent
  57666. * @returns world space position
  57667. */
  57668. getAgentPosition(index: number): Vector3;
  57669. /**
  57670. * Returns the agent velocity in world space
  57671. * @param index agent index returned by addAgent
  57672. * @returns world space velocity
  57673. */
  57674. getAgentVelocity(index: number): Vector3;
  57675. /**
  57676. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57677. * @param index agent index returned by addAgent
  57678. * @param destination targeted world position
  57679. */
  57680. agentGoto(index: number, destination: Vector3): void;
  57681. /**
  57682. * remove a particular agent previously created
  57683. * @param index agent index returned by addAgent
  57684. */
  57685. removeAgent(index: number): void;
  57686. /**
  57687. * get the list of all agents attached to this crowd
  57688. * @returns list of agent indices
  57689. */
  57690. getAgents(): number[];
  57691. /**
  57692. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57693. * @param deltaTime in seconds
  57694. */
  57695. update(deltaTime: number): void;
  57696. /**
  57697. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57698. * The queries will try to find a solution within those bounds
  57699. * default is (1,1,1)
  57700. * @param extent x,y,z value that define the extent around the queries point of reference
  57701. */
  57702. setDefaultQueryExtent(extent: Vector3): void;
  57703. /**
  57704. * Get the Bounding box extent specified by setDefaultQueryExtent
  57705. * @returns the box extent values
  57706. */
  57707. getDefaultQueryExtent(): Vector3;
  57708. /**
  57709. * Release all resources
  57710. */
  57711. dispose(): void;
  57712. }
  57713. }
  57714. declare module BABYLON {
  57715. /**
  57716. * Class used to enable access to IndexedDB
  57717. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57718. */
  57719. export class Database implements IOfflineProvider {
  57720. private _callbackManifestChecked;
  57721. private _currentSceneUrl;
  57722. private _db;
  57723. private _enableSceneOffline;
  57724. private _enableTexturesOffline;
  57725. private _manifestVersionFound;
  57726. private _mustUpdateRessources;
  57727. private _hasReachedQuota;
  57728. private _isSupported;
  57729. private _idbFactory;
  57730. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57731. private static IsUASupportingBlobStorage;
  57732. /**
  57733. * Gets a boolean indicating if Database storate is enabled (off by default)
  57734. */
  57735. static IDBStorageEnabled: boolean;
  57736. /**
  57737. * Gets a boolean indicating if scene must be saved in the database
  57738. */
  57739. readonly enableSceneOffline: boolean;
  57740. /**
  57741. * Gets a boolean indicating if textures must be saved in the database
  57742. */
  57743. readonly enableTexturesOffline: boolean;
  57744. /**
  57745. * Creates a new Database
  57746. * @param urlToScene defines the url to load the scene
  57747. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57748. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57749. */
  57750. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57751. private static _ParseURL;
  57752. private static _ReturnFullUrlLocation;
  57753. private _checkManifestFile;
  57754. /**
  57755. * Open the database and make it available
  57756. * @param successCallback defines the callback to call on success
  57757. * @param errorCallback defines the callback to call on error
  57758. */
  57759. open(successCallback: () => void, errorCallback: () => void): void;
  57760. /**
  57761. * Loads an image from the database
  57762. * @param url defines the url to load from
  57763. * @param image defines the target DOM image
  57764. */
  57765. loadImage(url: string, image: HTMLImageElement): void;
  57766. private _loadImageFromDBAsync;
  57767. private _saveImageIntoDBAsync;
  57768. private _checkVersionFromDB;
  57769. private _loadVersionFromDBAsync;
  57770. private _saveVersionIntoDBAsync;
  57771. /**
  57772. * Loads a file from database
  57773. * @param url defines the URL to load from
  57774. * @param sceneLoaded defines a callback to call on success
  57775. * @param progressCallBack defines a callback to call when progress changed
  57776. * @param errorCallback defines a callback to call on error
  57777. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57778. */
  57779. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57780. private _loadFileAsync;
  57781. private _saveFileAsync;
  57782. /**
  57783. * Validates if xhr data is correct
  57784. * @param xhr defines the request to validate
  57785. * @param dataType defines the expected data type
  57786. * @returns true if data is correct
  57787. */
  57788. private static _ValidateXHRData;
  57789. }
  57790. }
  57791. declare module BABYLON {
  57792. /** @hidden */
  57793. export var gpuUpdateParticlesPixelShader: {
  57794. name: string;
  57795. shader: string;
  57796. };
  57797. }
  57798. declare module BABYLON {
  57799. /** @hidden */
  57800. export var gpuUpdateParticlesVertexShader: {
  57801. name: string;
  57802. shader: string;
  57803. };
  57804. }
  57805. declare module BABYLON {
  57806. /** @hidden */
  57807. export var clipPlaneFragmentDeclaration2: {
  57808. name: string;
  57809. shader: string;
  57810. };
  57811. }
  57812. declare module BABYLON {
  57813. /** @hidden */
  57814. export var gpuRenderParticlesPixelShader: {
  57815. name: string;
  57816. shader: string;
  57817. };
  57818. }
  57819. declare module BABYLON {
  57820. /** @hidden */
  57821. export var clipPlaneVertexDeclaration2: {
  57822. name: string;
  57823. shader: string;
  57824. };
  57825. }
  57826. declare module BABYLON {
  57827. /** @hidden */
  57828. export var gpuRenderParticlesVertexShader: {
  57829. name: string;
  57830. shader: string;
  57831. };
  57832. }
  57833. declare module BABYLON {
  57834. /**
  57835. * This represents a GPU particle system in Babylon
  57836. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57837. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57838. */
  57839. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57840. /**
  57841. * The layer mask we are rendering the particles through.
  57842. */
  57843. layerMask: number;
  57844. private _capacity;
  57845. private _activeCount;
  57846. private _currentActiveCount;
  57847. private _accumulatedCount;
  57848. private _renderEffect;
  57849. private _updateEffect;
  57850. private _buffer0;
  57851. private _buffer1;
  57852. private _spriteBuffer;
  57853. private _updateVAO;
  57854. private _renderVAO;
  57855. private _targetIndex;
  57856. private _sourceBuffer;
  57857. private _targetBuffer;
  57858. private _engine;
  57859. private _currentRenderId;
  57860. private _started;
  57861. private _stopped;
  57862. private _timeDelta;
  57863. private _randomTexture;
  57864. private _randomTexture2;
  57865. private _attributesStrideSize;
  57866. private _updateEffectOptions;
  57867. private _randomTextureSize;
  57868. private _actualFrame;
  57869. private readonly _rawTextureWidth;
  57870. /**
  57871. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57872. */
  57873. static readonly IsSupported: boolean;
  57874. /**
  57875. * An event triggered when the system is disposed.
  57876. */
  57877. onDisposeObservable: Observable<GPUParticleSystem>;
  57878. /**
  57879. * Gets the maximum number of particles active at the same time.
  57880. * @returns The max number of active particles.
  57881. */
  57882. getCapacity(): number;
  57883. /**
  57884. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57885. * to override the particles.
  57886. */
  57887. forceDepthWrite: boolean;
  57888. /**
  57889. * Gets or set the number of active particles
  57890. */
  57891. activeParticleCount: number;
  57892. private _preWarmDone;
  57893. /**
  57894. * Is this system ready to be used/rendered
  57895. * @return true if the system is ready
  57896. */
  57897. isReady(): boolean;
  57898. /**
  57899. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57900. * @returns True if it has been started, otherwise false.
  57901. */
  57902. isStarted(): boolean;
  57903. /**
  57904. * Starts the particle system and begins to emit
  57905. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57906. */
  57907. start(delay?: number): void;
  57908. /**
  57909. * Stops the particle system.
  57910. */
  57911. stop(): void;
  57912. /**
  57913. * Remove all active particles
  57914. */
  57915. reset(): void;
  57916. /**
  57917. * Returns the string "GPUParticleSystem"
  57918. * @returns a string containing the class name
  57919. */
  57920. getClassName(): string;
  57921. private _colorGradientsTexture;
  57922. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57923. /**
  57924. * Adds a new color gradient
  57925. * @param gradient defines the gradient to use (between 0 and 1)
  57926. * @param color1 defines the color to affect to the specified gradient
  57927. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57928. * @returns the current particle system
  57929. */
  57930. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57931. /**
  57932. * Remove a specific color gradient
  57933. * @param gradient defines the gradient to remove
  57934. * @returns the current particle system
  57935. */
  57936. removeColorGradient(gradient: number): GPUParticleSystem;
  57937. private _angularSpeedGradientsTexture;
  57938. private _sizeGradientsTexture;
  57939. private _velocityGradientsTexture;
  57940. private _limitVelocityGradientsTexture;
  57941. private _dragGradientsTexture;
  57942. private _addFactorGradient;
  57943. /**
  57944. * Adds a new size gradient
  57945. * @param gradient defines the gradient to use (between 0 and 1)
  57946. * @param factor defines the size factor to affect to the specified gradient
  57947. * @returns the current particle system
  57948. */
  57949. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57950. /**
  57951. * Remove a specific size gradient
  57952. * @param gradient defines the gradient to remove
  57953. * @returns the current particle system
  57954. */
  57955. removeSizeGradient(gradient: number): GPUParticleSystem;
  57956. /**
  57957. * Adds a new angular speed gradient
  57958. * @param gradient defines the gradient to use (between 0 and 1)
  57959. * @param factor defines the angular speed to affect to the specified gradient
  57960. * @returns the current particle system
  57961. */
  57962. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57963. /**
  57964. * Remove a specific angular speed gradient
  57965. * @param gradient defines the gradient to remove
  57966. * @returns the current particle system
  57967. */
  57968. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57969. /**
  57970. * Adds a new velocity gradient
  57971. * @param gradient defines the gradient to use (between 0 and 1)
  57972. * @param factor defines the velocity to affect to the specified gradient
  57973. * @returns the current particle system
  57974. */
  57975. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57976. /**
  57977. * Remove a specific velocity gradient
  57978. * @param gradient defines the gradient to remove
  57979. * @returns the current particle system
  57980. */
  57981. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57982. /**
  57983. * Adds a new limit velocity gradient
  57984. * @param gradient defines the gradient to use (between 0 and 1)
  57985. * @param factor defines the limit velocity value to affect to the specified gradient
  57986. * @returns the current particle system
  57987. */
  57988. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57989. /**
  57990. * Remove a specific limit velocity gradient
  57991. * @param gradient defines the gradient to remove
  57992. * @returns the current particle system
  57993. */
  57994. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57995. /**
  57996. * Adds a new drag gradient
  57997. * @param gradient defines the gradient to use (between 0 and 1)
  57998. * @param factor defines the drag value to affect to the specified gradient
  57999. * @returns the current particle system
  58000. */
  58001. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58002. /**
  58003. * Remove a specific drag gradient
  58004. * @param gradient defines the gradient to remove
  58005. * @returns the current particle system
  58006. */
  58007. removeDragGradient(gradient: number): GPUParticleSystem;
  58008. /**
  58009. * Not supported by GPUParticleSystem
  58010. * @param gradient defines the gradient to use (between 0 and 1)
  58011. * @param factor defines the emit rate value to affect to the specified gradient
  58012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58013. * @returns the current particle system
  58014. */
  58015. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58016. /**
  58017. * Not supported by GPUParticleSystem
  58018. * @param gradient defines the gradient to remove
  58019. * @returns the current particle system
  58020. */
  58021. removeEmitRateGradient(gradient: number): IParticleSystem;
  58022. /**
  58023. * Not supported by GPUParticleSystem
  58024. * @param gradient defines the gradient to use (between 0 and 1)
  58025. * @param factor defines the start size value to affect to the specified gradient
  58026. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58027. * @returns the current particle system
  58028. */
  58029. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58030. /**
  58031. * Not supported by GPUParticleSystem
  58032. * @param gradient defines the gradient to remove
  58033. * @returns the current particle system
  58034. */
  58035. removeStartSizeGradient(gradient: number): IParticleSystem;
  58036. /**
  58037. * Not supported by GPUParticleSystem
  58038. * @param gradient defines the gradient to use (between 0 and 1)
  58039. * @param min defines the color remap minimal range
  58040. * @param max defines the color remap maximal range
  58041. * @returns the current particle system
  58042. */
  58043. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58044. /**
  58045. * Not supported by GPUParticleSystem
  58046. * @param gradient defines the gradient to remove
  58047. * @returns the current particle system
  58048. */
  58049. removeColorRemapGradient(): IParticleSystem;
  58050. /**
  58051. * Not supported by GPUParticleSystem
  58052. * @param gradient defines the gradient to use (between 0 and 1)
  58053. * @param min defines the alpha remap minimal range
  58054. * @param max defines the alpha remap maximal range
  58055. * @returns the current particle system
  58056. */
  58057. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58058. /**
  58059. * Not supported by GPUParticleSystem
  58060. * @param gradient defines the gradient to remove
  58061. * @returns the current particle system
  58062. */
  58063. removeAlphaRemapGradient(): IParticleSystem;
  58064. /**
  58065. * Not supported by GPUParticleSystem
  58066. * @param gradient defines the gradient to use (between 0 and 1)
  58067. * @param color defines the color to affect to the specified gradient
  58068. * @returns the current particle system
  58069. */
  58070. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58071. /**
  58072. * Not supported by GPUParticleSystem
  58073. * @param gradient defines the gradient to remove
  58074. * @returns the current particle system
  58075. */
  58076. removeRampGradient(): IParticleSystem;
  58077. /**
  58078. * Not supported by GPUParticleSystem
  58079. * @returns the list of ramp gradients
  58080. */
  58081. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58082. /**
  58083. * Not supported by GPUParticleSystem
  58084. * Gets or sets a boolean indicating that ramp gradients must be used
  58085. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58086. */
  58087. useRampGradients: boolean;
  58088. /**
  58089. * Not supported by GPUParticleSystem
  58090. * @param gradient defines the gradient to use (between 0 and 1)
  58091. * @param factor defines the life time factor to affect to the specified gradient
  58092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58093. * @returns the current particle system
  58094. */
  58095. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58096. /**
  58097. * Not supported by GPUParticleSystem
  58098. * @param gradient defines the gradient to remove
  58099. * @returns the current particle system
  58100. */
  58101. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58102. /**
  58103. * Instantiates a GPU particle system.
  58104. * 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.
  58105. * @param name The name of the particle system
  58106. * @param options The options used to create the system
  58107. * @param scene The scene the particle system belongs to
  58108. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58109. */
  58110. constructor(name: string, options: Partial<{
  58111. capacity: number;
  58112. randomTextureSize: number;
  58113. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58114. protected _reset(): void;
  58115. private _createUpdateVAO;
  58116. private _createRenderVAO;
  58117. private _initialize;
  58118. /** @hidden */
  58119. _recreateUpdateEffect(): void;
  58120. /** @hidden */
  58121. _recreateRenderEffect(): void;
  58122. /**
  58123. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58124. * @param preWarm defines if we are in the pre-warmimg phase
  58125. */
  58126. animate(preWarm?: boolean): void;
  58127. private _createFactorGradientTexture;
  58128. private _createSizeGradientTexture;
  58129. private _createAngularSpeedGradientTexture;
  58130. private _createVelocityGradientTexture;
  58131. private _createLimitVelocityGradientTexture;
  58132. private _createDragGradientTexture;
  58133. private _createColorGradientTexture;
  58134. /**
  58135. * Renders the particle system in its current state
  58136. * @param preWarm defines if the system should only update the particles but not render them
  58137. * @returns the current number of particles
  58138. */
  58139. render(preWarm?: boolean): number;
  58140. /**
  58141. * Rebuilds the particle system
  58142. */
  58143. rebuild(): void;
  58144. private _releaseBuffers;
  58145. private _releaseVAOs;
  58146. /**
  58147. * Disposes the particle system and free the associated resources
  58148. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58149. */
  58150. dispose(disposeTexture?: boolean): void;
  58151. /**
  58152. * Clones the particle system.
  58153. * @param name The name of the cloned object
  58154. * @param newEmitter The new emitter to use
  58155. * @returns the cloned particle system
  58156. */
  58157. clone(name: string, newEmitter: any): GPUParticleSystem;
  58158. /**
  58159. * Serializes the particle system to a JSON object.
  58160. * @returns the JSON object
  58161. */
  58162. serialize(): any;
  58163. /**
  58164. * Parses a JSON object to create a GPU particle system.
  58165. * @param parsedParticleSystem The JSON object to parse
  58166. * @param scene The scene to create the particle system in
  58167. * @param rootUrl The root url to use to load external dependencies like texture
  58168. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58169. * @returns the parsed GPU particle system
  58170. */
  58171. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58172. }
  58173. }
  58174. declare module BABYLON {
  58175. /**
  58176. * Represents a set of particle systems working together to create a specific effect
  58177. */
  58178. export class ParticleSystemSet implements IDisposable {
  58179. private _emitterCreationOptions;
  58180. private _emitterNode;
  58181. /**
  58182. * Gets the particle system list
  58183. */
  58184. systems: IParticleSystem[];
  58185. /**
  58186. * Gets the emitter node used with this set
  58187. */
  58188. readonly emitterNode: Nullable<TransformNode>;
  58189. /**
  58190. * Creates a new emitter mesh as a sphere
  58191. * @param options defines the options used to create the sphere
  58192. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58193. * @param scene defines the hosting scene
  58194. */
  58195. setEmitterAsSphere(options: {
  58196. diameter: number;
  58197. segments: number;
  58198. color: Color3;
  58199. }, renderingGroupId: number, scene: Scene): void;
  58200. /**
  58201. * Starts all particle systems of the set
  58202. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58203. */
  58204. start(emitter?: AbstractMesh): void;
  58205. /**
  58206. * Release all associated resources
  58207. */
  58208. dispose(): void;
  58209. /**
  58210. * Serialize the set into a JSON compatible object
  58211. * @returns a JSON compatible representation of the set
  58212. */
  58213. serialize(): any;
  58214. /**
  58215. * Parse a new ParticleSystemSet from a serialized source
  58216. * @param data defines a JSON compatible representation of the set
  58217. * @param scene defines the hosting scene
  58218. * @param gpu defines if we want GPU particles or CPU particles
  58219. * @returns a new ParticleSystemSet
  58220. */
  58221. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58222. }
  58223. }
  58224. declare module BABYLON {
  58225. /**
  58226. * This class is made for on one-liner static method to help creating particle system set.
  58227. */
  58228. export class ParticleHelper {
  58229. /**
  58230. * Gets or sets base Assets URL
  58231. */
  58232. static BaseAssetsUrl: string;
  58233. /**
  58234. * Create a default particle system that you can tweak
  58235. * @param emitter defines the emitter to use
  58236. * @param capacity defines the system capacity (default is 500 particles)
  58237. * @param scene defines the hosting scene
  58238. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58239. * @returns the new Particle system
  58240. */
  58241. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58242. /**
  58243. * This is the main static method (one-liner) of this helper to create different particle systems
  58244. * @param type This string represents the type to the particle system to create
  58245. * @param scene The scene where the particle system should live
  58246. * @param gpu If the system will use gpu
  58247. * @returns the ParticleSystemSet created
  58248. */
  58249. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58250. /**
  58251. * Static function used to export a particle system to a ParticleSystemSet variable.
  58252. * Please note that the emitter shape is not exported
  58253. * @param systems defines the particle systems to export
  58254. * @returns the created particle system set
  58255. */
  58256. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58257. }
  58258. }
  58259. declare module BABYLON {
  58260. interface Engine {
  58261. /**
  58262. * Create an effect to use with particle systems.
  58263. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58264. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58265. * @param uniformsNames defines a list of attribute names
  58266. * @param samplers defines an array of string used to represent textures
  58267. * @param defines defines the string containing the defines to use to compile the shaders
  58268. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58269. * @param onCompiled defines a function to call when the effect creation is successful
  58270. * @param onError defines a function to call when the effect creation has failed
  58271. * @returns the new Effect
  58272. */
  58273. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58274. }
  58275. interface Mesh {
  58276. /**
  58277. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58278. * @returns an array of IParticleSystem
  58279. */
  58280. getEmittedParticleSystems(): IParticleSystem[];
  58281. /**
  58282. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58283. * @returns an array of IParticleSystem
  58284. */
  58285. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58286. }
  58287. /**
  58288. * @hidden
  58289. */
  58290. export var _IDoNeedToBeInTheBuild: number;
  58291. }
  58292. declare module BABYLON {
  58293. /** Defines the 4 color options */
  58294. export enum PointColor {
  58295. /** color value */
  58296. Color = 2,
  58297. /** uv value */
  58298. UV = 1,
  58299. /** random value */
  58300. Random = 0,
  58301. /** stated value */
  58302. Stated = 3
  58303. }
  58304. /**
  58305. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  58306. * 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.
  58307. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  58308. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  58309. *
  58310. * Full documentation here : TO BE ENTERED
  58311. */
  58312. export class PointsCloudSystem implements IDisposable {
  58313. /**
  58314. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  58315. * Example : var p = SPS.particles[i];
  58316. */
  58317. particles: CloudPoint[];
  58318. /**
  58319. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  58320. */
  58321. nbParticles: number;
  58322. /**
  58323. * This a counter for your own usage. It's not set by any SPS functions.
  58324. */
  58325. counter: number;
  58326. /**
  58327. * The PCS name. This name is also given to the underlying mesh.
  58328. */
  58329. name: string;
  58330. /**
  58331. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  58332. */
  58333. mesh: Mesh;
  58334. /**
  58335. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  58336. * Please read :
  58337. */
  58338. vars: any;
  58339. /**
  58340. * @hidden
  58341. */
  58342. _size: number;
  58343. private _scene;
  58344. private _promises;
  58345. private _positions;
  58346. private _indices;
  58347. private _normals;
  58348. private _colors;
  58349. private _uvs;
  58350. private _indices32;
  58351. private _positions32;
  58352. private _colors32;
  58353. private _uvs32;
  58354. private _updatable;
  58355. private _isVisibilityBoxLocked;
  58356. private _alwaysVisible;
  58357. private _groups;
  58358. private _groupCounter;
  58359. private _computeParticleColor;
  58360. private _computeParticleTexture;
  58361. private _computeParticleRotation;
  58362. private _computeBoundingBox;
  58363. private _isReady;
  58364. /**
  58365. * Creates a PCS (Points Cloud System) object
  58366. * @param name (String) is the PCS name, this will be the underlying mesh name
  58367. * @param pointSize (number) is the size for each point
  58368. * @param scene (Scene) is the scene in which the PCS is added
  58369. * @param options defines the options of the PCS e.g.
  58370. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  58371. */
  58372. constructor(name: string, pointSize: number, scene: Scene, options?: {
  58373. updatable?: boolean;
  58374. });
  58375. /**
  58376. * Builds the PCS underlying mesh. Returns a standard Mesh.
  58377. * If no points were added to the PCS, the returned mesh is just a single point.
  58378. * @returns a promise for the created mesh
  58379. */
  58380. buildMeshAsync(): Promise<Mesh>;
  58381. /**
  58382. * @hidden
  58383. */
  58384. private _buildMesh;
  58385. private _addParticle;
  58386. private _randomUnitVector;
  58387. private _getColorIndicesForCoord;
  58388. private _setPointsColorOrUV;
  58389. private _colorFromTexture;
  58390. private _calculateDensity;
  58391. /**
  58392. * Adds points to the PCS in random positions within a unit sphere
  58393. * @param nb (positive integer) the number of particles to be created from this model
  58394. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  58395. * @returns the number of groups in the system
  58396. */
  58397. addPoints(nb: number, pointFunction?: any): number;
  58398. /**
  58399. * Adds points to the PCS from the surface of the model shape
  58400. * @param mesh is any Mesh object that will be used as a surface model for the points
  58401. * @param nb (positive integer) the number of particles to be created from this model
  58402. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  58403. * @param color (color3) to be used when colorWith is stated
  58404. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58405. * @returns the number of groups in the system
  58406. */
  58407. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58408. /**
  58409. * Adds points to the PCS inside the model shape
  58410. * @param mesh is any Mesh object that will be used as a surface model for the points
  58411. * @param nb (positive integer) the number of particles to be created from this model
  58412. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  58413. * @param color (color4) to be used when colorWith is stated
  58414. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58415. * @returns the number of groups in the system
  58416. */
  58417. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58418. /**
  58419. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  58420. * This method calls `updateParticle()` for each particle of the SPS.
  58421. * For an animated SPS, it is usually called within the render loop.
  58422. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  58423. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  58424. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  58425. * @returns the PCS.
  58426. */
  58427. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  58428. /**
  58429. * Disposes the PCS.
  58430. */
  58431. dispose(): void;
  58432. /**
  58433. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  58434. * doc :
  58435. * @returns the PCS.
  58436. */
  58437. refreshVisibleSize(): PointsCloudSystem;
  58438. /**
  58439. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  58440. * @param size the size (float) of the visibility box
  58441. * note : this doesn't lock the PCS mesh bounding box.
  58442. * doc :
  58443. */
  58444. setVisibilityBox(size: number): void;
  58445. /**
  58446. * Gets whether the PCS is always visible or not
  58447. * doc :
  58448. */
  58449. /**
  58450. * Sets the PCS as always visible or not
  58451. * doc :
  58452. */
  58453. isAlwaysVisible: boolean;
  58454. /**
  58455. * Tells to `setParticles()` to compute the particle rotations or not
  58456. * Default value : false. The PCS is faster when it's set to false
  58457. * Note : particle rotations are only applied to parent particles
  58458. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  58459. */
  58460. computeParticleRotation: boolean;
  58461. /**
  58462. * Tells to `setParticles()` to compute the particle colors or not.
  58463. * Default value : true. The PCS is faster when it's set to false.
  58464. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58465. */
  58466. /**
  58467. * Gets if `setParticles()` computes the particle colors or not.
  58468. * Default value : false. The PCS is faster when it's set to false.
  58469. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58470. */
  58471. computeParticleColor: boolean;
  58472. /**
  58473. * Gets if `setParticles()` computes the particle textures or not.
  58474. * Default value : false. The PCS is faster when it's set to false.
  58475. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  58476. */
  58477. computeParticleTexture: boolean;
  58478. /**
  58479. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  58480. */
  58481. /**
  58482. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  58483. */
  58484. computeBoundingBox: boolean;
  58485. /**
  58486. * This function does nothing. It may be overwritten to set all the particle first values.
  58487. * The PCS doesn't call this function, you may have to call it by your own.
  58488. * doc :
  58489. */
  58490. initParticles(): void;
  58491. /**
  58492. * This function does nothing. It may be overwritten to recycle a particle
  58493. * The PCS doesn't call this function, you can to call it
  58494. * doc :
  58495. * @param particle The particle to recycle
  58496. * @returns the recycled particle
  58497. */
  58498. recycleParticle(particle: CloudPoint): CloudPoint;
  58499. /**
  58500. * Updates a particle : this function should be overwritten by the user.
  58501. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  58502. * doc :
  58503. * @example : just set a particle position or velocity and recycle conditions
  58504. * @param particle The particle to update
  58505. * @returns the updated particle
  58506. */
  58507. updateParticle(particle: CloudPoint): CloudPoint;
  58508. /**
  58509. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  58510. * This does nothing and may be overwritten by the user.
  58511. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58512. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58513. * @param update the boolean update value actually passed to setParticles()
  58514. */
  58515. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58516. /**
  58517. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  58518. * This will be passed three parameters.
  58519. * This does nothing and may be overwritten by the user.
  58520. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58521. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58522. * @param update the boolean update value actually passed to setParticles()
  58523. */
  58524. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58525. }
  58526. }
  58527. declare module BABYLON {
  58528. /**
  58529. * Represents one particle of a points cloud system.
  58530. */
  58531. export class CloudPoint {
  58532. /**
  58533. * particle global index
  58534. */
  58535. idx: number;
  58536. /**
  58537. * The color of the particle
  58538. */
  58539. color: Nullable<Color4>;
  58540. /**
  58541. * The world space position of the particle.
  58542. */
  58543. position: Vector3;
  58544. /**
  58545. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  58546. */
  58547. rotation: Vector3;
  58548. /**
  58549. * The world space rotation quaternion of the particle.
  58550. */
  58551. rotationQuaternion: Nullable<Quaternion>;
  58552. /**
  58553. * The uv of the particle.
  58554. */
  58555. uv: Nullable<Vector2>;
  58556. /**
  58557. * The current speed of the particle.
  58558. */
  58559. velocity: Vector3;
  58560. /**
  58561. * The pivot point in the particle local space.
  58562. */
  58563. pivot: Vector3;
  58564. /**
  58565. * Must the particle be translated from its pivot point in its local space ?
  58566. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  58567. * Default : false
  58568. */
  58569. translateFromPivot: boolean;
  58570. /**
  58571. * Index of this particle in the global "positions" array (Internal use)
  58572. * @hidden
  58573. */
  58574. _pos: number;
  58575. /**
  58576. * @hidden Index of this particle in the global "indices" array (Internal use)
  58577. */
  58578. _ind: number;
  58579. /**
  58580. * Group this particle belongs to
  58581. */
  58582. _group: PointsGroup;
  58583. /**
  58584. * Group id of this particle
  58585. */
  58586. groupId: number;
  58587. /**
  58588. * Index of the particle in its group id (Internal use)
  58589. */
  58590. idxInGroup: number;
  58591. /**
  58592. * @hidden Particle BoundingInfo object (Internal use)
  58593. */
  58594. _boundingInfo: BoundingInfo;
  58595. /**
  58596. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  58597. */
  58598. _pcs: PointsCloudSystem;
  58599. /**
  58600. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  58601. */
  58602. _stillInvisible: boolean;
  58603. /**
  58604. * @hidden Last computed particle rotation matrix
  58605. */
  58606. _rotationMatrix: number[];
  58607. /**
  58608. * Parent particle Id, if any.
  58609. * Default null.
  58610. */
  58611. parentId: Nullable<number>;
  58612. /**
  58613. * @hidden Internal global position in the PCS.
  58614. */
  58615. _globalPosition: Vector3;
  58616. /**
  58617. * Creates a Point Cloud object.
  58618. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  58619. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  58620. * @param group (PointsGroup) is the group the particle belongs to
  58621. * @param groupId (integer) is the group identifier in the PCS.
  58622. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  58623. * @param pcs defines the PCS it is associated to
  58624. */
  58625. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  58626. /**
  58627. * get point size
  58628. */
  58629. /**
  58630. * Set point size
  58631. */
  58632. size: Vector3;
  58633. /**
  58634. * Legacy support, changed quaternion to rotationQuaternion
  58635. */
  58636. /**
  58637. * Legacy support, changed quaternion to rotationQuaternion
  58638. */
  58639. quaternion: Nullable<Quaternion>;
  58640. /**
  58641. * Returns a boolean. True if the particle intersects a mesh, else false
  58642. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  58643. * @param target is the object (point or mesh) what the intersection is computed against
  58644. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  58645. * @returns true if it intersects
  58646. */
  58647. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  58648. /**
  58649. * get the rotation matrix of the particle
  58650. * @hidden
  58651. */
  58652. getRotationMatrix(m: Matrix): void;
  58653. }
  58654. /**
  58655. * Represents a group of points in a points cloud system
  58656. * * PCS internal tool, don't use it manually.
  58657. */
  58658. export class PointsGroup {
  58659. /**
  58660. * The group id
  58661. * @hidden
  58662. */
  58663. groupID: number;
  58664. /**
  58665. * image data for group (internal use)
  58666. * @hidden
  58667. */
  58668. _groupImageData: Nullable<ArrayBufferView>;
  58669. /**
  58670. * Image Width (internal use)
  58671. * @hidden
  58672. */
  58673. _groupImgWidth: number;
  58674. /**
  58675. * Image Height (internal use)
  58676. * @hidden
  58677. */
  58678. _groupImgHeight: number;
  58679. /**
  58680. * Custom position function (internal use)
  58681. * @hidden
  58682. */
  58683. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  58684. /**
  58685. * density per facet for surface points
  58686. * @hidden
  58687. */
  58688. _groupDensity: number[];
  58689. /**
  58690. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  58691. * PCS internal tool, don't use it manually.
  58692. * @hidden
  58693. */
  58694. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  58695. }
  58696. }
  58697. declare module BABYLON {
  58698. interface Scene {
  58699. /** @hidden (Backing field) */
  58700. _physicsEngine: Nullable<IPhysicsEngine>;
  58701. /**
  58702. * Gets the current physics engine
  58703. * @returns a IPhysicsEngine or null if none attached
  58704. */
  58705. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58706. /**
  58707. * Enables physics to the current scene
  58708. * @param gravity defines the scene's gravity for the physics engine
  58709. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58710. * @return a boolean indicating if the physics engine was initialized
  58711. */
  58712. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58713. /**
  58714. * Disables and disposes the physics engine associated with the scene
  58715. */
  58716. disablePhysicsEngine(): void;
  58717. /**
  58718. * Gets a boolean indicating if there is an active physics engine
  58719. * @returns a boolean indicating if there is an active physics engine
  58720. */
  58721. isPhysicsEnabled(): boolean;
  58722. /**
  58723. * Deletes a physics compound impostor
  58724. * @param compound defines the compound to delete
  58725. */
  58726. deleteCompoundImpostor(compound: any): void;
  58727. /**
  58728. * An event triggered when physic simulation is about to be run
  58729. */
  58730. onBeforePhysicsObservable: Observable<Scene>;
  58731. /**
  58732. * An event triggered when physic simulation has been done
  58733. */
  58734. onAfterPhysicsObservable: Observable<Scene>;
  58735. }
  58736. interface AbstractMesh {
  58737. /** @hidden */
  58738. _physicsImpostor: Nullable<PhysicsImpostor>;
  58739. /**
  58740. * Gets or sets impostor used for physic simulation
  58741. * @see http://doc.babylonjs.com/features/physics_engine
  58742. */
  58743. physicsImpostor: Nullable<PhysicsImpostor>;
  58744. /**
  58745. * Gets the current physics impostor
  58746. * @see http://doc.babylonjs.com/features/physics_engine
  58747. * @returns a physics impostor or null
  58748. */
  58749. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58750. /** Apply a physic impulse to the mesh
  58751. * @param force defines the force to apply
  58752. * @param contactPoint defines where to apply the force
  58753. * @returns the current mesh
  58754. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58755. */
  58756. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58757. /**
  58758. * Creates a physic joint between two meshes
  58759. * @param otherMesh defines the other mesh to use
  58760. * @param pivot1 defines the pivot to use on this mesh
  58761. * @param pivot2 defines the pivot to use on the other mesh
  58762. * @param options defines additional options (can be plugin dependent)
  58763. * @returns the current mesh
  58764. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58765. */
  58766. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58767. /** @hidden */
  58768. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58769. }
  58770. /**
  58771. * Defines the physics engine scene component responsible to manage a physics engine
  58772. */
  58773. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58774. /**
  58775. * The component name helpful to identify the component in the list of scene components.
  58776. */
  58777. readonly name: string;
  58778. /**
  58779. * The scene the component belongs to.
  58780. */
  58781. scene: Scene;
  58782. /**
  58783. * Creates a new instance of the component for the given scene
  58784. * @param scene Defines the scene to register the component in
  58785. */
  58786. constructor(scene: Scene);
  58787. /**
  58788. * Registers the component in a given scene
  58789. */
  58790. register(): void;
  58791. /**
  58792. * Rebuilds the elements related to this component in case of
  58793. * context lost for instance.
  58794. */
  58795. rebuild(): void;
  58796. /**
  58797. * Disposes the component and the associated ressources
  58798. */
  58799. dispose(): void;
  58800. }
  58801. }
  58802. declare module BABYLON {
  58803. /**
  58804. * A helper for physics simulations
  58805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58806. */
  58807. export class PhysicsHelper {
  58808. private _scene;
  58809. private _physicsEngine;
  58810. /**
  58811. * Initializes the Physics helper
  58812. * @param scene Babylon.js scene
  58813. */
  58814. constructor(scene: Scene);
  58815. /**
  58816. * Applies a radial explosion impulse
  58817. * @param origin the origin of the explosion
  58818. * @param radiusOrEventOptions the radius or the options of radial explosion
  58819. * @param strength the explosion strength
  58820. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58821. * @returns A physics radial explosion event, or null
  58822. */
  58823. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58824. /**
  58825. * Applies a radial explosion force
  58826. * @param origin the origin of the explosion
  58827. * @param radiusOrEventOptions the radius or the options of radial explosion
  58828. * @param strength the explosion strength
  58829. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58830. * @returns A physics radial explosion event, or null
  58831. */
  58832. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58833. /**
  58834. * Creates a gravitational field
  58835. * @param origin the origin of the explosion
  58836. * @param radiusOrEventOptions the radius or the options of radial explosion
  58837. * @param strength the explosion strength
  58838. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58839. * @returns A physics gravitational field event, or null
  58840. */
  58841. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58842. /**
  58843. * Creates a physics updraft event
  58844. * @param origin the origin of the updraft
  58845. * @param radiusOrEventOptions the radius or the options of the updraft
  58846. * @param strength the strength of the updraft
  58847. * @param height the height of the updraft
  58848. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58849. * @returns A physics updraft event, or null
  58850. */
  58851. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58852. /**
  58853. * Creates a physics vortex event
  58854. * @param origin the of the vortex
  58855. * @param radiusOrEventOptions the radius or the options of the vortex
  58856. * @param strength the strength of the vortex
  58857. * @param height the height of the vortex
  58858. * @returns a Physics vortex event, or null
  58859. * A physics vortex event or null
  58860. */
  58861. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58862. }
  58863. /**
  58864. * Represents a physics radial explosion event
  58865. */
  58866. class PhysicsRadialExplosionEvent {
  58867. private _scene;
  58868. private _options;
  58869. private _sphere;
  58870. private _dataFetched;
  58871. /**
  58872. * Initializes a radial explosioin event
  58873. * @param _scene BabylonJS scene
  58874. * @param _options The options for the vortex event
  58875. */
  58876. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58877. /**
  58878. * Returns the data related to the radial explosion event (sphere).
  58879. * @returns The radial explosion event data
  58880. */
  58881. getData(): PhysicsRadialExplosionEventData;
  58882. /**
  58883. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58884. * @param impostor A physics imposter
  58885. * @param origin the origin of the explosion
  58886. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58887. */
  58888. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58889. /**
  58890. * Triggers affecterd impostors callbacks
  58891. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58892. */
  58893. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58894. /**
  58895. * Disposes the sphere.
  58896. * @param force Specifies if the sphere should be disposed by force
  58897. */
  58898. dispose(force?: boolean): void;
  58899. /*** Helpers ***/
  58900. private _prepareSphere;
  58901. private _intersectsWithSphere;
  58902. }
  58903. /**
  58904. * Represents a gravitational field event
  58905. */
  58906. class PhysicsGravitationalFieldEvent {
  58907. private _physicsHelper;
  58908. private _scene;
  58909. private _origin;
  58910. private _options;
  58911. private _tickCallback;
  58912. private _sphere;
  58913. private _dataFetched;
  58914. /**
  58915. * Initializes the physics gravitational field event
  58916. * @param _physicsHelper A physics helper
  58917. * @param _scene BabylonJS scene
  58918. * @param _origin The origin position of the gravitational field event
  58919. * @param _options The options for the vortex event
  58920. */
  58921. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58922. /**
  58923. * Returns the data related to the gravitational field event (sphere).
  58924. * @returns A gravitational field event
  58925. */
  58926. getData(): PhysicsGravitationalFieldEventData;
  58927. /**
  58928. * Enables the gravitational field.
  58929. */
  58930. enable(): void;
  58931. /**
  58932. * Disables the gravitational field.
  58933. */
  58934. disable(): void;
  58935. /**
  58936. * Disposes the sphere.
  58937. * @param force The force to dispose from the gravitational field event
  58938. */
  58939. dispose(force?: boolean): void;
  58940. private _tick;
  58941. }
  58942. /**
  58943. * Represents a physics updraft event
  58944. */
  58945. class PhysicsUpdraftEvent {
  58946. private _scene;
  58947. private _origin;
  58948. private _options;
  58949. private _physicsEngine;
  58950. private _originTop;
  58951. private _originDirection;
  58952. private _tickCallback;
  58953. private _cylinder;
  58954. private _cylinderPosition;
  58955. private _dataFetched;
  58956. /**
  58957. * Initializes the physics updraft event
  58958. * @param _scene BabylonJS scene
  58959. * @param _origin The origin position of the updraft
  58960. * @param _options The options for the updraft event
  58961. */
  58962. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58963. /**
  58964. * Returns the data related to the updraft event (cylinder).
  58965. * @returns A physics updraft event
  58966. */
  58967. getData(): PhysicsUpdraftEventData;
  58968. /**
  58969. * Enables the updraft.
  58970. */
  58971. enable(): void;
  58972. /**
  58973. * Disables the updraft.
  58974. */
  58975. disable(): void;
  58976. /**
  58977. * Disposes the cylinder.
  58978. * @param force Specifies if the updraft should be disposed by force
  58979. */
  58980. dispose(force?: boolean): void;
  58981. private getImpostorHitData;
  58982. private _tick;
  58983. /*** Helpers ***/
  58984. private _prepareCylinder;
  58985. private _intersectsWithCylinder;
  58986. }
  58987. /**
  58988. * Represents a physics vortex event
  58989. */
  58990. class PhysicsVortexEvent {
  58991. private _scene;
  58992. private _origin;
  58993. private _options;
  58994. private _physicsEngine;
  58995. private _originTop;
  58996. private _tickCallback;
  58997. private _cylinder;
  58998. private _cylinderPosition;
  58999. private _dataFetched;
  59000. /**
  59001. * Initializes the physics vortex event
  59002. * @param _scene The BabylonJS scene
  59003. * @param _origin The origin position of the vortex
  59004. * @param _options The options for the vortex event
  59005. */
  59006. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59007. /**
  59008. * Returns the data related to the vortex event (cylinder).
  59009. * @returns The physics vortex event data
  59010. */
  59011. getData(): PhysicsVortexEventData;
  59012. /**
  59013. * Enables the vortex.
  59014. */
  59015. enable(): void;
  59016. /**
  59017. * Disables the cortex.
  59018. */
  59019. disable(): void;
  59020. /**
  59021. * Disposes the sphere.
  59022. * @param force
  59023. */
  59024. dispose(force?: boolean): void;
  59025. private getImpostorHitData;
  59026. private _tick;
  59027. /*** Helpers ***/
  59028. private _prepareCylinder;
  59029. private _intersectsWithCylinder;
  59030. }
  59031. /**
  59032. * Options fot the radial explosion event
  59033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59034. */
  59035. export class PhysicsRadialExplosionEventOptions {
  59036. /**
  59037. * The radius of the sphere for the radial explosion.
  59038. */
  59039. radius: number;
  59040. /**
  59041. * The strenth of the explosion.
  59042. */
  59043. strength: number;
  59044. /**
  59045. * The strenght of the force in correspondence to the distance of the affected object
  59046. */
  59047. falloff: PhysicsRadialImpulseFalloff;
  59048. /**
  59049. * Sphere options for the radial explosion.
  59050. */
  59051. sphere: {
  59052. segments: number;
  59053. diameter: number;
  59054. };
  59055. /**
  59056. * Sphere options for the radial explosion.
  59057. */
  59058. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59059. }
  59060. /**
  59061. * Options fot the updraft event
  59062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59063. */
  59064. export class PhysicsUpdraftEventOptions {
  59065. /**
  59066. * The radius of the cylinder for the vortex
  59067. */
  59068. radius: number;
  59069. /**
  59070. * The strenth of the updraft.
  59071. */
  59072. strength: number;
  59073. /**
  59074. * The height of the cylinder for the updraft.
  59075. */
  59076. height: number;
  59077. /**
  59078. * The mode for the the updraft.
  59079. */
  59080. updraftMode: PhysicsUpdraftMode;
  59081. }
  59082. /**
  59083. * Options fot the vortex event
  59084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59085. */
  59086. export class PhysicsVortexEventOptions {
  59087. /**
  59088. * The radius of the cylinder for the vortex
  59089. */
  59090. radius: number;
  59091. /**
  59092. * The strenth of the vortex.
  59093. */
  59094. strength: number;
  59095. /**
  59096. * The height of the cylinder for the vortex.
  59097. */
  59098. height: number;
  59099. /**
  59100. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59101. */
  59102. centripetalForceThreshold: number;
  59103. /**
  59104. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59105. */
  59106. centripetalForceMultiplier: number;
  59107. /**
  59108. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59109. */
  59110. centrifugalForceMultiplier: number;
  59111. /**
  59112. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59113. */
  59114. updraftForceMultiplier: number;
  59115. }
  59116. /**
  59117. * The strenght of the force in correspondence to the distance of the affected object
  59118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59119. */
  59120. export enum PhysicsRadialImpulseFalloff {
  59121. /** Defines that impulse is constant in strength across it's whole radius */
  59122. Constant = 0,
  59123. /** Defines that impulse gets weaker if it's further from the origin */
  59124. Linear = 1
  59125. }
  59126. /**
  59127. * The strength of the force in correspondence to the distance of the affected object
  59128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59129. */
  59130. export enum PhysicsUpdraftMode {
  59131. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59132. Center = 0,
  59133. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59134. Perpendicular = 1
  59135. }
  59136. /**
  59137. * Interface for a physics hit data
  59138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59139. */
  59140. export interface PhysicsHitData {
  59141. /**
  59142. * The force applied at the contact point
  59143. */
  59144. force: Vector3;
  59145. /**
  59146. * The contact point
  59147. */
  59148. contactPoint: Vector3;
  59149. /**
  59150. * The distance from the origin to the contact point
  59151. */
  59152. distanceFromOrigin: number;
  59153. }
  59154. /**
  59155. * Interface for radial explosion event data
  59156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59157. */
  59158. export interface PhysicsRadialExplosionEventData {
  59159. /**
  59160. * A sphere used for the radial explosion event
  59161. */
  59162. sphere: Mesh;
  59163. }
  59164. /**
  59165. * Interface for gravitational field event data
  59166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59167. */
  59168. export interface PhysicsGravitationalFieldEventData {
  59169. /**
  59170. * A sphere mesh used for the gravitational field event
  59171. */
  59172. sphere: Mesh;
  59173. }
  59174. /**
  59175. * Interface for updraft event data
  59176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59177. */
  59178. export interface PhysicsUpdraftEventData {
  59179. /**
  59180. * A cylinder used for the updraft event
  59181. */
  59182. cylinder: Mesh;
  59183. }
  59184. /**
  59185. * Interface for vortex event data
  59186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59187. */
  59188. export interface PhysicsVortexEventData {
  59189. /**
  59190. * A cylinder used for the vortex event
  59191. */
  59192. cylinder: Mesh;
  59193. }
  59194. /**
  59195. * Interface for an affected physics impostor
  59196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59197. */
  59198. export interface PhysicsAffectedImpostorWithData {
  59199. /**
  59200. * The impostor affected by the effect
  59201. */
  59202. impostor: PhysicsImpostor;
  59203. /**
  59204. * The data about the hit/horce from the explosion
  59205. */
  59206. hitData: PhysicsHitData;
  59207. }
  59208. }
  59209. declare module BABYLON {
  59210. /** @hidden */
  59211. export var blackAndWhitePixelShader: {
  59212. name: string;
  59213. shader: string;
  59214. };
  59215. }
  59216. declare module BABYLON {
  59217. /**
  59218. * Post process used to render in black and white
  59219. */
  59220. export class BlackAndWhitePostProcess extends PostProcess {
  59221. /**
  59222. * Linear about to convert he result to black and white (default: 1)
  59223. */
  59224. degree: number;
  59225. /**
  59226. * Creates a black and white post process
  59227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59228. * @param name The name of the effect.
  59229. * @param options The required width/height ratio to downsize to before computing the render pass.
  59230. * @param camera The camera to apply the render pass to.
  59231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59232. * @param engine The engine which the post process will be applied. (default: current engine)
  59233. * @param reusable If the post process can be reused on the same frame. (default: false)
  59234. */
  59235. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59236. }
  59237. }
  59238. declare module BABYLON {
  59239. /**
  59240. * This represents a set of one or more post processes in Babylon.
  59241. * A post process can be used to apply a shader to a texture after it is rendered.
  59242. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59243. */
  59244. export class PostProcessRenderEffect {
  59245. private _postProcesses;
  59246. private _getPostProcesses;
  59247. private _singleInstance;
  59248. private _cameras;
  59249. private _indicesForCamera;
  59250. /**
  59251. * Name of the effect
  59252. * @hidden
  59253. */
  59254. _name: string;
  59255. /**
  59256. * Instantiates a post process render effect.
  59257. * A post process can be used to apply a shader to a texture after it is rendered.
  59258. * @param engine The engine the effect is tied to
  59259. * @param name The name of the effect
  59260. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59261. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59262. */
  59263. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59264. /**
  59265. * Checks if all the post processes in the effect are supported.
  59266. */
  59267. readonly isSupported: boolean;
  59268. /**
  59269. * Updates the current state of the effect
  59270. * @hidden
  59271. */
  59272. _update(): void;
  59273. /**
  59274. * Attaches the effect on cameras
  59275. * @param cameras The camera to attach to.
  59276. * @hidden
  59277. */
  59278. _attachCameras(cameras: Camera): void;
  59279. /**
  59280. * Attaches the effect on cameras
  59281. * @param cameras The camera to attach to.
  59282. * @hidden
  59283. */
  59284. _attachCameras(cameras: Camera[]): void;
  59285. /**
  59286. * Detaches the effect on cameras
  59287. * @param cameras The camera to detatch from.
  59288. * @hidden
  59289. */
  59290. _detachCameras(cameras: Camera): void;
  59291. /**
  59292. * Detatches the effect on cameras
  59293. * @param cameras The camera to detatch from.
  59294. * @hidden
  59295. */
  59296. _detachCameras(cameras: Camera[]): void;
  59297. /**
  59298. * Enables the effect on given cameras
  59299. * @param cameras The camera to enable.
  59300. * @hidden
  59301. */
  59302. _enable(cameras: Camera): void;
  59303. /**
  59304. * Enables the effect on given cameras
  59305. * @param cameras The camera to enable.
  59306. * @hidden
  59307. */
  59308. _enable(cameras: Nullable<Camera[]>): void;
  59309. /**
  59310. * Disables the effect on the given cameras
  59311. * @param cameras The camera to disable.
  59312. * @hidden
  59313. */
  59314. _disable(cameras: Camera): void;
  59315. /**
  59316. * Disables the effect on the given cameras
  59317. * @param cameras The camera to disable.
  59318. * @hidden
  59319. */
  59320. _disable(cameras: Nullable<Camera[]>): void;
  59321. /**
  59322. * Gets a list of the post processes contained in the effect.
  59323. * @param camera The camera to get the post processes on.
  59324. * @returns The list of the post processes in the effect.
  59325. */
  59326. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59327. }
  59328. }
  59329. declare module BABYLON {
  59330. /** @hidden */
  59331. export var extractHighlightsPixelShader: {
  59332. name: string;
  59333. shader: string;
  59334. };
  59335. }
  59336. declare module BABYLON {
  59337. /**
  59338. * 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.
  59339. */
  59340. export class ExtractHighlightsPostProcess extends PostProcess {
  59341. /**
  59342. * The luminance threshold, pixels below this value will be set to black.
  59343. */
  59344. threshold: number;
  59345. /** @hidden */
  59346. _exposure: number;
  59347. /**
  59348. * Post process which has the input texture to be used when performing highlight extraction
  59349. * @hidden
  59350. */
  59351. _inputPostProcess: Nullable<PostProcess>;
  59352. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59353. }
  59354. }
  59355. declare module BABYLON {
  59356. /** @hidden */
  59357. export var bloomMergePixelShader: {
  59358. name: string;
  59359. shader: string;
  59360. };
  59361. }
  59362. declare module BABYLON {
  59363. /**
  59364. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59365. */
  59366. export class BloomMergePostProcess extends PostProcess {
  59367. /** Weight of the bloom to be added to the original input. */
  59368. weight: number;
  59369. /**
  59370. * Creates a new instance of @see BloomMergePostProcess
  59371. * @param name The name of the effect.
  59372. * @param originalFromInput Post process which's input will be used for the merge.
  59373. * @param blurred Blurred highlights post process which's output will be used.
  59374. * @param weight Weight of the bloom to be added to the original input.
  59375. * @param options The required width/height ratio to downsize to before computing the render pass.
  59376. * @param camera The camera to apply the render pass to.
  59377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59378. * @param engine The engine which the post process will be applied. (default: current engine)
  59379. * @param reusable If the post process can be reused on the same frame. (default: false)
  59380. * @param textureType Type of textures used when performing the post process. (default: 0)
  59381. * @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)
  59382. */
  59383. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59384. /** Weight of the bloom to be added to the original input. */
  59385. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59386. }
  59387. }
  59388. declare module BABYLON {
  59389. /**
  59390. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59391. */
  59392. export class BloomEffect extends PostProcessRenderEffect {
  59393. private bloomScale;
  59394. /**
  59395. * @hidden Internal
  59396. */
  59397. _effects: Array<PostProcess>;
  59398. /**
  59399. * @hidden Internal
  59400. */
  59401. _downscale: ExtractHighlightsPostProcess;
  59402. private _blurX;
  59403. private _blurY;
  59404. private _merge;
  59405. /**
  59406. * The luminance threshold to find bright areas of the image to bloom.
  59407. */
  59408. threshold: number;
  59409. /**
  59410. * The strength of the bloom.
  59411. */
  59412. weight: number;
  59413. /**
  59414. * Specifies the size of the bloom blur kernel, relative to the final output size
  59415. */
  59416. kernel: number;
  59417. /**
  59418. * Creates a new instance of @see BloomEffect
  59419. * @param scene The scene the effect belongs to.
  59420. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59421. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59422. * @param bloomWeight The the strength of bloom.
  59423. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59424. * @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)
  59425. */
  59426. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59427. /**
  59428. * Disposes each of the internal effects for a given camera.
  59429. * @param camera The camera to dispose the effect on.
  59430. */
  59431. disposeEffects(camera: Camera): void;
  59432. /**
  59433. * @hidden Internal
  59434. */
  59435. _updateEffects(): void;
  59436. /**
  59437. * Internal
  59438. * @returns if all the contained post processes are ready.
  59439. * @hidden
  59440. */
  59441. _isReady(): boolean;
  59442. }
  59443. }
  59444. declare module BABYLON {
  59445. /** @hidden */
  59446. export var chromaticAberrationPixelShader: {
  59447. name: string;
  59448. shader: string;
  59449. };
  59450. }
  59451. declare module BABYLON {
  59452. /**
  59453. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59454. */
  59455. export class ChromaticAberrationPostProcess extends PostProcess {
  59456. /**
  59457. * The amount of seperation of rgb channels (default: 30)
  59458. */
  59459. aberrationAmount: number;
  59460. /**
  59461. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59462. */
  59463. radialIntensity: number;
  59464. /**
  59465. * 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))
  59466. */
  59467. direction: Vector2;
  59468. /**
  59469. * 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))
  59470. */
  59471. centerPosition: Vector2;
  59472. /**
  59473. * Creates a new instance ChromaticAberrationPostProcess
  59474. * @param name The name of the effect.
  59475. * @param screenWidth The width of the screen to apply the effect on.
  59476. * @param screenHeight The height of the screen to apply the effect on.
  59477. * @param options The required width/height ratio to downsize to before computing the render pass.
  59478. * @param camera The camera to apply the render pass to.
  59479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59480. * @param engine The engine which the post process will be applied. (default: current engine)
  59481. * @param reusable If the post process can be reused on the same frame. (default: false)
  59482. * @param textureType Type of textures used when performing the post process. (default: 0)
  59483. * @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)
  59484. */
  59485. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59486. }
  59487. }
  59488. declare module BABYLON {
  59489. /** @hidden */
  59490. export var circleOfConfusionPixelShader: {
  59491. name: string;
  59492. shader: string;
  59493. };
  59494. }
  59495. declare module BABYLON {
  59496. /**
  59497. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59498. */
  59499. export class CircleOfConfusionPostProcess extends PostProcess {
  59500. /**
  59501. * 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.
  59502. */
  59503. lensSize: number;
  59504. /**
  59505. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59506. */
  59507. fStop: number;
  59508. /**
  59509. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59510. */
  59511. focusDistance: number;
  59512. /**
  59513. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59514. */
  59515. focalLength: number;
  59516. private _depthTexture;
  59517. /**
  59518. * Creates a new instance CircleOfConfusionPostProcess
  59519. * @param name The name of the effect.
  59520. * @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.
  59521. * @param options The required width/height ratio to downsize to before computing the render pass.
  59522. * @param camera The camera to apply the render pass to.
  59523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59524. * @param engine The engine which the post process will be applied. (default: current engine)
  59525. * @param reusable If the post process can be reused on the same frame. (default: false)
  59526. * @param textureType Type of textures used when performing the post process. (default: 0)
  59527. * @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)
  59528. */
  59529. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59530. /**
  59531. * 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.
  59532. */
  59533. depthTexture: RenderTargetTexture;
  59534. }
  59535. }
  59536. declare module BABYLON {
  59537. /** @hidden */
  59538. export var colorCorrectionPixelShader: {
  59539. name: string;
  59540. shader: string;
  59541. };
  59542. }
  59543. declare module BABYLON {
  59544. /**
  59545. *
  59546. * This post-process allows the modification of rendered colors by using
  59547. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59548. *
  59549. * The object needs to be provided an url to a texture containing the color
  59550. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59551. * Use an image editing software to tweak the LUT to match your needs.
  59552. *
  59553. * For an example of a color LUT, see here:
  59554. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59555. * For explanations on color grading, see here:
  59556. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59557. *
  59558. */
  59559. export class ColorCorrectionPostProcess extends PostProcess {
  59560. private _colorTableTexture;
  59561. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59562. }
  59563. }
  59564. declare module BABYLON {
  59565. /** @hidden */
  59566. export var convolutionPixelShader: {
  59567. name: string;
  59568. shader: string;
  59569. };
  59570. }
  59571. declare module BABYLON {
  59572. /**
  59573. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59574. * input texture to perform effects such as edge detection or sharpening
  59575. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59576. */
  59577. export class ConvolutionPostProcess extends PostProcess {
  59578. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59579. kernel: number[];
  59580. /**
  59581. * Creates a new instance ConvolutionPostProcess
  59582. * @param name The name of the effect.
  59583. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59584. * @param options The required width/height ratio to downsize to before computing the render pass.
  59585. * @param camera The camera to apply the render pass to.
  59586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59587. * @param engine The engine which the post process will be applied. (default: current engine)
  59588. * @param reusable If the post process can be reused on the same frame. (default: false)
  59589. * @param textureType Type of textures used when performing the post process. (default: 0)
  59590. */
  59591. constructor(name: string,
  59592. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59593. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59594. /**
  59595. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59596. */
  59597. static EdgeDetect0Kernel: number[];
  59598. /**
  59599. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59600. */
  59601. static EdgeDetect1Kernel: number[];
  59602. /**
  59603. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59604. */
  59605. static EdgeDetect2Kernel: number[];
  59606. /**
  59607. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59608. */
  59609. static SharpenKernel: number[];
  59610. /**
  59611. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59612. */
  59613. static EmbossKernel: number[];
  59614. /**
  59615. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59616. */
  59617. static GaussianKernel: number[];
  59618. }
  59619. }
  59620. declare module BABYLON {
  59621. /**
  59622. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59623. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59624. * based on samples that have a large difference in distance than the center pixel.
  59625. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59626. */
  59627. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59628. direction: Vector2;
  59629. /**
  59630. * Creates a new instance CircleOfConfusionPostProcess
  59631. * @param name The name of the effect.
  59632. * @param scene The scene the effect belongs to.
  59633. * @param direction The direction the blur should be applied.
  59634. * @param kernel The size of the kernel used to blur.
  59635. * @param options The required width/height ratio to downsize to before computing the render pass.
  59636. * @param camera The camera to apply the render pass to.
  59637. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59638. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59640. * @param engine The engine which the post process will be applied. (default: current engine)
  59641. * @param reusable If the post process can be reused on the same frame. (default: false)
  59642. * @param textureType Type of textures used when performing the post process. (default: 0)
  59643. * @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)
  59644. */
  59645. 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);
  59646. }
  59647. }
  59648. declare module BABYLON {
  59649. /** @hidden */
  59650. export var depthOfFieldMergePixelShader: {
  59651. name: string;
  59652. shader: string;
  59653. };
  59654. }
  59655. declare module BABYLON {
  59656. /**
  59657. * Options to be set when merging outputs from the default pipeline.
  59658. */
  59659. export class DepthOfFieldMergePostProcessOptions {
  59660. /**
  59661. * The original image to merge on top of
  59662. */
  59663. originalFromInput: PostProcess;
  59664. /**
  59665. * Parameters to perform the merge of the depth of field effect
  59666. */
  59667. depthOfField?: {
  59668. circleOfConfusion: PostProcess;
  59669. blurSteps: Array<PostProcess>;
  59670. };
  59671. /**
  59672. * Parameters to perform the merge of bloom effect
  59673. */
  59674. bloom?: {
  59675. blurred: PostProcess;
  59676. weight: number;
  59677. };
  59678. }
  59679. /**
  59680. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59681. */
  59682. export class DepthOfFieldMergePostProcess extends PostProcess {
  59683. private blurSteps;
  59684. /**
  59685. * Creates a new instance of DepthOfFieldMergePostProcess
  59686. * @param name The name of the effect.
  59687. * @param originalFromInput Post process which's input will be used for the merge.
  59688. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59689. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59690. * @param options The required width/height ratio to downsize to before computing the render pass.
  59691. * @param camera The camera to apply the render pass to.
  59692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59693. * @param engine The engine which the post process will be applied. (default: current engine)
  59694. * @param reusable If the post process can be reused on the same frame. (default: false)
  59695. * @param textureType Type of textures used when performing the post process. (default: 0)
  59696. * @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)
  59697. */
  59698. 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);
  59699. /**
  59700. * Updates the effect with the current post process compile time values and recompiles the shader.
  59701. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59702. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59703. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59704. * @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
  59705. * @param onCompiled Called when the shader has been compiled.
  59706. * @param onError Called if there is an error when compiling a shader.
  59707. */
  59708. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59709. }
  59710. }
  59711. declare module BABYLON {
  59712. /**
  59713. * Specifies the level of max blur that should be applied when using the depth of field effect
  59714. */
  59715. export enum DepthOfFieldEffectBlurLevel {
  59716. /**
  59717. * Subtle blur
  59718. */
  59719. Low = 0,
  59720. /**
  59721. * Medium blur
  59722. */
  59723. Medium = 1,
  59724. /**
  59725. * Large blur
  59726. */
  59727. High = 2
  59728. }
  59729. /**
  59730. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59731. */
  59732. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59733. private _circleOfConfusion;
  59734. /**
  59735. * @hidden Internal, blurs from high to low
  59736. */
  59737. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59738. private _depthOfFieldBlurY;
  59739. private _dofMerge;
  59740. /**
  59741. * @hidden Internal post processes in depth of field effect
  59742. */
  59743. _effects: Array<PostProcess>;
  59744. /**
  59745. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59746. */
  59747. focalLength: number;
  59748. /**
  59749. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59750. */
  59751. fStop: number;
  59752. /**
  59753. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59754. */
  59755. focusDistance: number;
  59756. /**
  59757. * 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.
  59758. */
  59759. lensSize: number;
  59760. /**
  59761. * Creates a new instance DepthOfFieldEffect
  59762. * @param scene The scene the effect belongs to.
  59763. * @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.
  59764. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59765. * @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)
  59766. */
  59767. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59768. /**
  59769. * Get the current class name of the current effet
  59770. * @returns "DepthOfFieldEffect"
  59771. */
  59772. getClassName(): string;
  59773. /**
  59774. * 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.
  59775. */
  59776. depthTexture: RenderTargetTexture;
  59777. /**
  59778. * Disposes each of the internal effects for a given camera.
  59779. * @param camera The camera to dispose the effect on.
  59780. */
  59781. disposeEffects(camera: Camera): void;
  59782. /**
  59783. * @hidden Internal
  59784. */
  59785. _updateEffects(): void;
  59786. /**
  59787. * Internal
  59788. * @returns if all the contained post processes are ready.
  59789. * @hidden
  59790. */
  59791. _isReady(): boolean;
  59792. }
  59793. }
  59794. declare module BABYLON {
  59795. /** @hidden */
  59796. export var displayPassPixelShader: {
  59797. name: string;
  59798. shader: string;
  59799. };
  59800. }
  59801. declare module BABYLON {
  59802. /**
  59803. * DisplayPassPostProcess which produces an output the same as it's input
  59804. */
  59805. export class DisplayPassPostProcess extends PostProcess {
  59806. /**
  59807. * Creates the DisplayPassPostProcess
  59808. * @param name The name of the effect.
  59809. * @param options The required width/height ratio to downsize to before computing the render pass.
  59810. * @param camera The camera to apply the render pass to.
  59811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59812. * @param engine The engine which the post process will be applied. (default: current engine)
  59813. * @param reusable If the post process can be reused on the same frame. (default: false)
  59814. */
  59815. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59816. }
  59817. }
  59818. declare module BABYLON {
  59819. /** @hidden */
  59820. export var filterPixelShader: {
  59821. name: string;
  59822. shader: string;
  59823. };
  59824. }
  59825. declare module BABYLON {
  59826. /**
  59827. * Applies a kernel filter to the image
  59828. */
  59829. export class FilterPostProcess extends PostProcess {
  59830. /** The matrix to be applied to the image */
  59831. kernelMatrix: Matrix;
  59832. /**
  59833. *
  59834. * @param name The name of the effect.
  59835. * @param kernelMatrix The matrix to be applied to the image
  59836. * @param options The required width/height ratio to downsize to before computing the render pass.
  59837. * @param camera The camera to apply the render pass to.
  59838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59839. * @param engine The engine which the post process will be applied. (default: current engine)
  59840. * @param reusable If the post process can be reused on the same frame. (default: false)
  59841. */
  59842. constructor(name: string,
  59843. /** The matrix to be applied to the image */
  59844. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59845. }
  59846. }
  59847. declare module BABYLON {
  59848. /** @hidden */
  59849. export var fxaaPixelShader: {
  59850. name: string;
  59851. shader: string;
  59852. };
  59853. }
  59854. declare module BABYLON {
  59855. /** @hidden */
  59856. export var fxaaVertexShader: {
  59857. name: string;
  59858. shader: string;
  59859. };
  59860. }
  59861. declare module BABYLON {
  59862. /**
  59863. * Fxaa post process
  59864. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59865. */
  59866. export class FxaaPostProcess extends PostProcess {
  59867. /** @hidden */
  59868. texelWidth: number;
  59869. /** @hidden */
  59870. texelHeight: number;
  59871. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59872. private _getDefines;
  59873. }
  59874. }
  59875. declare module BABYLON {
  59876. /** @hidden */
  59877. export var grainPixelShader: {
  59878. name: string;
  59879. shader: string;
  59880. };
  59881. }
  59882. declare module BABYLON {
  59883. /**
  59884. * The GrainPostProcess adds noise to the image at mid luminance levels
  59885. */
  59886. export class GrainPostProcess extends PostProcess {
  59887. /**
  59888. * The intensity of the grain added (default: 30)
  59889. */
  59890. intensity: number;
  59891. /**
  59892. * If the grain should be randomized on every frame
  59893. */
  59894. animated: boolean;
  59895. /**
  59896. * Creates a new instance of @see GrainPostProcess
  59897. * @param name The name of the effect.
  59898. * @param options The required width/height ratio to downsize to before computing the render pass.
  59899. * @param camera The camera to apply the render pass to.
  59900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59901. * @param engine The engine which the post process will be applied. (default: current engine)
  59902. * @param reusable If the post process can be reused on the same frame. (default: false)
  59903. * @param textureType Type of textures used when performing the post process. (default: 0)
  59904. * @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)
  59905. */
  59906. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59907. }
  59908. }
  59909. declare module BABYLON {
  59910. /** @hidden */
  59911. export var highlightsPixelShader: {
  59912. name: string;
  59913. shader: string;
  59914. };
  59915. }
  59916. declare module BABYLON {
  59917. /**
  59918. * Extracts highlights from the image
  59919. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59920. */
  59921. export class HighlightsPostProcess extends PostProcess {
  59922. /**
  59923. * Extracts highlights from the image
  59924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59925. * @param name The name of the effect.
  59926. * @param options The required width/height ratio to downsize to before computing the render pass.
  59927. * @param camera The camera to apply the render pass to.
  59928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59929. * @param engine The engine which the post process will be applied. (default: current engine)
  59930. * @param reusable If the post process can be reused on the same frame. (default: false)
  59931. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59932. */
  59933. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59934. }
  59935. }
  59936. declare module BABYLON {
  59937. /** @hidden */
  59938. export var mrtFragmentDeclaration: {
  59939. name: string;
  59940. shader: string;
  59941. };
  59942. }
  59943. declare module BABYLON {
  59944. /** @hidden */
  59945. export var geometryPixelShader: {
  59946. name: string;
  59947. shader: string;
  59948. };
  59949. }
  59950. declare module BABYLON {
  59951. /** @hidden */
  59952. export var geometryVertexShader: {
  59953. name: string;
  59954. shader: string;
  59955. };
  59956. }
  59957. declare module BABYLON {
  59958. /** @hidden */
  59959. interface ISavedTransformationMatrix {
  59960. world: Matrix;
  59961. viewProjection: Matrix;
  59962. }
  59963. /**
  59964. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59965. */
  59966. export class GeometryBufferRenderer {
  59967. /**
  59968. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59969. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59970. */
  59971. static readonly POSITION_TEXTURE_TYPE: number;
  59972. /**
  59973. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59974. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59975. */
  59976. static readonly VELOCITY_TEXTURE_TYPE: number;
  59977. /**
  59978. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59979. * in order to compute objects velocities when enableVelocity is set to "true"
  59980. * @hidden
  59981. */
  59982. _previousTransformationMatrices: {
  59983. [index: number]: ISavedTransformationMatrix;
  59984. };
  59985. /**
  59986. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59987. * in order to compute objects velocities when enableVelocity is set to "true"
  59988. * @hidden
  59989. */
  59990. _previousBonesTransformationMatrices: {
  59991. [index: number]: Float32Array;
  59992. };
  59993. /**
  59994. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59995. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59996. */
  59997. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59998. private _scene;
  59999. private _multiRenderTarget;
  60000. private _ratio;
  60001. private _enablePosition;
  60002. private _enableVelocity;
  60003. private _positionIndex;
  60004. private _velocityIndex;
  60005. protected _effect: Effect;
  60006. protected _cachedDefines: string;
  60007. /**
  60008. * Set the render list (meshes to be rendered) used in the G buffer.
  60009. */
  60010. renderList: Mesh[];
  60011. /**
  60012. * Gets wether or not G buffer are supported by the running hardware.
  60013. * This requires draw buffer supports
  60014. */
  60015. readonly isSupported: boolean;
  60016. /**
  60017. * Returns the index of the given texture type in the G-Buffer textures array
  60018. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60019. * @returns the index of the given texture type in the G-Buffer textures array
  60020. */
  60021. getTextureIndex(textureType: number): number;
  60022. /**
  60023. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60024. */
  60025. /**
  60026. * Sets whether or not objects positions are enabled for the G buffer.
  60027. */
  60028. enablePosition: boolean;
  60029. /**
  60030. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60031. */
  60032. /**
  60033. * Sets wether or not objects velocities are enabled for the G buffer.
  60034. */
  60035. enableVelocity: boolean;
  60036. /**
  60037. * Gets the scene associated with the buffer.
  60038. */
  60039. readonly scene: Scene;
  60040. /**
  60041. * Gets the ratio used by the buffer during its creation.
  60042. * How big is the buffer related to the main canvas.
  60043. */
  60044. readonly ratio: number;
  60045. /** @hidden */
  60046. static _SceneComponentInitialization: (scene: Scene) => void;
  60047. /**
  60048. * Creates a new G Buffer for the scene
  60049. * @param scene The scene the buffer belongs to
  60050. * @param ratio How big is the buffer related to the main canvas.
  60051. */
  60052. constructor(scene: Scene, ratio?: number);
  60053. /**
  60054. * Checks wether everything is ready to render a submesh to the G buffer.
  60055. * @param subMesh the submesh to check readiness for
  60056. * @param useInstances is the mesh drawn using instance or not
  60057. * @returns true if ready otherwise false
  60058. */
  60059. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60060. /**
  60061. * Gets the current underlying G Buffer.
  60062. * @returns the buffer
  60063. */
  60064. getGBuffer(): MultiRenderTarget;
  60065. /**
  60066. * Gets the number of samples used to render the buffer (anti aliasing).
  60067. */
  60068. /**
  60069. * Sets the number of samples used to render the buffer (anti aliasing).
  60070. */
  60071. samples: number;
  60072. /**
  60073. * Disposes the renderer and frees up associated resources.
  60074. */
  60075. dispose(): void;
  60076. protected _createRenderTargets(): void;
  60077. private _copyBonesTransformationMatrices;
  60078. }
  60079. }
  60080. declare module BABYLON {
  60081. interface Scene {
  60082. /** @hidden (Backing field) */
  60083. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60084. /**
  60085. * Gets or Sets the current geometry buffer associated to the scene.
  60086. */
  60087. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60088. /**
  60089. * Enables a GeometryBufferRender and associates it with the scene
  60090. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60091. * @returns the GeometryBufferRenderer
  60092. */
  60093. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60094. /**
  60095. * Disables the GeometryBufferRender associated with the scene
  60096. */
  60097. disableGeometryBufferRenderer(): void;
  60098. }
  60099. /**
  60100. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60101. * in several rendering techniques.
  60102. */
  60103. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60104. /**
  60105. * The component name helpful to identify the component in the list of scene components.
  60106. */
  60107. readonly name: string;
  60108. /**
  60109. * The scene the component belongs to.
  60110. */
  60111. scene: Scene;
  60112. /**
  60113. * Creates a new instance of the component for the given scene
  60114. * @param scene Defines the scene to register the component in
  60115. */
  60116. constructor(scene: Scene);
  60117. /**
  60118. * Registers the component in a given scene
  60119. */
  60120. register(): void;
  60121. /**
  60122. * Rebuilds the elements related to this component in case of
  60123. * context lost for instance.
  60124. */
  60125. rebuild(): void;
  60126. /**
  60127. * Disposes the component and the associated ressources
  60128. */
  60129. dispose(): void;
  60130. private _gatherRenderTargets;
  60131. }
  60132. }
  60133. declare module BABYLON {
  60134. /** @hidden */
  60135. export var motionBlurPixelShader: {
  60136. name: string;
  60137. shader: string;
  60138. };
  60139. }
  60140. declare module BABYLON {
  60141. /**
  60142. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60143. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60144. * As an example, all you have to do is to create the post-process:
  60145. * var mb = new BABYLON.MotionBlurPostProcess(
  60146. * 'mb', // The name of the effect.
  60147. * scene, // The scene containing the objects to blur according to their velocity.
  60148. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60149. * camera // The camera to apply the render pass to.
  60150. * );
  60151. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60152. */
  60153. export class MotionBlurPostProcess extends PostProcess {
  60154. /**
  60155. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60156. */
  60157. motionStrength: number;
  60158. /**
  60159. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60160. */
  60161. /**
  60162. * Sets the number of iterations to be used for motion blur quality
  60163. */
  60164. motionBlurSamples: number;
  60165. private _motionBlurSamples;
  60166. private _geometryBufferRenderer;
  60167. /**
  60168. * Creates a new instance MotionBlurPostProcess
  60169. * @param name The name of the effect.
  60170. * @param scene The scene containing the objects to blur according to their velocity.
  60171. * @param options The required width/height ratio to downsize to before computing the render pass.
  60172. * @param camera The camera to apply the render pass to.
  60173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60174. * @param engine The engine which the post process will be applied. (default: current engine)
  60175. * @param reusable If the post process can be reused on the same frame. (default: false)
  60176. * @param textureType Type of textures used when performing the post process. (default: 0)
  60177. * @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)
  60178. */
  60179. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60180. /**
  60181. * Excludes the given skinned mesh from computing bones velocities.
  60182. * 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.
  60183. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60184. */
  60185. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60186. /**
  60187. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60188. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60189. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60190. */
  60191. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60192. /**
  60193. * Disposes the post process.
  60194. * @param camera The camera to dispose the post process on.
  60195. */
  60196. dispose(camera?: Camera): void;
  60197. }
  60198. }
  60199. declare module BABYLON {
  60200. /** @hidden */
  60201. export var refractionPixelShader: {
  60202. name: string;
  60203. shader: string;
  60204. };
  60205. }
  60206. declare module BABYLON {
  60207. /**
  60208. * Post process which applies a refractin texture
  60209. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60210. */
  60211. export class RefractionPostProcess extends PostProcess {
  60212. /** the base color of the refraction (used to taint the rendering) */
  60213. color: Color3;
  60214. /** simulated refraction depth */
  60215. depth: number;
  60216. /** the coefficient of the base color (0 to remove base color tainting) */
  60217. colorLevel: number;
  60218. private _refTexture;
  60219. private _ownRefractionTexture;
  60220. /**
  60221. * Gets or sets the refraction texture
  60222. * Please note that you are responsible for disposing the texture if you set it manually
  60223. */
  60224. refractionTexture: Texture;
  60225. /**
  60226. * Initializes the RefractionPostProcess
  60227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60228. * @param name The name of the effect.
  60229. * @param refractionTextureUrl Url of the refraction texture to use
  60230. * @param color the base color of the refraction (used to taint the rendering)
  60231. * @param depth simulated refraction depth
  60232. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60233. * @param camera The camera to apply the render pass to.
  60234. * @param options The required width/height ratio to downsize to before computing the render pass.
  60235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60236. * @param engine The engine which the post process will be applied. (default: current engine)
  60237. * @param reusable If the post process can be reused on the same frame. (default: false)
  60238. */
  60239. constructor(name: string, refractionTextureUrl: string,
  60240. /** the base color of the refraction (used to taint the rendering) */
  60241. color: Color3,
  60242. /** simulated refraction depth */
  60243. depth: number,
  60244. /** the coefficient of the base color (0 to remove base color tainting) */
  60245. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60246. /**
  60247. * Disposes of the post process
  60248. * @param camera Camera to dispose post process on
  60249. */
  60250. dispose(camera: Camera): void;
  60251. }
  60252. }
  60253. declare module BABYLON {
  60254. /** @hidden */
  60255. export var sharpenPixelShader: {
  60256. name: string;
  60257. shader: string;
  60258. };
  60259. }
  60260. declare module BABYLON {
  60261. /**
  60262. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60263. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60264. */
  60265. export class SharpenPostProcess extends PostProcess {
  60266. /**
  60267. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60268. */
  60269. colorAmount: number;
  60270. /**
  60271. * How much sharpness should be applied (default: 0.3)
  60272. */
  60273. edgeAmount: number;
  60274. /**
  60275. * Creates a new instance ConvolutionPostProcess
  60276. * @param name The name of the effect.
  60277. * @param options The required width/height ratio to downsize to before computing the render pass.
  60278. * @param camera The camera to apply the render pass to.
  60279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60280. * @param engine The engine which the post process will be applied. (default: current engine)
  60281. * @param reusable If the post process can be reused on the same frame. (default: false)
  60282. * @param textureType Type of textures used when performing the post process. (default: 0)
  60283. * @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)
  60284. */
  60285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60286. }
  60287. }
  60288. declare module BABYLON {
  60289. /**
  60290. * PostProcessRenderPipeline
  60291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60292. */
  60293. export class PostProcessRenderPipeline {
  60294. private engine;
  60295. private _renderEffects;
  60296. private _renderEffectsForIsolatedPass;
  60297. /**
  60298. * List of inspectable custom properties (used by the Inspector)
  60299. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60300. */
  60301. inspectableCustomProperties: IInspectable[];
  60302. /**
  60303. * @hidden
  60304. */
  60305. protected _cameras: Camera[];
  60306. /** @hidden */
  60307. _name: string;
  60308. /**
  60309. * Gets pipeline name
  60310. */
  60311. readonly name: string;
  60312. /**
  60313. * Initializes a PostProcessRenderPipeline
  60314. * @param engine engine to add the pipeline to
  60315. * @param name name of the pipeline
  60316. */
  60317. constructor(engine: Engine, name: string);
  60318. /**
  60319. * Gets the class name
  60320. * @returns "PostProcessRenderPipeline"
  60321. */
  60322. getClassName(): string;
  60323. /**
  60324. * If all the render effects in the pipeline are supported
  60325. */
  60326. readonly isSupported: boolean;
  60327. /**
  60328. * Adds an effect to the pipeline
  60329. * @param renderEffect the effect to add
  60330. */
  60331. addEffect(renderEffect: PostProcessRenderEffect): void;
  60332. /** @hidden */
  60333. _rebuild(): void;
  60334. /** @hidden */
  60335. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60336. /** @hidden */
  60337. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60338. /** @hidden */
  60339. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60340. /** @hidden */
  60341. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60342. /** @hidden */
  60343. _attachCameras(cameras: Camera, unique: boolean): void;
  60344. /** @hidden */
  60345. _attachCameras(cameras: Camera[], unique: boolean): void;
  60346. /** @hidden */
  60347. _detachCameras(cameras: Camera): void;
  60348. /** @hidden */
  60349. _detachCameras(cameras: Nullable<Camera[]>): void;
  60350. /** @hidden */
  60351. _update(): void;
  60352. /** @hidden */
  60353. _reset(): void;
  60354. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60355. /**
  60356. * Disposes of the pipeline
  60357. */
  60358. dispose(): void;
  60359. }
  60360. }
  60361. declare module BABYLON {
  60362. /**
  60363. * PostProcessRenderPipelineManager class
  60364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60365. */
  60366. export class PostProcessRenderPipelineManager {
  60367. private _renderPipelines;
  60368. /**
  60369. * Initializes a PostProcessRenderPipelineManager
  60370. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60371. */
  60372. constructor();
  60373. /**
  60374. * Gets the list of supported render pipelines
  60375. */
  60376. readonly supportedPipelines: PostProcessRenderPipeline[];
  60377. /**
  60378. * Adds a pipeline to the manager
  60379. * @param renderPipeline The pipeline to add
  60380. */
  60381. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60382. /**
  60383. * Attaches a camera to the pipeline
  60384. * @param renderPipelineName The name of the pipeline to attach to
  60385. * @param cameras the camera to attach
  60386. * @param unique if the camera can be attached multiple times to the pipeline
  60387. */
  60388. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60389. /**
  60390. * Detaches a camera from the pipeline
  60391. * @param renderPipelineName The name of the pipeline to detach from
  60392. * @param cameras the camera to detach
  60393. */
  60394. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60395. /**
  60396. * Enables an effect by name on a pipeline
  60397. * @param renderPipelineName the name of the pipeline to enable the effect in
  60398. * @param renderEffectName the name of the effect to enable
  60399. * @param cameras the cameras that the effect should be enabled on
  60400. */
  60401. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60402. /**
  60403. * Disables an effect by name on a pipeline
  60404. * @param renderPipelineName the name of the pipeline to disable the effect in
  60405. * @param renderEffectName the name of the effect to disable
  60406. * @param cameras the cameras that the effect should be disabled on
  60407. */
  60408. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60409. /**
  60410. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60411. */
  60412. update(): void;
  60413. /** @hidden */
  60414. _rebuild(): void;
  60415. /**
  60416. * Disposes of the manager and pipelines
  60417. */
  60418. dispose(): void;
  60419. }
  60420. }
  60421. declare module BABYLON {
  60422. interface Scene {
  60423. /** @hidden (Backing field) */
  60424. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60425. /**
  60426. * Gets the postprocess render pipeline manager
  60427. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60428. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60429. */
  60430. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60431. }
  60432. /**
  60433. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60434. */
  60435. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60436. /**
  60437. * The component name helpfull to identify the component in the list of scene components.
  60438. */
  60439. readonly name: string;
  60440. /**
  60441. * The scene the component belongs to.
  60442. */
  60443. scene: Scene;
  60444. /**
  60445. * Creates a new instance of the component for the given scene
  60446. * @param scene Defines the scene to register the component in
  60447. */
  60448. constructor(scene: Scene);
  60449. /**
  60450. * Registers the component in a given scene
  60451. */
  60452. register(): void;
  60453. /**
  60454. * Rebuilds the elements related to this component in case of
  60455. * context lost for instance.
  60456. */
  60457. rebuild(): void;
  60458. /**
  60459. * Disposes the component and the associated ressources
  60460. */
  60461. dispose(): void;
  60462. private _gatherRenderTargets;
  60463. }
  60464. }
  60465. declare module BABYLON {
  60466. /**
  60467. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60468. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60469. */
  60470. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60471. private _scene;
  60472. private _camerasToBeAttached;
  60473. /**
  60474. * ID of the sharpen post process,
  60475. */
  60476. private readonly SharpenPostProcessId;
  60477. /**
  60478. * @ignore
  60479. * ID of the image processing post process;
  60480. */
  60481. readonly ImageProcessingPostProcessId: string;
  60482. /**
  60483. * @ignore
  60484. * ID of the Fast Approximate Anti-Aliasing post process;
  60485. */
  60486. readonly FxaaPostProcessId: string;
  60487. /**
  60488. * ID of the chromatic aberration post process,
  60489. */
  60490. private readonly ChromaticAberrationPostProcessId;
  60491. /**
  60492. * ID of the grain post process
  60493. */
  60494. private readonly GrainPostProcessId;
  60495. /**
  60496. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60497. */
  60498. sharpen: SharpenPostProcess;
  60499. private _sharpenEffect;
  60500. private bloom;
  60501. /**
  60502. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60503. */
  60504. depthOfField: DepthOfFieldEffect;
  60505. /**
  60506. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60507. */
  60508. fxaa: FxaaPostProcess;
  60509. /**
  60510. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60511. */
  60512. imageProcessing: ImageProcessingPostProcess;
  60513. /**
  60514. * Chromatic aberration post process which will shift rgb colors in the image
  60515. */
  60516. chromaticAberration: ChromaticAberrationPostProcess;
  60517. private _chromaticAberrationEffect;
  60518. /**
  60519. * Grain post process which add noise to the image
  60520. */
  60521. grain: GrainPostProcess;
  60522. private _grainEffect;
  60523. /**
  60524. * Glow post process which adds a glow to emissive areas of the image
  60525. */
  60526. private _glowLayer;
  60527. /**
  60528. * Animations which can be used to tweak settings over a period of time
  60529. */
  60530. animations: Animation[];
  60531. private _imageProcessingConfigurationObserver;
  60532. private _sharpenEnabled;
  60533. private _bloomEnabled;
  60534. private _depthOfFieldEnabled;
  60535. private _depthOfFieldBlurLevel;
  60536. private _fxaaEnabled;
  60537. private _imageProcessingEnabled;
  60538. private _defaultPipelineTextureType;
  60539. private _bloomScale;
  60540. private _chromaticAberrationEnabled;
  60541. private _grainEnabled;
  60542. private _buildAllowed;
  60543. /**
  60544. * Gets active scene
  60545. */
  60546. readonly scene: Scene;
  60547. /**
  60548. * Enable or disable the sharpen process from the pipeline
  60549. */
  60550. sharpenEnabled: boolean;
  60551. private _resizeObserver;
  60552. private _hardwareScaleLevel;
  60553. private _bloomKernel;
  60554. /**
  60555. * Specifies the size of the bloom blur kernel, relative to the final output size
  60556. */
  60557. bloomKernel: number;
  60558. /**
  60559. * Specifies the weight of the bloom in the final rendering
  60560. */
  60561. private _bloomWeight;
  60562. /**
  60563. * Specifies the luma threshold for the area that will be blurred by the bloom
  60564. */
  60565. private _bloomThreshold;
  60566. private _hdr;
  60567. /**
  60568. * The strength of the bloom.
  60569. */
  60570. bloomWeight: number;
  60571. /**
  60572. * The strength of the bloom.
  60573. */
  60574. bloomThreshold: number;
  60575. /**
  60576. * The scale of the bloom, lower value will provide better performance.
  60577. */
  60578. bloomScale: number;
  60579. /**
  60580. * Enable or disable the bloom from the pipeline
  60581. */
  60582. bloomEnabled: boolean;
  60583. private _rebuildBloom;
  60584. /**
  60585. * If the depth of field is enabled.
  60586. */
  60587. depthOfFieldEnabled: boolean;
  60588. /**
  60589. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60590. */
  60591. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60592. /**
  60593. * If the anti aliasing is enabled.
  60594. */
  60595. fxaaEnabled: boolean;
  60596. private _samples;
  60597. /**
  60598. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60599. */
  60600. samples: number;
  60601. /**
  60602. * If image processing is enabled.
  60603. */
  60604. imageProcessingEnabled: boolean;
  60605. /**
  60606. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60607. */
  60608. glowLayerEnabled: boolean;
  60609. /**
  60610. * Gets the glow layer (or null if not defined)
  60611. */
  60612. readonly glowLayer: Nullable<GlowLayer>;
  60613. /**
  60614. * Enable or disable the chromaticAberration process from the pipeline
  60615. */
  60616. chromaticAberrationEnabled: boolean;
  60617. /**
  60618. * Enable or disable the grain process from the pipeline
  60619. */
  60620. grainEnabled: boolean;
  60621. /**
  60622. * @constructor
  60623. * @param name - The rendering pipeline name (default: "")
  60624. * @param hdr - If high dynamic range textures should be used (default: true)
  60625. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60626. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60627. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60628. */
  60629. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60630. /**
  60631. * Get the class name
  60632. * @returns "DefaultRenderingPipeline"
  60633. */
  60634. getClassName(): string;
  60635. /**
  60636. * Force the compilation of the entire pipeline.
  60637. */
  60638. prepare(): void;
  60639. private _hasCleared;
  60640. private _prevPostProcess;
  60641. private _prevPrevPostProcess;
  60642. private _setAutoClearAndTextureSharing;
  60643. private _depthOfFieldSceneObserver;
  60644. private _buildPipeline;
  60645. private _disposePostProcesses;
  60646. /**
  60647. * Adds a camera to the pipeline
  60648. * @param camera the camera to be added
  60649. */
  60650. addCamera(camera: Camera): void;
  60651. /**
  60652. * Removes a camera from the pipeline
  60653. * @param camera the camera to remove
  60654. */
  60655. removeCamera(camera: Camera): void;
  60656. /**
  60657. * Dispose of the pipeline and stop all post processes
  60658. */
  60659. dispose(): void;
  60660. /**
  60661. * Serialize the rendering pipeline (Used when exporting)
  60662. * @returns the serialized object
  60663. */
  60664. serialize(): any;
  60665. /**
  60666. * Parse the serialized pipeline
  60667. * @param source Source pipeline.
  60668. * @param scene The scene to load the pipeline to.
  60669. * @param rootUrl The URL of the serialized pipeline.
  60670. * @returns An instantiated pipeline from the serialized object.
  60671. */
  60672. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60673. }
  60674. }
  60675. declare module BABYLON {
  60676. /** @hidden */
  60677. export var lensHighlightsPixelShader: {
  60678. name: string;
  60679. shader: string;
  60680. };
  60681. }
  60682. declare module BABYLON {
  60683. /** @hidden */
  60684. export var depthOfFieldPixelShader: {
  60685. name: string;
  60686. shader: string;
  60687. };
  60688. }
  60689. declare module BABYLON {
  60690. /**
  60691. * BABYLON.JS Chromatic Aberration GLSL Shader
  60692. * Author: Olivier Guyot
  60693. * Separates very slightly R, G and B colors on the edges of the screen
  60694. * Inspired by Francois Tarlier & Martins Upitis
  60695. */
  60696. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60697. /**
  60698. * @ignore
  60699. * The chromatic aberration PostProcess id in the pipeline
  60700. */
  60701. LensChromaticAberrationEffect: string;
  60702. /**
  60703. * @ignore
  60704. * The highlights enhancing PostProcess id in the pipeline
  60705. */
  60706. HighlightsEnhancingEffect: string;
  60707. /**
  60708. * @ignore
  60709. * The depth-of-field PostProcess id in the pipeline
  60710. */
  60711. LensDepthOfFieldEffect: string;
  60712. private _scene;
  60713. private _depthTexture;
  60714. private _grainTexture;
  60715. private _chromaticAberrationPostProcess;
  60716. private _highlightsPostProcess;
  60717. private _depthOfFieldPostProcess;
  60718. private _edgeBlur;
  60719. private _grainAmount;
  60720. private _chromaticAberration;
  60721. private _distortion;
  60722. private _highlightsGain;
  60723. private _highlightsThreshold;
  60724. private _dofDistance;
  60725. private _dofAperture;
  60726. private _dofDarken;
  60727. private _dofPentagon;
  60728. private _blurNoise;
  60729. /**
  60730. * @constructor
  60731. *
  60732. * Effect parameters are as follow:
  60733. * {
  60734. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60735. * edge_blur: number; // from 0 to x (1 for realism)
  60736. * distortion: number; // from 0 to x (1 for realism)
  60737. * grain_amount: number; // from 0 to 1
  60738. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60739. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60740. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60741. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60742. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60743. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60744. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60745. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60746. * }
  60747. * Note: if an effect parameter is unset, effect is disabled
  60748. *
  60749. * @param name The rendering pipeline name
  60750. * @param parameters - An object containing all parameters (see above)
  60751. * @param scene The scene linked to this pipeline
  60752. * @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)
  60753. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60754. */
  60755. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60756. /**
  60757. * Get the class name
  60758. * @returns "LensRenderingPipeline"
  60759. */
  60760. getClassName(): string;
  60761. /**
  60762. * Gets associated scene
  60763. */
  60764. readonly scene: Scene;
  60765. /**
  60766. * Gets or sets the edge blur
  60767. */
  60768. edgeBlur: number;
  60769. /**
  60770. * Gets or sets the grain amount
  60771. */
  60772. grainAmount: number;
  60773. /**
  60774. * Gets or sets the chromatic aberration amount
  60775. */
  60776. chromaticAberration: number;
  60777. /**
  60778. * Gets or sets the depth of field aperture
  60779. */
  60780. dofAperture: number;
  60781. /**
  60782. * Gets or sets the edge distortion
  60783. */
  60784. edgeDistortion: number;
  60785. /**
  60786. * Gets or sets the depth of field distortion
  60787. */
  60788. dofDistortion: number;
  60789. /**
  60790. * Gets or sets the darken out of focus amount
  60791. */
  60792. darkenOutOfFocus: number;
  60793. /**
  60794. * Gets or sets a boolean indicating if blur noise is enabled
  60795. */
  60796. blurNoise: boolean;
  60797. /**
  60798. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60799. */
  60800. pentagonBokeh: boolean;
  60801. /**
  60802. * Gets or sets the highlight grain amount
  60803. */
  60804. highlightsGain: number;
  60805. /**
  60806. * Gets or sets the highlight threshold
  60807. */
  60808. highlightsThreshold: number;
  60809. /**
  60810. * Sets the amount of blur at the edges
  60811. * @param amount blur amount
  60812. */
  60813. setEdgeBlur(amount: number): void;
  60814. /**
  60815. * Sets edge blur to 0
  60816. */
  60817. disableEdgeBlur(): void;
  60818. /**
  60819. * Sets the amout of grain
  60820. * @param amount Amount of grain
  60821. */
  60822. setGrainAmount(amount: number): void;
  60823. /**
  60824. * Set grain amount to 0
  60825. */
  60826. disableGrain(): void;
  60827. /**
  60828. * Sets the chromatic aberration amount
  60829. * @param amount amount of chromatic aberration
  60830. */
  60831. setChromaticAberration(amount: number): void;
  60832. /**
  60833. * Sets chromatic aberration amount to 0
  60834. */
  60835. disableChromaticAberration(): void;
  60836. /**
  60837. * Sets the EdgeDistortion amount
  60838. * @param amount amount of EdgeDistortion
  60839. */
  60840. setEdgeDistortion(amount: number): void;
  60841. /**
  60842. * Sets edge distortion to 0
  60843. */
  60844. disableEdgeDistortion(): void;
  60845. /**
  60846. * Sets the FocusDistance amount
  60847. * @param amount amount of FocusDistance
  60848. */
  60849. setFocusDistance(amount: number): void;
  60850. /**
  60851. * Disables depth of field
  60852. */
  60853. disableDepthOfField(): void;
  60854. /**
  60855. * Sets the Aperture amount
  60856. * @param amount amount of Aperture
  60857. */
  60858. setAperture(amount: number): void;
  60859. /**
  60860. * Sets the DarkenOutOfFocus amount
  60861. * @param amount amount of DarkenOutOfFocus
  60862. */
  60863. setDarkenOutOfFocus(amount: number): void;
  60864. private _pentagonBokehIsEnabled;
  60865. /**
  60866. * Creates a pentagon bokeh effect
  60867. */
  60868. enablePentagonBokeh(): void;
  60869. /**
  60870. * Disables the pentagon bokeh effect
  60871. */
  60872. disablePentagonBokeh(): void;
  60873. /**
  60874. * Enables noise blur
  60875. */
  60876. enableNoiseBlur(): void;
  60877. /**
  60878. * Disables noise blur
  60879. */
  60880. disableNoiseBlur(): void;
  60881. /**
  60882. * Sets the HighlightsGain amount
  60883. * @param amount amount of HighlightsGain
  60884. */
  60885. setHighlightsGain(amount: number): void;
  60886. /**
  60887. * Sets the HighlightsThreshold amount
  60888. * @param amount amount of HighlightsThreshold
  60889. */
  60890. setHighlightsThreshold(amount: number): void;
  60891. /**
  60892. * Disables highlights
  60893. */
  60894. disableHighlights(): void;
  60895. /**
  60896. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60897. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60898. */
  60899. dispose(disableDepthRender?: boolean): void;
  60900. private _createChromaticAberrationPostProcess;
  60901. private _createHighlightsPostProcess;
  60902. private _createDepthOfFieldPostProcess;
  60903. private _createGrainTexture;
  60904. }
  60905. }
  60906. declare module BABYLON {
  60907. /** @hidden */
  60908. export var ssao2PixelShader: {
  60909. name: string;
  60910. shader: string;
  60911. };
  60912. }
  60913. declare module BABYLON {
  60914. /** @hidden */
  60915. export var ssaoCombinePixelShader: {
  60916. name: string;
  60917. shader: string;
  60918. };
  60919. }
  60920. declare module BABYLON {
  60921. /**
  60922. * Render pipeline to produce ssao effect
  60923. */
  60924. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60925. /**
  60926. * @ignore
  60927. * The PassPostProcess id in the pipeline that contains the original scene color
  60928. */
  60929. SSAOOriginalSceneColorEffect: string;
  60930. /**
  60931. * @ignore
  60932. * The SSAO PostProcess id in the pipeline
  60933. */
  60934. SSAORenderEffect: string;
  60935. /**
  60936. * @ignore
  60937. * The horizontal blur PostProcess id in the pipeline
  60938. */
  60939. SSAOBlurHRenderEffect: string;
  60940. /**
  60941. * @ignore
  60942. * The vertical blur PostProcess id in the pipeline
  60943. */
  60944. SSAOBlurVRenderEffect: string;
  60945. /**
  60946. * @ignore
  60947. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60948. */
  60949. SSAOCombineRenderEffect: string;
  60950. /**
  60951. * The output strength of the SSAO post-process. Default value is 1.0.
  60952. */
  60953. totalStrength: number;
  60954. /**
  60955. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60956. */
  60957. maxZ: number;
  60958. /**
  60959. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60960. */
  60961. minZAspect: number;
  60962. private _samples;
  60963. /**
  60964. * Number of samples used for the SSAO calculations. Default value is 8
  60965. */
  60966. samples: number;
  60967. private _textureSamples;
  60968. /**
  60969. * Number of samples to use for antialiasing
  60970. */
  60971. textureSamples: number;
  60972. /**
  60973. * Ratio object used for SSAO ratio and blur ratio
  60974. */
  60975. private _ratio;
  60976. /**
  60977. * Dynamically generated sphere sampler.
  60978. */
  60979. private _sampleSphere;
  60980. /**
  60981. * Blur filter offsets
  60982. */
  60983. private _samplerOffsets;
  60984. private _expensiveBlur;
  60985. /**
  60986. * If bilateral blur should be used
  60987. */
  60988. expensiveBlur: boolean;
  60989. /**
  60990. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60991. */
  60992. radius: number;
  60993. /**
  60994. * The base color of the SSAO post-process
  60995. * The final result is "base + ssao" between [0, 1]
  60996. */
  60997. base: number;
  60998. /**
  60999. * Support test.
  61000. */
  61001. static readonly IsSupported: boolean;
  61002. private _scene;
  61003. private _depthTexture;
  61004. private _normalTexture;
  61005. private _randomTexture;
  61006. private _originalColorPostProcess;
  61007. private _ssaoPostProcess;
  61008. private _blurHPostProcess;
  61009. private _blurVPostProcess;
  61010. private _ssaoCombinePostProcess;
  61011. private _firstUpdate;
  61012. /**
  61013. * Gets active scene
  61014. */
  61015. readonly scene: Scene;
  61016. /**
  61017. * @constructor
  61018. * @param name The rendering pipeline name
  61019. * @param scene The scene linked to this pipeline
  61020. * @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 }
  61021. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61022. */
  61023. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61024. /**
  61025. * Get the class name
  61026. * @returns "SSAO2RenderingPipeline"
  61027. */
  61028. getClassName(): string;
  61029. /**
  61030. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61031. */
  61032. dispose(disableGeometryBufferRenderer?: boolean): void;
  61033. private _createBlurPostProcess;
  61034. /** @hidden */
  61035. _rebuild(): void;
  61036. private _bits;
  61037. private _radicalInverse_VdC;
  61038. private _hammersley;
  61039. private _hemisphereSample_uniform;
  61040. private _generateHemisphere;
  61041. private _createSSAOPostProcess;
  61042. private _createSSAOCombinePostProcess;
  61043. private _createRandomTexture;
  61044. /**
  61045. * Serialize the rendering pipeline (Used when exporting)
  61046. * @returns the serialized object
  61047. */
  61048. serialize(): any;
  61049. /**
  61050. * Parse the serialized pipeline
  61051. * @param source Source pipeline.
  61052. * @param scene The scene to load the pipeline to.
  61053. * @param rootUrl The URL of the serialized pipeline.
  61054. * @returns An instantiated pipeline from the serialized object.
  61055. */
  61056. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61057. }
  61058. }
  61059. declare module BABYLON {
  61060. /** @hidden */
  61061. export var ssaoPixelShader: {
  61062. name: string;
  61063. shader: string;
  61064. };
  61065. }
  61066. declare module BABYLON {
  61067. /**
  61068. * Render pipeline to produce ssao effect
  61069. */
  61070. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61071. /**
  61072. * @ignore
  61073. * The PassPostProcess id in the pipeline that contains the original scene color
  61074. */
  61075. SSAOOriginalSceneColorEffect: string;
  61076. /**
  61077. * @ignore
  61078. * The SSAO PostProcess id in the pipeline
  61079. */
  61080. SSAORenderEffect: string;
  61081. /**
  61082. * @ignore
  61083. * The horizontal blur PostProcess id in the pipeline
  61084. */
  61085. SSAOBlurHRenderEffect: string;
  61086. /**
  61087. * @ignore
  61088. * The vertical blur PostProcess id in the pipeline
  61089. */
  61090. SSAOBlurVRenderEffect: string;
  61091. /**
  61092. * @ignore
  61093. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61094. */
  61095. SSAOCombineRenderEffect: string;
  61096. /**
  61097. * The output strength of the SSAO post-process. Default value is 1.0.
  61098. */
  61099. totalStrength: number;
  61100. /**
  61101. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61102. */
  61103. radius: number;
  61104. /**
  61105. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61106. * Must not be equal to fallOff and superior to fallOff.
  61107. * Default value is 0.0075
  61108. */
  61109. area: number;
  61110. /**
  61111. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61112. * Must not be equal to area and inferior to area.
  61113. * Default value is 0.000001
  61114. */
  61115. fallOff: number;
  61116. /**
  61117. * The base color of the SSAO post-process
  61118. * The final result is "base + ssao" between [0, 1]
  61119. */
  61120. base: number;
  61121. private _scene;
  61122. private _depthTexture;
  61123. private _randomTexture;
  61124. private _originalColorPostProcess;
  61125. private _ssaoPostProcess;
  61126. private _blurHPostProcess;
  61127. private _blurVPostProcess;
  61128. private _ssaoCombinePostProcess;
  61129. private _firstUpdate;
  61130. /**
  61131. * Gets active scene
  61132. */
  61133. readonly scene: Scene;
  61134. /**
  61135. * @constructor
  61136. * @param name - The rendering pipeline name
  61137. * @param scene - The scene linked to this pipeline
  61138. * @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 }
  61139. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61140. */
  61141. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61142. /**
  61143. * Get the class name
  61144. * @returns "SSAORenderingPipeline"
  61145. */
  61146. getClassName(): string;
  61147. /**
  61148. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61149. */
  61150. dispose(disableDepthRender?: boolean): void;
  61151. private _createBlurPostProcess;
  61152. /** @hidden */
  61153. _rebuild(): void;
  61154. private _createSSAOPostProcess;
  61155. private _createSSAOCombinePostProcess;
  61156. private _createRandomTexture;
  61157. }
  61158. }
  61159. declare module BABYLON {
  61160. /** @hidden */
  61161. export var standardPixelShader: {
  61162. name: string;
  61163. shader: string;
  61164. };
  61165. }
  61166. declare module BABYLON {
  61167. /**
  61168. * Standard rendering pipeline
  61169. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61170. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61171. */
  61172. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61173. /**
  61174. * Public members
  61175. */
  61176. /**
  61177. * Post-process which contains the original scene color before the pipeline applies all the effects
  61178. */
  61179. originalPostProcess: Nullable<PostProcess>;
  61180. /**
  61181. * Post-process used to down scale an image x4
  61182. */
  61183. downSampleX4PostProcess: Nullable<PostProcess>;
  61184. /**
  61185. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61186. */
  61187. brightPassPostProcess: Nullable<PostProcess>;
  61188. /**
  61189. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61190. */
  61191. blurHPostProcesses: PostProcess[];
  61192. /**
  61193. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61194. */
  61195. blurVPostProcesses: PostProcess[];
  61196. /**
  61197. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61198. */
  61199. textureAdderPostProcess: Nullable<PostProcess>;
  61200. /**
  61201. * Post-process used to create volumetric lighting effect
  61202. */
  61203. volumetricLightPostProcess: Nullable<PostProcess>;
  61204. /**
  61205. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61206. */
  61207. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61208. /**
  61209. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61210. */
  61211. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61212. /**
  61213. * Post-process used to merge the volumetric light effect and the real scene color
  61214. */
  61215. volumetricLightMergePostProces: Nullable<PostProcess>;
  61216. /**
  61217. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61218. */
  61219. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61220. /**
  61221. * Base post-process used to calculate the average luminance of the final image for HDR
  61222. */
  61223. luminancePostProcess: Nullable<PostProcess>;
  61224. /**
  61225. * Post-processes used to create down sample post-processes in order to get
  61226. * the average luminance of the final image for HDR
  61227. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61228. */
  61229. luminanceDownSamplePostProcesses: PostProcess[];
  61230. /**
  61231. * Post-process used to create a HDR effect (light adaptation)
  61232. */
  61233. hdrPostProcess: Nullable<PostProcess>;
  61234. /**
  61235. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61236. */
  61237. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61238. /**
  61239. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61240. */
  61241. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61242. /**
  61243. * Post-process used to merge the final HDR post-process and the real scene color
  61244. */
  61245. hdrFinalPostProcess: Nullable<PostProcess>;
  61246. /**
  61247. * Post-process used to create a lens flare effect
  61248. */
  61249. lensFlarePostProcess: Nullable<PostProcess>;
  61250. /**
  61251. * Post-process that merges the result of the lens flare post-process and the real scene color
  61252. */
  61253. lensFlareComposePostProcess: Nullable<PostProcess>;
  61254. /**
  61255. * Post-process used to create a motion blur effect
  61256. */
  61257. motionBlurPostProcess: Nullable<PostProcess>;
  61258. /**
  61259. * Post-process used to create a depth of field effect
  61260. */
  61261. depthOfFieldPostProcess: Nullable<PostProcess>;
  61262. /**
  61263. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61264. */
  61265. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61266. /**
  61267. * Represents the brightness threshold in order to configure the illuminated surfaces
  61268. */
  61269. brightThreshold: number;
  61270. /**
  61271. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61272. */
  61273. blurWidth: number;
  61274. /**
  61275. * Sets if the blur for highlighted surfaces must be only horizontal
  61276. */
  61277. horizontalBlur: boolean;
  61278. /**
  61279. * Gets the overall exposure used by the pipeline
  61280. */
  61281. /**
  61282. * Sets the overall exposure used by the pipeline
  61283. */
  61284. exposure: number;
  61285. /**
  61286. * Texture used typically to simulate "dirty" on camera lens
  61287. */
  61288. lensTexture: Nullable<Texture>;
  61289. /**
  61290. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61291. */
  61292. volumetricLightCoefficient: number;
  61293. /**
  61294. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61295. */
  61296. volumetricLightPower: number;
  61297. /**
  61298. * Used the set the blur intensity to smooth the volumetric lights
  61299. */
  61300. volumetricLightBlurScale: number;
  61301. /**
  61302. * Light (spot or directional) used to generate the volumetric lights rays
  61303. * The source light must have a shadow generate so the pipeline can get its
  61304. * depth map
  61305. */
  61306. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61307. /**
  61308. * For eye adaptation, represents the minimum luminance the eye can see
  61309. */
  61310. hdrMinimumLuminance: number;
  61311. /**
  61312. * For eye adaptation, represents the decrease luminance speed
  61313. */
  61314. hdrDecreaseRate: number;
  61315. /**
  61316. * For eye adaptation, represents the increase luminance speed
  61317. */
  61318. hdrIncreaseRate: number;
  61319. /**
  61320. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61321. */
  61322. /**
  61323. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61324. */
  61325. hdrAutoExposure: boolean;
  61326. /**
  61327. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61328. */
  61329. lensColorTexture: Nullable<Texture>;
  61330. /**
  61331. * The overall strengh for the lens flare effect
  61332. */
  61333. lensFlareStrength: number;
  61334. /**
  61335. * Dispersion coefficient for lens flare ghosts
  61336. */
  61337. lensFlareGhostDispersal: number;
  61338. /**
  61339. * Main lens flare halo width
  61340. */
  61341. lensFlareHaloWidth: number;
  61342. /**
  61343. * Based on the lens distortion effect, defines how much the lens flare result
  61344. * is distorted
  61345. */
  61346. lensFlareDistortionStrength: number;
  61347. /**
  61348. * Configures the blur intensity used for for lens flare (halo)
  61349. */
  61350. lensFlareBlurWidth: number;
  61351. /**
  61352. * Lens star texture must be used to simulate rays on the flares and is available
  61353. * in the documentation
  61354. */
  61355. lensStarTexture: Nullable<Texture>;
  61356. /**
  61357. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61358. * flare effect by taking account of the dirt texture
  61359. */
  61360. lensFlareDirtTexture: Nullable<Texture>;
  61361. /**
  61362. * Represents the focal length for the depth of field effect
  61363. */
  61364. depthOfFieldDistance: number;
  61365. /**
  61366. * Represents the blur intensity for the blurred part of the depth of field effect
  61367. */
  61368. depthOfFieldBlurWidth: number;
  61369. /**
  61370. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61371. */
  61372. /**
  61373. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61374. */
  61375. motionStrength: number;
  61376. /**
  61377. * Gets wether or not the motion blur post-process is object based or screen based.
  61378. */
  61379. /**
  61380. * Sets wether or not the motion blur post-process should be object based or screen based
  61381. */
  61382. objectBasedMotionBlur: boolean;
  61383. /**
  61384. * List of animations for the pipeline (IAnimatable implementation)
  61385. */
  61386. animations: Animation[];
  61387. /**
  61388. * Private members
  61389. */
  61390. private _scene;
  61391. private _currentDepthOfFieldSource;
  61392. private _basePostProcess;
  61393. private _fixedExposure;
  61394. private _currentExposure;
  61395. private _hdrAutoExposure;
  61396. private _hdrCurrentLuminance;
  61397. private _motionStrength;
  61398. private _isObjectBasedMotionBlur;
  61399. private _floatTextureType;
  61400. private _camerasToBeAttached;
  61401. private _ratio;
  61402. private _bloomEnabled;
  61403. private _depthOfFieldEnabled;
  61404. private _vlsEnabled;
  61405. private _lensFlareEnabled;
  61406. private _hdrEnabled;
  61407. private _motionBlurEnabled;
  61408. private _fxaaEnabled;
  61409. private _motionBlurSamples;
  61410. private _volumetricLightStepsCount;
  61411. private _samples;
  61412. /**
  61413. * @ignore
  61414. * Specifies if the bloom pipeline is enabled
  61415. */
  61416. BloomEnabled: boolean;
  61417. /**
  61418. * @ignore
  61419. * Specifies if the depth of field pipeline is enabed
  61420. */
  61421. DepthOfFieldEnabled: boolean;
  61422. /**
  61423. * @ignore
  61424. * Specifies if the lens flare pipeline is enabed
  61425. */
  61426. LensFlareEnabled: boolean;
  61427. /**
  61428. * @ignore
  61429. * Specifies if the HDR pipeline is enabled
  61430. */
  61431. HDREnabled: boolean;
  61432. /**
  61433. * @ignore
  61434. * Specifies if the volumetric lights scattering effect is enabled
  61435. */
  61436. VLSEnabled: boolean;
  61437. /**
  61438. * @ignore
  61439. * Specifies if the motion blur effect is enabled
  61440. */
  61441. MotionBlurEnabled: boolean;
  61442. /**
  61443. * Specifies if anti-aliasing is enabled
  61444. */
  61445. fxaaEnabled: boolean;
  61446. /**
  61447. * Specifies the number of steps used to calculate the volumetric lights
  61448. * Typically in interval [50, 200]
  61449. */
  61450. volumetricLightStepsCount: number;
  61451. /**
  61452. * Specifies the number of samples used for the motion blur effect
  61453. * Typically in interval [16, 64]
  61454. */
  61455. motionBlurSamples: number;
  61456. /**
  61457. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61458. */
  61459. samples: number;
  61460. /**
  61461. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61462. * @constructor
  61463. * @param name The rendering pipeline name
  61464. * @param scene The scene linked to this pipeline
  61465. * @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)
  61466. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61467. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61468. */
  61469. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61470. private _buildPipeline;
  61471. private _createDownSampleX4PostProcess;
  61472. private _createBrightPassPostProcess;
  61473. private _createBlurPostProcesses;
  61474. private _createTextureAdderPostProcess;
  61475. private _createVolumetricLightPostProcess;
  61476. private _createLuminancePostProcesses;
  61477. private _createHdrPostProcess;
  61478. private _createLensFlarePostProcess;
  61479. private _createDepthOfFieldPostProcess;
  61480. private _createMotionBlurPostProcess;
  61481. private _getDepthTexture;
  61482. private _disposePostProcesses;
  61483. /**
  61484. * Dispose of the pipeline and stop all post processes
  61485. */
  61486. dispose(): void;
  61487. /**
  61488. * Serialize the rendering pipeline (Used when exporting)
  61489. * @returns the serialized object
  61490. */
  61491. serialize(): any;
  61492. /**
  61493. * Parse the serialized pipeline
  61494. * @param source Source pipeline.
  61495. * @param scene The scene to load the pipeline to.
  61496. * @param rootUrl The URL of the serialized pipeline.
  61497. * @returns An instantiated pipeline from the serialized object.
  61498. */
  61499. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61500. /**
  61501. * Luminance steps
  61502. */
  61503. static LuminanceSteps: number;
  61504. }
  61505. }
  61506. declare module BABYLON {
  61507. /** @hidden */
  61508. export var tonemapPixelShader: {
  61509. name: string;
  61510. shader: string;
  61511. };
  61512. }
  61513. declare module BABYLON {
  61514. /** Defines operator used for tonemapping */
  61515. export enum TonemappingOperator {
  61516. /** Hable */
  61517. Hable = 0,
  61518. /** Reinhard */
  61519. Reinhard = 1,
  61520. /** HejiDawson */
  61521. HejiDawson = 2,
  61522. /** Photographic */
  61523. Photographic = 3
  61524. }
  61525. /**
  61526. * Defines a post process to apply tone mapping
  61527. */
  61528. export class TonemapPostProcess extends PostProcess {
  61529. private _operator;
  61530. /** Defines the required exposure adjustement */
  61531. exposureAdjustment: number;
  61532. /**
  61533. * Creates a new TonemapPostProcess
  61534. * @param name defines the name of the postprocess
  61535. * @param _operator defines the operator to use
  61536. * @param exposureAdjustment defines the required exposure adjustement
  61537. * @param camera defines the camera to use (can be null)
  61538. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61539. * @param engine defines the hosting engine (can be ignore if camera is set)
  61540. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61541. */
  61542. constructor(name: string, _operator: TonemappingOperator,
  61543. /** Defines the required exposure adjustement */
  61544. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61545. }
  61546. }
  61547. declare module BABYLON {
  61548. /** @hidden */
  61549. export var depthVertexShader: {
  61550. name: string;
  61551. shader: string;
  61552. };
  61553. }
  61554. declare module BABYLON {
  61555. /** @hidden */
  61556. export var volumetricLightScatteringPixelShader: {
  61557. name: string;
  61558. shader: string;
  61559. };
  61560. }
  61561. declare module BABYLON {
  61562. /** @hidden */
  61563. export var volumetricLightScatteringPassVertexShader: {
  61564. name: string;
  61565. shader: string;
  61566. };
  61567. }
  61568. declare module BABYLON {
  61569. /** @hidden */
  61570. export var volumetricLightScatteringPassPixelShader: {
  61571. name: string;
  61572. shader: string;
  61573. };
  61574. }
  61575. declare module BABYLON {
  61576. /**
  61577. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61578. */
  61579. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61580. private _volumetricLightScatteringPass;
  61581. private _volumetricLightScatteringRTT;
  61582. private _viewPort;
  61583. private _screenCoordinates;
  61584. private _cachedDefines;
  61585. /**
  61586. * If not undefined, the mesh position is computed from the attached node position
  61587. */
  61588. attachedNode: {
  61589. position: Vector3;
  61590. };
  61591. /**
  61592. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61593. */
  61594. customMeshPosition: Vector3;
  61595. /**
  61596. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61597. */
  61598. useCustomMeshPosition: boolean;
  61599. /**
  61600. * If the post-process should inverse the light scattering direction
  61601. */
  61602. invert: boolean;
  61603. /**
  61604. * The internal mesh used by the post-process
  61605. */
  61606. mesh: Mesh;
  61607. /**
  61608. * @hidden
  61609. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61610. */
  61611. useDiffuseColor: boolean;
  61612. /**
  61613. * Array containing the excluded meshes not rendered in the internal pass
  61614. */
  61615. excludedMeshes: AbstractMesh[];
  61616. /**
  61617. * Controls the overall intensity of the post-process
  61618. */
  61619. exposure: number;
  61620. /**
  61621. * Dissipates each sample's contribution in range [0, 1]
  61622. */
  61623. decay: number;
  61624. /**
  61625. * Controls the overall intensity of each sample
  61626. */
  61627. weight: number;
  61628. /**
  61629. * Controls the density of each sample
  61630. */
  61631. density: number;
  61632. /**
  61633. * @constructor
  61634. * @param name The post-process name
  61635. * @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)
  61636. * @param camera The camera that the post-process will be attached to
  61637. * @param mesh The mesh used to create the light scattering
  61638. * @param samples The post-process quality, default 100
  61639. * @param samplingModeThe post-process filtering mode
  61640. * @param engine The babylon engine
  61641. * @param reusable If the post-process is reusable
  61642. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61643. */
  61644. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61645. /**
  61646. * Returns the string "VolumetricLightScatteringPostProcess"
  61647. * @returns "VolumetricLightScatteringPostProcess"
  61648. */
  61649. getClassName(): string;
  61650. private _isReady;
  61651. /**
  61652. * Sets the new light position for light scattering effect
  61653. * @param position The new custom light position
  61654. */
  61655. setCustomMeshPosition(position: Vector3): void;
  61656. /**
  61657. * Returns the light position for light scattering effect
  61658. * @return Vector3 The custom light position
  61659. */
  61660. getCustomMeshPosition(): Vector3;
  61661. /**
  61662. * Disposes the internal assets and detaches the post-process from the camera
  61663. */
  61664. dispose(camera: Camera): void;
  61665. /**
  61666. * Returns the render target texture used by the post-process
  61667. * @return the render target texture used by the post-process
  61668. */
  61669. getPass(): RenderTargetTexture;
  61670. private _meshExcluded;
  61671. private _createPass;
  61672. private _updateMeshScreenCoordinates;
  61673. /**
  61674. * Creates a default mesh for the Volumeric Light Scattering post-process
  61675. * @param name The mesh name
  61676. * @param scene The scene where to create the mesh
  61677. * @return the default mesh
  61678. */
  61679. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61680. }
  61681. }
  61682. declare module BABYLON {
  61683. interface Scene {
  61684. /** @hidden (Backing field) */
  61685. _boundingBoxRenderer: BoundingBoxRenderer;
  61686. /** @hidden (Backing field) */
  61687. _forceShowBoundingBoxes: boolean;
  61688. /**
  61689. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61690. */
  61691. forceShowBoundingBoxes: boolean;
  61692. /**
  61693. * Gets the bounding box renderer associated with the scene
  61694. * @returns a BoundingBoxRenderer
  61695. */
  61696. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61697. }
  61698. interface AbstractMesh {
  61699. /** @hidden (Backing field) */
  61700. _showBoundingBox: boolean;
  61701. /**
  61702. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61703. */
  61704. showBoundingBox: boolean;
  61705. }
  61706. /**
  61707. * Component responsible of rendering the bounding box of the meshes in a scene.
  61708. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61709. */
  61710. export class BoundingBoxRenderer implements ISceneComponent {
  61711. /**
  61712. * The component name helpfull to identify the component in the list of scene components.
  61713. */
  61714. readonly name: string;
  61715. /**
  61716. * The scene the component belongs to.
  61717. */
  61718. scene: Scene;
  61719. /**
  61720. * Color of the bounding box lines placed in front of an object
  61721. */
  61722. frontColor: Color3;
  61723. /**
  61724. * Color of the bounding box lines placed behind an object
  61725. */
  61726. backColor: Color3;
  61727. /**
  61728. * Defines if the renderer should show the back lines or not
  61729. */
  61730. showBackLines: boolean;
  61731. /**
  61732. * @hidden
  61733. */
  61734. renderList: SmartArray<BoundingBox>;
  61735. private _colorShader;
  61736. private _vertexBuffers;
  61737. private _indexBuffer;
  61738. private _fillIndexBuffer;
  61739. private _fillIndexData;
  61740. /**
  61741. * Instantiates a new bounding box renderer in a scene.
  61742. * @param scene the scene the renderer renders in
  61743. */
  61744. constructor(scene: Scene);
  61745. /**
  61746. * Registers the component in a given scene
  61747. */
  61748. register(): void;
  61749. private _evaluateSubMesh;
  61750. private _activeMesh;
  61751. private _prepareRessources;
  61752. private _createIndexBuffer;
  61753. /**
  61754. * Rebuilds the elements related to this component in case of
  61755. * context lost for instance.
  61756. */
  61757. rebuild(): void;
  61758. /**
  61759. * @hidden
  61760. */
  61761. reset(): void;
  61762. /**
  61763. * Render the bounding boxes of a specific rendering group
  61764. * @param renderingGroupId defines the rendering group to render
  61765. */
  61766. render(renderingGroupId: number): void;
  61767. /**
  61768. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61769. * @param mesh Define the mesh to render the occlusion bounding box for
  61770. */
  61771. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61772. /**
  61773. * Dispose and release the resources attached to this renderer.
  61774. */
  61775. dispose(): void;
  61776. }
  61777. }
  61778. declare module BABYLON {
  61779. /** @hidden */
  61780. export var depthPixelShader: {
  61781. name: string;
  61782. shader: string;
  61783. };
  61784. }
  61785. declare module BABYLON {
  61786. /**
  61787. * This represents a depth renderer in Babylon.
  61788. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61789. */
  61790. export class DepthRenderer {
  61791. private _scene;
  61792. private _depthMap;
  61793. private _effect;
  61794. private readonly _storeNonLinearDepth;
  61795. private readonly _clearColor;
  61796. /** Get if the depth renderer is using packed depth or not */
  61797. readonly isPacked: boolean;
  61798. private _cachedDefines;
  61799. private _camera;
  61800. /**
  61801. * Specifiess that the depth renderer will only be used within
  61802. * the camera it is created for.
  61803. * This can help forcing its rendering during the camera processing.
  61804. */
  61805. useOnlyInActiveCamera: boolean;
  61806. /** @hidden */
  61807. static _SceneComponentInitialization: (scene: Scene) => void;
  61808. /**
  61809. * Instantiates a depth renderer
  61810. * @param scene The scene the renderer belongs to
  61811. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61812. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61813. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61814. */
  61815. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61816. /**
  61817. * Creates the depth rendering effect and checks if the effect is ready.
  61818. * @param subMesh The submesh to be used to render the depth map of
  61819. * @param useInstances If multiple world instances should be used
  61820. * @returns if the depth renderer is ready to render the depth map
  61821. */
  61822. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61823. /**
  61824. * Gets the texture which the depth map will be written to.
  61825. * @returns The depth map texture
  61826. */
  61827. getDepthMap(): RenderTargetTexture;
  61828. /**
  61829. * Disposes of the depth renderer.
  61830. */
  61831. dispose(): void;
  61832. }
  61833. }
  61834. declare module BABYLON {
  61835. interface Scene {
  61836. /** @hidden (Backing field) */
  61837. _depthRenderer: {
  61838. [id: string]: DepthRenderer;
  61839. };
  61840. /**
  61841. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61842. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61843. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61844. * @returns the created depth renderer
  61845. */
  61846. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61847. /**
  61848. * Disables a depth renderer for a given camera
  61849. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61850. */
  61851. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61852. }
  61853. /**
  61854. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61855. * in several rendering techniques.
  61856. */
  61857. export class DepthRendererSceneComponent implements ISceneComponent {
  61858. /**
  61859. * The component name helpfull to identify the component in the list of scene components.
  61860. */
  61861. readonly name: string;
  61862. /**
  61863. * The scene the component belongs to.
  61864. */
  61865. scene: Scene;
  61866. /**
  61867. * Creates a new instance of the component for the given scene
  61868. * @param scene Defines the scene to register the component in
  61869. */
  61870. constructor(scene: Scene);
  61871. /**
  61872. * Registers the component in a given scene
  61873. */
  61874. register(): void;
  61875. /**
  61876. * Rebuilds the elements related to this component in case of
  61877. * context lost for instance.
  61878. */
  61879. rebuild(): void;
  61880. /**
  61881. * Disposes the component and the associated ressources
  61882. */
  61883. dispose(): void;
  61884. private _gatherRenderTargets;
  61885. private _gatherActiveCameraRenderTargets;
  61886. }
  61887. }
  61888. declare module BABYLON {
  61889. /** @hidden */
  61890. export var outlinePixelShader: {
  61891. name: string;
  61892. shader: string;
  61893. };
  61894. }
  61895. declare module BABYLON {
  61896. /** @hidden */
  61897. export var outlineVertexShader: {
  61898. name: string;
  61899. shader: string;
  61900. };
  61901. }
  61902. declare module BABYLON {
  61903. interface Scene {
  61904. /** @hidden */
  61905. _outlineRenderer: OutlineRenderer;
  61906. /**
  61907. * Gets the outline renderer associated with the scene
  61908. * @returns a OutlineRenderer
  61909. */
  61910. getOutlineRenderer(): OutlineRenderer;
  61911. }
  61912. interface AbstractMesh {
  61913. /** @hidden (Backing field) */
  61914. _renderOutline: boolean;
  61915. /**
  61916. * Gets or sets a boolean indicating if the outline must be rendered as well
  61917. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61918. */
  61919. renderOutline: boolean;
  61920. /** @hidden (Backing field) */
  61921. _renderOverlay: boolean;
  61922. /**
  61923. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61924. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61925. */
  61926. renderOverlay: boolean;
  61927. }
  61928. /**
  61929. * This class is responsible to draw bothe outline/overlay of meshes.
  61930. * It should not be used directly but through the available method on mesh.
  61931. */
  61932. export class OutlineRenderer implements ISceneComponent {
  61933. /**
  61934. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61935. */
  61936. private static _StencilReference;
  61937. /**
  61938. * The name of the component. Each component must have a unique name.
  61939. */
  61940. name: string;
  61941. /**
  61942. * The scene the component belongs to.
  61943. */
  61944. scene: Scene;
  61945. /**
  61946. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61947. */
  61948. zOffset: number;
  61949. private _engine;
  61950. private _effect;
  61951. private _cachedDefines;
  61952. private _savedDepthWrite;
  61953. /**
  61954. * Instantiates a new outline renderer. (There could be only one per scene).
  61955. * @param scene Defines the scene it belongs to
  61956. */
  61957. constructor(scene: Scene);
  61958. /**
  61959. * Register the component to one instance of a scene.
  61960. */
  61961. register(): void;
  61962. /**
  61963. * Rebuilds the elements related to this component in case of
  61964. * context lost for instance.
  61965. */
  61966. rebuild(): void;
  61967. /**
  61968. * Disposes the component and the associated ressources.
  61969. */
  61970. dispose(): void;
  61971. /**
  61972. * Renders the outline in the canvas.
  61973. * @param subMesh Defines the sumesh to render
  61974. * @param batch Defines the batch of meshes in case of instances
  61975. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61976. */
  61977. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61978. /**
  61979. * Returns whether or not the outline renderer is ready for a given submesh.
  61980. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61981. * @param subMesh Defines the submesh to check readyness for
  61982. * @param useInstances Defines wheter wee are trying to render instances or not
  61983. * @returns true if ready otherwise false
  61984. */
  61985. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61986. private _beforeRenderingMesh;
  61987. private _afterRenderingMesh;
  61988. }
  61989. }
  61990. declare module BABYLON {
  61991. /**
  61992. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61993. * @see http://doc.babylonjs.com/babylon101/sprites
  61994. */
  61995. export class SpritePackedManager extends SpriteManager {
  61996. /** defines the packed manager's name */
  61997. name: string;
  61998. /**
  61999. * Creates a new sprite manager from a packed sprite sheet
  62000. * @param name defines the manager's name
  62001. * @param imgUrl defines the sprite sheet url
  62002. * @param capacity defines the maximum allowed number of sprites
  62003. * @param scene defines the hosting scene
  62004. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62005. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62006. * @param samplingMode defines the smapling mode to use with spritesheet
  62007. * @param fromPacked set to true; do not alter
  62008. */
  62009. constructor(
  62010. /** defines the packed manager's name */
  62011. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62012. }
  62013. }
  62014. declare module BABYLON {
  62015. /**
  62016. * Defines the list of states available for a task inside a AssetsManager
  62017. */
  62018. export enum AssetTaskState {
  62019. /**
  62020. * Initialization
  62021. */
  62022. INIT = 0,
  62023. /**
  62024. * Running
  62025. */
  62026. RUNNING = 1,
  62027. /**
  62028. * Done
  62029. */
  62030. DONE = 2,
  62031. /**
  62032. * Error
  62033. */
  62034. ERROR = 3
  62035. }
  62036. /**
  62037. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62038. */
  62039. export abstract class AbstractAssetTask {
  62040. /**
  62041. * Task name
  62042. */ name: string;
  62043. /**
  62044. * Callback called when the task is successful
  62045. */
  62046. onSuccess: (task: any) => void;
  62047. /**
  62048. * Callback called when the task is not successful
  62049. */
  62050. onError: (task: any, message?: string, exception?: any) => void;
  62051. /**
  62052. * Creates a new AssetsManager
  62053. * @param name defines the name of the task
  62054. */
  62055. constructor(
  62056. /**
  62057. * Task name
  62058. */ name: string);
  62059. private _isCompleted;
  62060. private _taskState;
  62061. private _errorObject;
  62062. /**
  62063. * Get if the task is completed
  62064. */
  62065. readonly isCompleted: boolean;
  62066. /**
  62067. * Gets the current state of the task
  62068. */
  62069. readonly taskState: AssetTaskState;
  62070. /**
  62071. * Gets the current error object (if task is in error)
  62072. */
  62073. readonly errorObject: {
  62074. message?: string;
  62075. exception?: any;
  62076. };
  62077. /**
  62078. * Internal only
  62079. * @hidden
  62080. */
  62081. _setErrorObject(message?: string, exception?: any): void;
  62082. /**
  62083. * Execute the current task
  62084. * @param scene defines the scene where you want your assets to be loaded
  62085. * @param onSuccess is a callback called when the task is successfully executed
  62086. * @param onError is a callback called if an error occurs
  62087. */
  62088. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62089. /**
  62090. * Execute the current task
  62091. * @param scene defines the scene where you want your assets to be loaded
  62092. * @param onSuccess is a callback called when the task is successfully executed
  62093. * @param onError is a callback called if an error occurs
  62094. */
  62095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62096. /**
  62097. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62098. * This can be used with failed tasks that have the reason for failure fixed.
  62099. */
  62100. reset(): void;
  62101. private onErrorCallback;
  62102. private onDoneCallback;
  62103. }
  62104. /**
  62105. * Define the interface used by progress events raised during assets loading
  62106. */
  62107. export interface IAssetsProgressEvent {
  62108. /**
  62109. * Defines the number of remaining tasks to process
  62110. */
  62111. remainingCount: number;
  62112. /**
  62113. * Defines the total number of tasks
  62114. */
  62115. totalCount: number;
  62116. /**
  62117. * Defines the task that was just processed
  62118. */
  62119. task: AbstractAssetTask;
  62120. }
  62121. /**
  62122. * Class used to share progress information about assets loading
  62123. */
  62124. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62125. /**
  62126. * Defines the number of remaining tasks to process
  62127. */
  62128. remainingCount: number;
  62129. /**
  62130. * Defines the total number of tasks
  62131. */
  62132. totalCount: number;
  62133. /**
  62134. * Defines the task that was just processed
  62135. */
  62136. task: AbstractAssetTask;
  62137. /**
  62138. * Creates a AssetsProgressEvent
  62139. * @param remainingCount defines the number of remaining tasks to process
  62140. * @param totalCount defines the total number of tasks
  62141. * @param task defines the task that was just processed
  62142. */
  62143. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62144. }
  62145. /**
  62146. * Define a task used by AssetsManager to load meshes
  62147. */
  62148. export class MeshAssetTask extends AbstractAssetTask {
  62149. /**
  62150. * Defines the name of the task
  62151. */
  62152. name: string;
  62153. /**
  62154. * Defines the list of mesh's names you want to load
  62155. */
  62156. meshesNames: any;
  62157. /**
  62158. * Defines the root url to use as a base to load your meshes and associated resources
  62159. */
  62160. rootUrl: string;
  62161. /**
  62162. * Defines the filename of the scene to load from
  62163. */
  62164. sceneFilename: string;
  62165. /**
  62166. * Gets the list of loaded meshes
  62167. */
  62168. loadedMeshes: Array<AbstractMesh>;
  62169. /**
  62170. * Gets the list of loaded particle systems
  62171. */
  62172. loadedParticleSystems: Array<IParticleSystem>;
  62173. /**
  62174. * Gets the list of loaded skeletons
  62175. */
  62176. loadedSkeletons: Array<Skeleton>;
  62177. /**
  62178. * Gets the list of loaded animation groups
  62179. */
  62180. loadedAnimationGroups: Array<AnimationGroup>;
  62181. /**
  62182. * Callback called when the task is successful
  62183. */
  62184. onSuccess: (task: MeshAssetTask) => void;
  62185. /**
  62186. * Callback called when the task is successful
  62187. */
  62188. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62189. /**
  62190. * Creates a new MeshAssetTask
  62191. * @param name defines the name of the task
  62192. * @param meshesNames defines the list of mesh's names you want to load
  62193. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62194. * @param sceneFilename defines the filename of the scene to load from
  62195. */
  62196. constructor(
  62197. /**
  62198. * Defines the name of the task
  62199. */
  62200. name: string,
  62201. /**
  62202. * Defines the list of mesh's names you want to load
  62203. */
  62204. meshesNames: any,
  62205. /**
  62206. * Defines the root url to use as a base to load your meshes and associated resources
  62207. */
  62208. rootUrl: string,
  62209. /**
  62210. * Defines the filename of the scene to load from
  62211. */
  62212. sceneFilename: string);
  62213. /**
  62214. * Execute the current task
  62215. * @param scene defines the scene where you want your assets to be loaded
  62216. * @param onSuccess is a callback called when the task is successfully executed
  62217. * @param onError is a callback called if an error occurs
  62218. */
  62219. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62220. }
  62221. /**
  62222. * Define a task used by AssetsManager to load text content
  62223. */
  62224. export class TextFileAssetTask extends AbstractAssetTask {
  62225. /**
  62226. * Defines the name of the task
  62227. */
  62228. name: string;
  62229. /**
  62230. * Defines the location of the file to load
  62231. */
  62232. url: string;
  62233. /**
  62234. * Gets the loaded text string
  62235. */
  62236. text: string;
  62237. /**
  62238. * Callback called when the task is successful
  62239. */
  62240. onSuccess: (task: TextFileAssetTask) => void;
  62241. /**
  62242. * Callback called when the task is successful
  62243. */
  62244. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62245. /**
  62246. * Creates a new TextFileAssetTask object
  62247. * @param name defines the name of the task
  62248. * @param url defines the location of the file to load
  62249. */
  62250. constructor(
  62251. /**
  62252. * Defines the name of the task
  62253. */
  62254. name: string,
  62255. /**
  62256. * Defines the location of the file to load
  62257. */
  62258. url: string);
  62259. /**
  62260. * Execute the current task
  62261. * @param scene defines the scene where you want your assets to be loaded
  62262. * @param onSuccess is a callback called when the task is successfully executed
  62263. * @param onError is a callback called if an error occurs
  62264. */
  62265. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62266. }
  62267. /**
  62268. * Define a task used by AssetsManager to load binary data
  62269. */
  62270. export class BinaryFileAssetTask extends AbstractAssetTask {
  62271. /**
  62272. * Defines the name of the task
  62273. */
  62274. name: string;
  62275. /**
  62276. * Defines the location of the file to load
  62277. */
  62278. url: string;
  62279. /**
  62280. * Gets the lodaded data (as an array buffer)
  62281. */
  62282. data: ArrayBuffer;
  62283. /**
  62284. * Callback called when the task is successful
  62285. */
  62286. onSuccess: (task: BinaryFileAssetTask) => void;
  62287. /**
  62288. * Callback called when the task is successful
  62289. */
  62290. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62291. /**
  62292. * Creates a new BinaryFileAssetTask object
  62293. * @param name defines the name of the new task
  62294. * @param url defines the location of the file to load
  62295. */
  62296. constructor(
  62297. /**
  62298. * Defines the name of the task
  62299. */
  62300. name: string,
  62301. /**
  62302. * Defines the location of the file to load
  62303. */
  62304. url: string);
  62305. /**
  62306. * Execute the current task
  62307. * @param scene defines the scene where you want your assets to be loaded
  62308. * @param onSuccess is a callback called when the task is successfully executed
  62309. * @param onError is a callback called if an error occurs
  62310. */
  62311. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62312. }
  62313. /**
  62314. * Define a task used by AssetsManager to load images
  62315. */
  62316. export class ImageAssetTask extends AbstractAssetTask {
  62317. /**
  62318. * Defines the name of the task
  62319. */
  62320. name: string;
  62321. /**
  62322. * Defines the location of the image to load
  62323. */
  62324. url: string;
  62325. /**
  62326. * Gets the loaded images
  62327. */
  62328. image: HTMLImageElement;
  62329. /**
  62330. * Callback called when the task is successful
  62331. */
  62332. onSuccess: (task: ImageAssetTask) => void;
  62333. /**
  62334. * Callback called when the task is successful
  62335. */
  62336. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62337. /**
  62338. * Creates a new ImageAssetTask
  62339. * @param name defines the name of the task
  62340. * @param url defines the location of the image to load
  62341. */
  62342. constructor(
  62343. /**
  62344. * Defines the name of the task
  62345. */
  62346. name: string,
  62347. /**
  62348. * Defines the location of the image to load
  62349. */
  62350. url: string);
  62351. /**
  62352. * Execute the current task
  62353. * @param scene defines the scene where you want your assets to be loaded
  62354. * @param onSuccess is a callback called when the task is successfully executed
  62355. * @param onError is a callback called if an error occurs
  62356. */
  62357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62358. }
  62359. /**
  62360. * Defines the interface used by texture loading tasks
  62361. */
  62362. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62363. /**
  62364. * Gets the loaded texture
  62365. */
  62366. texture: TEX;
  62367. }
  62368. /**
  62369. * Define a task used by AssetsManager to load 2D textures
  62370. */
  62371. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62372. /**
  62373. * Defines the name of the task
  62374. */
  62375. name: string;
  62376. /**
  62377. * Defines the location of the file to load
  62378. */
  62379. url: string;
  62380. /**
  62381. * Defines if mipmap should not be generated (default is false)
  62382. */
  62383. noMipmap?: boolean | undefined;
  62384. /**
  62385. * Defines if texture must be inverted on Y axis (default is false)
  62386. */
  62387. invertY?: boolean | undefined;
  62388. /**
  62389. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62390. */
  62391. samplingMode: number;
  62392. /**
  62393. * Gets the loaded texture
  62394. */
  62395. texture: Texture;
  62396. /**
  62397. * Callback called when the task is successful
  62398. */
  62399. onSuccess: (task: TextureAssetTask) => void;
  62400. /**
  62401. * Callback called when the task is successful
  62402. */
  62403. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62404. /**
  62405. * Creates a new TextureAssetTask object
  62406. * @param name defines the name of the task
  62407. * @param url defines the location of the file to load
  62408. * @param noMipmap defines if mipmap should not be generated (default is false)
  62409. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62410. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62411. */
  62412. constructor(
  62413. /**
  62414. * Defines the name of the task
  62415. */
  62416. name: string,
  62417. /**
  62418. * Defines the location of the file to load
  62419. */
  62420. url: string,
  62421. /**
  62422. * Defines if mipmap should not be generated (default is false)
  62423. */
  62424. noMipmap?: boolean | undefined,
  62425. /**
  62426. * Defines if texture must be inverted on Y axis (default is false)
  62427. */
  62428. invertY?: boolean | undefined,
  62429. /**
  62430. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62431. */
  62432. samplingMode?: number);
  62433. /**
  62434. * Execute the current task
  62435. * @param scene defines the scene where you want your assets to be loaded
  62436. * @param onSuccess is a callback called when the task is successfully executed
  62437. * @param onError is a callback called if an error occurs
  62438. */
  62439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62440. }
  62441. /**
  62442. * Define a task used by AssetsManager to load cube textures
  62443. */
  62444. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62445. /**
  62446. * Defines the name of the task
  62447. */
  62448. name: string;
  62449. /**
  62450. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62451. */
  62452. url: string;
  62453. /**
  62454. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62455. */
  62456. extensions?: string[] | undefined;
  62457. /**
  62458. * Defines if mipmaps should not be generated (default is false)
  62459. */
  62460. noMipmap?: boolean | undefined;
  62461. /**
  62462. * Defines the explicit list of files (undefined by default)
  62463. */
  62464. files?: string[] | undefined;
  62465. /**
  62466. * Gets the loaded texture
  62467. */
  62468. texture: CubeTexture;
  62469. /**
  62470. * Callback called when the task is successful
  62471. */
  62472. onSuccess: (task: CubeTextureAssetTask) => void;
  62473. /**
  62474. * Callback called when the task is successful
  62475. */
  62476. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62477. /**
  62478. * Creates a new CubeTextureAssetTask
  62479. * @param name defines the name of the task
  62480. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62481. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62482. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62483. * @param files defines the explicit list of files (undefined by default)
  62484. */
  62485. constructor(
  62486. /**
  62487. * Defines the name of the task
  62488. */
  62489. name: string,
  62490. /**
  62491. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62492. */
  62493. url: string,
  62494. /**
  62495. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62496. */
  62497. extensions?: string[] | undefined,
  62498. /**
  62499. * Defines if mipmaps should not be generated (default is false)
  62500. */
  62501. noMipmap?: boolean | undefined,
  62502. /**
  62503. * Defines the explicit list of files (undefined by default)
  62504. */
  62505. files?: string[] | undefined);
  62506. /**
  62507. * Execute the current task
  62508. * @param scene defines the scene where you want your assets to be loaded
  62509. * @param onSuccess is a callback called when the task is successfully executed
  62510. * @param onError is a callback called if an error occurs
  62511. */
  62512. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62513. }
  62514. /**
  62515. * Define a task used by AssetsManager to load HDR cube textures
  62516. */
  62517. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62518. /**
  62519. * Defines the name of the task
  62520. */
  62521. name: string;
  62522. /**
  62523. * Defines the location of the file to load
  62524. */
  62525. url: string;
  62526. /**
  62527. * Defines the desired size (the more it increases the longer the generation will be)
  62528. */
  62529. size: number;
  62530. /**
  62531. * Defines if mipmaps should not be generated (default is false)
  62532. */
  62533. noMipmap: boolean;
  62534. /**
  62535. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62536. */
  62537. generateHarmonics: boolean;
  62538. /**
  62539. * 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)
  62540. */
  62541. gammaSpace: boolean;
  62542. /**
  62543. * Internal Use Only
  62544. */
  62545. reserved: boolean;
  62546. /**
  62547. * Gets the loaded texture
  62548. */
  62549. texture: HDRCubeTexture;
  62550. /**
  62551. * Callback called when the task is successful
  62552. */
  62553. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62554. /**
  62555. * Callback called when the task is successful
  62556. */
  62557. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62558. /**
  62559. * Creates a new HDRCubeTextureAssetTask object
  62560. * @param name defines the name of the task
  62561. * @param url defines the location of the file to load
  62562. * @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.
  62563. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62564. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62565. * @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)
  62566. * @param reserved Internal use only
  62567. */
  62568. constructor(
  62569. /**
  62570. * Defines the name of the task
  62571. */
  62572. name: string,
  62573. /**
  62574. * Defines the location of the file to load
  62575. */
  62576. url: string,
  62577. /**
  62578. * Defines the desired size (the more it increases the longer the generation will be)
  62579. */
  62580. size: number,
  62581. /**
  62582. * Defines if mipmaps should not be generated (default is false)
  62583. */
  62584. noMipmap?: boolean,
  62585. /**
  62586. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62587. */
  62588. generateHarmonics?: boolean,
  62589. /**
  62590. * 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)
  62591. */
  62592. gammaSpace?: boolean,
  62593. /**
  62594. * Internal Use Only
  62595. */
  62596. reserved?: boolean);
  62597. /**
  62598. * Execute the current task
  62599. * @param scene defines the scene where you want your assets to be loaded
  62600. * @param onSuccess is a callback called when the task is successfully executed
  62601. * @param onError is a callback called if an error occurs
  62602. */
  62603. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62604. }
  62605. /**
  62606. * Define a task used by AssetsManager to load Equirectangular cube textures
  62607. */
  62608. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62609. /**
  62610. * Defines the name of the task
  62611. */
  62612. name: string;
  62613. /**
  62614. * Defines the location of the file to load
  62615. */
  62616. url: string;
  62617. /**
  62618. * Defines the desired size (the more it increases the longer the generation will be)
  62619. */
  62620. size: number;
  62621. /**
  62622. * Defines if mipmaps should not be generated (default is false)
  62623. */
  62624. noMipmap: boolean;
  62625. /**
  62626. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62627. * but the standard material would require them in Gamma space) (default is true)
  62628. */
  62629. gammaSpace: boolean;
  62630. /**
  62631. * Gets the loaded texture
  62632. */
  62633. texture: EquiRectangularCubeTexture;
  62634. /**
  62635. * Callback called when the task is successful
  62636. */
  62637. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62638. /**
  62639. * Callback called when the task is successful
  62640. */
  62641. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62642. /**
  62643. * Creates a new EquiRectangularCubeTextureAssetTask object
  62644. * @param name defines the name of the task
  62645. * @param url defines the location of the file to load
  62646. * @param size defines the desired size (the more it increases the longer the generation will be)
  62647. * If the size is omitted this implies you are using a preprocessed cubemap.
  62648. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62649. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62650. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62651. * (default is true)
  62652. */
  62653. constructor(
  62654. /**
  62655. * Defines the name of the task
  62656. */
  62657. name: string,
  62658. /**
  62659. * Defines the location of the file to load
  62660. */
  62661. url: string,
  62662. /**
  62663. * Defines the desired size (the more it increases the longer the generation will be)
  62664. */
  62665. size: number,
  62666. /**
  62667. * Defines if mipmaps should not be generated (default is false)
  62668. */
  62669. noMipmap?: boolean,
  62670. /**
  62671. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62672. * but the standard material would require them in Gamma space) (default is true)
  62673. */
  62674. gammaSpace?: boolean);
  62675. /**
  62676. * Execute the current task
  62677. * @param scene defines the scene where you want your assets to be loaded
  62678. * @param onSuccess is a callback called when the task is successfully executed
  62679. * @param onError is a callback called if an error occurs
  62680. */
  62681. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62682. }
  62683. /**
  62684. * This class can be used to easily import assets into a scene
  62685. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62686. */
  62687. export class AssetsManager {
  62688. private _scene;
  62689. private _isLoading;
  62690. protected _tasks: AbstractAssetTask[];
  62691. protected _waitingTasksCount: number;
  62692. protected _totalTasksCount: number;
  62693. /**
  62694. * Callback called when all tasks are processed
  62695. */
  62696. onFinish: (tasks: AbstractAssetTask[]) => void;
  62697. /**
  62698. * Callback called when a task is successful
  62699. */
  62700. onTaskSuccess: (task: AbstractAssetTask) => void;
  62701. /**
  62702. * Callback called when a task had an error
  62703. */
  62704. onTaskError: (task: AbstractAssetTask) => void;
  62705. /**
  62706. * Callback called when a task is done (whatever the result is)
  62707. */
  62708. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62709. /**
  62710. * Observable called when all tasks are processed
  62711. */
  62712. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62713. /**
  62714. * Observable called when a task had an error
  62715. */
  62716. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62717. /**
  62718. * Observable called when all tasks were executed
  62719. */
  62720. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62721. /**
  62722. * Observable called when a task is done (whatever the result is)
  62723. */
  62724. onProgressObservable: Observable<IAssetsProgressEvent>;
  62725. /**
  62726. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62727. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62728. */
  62729. useDefaultLoadingScreen: boolean;
  62730. /**
  62731. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62732. * when all assets have been downloaded.
  62733. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62734. */
  62735. autoHideLoadingUI: boolean;
  62736. /**
  62737. * Creates a new AssetsManager
  62738. * @param scene defines the scene to work on
  62739. */
  62740. constructor(scene: Scene);
  62741. /**
  62742. * Add a MeshAssetTask to the list of active tasks
  62743. * @param taskName defines the name of the new task
  62744. * @param meshesNames defines the name of meshes to load
  62745. * @param rootUrl defines the root url to use to locate files
  62746. * @param sceneFilename defines the filename of the scene file
  62747. * @returns a new MeshAssetTask object
  62748. */
  62749. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62750. /**
  62751. * Add a TextFileAssetTask to the list of active tasks
  62752. * @param taskName defines the name of the new task
  62753. * @param url defines the url of the file to load
  62754. * @returns a new TextFileAssetTask object
  62755. */
  62756. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62757. /**
  62758. * Add a BinaryFileAssetTask to the list of active tasks
  62759. * @param taskName defines the name of the new task
  62760. * @param url defines the url of the file to load
  62761. * @returns a new BinaryFileAssetTask object
  62762. */
  62763. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62764. /**
  62765. * Add a ImageAssetTask to the list of active tasks
  62766. * @param taskName defines the name of the new task
  62767. * @param url defines the url of the file to load
  62768. * @returns a new ImageAssetTask object
  62769. */
  62770. addImageTask(taskName: string, url: string): ImageAssetTask;
  62771. /**
  62772. * Add a TextureAssetTask to the list of active tasks
  62773. * @param taskName defines the name of the new task
  62774. * @param url defines the url of the file to load
  62775. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62776. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62777. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62778. * @returns a new TextureAssetTask object
  62779. */
  62780. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62781. /**
  62782. * Add a CubeTextureAssetTask to the list of active tasks
  62783. * @param taskName defines the name of the new task
  62784. * @param url defines the url of the file to load
  62785. * @param extensions defines the extension to use to load the cube map (can be null)
  62786. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62787. * @param files defines the list of files to load (can be null)
  62788. * @returns a new CubeTextureAssetTask object
  62789. */
  62790. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62791. /**
  62792. *
  62793. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62794. * @param taskName defines the name of the new task
  62795. * @param url defines the url of the file to load
  62796. * @param size defines the size you want for the cubemap (can be null)
  62797. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62798. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62799. * @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)
  62800. * @param reserved Internal use only
  62801. * @returns a new HDRCubeTextureAssetTask object
  62802. */
  62803. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62804. /**
  62805. *
  62806. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62807. * @param taskName defines the name of the new task
  62808. * @param url defines the url of the file to load
  62809. * @param size defines the size you want for the cubemap (can be null)
  62810. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62811. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62812. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62813. * @returns a new EquiRectangularCubeTextureAssetTask object
  62814. */
  62815. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62816. /**
  62817. * Remove a task from the assets manager.
  62818. * @param task the task to remove
  62819. */
  62820. removeTask(task: AbstractAssetTask): void;
  62821. private _decreaseWaitingTasksCount;
  62822. private _runTask;
  62823. /**
  62824. * Reset the AssetsManager and remove all tasks
  62825. * @return the current instance of the AssetsManager
  62826. */
  62827. reset(): AssetsManager;
  62828. /**
  62829. * Start the loading process
  62830. * @return the current instance of the AssetsManager
  62831. */
  62832. load(): AssetsManager;
  62833. /**
  62834. * Start the loading process as an async operation
  62835. * @return a promise returning the list of failed tasks
  62836. */
  62837. loadAsync(): Promise<void>;
  62838. }
  62839. }
  62840. declare module BABYLON {
  62841. /**
  62842. * Wrapper class for promise with external resolve and reject.
  62843. */
  62844. export class Deferred<T> {
  62845. /**
  62846. * The promise associated with this deferred object.
  62847. */
  62848. readonly promise: Promise<T>;
  62849. private _resolve;
  62850. private _reject;
  62851. /**
  62852. * The resolve method of the promise associated with this deferred object.
  62853. */
  62854. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62855. /**
  62856. * The reject method of the promise associated with this deferred object.
  62857. */
  62858. readonly reject: (reason?: any) => void;
  62859. /**
  62860. * Constructor for this deferred object.
  62861. */
  62862. constructor();
  62863. }
  62864. }
  62865. declare module BABYLON {
  62866. /**
  62867. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62868. */
  62869. export class MeshExploder {
  62870. private _centerMesh;
  62871. private _meshes;
  62872. private _meshesOrigins;
  62873. private _toCenterVectors;
  62874. private _scaledDirection;
  62875. private _newPosition;
  62876. private _centerPosition;
  62877. /**
  62878. * Explodes meshes from a center mesh.
  62879. * @param meshes The meshes to explode.
  62880. * @param centerMesh The mesh to be center of explosion.
  62881. */
  62882. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62883. private _setCenterMesh;
  62884. /**
  62885. * Get class name
  62886. * @returns "MeshExploder"
  62887. */
  62888. getClassName(): string;
  62889. /**
  62890. * "Exploded meshes"
  62891. * @returns Array of meshes with the centerMesh at index 0.
  62892. */
  62893. getMeshes(): Array<Mesh>;
  62894. /**
  62895. * Explodes meshes giving a specific direction
  62896. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62897. */
  62898. explode(direction?: number): void;
  62899. }
  62900. }
  62901. declare module BABYLON {
  62902. /**
  62903. * Class used to help managing file picking and drag'n'drop
  62904. */
  62905. export class FilesInput {
  62906. /**
  62907. * List of files ready to be loaded
  62908. */
  62909. static readonly FilesToLoad: {
  62910. [key: string]: File;
  62911. };
  62912. /**
  62913. * Callback called when a file is processed
  62914. */
  62915. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62916. private _engine;
  62917. private _currentScene;
  62918. private _sceneLoadedCallback;
  62919. private _progressCallback;
  62920. private _additionalRenderLoopLogicCallback;
  62921. private _textureLoadingCallback;
  62922. private _startingProcessingFilesCallback;
  62923. private _onReloadCallback;
  62924. private _errorCallback;
  62925. private _elementToMonitor;
  62926. private _sceneFileToLoad;
  62927. private _filesToLoad;
  62928. /**
  62929. * Creates a new FilesInput
  62930. * @param engine defines the rendering engine
  62931. * @param scene defines the hosting scene
  62932. * @param sceneLoadedCallback callback called when scene is loaded
  62933. * @param progressCallback callback called to track progress
  62934. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62935. * @param textureLoadingCallback callback called when a texture is loading
  62936. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62937. * @param onReloadCallback callback called when a reload is requested
  62938. * @param errorCallback callback call if an error occurs
  62939. */
  62940. 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);
  62941. private _dragEnterHandler;
  62942. private _dragOverHandler;
  62943. private _dropHandler;
  62944. /**
  62945. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62946. * @param elementToMonitor defines the DOM element to track
  62947. */
  62948. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62949. /**
  62950. * Release all associated resources
  62951. */
  62952. dispose(): void;
  62953. private renderFunction;
  62954. private drag;
  62955. private drop;
  62956. private _traverseFolder;
  62957. private _processFiles;
  62958. /**
  62959. * Load files from a drop event
  62960. * @param event defines the drop event to use as source
  62961. */
  62962. loadFiles(event: any): void;
  62963. private _processReload;
  62964. /**
  62965. * Reload the current scene from the loaded files
  62966. */
  62967. reload(): void;
  62968. }
  62969. }
  62970. declare module BABYLON {
  62971. /**
  62972. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62974. */
  62975. export class SceneOptimization {
  62976. /**
  62977. * Defines the priority of this optimization (0 by default which means first in the list)
  62978. */
  62979. priority: number;
  62980. /**
  62981. * Gets a string describing the action executed by the current optimization
  62982. * @returns description string
  62983. */
  62984. getDescription(): string;
  62985. /**
  62986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62987. * @param scene defines the current scene where to apply this optimization
  62988. * @param optimizer defines the current optimizer
  62989. * @returns true if everything that can be done was applied
  62990. */
  62991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62992. /**
  62993. * Creates the SceneOptimization object
  62994. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62995. * @param desc defines the description associated with the optimization
  62996. */
  62997. constructor(
  62998. /**
  62999. * Defines the priority of this optimization (0 by default which means first in the list)
  63000. */
  63001. priority?: number);
  63002. }
  63003. /**
  63004. * Defines an optimization used to reduce the size of render target textures
  63005. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63006. */
  63007. export class TextureOptimization extends SceneOptimization {
  63008. /**
  63009. * Defines the priority of this optimization (0 by default which means first in the list)
  63010. */
  63011. priority: number;
  63012. /**
  63013. * 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
  63014. */
  63015. maximumSize: number;
  63016. /**
  63017. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63018. */
  63019. step: number;
  63020. /**
  63021. * Gets a string describing the action executed by the current optimization
  63022. * @returns description string
  63023. */
  63024. getDescription(): string;
  63025. /**
  63026. * Creates the TextureOptimization object
  63027. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63028. * @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
  63029. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63030. */
  63031. constructor(
  63032. /**
  63033. * Defines the priority of this optimization (0 by default which means first in the list)
  63034. */
  63035. priority?: number,
  63036. /**
  63037. * 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
  63038. */
  63039. maximumSize?: number,
  63040. /**
  63041. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63042. */
  63043. step?: number);
  63044. /**
  63045. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63046. * @param scene defines the current scene where to apply this optimization
  63047. * @param optimizer defines the current optimizer
  63048. * @returns true if everything that can be done was applied
  63049. */
  63050. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63051. }
  63052. /**
  63053. * Defines an optimization used to increase or decrease the rendering resolution
  63054. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63055. */
  63056. export class HardwareScalingOptimization extends SceneOptimization {
  63057. /**
  63058. * Defines the priority of this optimization (0 by default which means first in the list)
  63059. */
  63060. priority: number;
  63061. /**
  63062. * Defines the maximum scale to use (2 by default)
  63063. */
  63064. maximumScale: number;
  63065. /**
  63066. * Defines the step to use between two passes (0.5 by default)
  63067. */
  63068. step: number;
  63069. private _currentScale;
  63070. private _directionOffset;
  63071. /**
  63072. * Gets a string describing the action executed by the current optimization
  63073. * @return description string
  63074. */
  63075. getDescription(): string;
  63076. /**
  63077. * Creates the HardwareScalingOptimization object
  63078. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63079. * @param maximumScale defines the maximum scale to use (2 by default)
  63080. * @param step defines the step to use between two passes (0.5 by default)
  63081. */
  63082. constructor(
  63083. /**
  63084. * Defines the priority of this optimization (0 by default which means first in the list)
  63085. */
  63086. priority?: number,
  63087. /**
  63088. * Defines the maximum scale to use (2 by default)
  63089. */
  63090. maximumScale?: number,
  63091. /**
  63092. * Defines the step to use between two passes (0.5 by default)
  63093. */
  63094. step?: number);
  63095. /**
  63096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63097. * @param scene defines the current scene where to apply this optimization
  63098. * @param optimizer defines the current optimizer
  63099. * @returns true if everything that can be done was applied
  63100. */
  63101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63102. }
  63103. /**
  63104. * Defines an optimization used to remove shadows
  63105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63106. */
  63107. export class ShadowsOptimization extends SceneOptimization {
  63108. /**
  63109. * Gets a string describing the action executed by the current optimization
  63110. * @return description string
  63111. */
  63112. getDescription(): string;
  63113. /**
  63114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63115. * @param scene defines the current scene where to apply this optimization
  63116. * @param optimizer defines the current optimizer
  63117. * @returns true if everything that can be done was applied
  63118. */
  63119. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63120. }
  63121. /**
  63122. * Defines an optimization used to turn post-processes off
  63123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63124. */
  63125. export class PostProcessesOptimization extends SceneOptimization {
  63126. /**
  63127. * Gets a string describing the action executed by the current optimization
  63128. * @return description string
  63129. */
  63130. getDescription(): string;
  63131. /**
  63132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63133. * @param scene defines the current scene where to apply this optimization
  63134. * @param optimizer defines the current optimizer
  63135. * @returns true if everything that can be done was applied
  63136. */
  63137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63138. }
  63139. /**
  63140. * Defines an optimization used to turn lens flares off
  63141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63142. */
  63143. export class LensFlaresOptimization extends SceneOptimization {
  63144. /**
  63145. * Gets a string describing the action executed by the current optimization
  63146. * @return description string
  63147. */
  63148. getDescription(): string;
  63149. /**
  63150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63151. * @param scene defines the current scene where to apply this optimization
  63152. * @param optimizer defines the current optimizer
  63153. * @returns true if everything that can be done was applied
  63154. */
  63155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63156. }
  63157. /**
  63158. * Defines an optimization based on user defined callback.
  63159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63160. */
  63161. export class CustomOptimization extends SceneOptimization {
  63162. /**
  63163. * Callback called to apply the custom optimization.
  63164. */
  63165. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63166. /**
  63167. * Callback called to get custom description
  63168. */
  63169. onGetDescription: () => string;
  63170. /**
  63171. * Gets a string describing the action executed by the current optimization
  63172. * @returns description string
  63173. */
  63174. getDescription(): string;
  63175. /**
  63176. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63177. * @param scene defines the current scene where to apply this optimization
  63178. * @param optimizer defines the current optimizer
  63179. * @returns true if everything that can be done was applied
  63180. */
  63181. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63182. }
  63183. /**
  63184. * Defines an optimization used to turn particles off
  63185. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63186. */
  63187. export class ParticlesOptimization extends SceneOptimization {
  63188. /**
  63189. * Gets a string describing the action executed by the current optimization
  63190. * @return description string
  63191. */
  63192. getDescription(): string;
  63193. /**
  63194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63195. * @param scene defines the current scene where to apply this optimization
  63196. * @param optimizer defines the current optimizer
  63197. * @returns true if everything that can be done was applied
  63198. */
  63199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63200. }
  63201. /**
  63202. * Defines an optimization used to turn render targets off
  63203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63204. */
  63205. export class RenderTargetsOptimization extends SceneOptimization {
  63206. /**
  63207. * Gets a string describing the action executed by the current optimization
  63208. * @return description string
  63209. */
  63210. getDescription(): string;
  63211. /**
  63212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63213. * @param scene defines the current scene where to apply this optimization
  63214. * @param optimizer defines the current optimizer
  63215. * @returns true if everything that can be done was applied
  63216. */
  63217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63218. }
  63219. /**
  63220. * Defines an optimization used to merge meshes with compatible materials
  63221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63222. */
  63223. export class MergeMeshesOptimization extends SceneOptimization {
  63224. private static _UpdateSelectionTree;
  63225. /**
  63226. * Gets or sets a boolean which defines if optimization octree has to be updated
  63227. */
  63228. /**
  63229. * Gets or sets a boolean which defines if optimization octree has to be updated
  63230. */
  63231. static UpdateSelectionTree: boolean;
  63232. /**
  63233. * Gets a string describing the action executed by the current optimization
  63234. * @return description string
  63235. */
  63236. getDescription(): string;
  63237. private _canBeMerged;
  63238. /**
  63239. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63240. * @param scene defines the current scene where to apply this optimization
  63241. * @param optimizer defines the current optimizer
  63242. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63243. * @returns true if everything that can be done was applied
  63244. */
  63245. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63246. }
  63247. /**
  63248. * Defines a list of options used by SceneOptimizer
  63249. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63250. */
  63251. export class SceneOptimizerOptions {
  63252. /**
  63253. * Defines the target frame rate to reach (60 by default)
  63254. */
  63255. targetFrameRate: number;
  63256. /**
  63257. * Defines the interval between two checkes (2000ms by default)
  63258. */
  63259. trackerDuration: number;
  63260. /**
  63261. * Gets the list of optimizations to apply
  63262. */
  63263. optimizations: SceneOptimization[];
  63264. /**
  63265. * Creates a new list of options used by SceneOptimizer
  63266. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63267. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63268. */
  63269. constructor(
  63270. /**
  63271. * Defines the target frame rate to reach (60 by default)
  63272. */
  63273. targetFrameRate?: number,
  63274. /**
  63275. * Defines the interval between two checkes (2000ms by default)
  63276. */
  63277. trackerDuration?: number);
  63278. /**
  63279. * Add a new optimization
  63280. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63281. * @returns the current SceneOptimizerOptions
  63282. */
  63283. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63284. /**
  63285. * Add a new custom optimization
  63286. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63287. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63288. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63289. * @returns the current SceneOptimizerOptions
  63290. */
  63291. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63292. /**
  63293. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63294. * @param targetFrameRate defines the target frame rate (60 by default)
  63295. * @returns a SceneOptimizerOptions object
  63296. */
  63297. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63298. /**
  63299. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63300. * @param targetFrameRate defines the target frame rate (60 by default)
  63301. * @returns a SceneOptimizerOptions object
  63302. */
  63303. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63304. /**
  63305. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63306. * @param targetFrameRate defines the target frame rate (60 by default)
  63307. * @returns a SceneOptimizerOptions object
  63308. */
  63309. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63310. }
  63311. /**
  63312. * Class used to run optimizations in order to reach a target frame rate
  63313. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63314. */
  63315. export class SceneOptimizer implements IDisposable {
  63316. private _isRunning;
  63317. private _options;
  63318. private _scene;
  63319. private _currentPriorityLevel;
  63320. private _targetFrameRate;
  63321. private _trackerDuration;
  63322. private _currentFrameRate;
  63323. private _sceneDisposeObserver;
  63324. private _improvementMode;
  63325. /**
  63326. * Defines an observable called when the optimizer reaches the target frame rate
  63327. */
  63328. onSuccessObservable: Observable<SceneOptimizer>;
  63329. /**
  63330. * Defines an observable called when the optimizer enables an optimization
  63331. */
  63332. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63333. /**
  63334. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63335. */
  63336. onFailureObservable: Observable<SceneOptimizer>;
  63337. /**
  63338. * Gets a boolean indicating if the optimizer is in improvement mode
  63339. */
  63340. readonly isInImprovementMode: boolean;
  63341. /**
  63342. * Gets the current priority level (0 at start)
  63343. */
  63344. readonly currentPriorityLevel: number;
  63345. /**
  63346. * Gets the current frame rate checked by the SceneOptimizer
  63347. */
  63348. readonly currentFrameRate: number;
  63349. /**
  63350. * Gets or sets the current target frame rate (60 by default)
  63351. */
  63352. /**
  63353. * Gets or sets the current target frame rate (60 by default)
  63354. */
  63355. targetFrameRate: number;
  63356. /**
  63357. * Gets or sets the current interval between two checks (every 2000ms by default)
  63358. */
  63359. /**
  63360. * Gets or sets the current interval between two checks (every 2000ms by default)
  63361. */
  63362. trackerDuration: number;
  63363. /**
  63364. * Gets the list of active optimizations
  63365. */
  63366. readonly optimizations: SceneOptimization[];
  63367. /**
  63368. * Creates a new SceneOptimizer
  63369. * @param scene defines the scene to work on
  63370. * @param options defines the options to use with the SceneOptimizer
  63371. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63372. * @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)
  63373. */
  63374. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63375. /**
  63376. * Stops the current optimizer
  63377. */
  63378. stop(): void;
  63379. /**
  63380. * Reset the optimizer to initial step (current priority level = 0)
  63381. */
  63382. reset(): void;
  63383. /**
  63384. * Start the optimizer. By default it will try to reach a specific framerate
  63385. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63386. */
  63387. start(): void;
  63388. private _checkCurrentState;
  63389. /**
  63390. * Release all resources
  63391. */
  63392. dispose(): void;
  63393. /**
  63394. * Helper function to create a SceneOptimizer with one single line of code
  63395. * @param scene defines the scene to work on
  63396. * @param options defines the options to use with the SceneOptimizer
  63397. * @param onSuccess defines a callback to call on success
  63398. * @param onFailure defines a callback to call on failure
  63399. * @returns the new SceneOptimizer object
  63400. */
  63401. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63402. }
  63403. }
  63404. declare module BABYLON {
  63405. /**
  63406. * Class used to serialize a scene into a string
  63407. */
  63408. export class SceneSerializer {
  63409. /**
  63410. * Clear cache used by a previous serialization
  63411. */
  63412. static ClearCache(): void;
  63413. /**
  63414. * Serialize a scene into a JSON compatible object
  63415. * @param scene defines the scene to serialize
  63416. * @returns a JSON compatible object
  63417. */
  63418. static Serialize(scene: Scene): any;
  63419. /**
  63420. * Serialize a mesh into a JSON compatible object
  63421. * @param toSerialize defines the mesh to serialize
  63422. * @param withParents defines if parents must be serialized as well
  63423. * @param withChildren defines if children must be serialized as well
  63424. * @returns a JSON compatible object
  63425. */
  63426. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63427. }
  63428. }
  63429. declare module BABYLON {
  63430. /**
  63431. * Class used to host texture specific utilities
  63432. */
  63433. export class TextureTools {
  63434. /**
  63435. * Uses the GPU to create a copy texture rescaled at a given size
  63436. * @param texture Texture to copy from
  63437. * @param width defines the desired width
  63438. * @param height defines the desired height
  63439. * @param useBilinearMode defines if bilinear mode has to be used
  63440. * @return the generated texture
  63441. */
  63442. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63443. }
  63444. }
  63445. declare module BABYLON {
  63446. /**
  63447. * This represents the different options available for the video capture.
  63448. */
  63449. export interface VideoRecorderOptions {
  63450. /** Defines the mime type of the video. */
  63451. mimeType: string;
  63452. /** Defines the FPS the video should be recorded at. */
  63453. fps: number;
  63454. /** Defines the chunk size for the recording data. */
  63455. recordChunckSize: number;
  63456. /** The audio tracks to attach to the recording. */
  63457. audioTracks?: MediaStreamTrack[];
  63458. }
  63459. /**
  63460. * This can help with recording videos from BabylonJS.
  63461. * This is based on the available WebRTC functionalities of the browser.
  63462. *
  63463. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63464. */
  63465. export class VideoRecorder {
  63466. private static readonly _defaultOptions;
  63467. /**
  63468. * Returns whether or not the VideoRecorder is available in your browser.
  63469. * @param engine Defines the Babylon Engine.
  63470. * @returns true if supported otherwise false.
  63471. */
  63472. static IsSupported(engine: Engine): boolean;
  63473. private readonly _options;
  63474. private _canvas;
  63475. private _mediaRecorder;
  63476. private _recordedChunks;
  63477. private _fileName;
  63478. private _resolve;
  63479. private _reject;
  63480. /**
  63481. * True when a recording is already in progress.
  63482. */
  63483. readonly isRecording: boolean;
  63484. /**
  63485. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63486. * @param engine Defines the BabylonJS Engine you wish to record.
  63487. * @param options Defines options that can be used to customize the capture.
  63488. */
  63489. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63490. /**
  63491. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63492. */
  63493. stopRecording(): void;
  63494. /**
  63495. * Starts recording the canvas for a max duration specified in parameters.
  63496. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63497. * If null no automatic download will start and you can rely on the promise to get the data back.
  63498. * @param maxDuration Defines the maximum recording time in seconds.
  63499. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63500. * @return A promise callback at the end of the recording with the video data in Blob.
  63501. */
  63502. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63503. /**
  63504. * Releases internal resources used during the recording.
  63505. */
  63506. dispose(): void;
  63507. private _handleDataAvailable;
  63508. private _handleError;
  63509. private _handleStop;
  63510. }
  63511. }
  63512. declare module BABYLON {
  63513. /**
  63514. * Class containing a set of static utilities functions for screenshots
  63515. */
  63516. export class ScreenshotTools {
  63517. /**
  63518. * Captures a screenshot of the current rendering
  63519. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63520. * @param engine defines the rendering engine
  63521. * @param camera defines the source camera
  63522. * @param size This parameter can be set to a single number or to an object with the
  63523. * following (optional) properties: precision, width, height. If a single number is passed,
  63524. * it will be used for both width and height. If an object is passed, the screenshot size
  63525. * will be derived from the parameters. The precision property is a multiplier allowing
  63526. * rendering at a higher or lower resolution
  63527. * @param successCallback defines the callback receives a single parameter which contains the
  63528. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63529. * src parameter of an <img> to display it
  63530. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63531. * Check your browser for supported MIME types
  63532. */
  63533. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63534. /**
  63535. * Captures a screenshot of the current rendering
  63536. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63537. * @param engine defines the rendering engine
  63538. * @param camera defines the source camera
  63539. * @param size This parameter can be set to a single number or to an object with the
  63540. * following (optional) properties: precision, width, height. If a single number is passed,
  63541. * it will be used for both width and height. If an object is passed, the screenshot size
  63542. * will be derived from the parameters. The precision property is a multiplier allowing
  63543. * rendering at a higher or lower resolution
  63544. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63545. * Check your browser for supported MIME types
  63546. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63547. * to the src parameter of an <img> to display it
  63548. */
  63549. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63550. /**
  63551. * Generates an image screenshot from the specified camera.
  63552. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63553. * @param engine The engine to use for rendering
  63554. * @param camera The camera to use for rendering
  63555. * @param size This parameter can be set to a single number or to an object with the
  63556. * following (optional) properties: precision, width, height. If a single number is passed,
  63557. * it will be used for both width and height. If an object is passed, the screenshot size
  63558. * will be derived from the parameters. The precision property is a multiplier allowing
  63559. * rendering at a higher or lower resolution
  63560. * @param successCallback The callback receives a single parameter which contains the
  63561. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63562. * src parameter of an <img> to display it
  63563. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63564. * Check your browser for supported MIME types
  63565. * @param samples Texture samples (default: 1)
  63566. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63567. * @param fileName A name for for the downloaded file.
  63568. */
  63569. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63570. /**
  63571. * Generates an image screenshot from the specified camera.
  63572. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63573. * @param engine The engine to use for rendering
  63574. * @param camera The camera to use for rendering
  63575. * @param size This parameter can be set to a single number or to an object with the
  63576. * following (optional) properties: precision, width, height. If a single number is passed,
  63577. * it will be used for both width and height. If an object is passed, the screenshot size
  63578. * will be derived from the parameters. The precision property is a multiplier allowing
  63579. * rendering at a higher or lower resolution
  63580. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63581. * Check your browser for supported MIME types
  63582. * @param samples Texture samples (default: 1)
  63583. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63584. * @param fileName A name for for the downloaded file.
  63585. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63586. * to the src parameter of an <img> to display it
  63587. */
  63588. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63589. /**
  63590. * Gets height and width for screenshot size
  63591. * @private
  63592. */
  63593. private static _getScreenshotSize;
  63594. }
  63595. }
  63596. declare module BABYLON {
  63597. /**
  63598. * A cursor which tracks a point on a path
  63599. */
  63600. export class PathCursor {
  63601. private path;
  63602. /**
  63603. * Stores path cursor callbacks for when an onchange event is triggered
  63604. */
  63605. private _onchange;
  63606. /**
  63607. * The value of the path cursor
  63608. */
  63609. value: number;
  63610. /**
  63611. * The animation array of the path cursor
  63612. */
  63613. animations: Animation[];
  63614. /**
  63615. * Initializes the path cursor
  63616. * @param path The path to track
  63617. */
  63618. constructor(path: Path2);
  63619. /**
  63620. * Gets the cursor point on the path
  63621. * @returns A point on the path cursor at the cursor location
  63622. */
  63623. getPoint(): Vector3;
  63624. /**
  63625. * Moves the cursor ahead by the step amount
  63626. * @param step The amount to move the cursor forward
  63627. * @returns This path cursor
  63628. */
  63629. moveAhead(step?: number): PathCursor;
  63630. /**
  63631. * Moves the cursor behind by the step amount
  63632. * @param step The amount to move the cursor back
  63633. * @returns This path cursor
  63634. */
  63635. moveBack(step?: number): PathCursor;
  63636. /**
  63637. * Moves the cursor by the step amount
  63638. * If the step amount is greater than one, an exception is thrown
  63639. * @param step The amount to move the cursor
  63640. * @returns This path cursor
  63641. */
  63642. move(step: number): PathCursor;
  63643. /**
  63644. * Ensures that the value is limited between zero and one
  63645. * @returns This path cursor
  63646. */
  63647. private ensureLimits;
  63648. /**
  63649. * Runs onchange callbacks on change (used by the animation engine)
  63650. * @returns This path cursor
  63651. */
  63652. private raiseOnChange;
  63653. /**
  63654. * Executes a function on change
  63655. * @param f A path cursor onchange callback
  63656. * @returns This path cursor
  63657. */
  63658. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63659. }
  63660. }
  63661. declare module BABYLON {
  63662. /** @hidden */
  63663. export var blurPixelShader: {
  63664. name: string;
  63665. shader: string;
  63666. };
  63667. }
  63668. declare module BABYLON {
  63669. /** @hidden */
  63670. export var pointCloudVertexDeclaration: {
  63671. name: string;
  63672. shader: string;
  63673. };
  63674. }
  63675. // Mixins
  63676. interface Window {
  63677. mozIndexedDB: IDBFactory;
  63678. webkitIndexedDB: IDBFactory;
  63679. msIndexedDB: IDBFactory;
  63680. webkitURL: typeof URL;
  63681. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63682. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63683. WebGLRenderingContext: WebGLRenderingContext;
  63684. MSGesture: MSGesture;
  63685. CANNON: any;
  63686. AudioContext: AudioContext;
  63687. webkitAudioContext: AudioContext;
  63688. PointerEvent: any;
  63689. Math: Math;
  63690. Uint8Array: Uint8ArrayConstructor;
  63691. Float32Array: Float32ArrayConstructor;
  63692. mozURL: typeof URL;
  63693. msURL: typeof URL;
  63694. VRFrameData: any; // WebVR, from specs 1.1
  63695. DracoDecoderModule: any;
  63696. setImmediate(handler: (...args: any[]) => void): number;
  63697. }
  63698. interface HTMLCanvasElement {
  63699. requestPointerLock(): void;
  63700. msRequestPointerLock?(): void;
  63701. mozRequestPointerLock?(): void;
  63702. webkitRequestPointerLock?(): void;
  63703. /** Track wether a record is in progress */
  63704. isRecording: boolean;
  63705. /** Capture Stream method defined by some browsers */
  63706. captureStream(fps?: number): MediaStream;
  63707. }
  63708. interface CanvasRenderingContext2D {
  63709. msImageSmoothingEnabled: boolean;
  63710. }
  63711. interface MouseEvent {
  63712. mozMovementX: number;
  63713. mozMovementY: number;
  63714. webkitMovementX: number;
  63715. webkitMovementY: number;
  63716. msMovementX: number;
  63717. msMovementY: number;
  63718. }
  63719. interface Navigator {
  63720. mozGetVRDevices: (any: any) => any;
  63721. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63722. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63723. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63724. webkitGetGamepads(): Gamepad[];
  63725. msGetGamepads(): Gamepad[];
  63726. webkitGamepads(): Gamepad[];
  63727. }
  63728. interface HTMLVideoElement {
  63729. mozSrcObject: any;
  63730. }
  63731. interface Math {
  63732. fround(x: number): number;
  63733. imul(a: number, b: number): number;
  63734. }
  63735. interface WebGLRenderingContext {
  63736. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63737. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63738. vertexAttribDivisor(index: number, divisor: number): void;
  63739. createVertexArray(): any;
  63740. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63741. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63742. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63743. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63744. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63745. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63746. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63747. // Queries
  63748. createQuery(): WebGLQuery;
  63749. deleteQuery(query: WebGLQuery): void;
  63750. beginQuery(target: number, query: WebGLQuery): void;
  63751. endQuery(target: number): void;
  63752. getQueryParameter(query: WebGLQuery, pname: number): any;
  63753. getQuery(target: number, pname: number): any;
  63754. MAX_SAMPLES: number;
  63755. RGBA8: number;
  63756. READ_FRAMEBUFFER: number;
  63757. DRAW_FRAMEBUFFER: number;
  63758. UNIFORM_BUFFER: number;
  63759. HALF_FLOAT_OES: number;
  63760. RGBA16F: number;
  63761. RGBA32F: number;
  63762. R32F: number;
  63763. RG32F: number;
  63764. RGB32F: number;
  63765. R16F: number;
  63766. RG16F: number;
  63767. RGB16F: number;
  63768. RED: number;
  63769. RG: number;
  63770. R8: number;
  63771. RG8: number;
  63772. UNSIGNED_INT_24_8: number;
  63773. DEPTH24_STENCIL8: number;
  63774. MIN: number;
  63775. MAX: number;
  63776. /* Multiple Render Targets */
  63777. drawBuffers(buffers: number[]): void;
  63778. readBuffer(src: number): void;
  63779. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63780. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63781. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63782. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63783. // Occlusion Query
  63784. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63785. ANY_SAMPLES_PASSED: number;
  63786. QUERY_RESULT_AVAILABLE: number;
  63787. QUERY_RESULT: number;
  63788. }
  63789. interface WebGLProgram {
  63790. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63791. }
  63792. interface EXT_disjoint_timer_query {
  63793. QUERY_COUNTER_BITS_EXT: number;
  63794. TIME_ELAPSED_EXT: number;
  63795. TIMESTAMP_EXT: number;
  63796. GPU_DISJOINT_EXT: number;
  63797. QUERY_RESULT_EXT: number;
  63798. QUERY_RESULT_AVAILABLE_EXT: number;
  63799. queryCounterEXT(query: WebGLQuery, target: number): void;
  63800. createQueryEXT(): WebGLQuery;
  63801. beginQueryEXT(target: number, query: WebGLQuery): void;
  63802. endQueryEXT(target: number): void;
  63803. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63804. deleteQueryEXT(query: WebGLQuery): void;
  63805. }
  63806. interface WebGLUniformLocation {
  63807. _currentState: any;
  63808. }
  63809. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63810. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63811. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63812. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63813. interface WebGLRenderingContext {
  63814. readonly RASTERIZER_DISCARD: number;
  63815. readonly DEPTH_COMPONENT24: number;
  63816. readonly TEXTURE_3D: number;
  63817. readonly TEXTURE_2D_ARRAY: number;
  63818. readonly TEXTURE_COMPARE_FUNC: number;
  63819. readonly TEXTURE_COMPARE_MODE: number;
  63820. readonly COMPARE_REF_TO_TEXTURE: number;
  63821. readonly TEXTURE_WRAP_R: number;
  63822. readonly HALF_FLOAT: number;
  63823. readonly RGB8: number;
  63824. readonly RED_INTEGER: number;
  63825. readonly RG_INTEGER: number;
  63826. readonly RGB_INTEGER: number;
  63827. readonly RGBA_INTEGER: number;
  63828. readonly R8_SNORM: number;
  63829. readonly RG8_SNORM: number;
  63830. readonly RGB8_SNORM: number;
  63831. readonly RGBA8_SNORM: number;
  63832. readonly R8I: number;
  63833. readonly RG8I: number;
  63834. readonly RGB8I: number;
  63835. readonly RGBA8I: number;
  63836. readonly R8UI: number;
  63837. readonly RG8UI: number;
  63838. readonly RGB8UI: number;
  63839. readonly RGBA8UI: number;
  63840. readonly R16I: number;
  63841. readonly RG16I: number;
  63842. readonly RGB16I: number;
  63843. readonly RGBA16I: number;
  63844. readonly R16UI: number;
  63845. readonly RG16UI: number;
  63846. readonly RGB16UI: number;
  63847. readonly RGBA16UI: number;
  63848. readonly R32I: number;
  63849. readonly RG32I: number;
  63850. readonly RGB32I: number;
  63851. readonly RGBA32I: number;
  63852. readonly R32UI: number;
  63853. readonly RG32UI: number;
  63854. readonly RGB32UI: number;
  63855. readonly RGBA32UI: number;
  63856. readonly RGB10_A2UI: number;
  63857. readonly R11F_G11F_B10F: number;
  63858. readonly RGB9_E5: number;
  63859. readonly RGB10_A2: number;
  63860. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63861. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63862. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63863. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63864. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63865. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63866. 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;
  63867. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63868. readonly TRANSFORM_FEEDBACK: number;
  63869. readonly INTERLEAVED_ATTRIBS: number;
  63870. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63871. createTransformFeedback(): WebGLTransformFeedback;
  63872. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63873. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63874. beginTransformFeedback(primitiveMode: number): void;
  63875. endTransformFeedback(): void;
  63876. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63877. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63878. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63879. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63880. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63881. }
  63882. interface ImageBitmap {
  63883. readonly width: number;
  63884. readonly height: number;
  63885. close(): void;
  63886. }
  63887. interface WebGLQuery extends WebGLObject {
  63888. }
  63889. declare var WebGLQuery: {
  63890. prototype: WebGLQuery;
  63891. new(): WebGLQuery;
  63892. };
  63893. interface WebGLSampler extends WebGLObject {
  63894. }
  63895. declare var WebGLSampler: {
  63896. prototype: WebGLSampler;
  63897. new(): WebGLSampler;
  63898. };
  63899. interface WebGLSync extends WebGLObject {
  63900. }
  63901. declare var WebGLSync: {
  63902. prototype: WebGLSync;
  63903. new(): WebGLSync;
  63904. };
  63905. interface WebGLTransformFeedback extends WebGLObject {
  63906. }
  63907. declare var WebGLTransformFeedback: {
  63908. prototype: WebGLTransformFeedback;
  63909. new(): WebGLTransformFeedback;
  63910. };
  63911. interface WebGLVertexArrayObject extends WebGLObject {
  63912. }
  63913. declare var WebGLVertexArrayObject: {
  63914. prototype: WebGLVertexArrayObject;
  63915. new(): WebGLVertexArrayObject;
  63916. };
  63917. // Type definitions for WebVR API
  63918. // Project: https://w3c.github.io/webvr/
  63919. // Definitions by: six a <https://github.com/lostfictions>
  63920. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63921. interface VRDisplay extends EventTarget {
  63922. /**
  63923. * Dictionary of capabilities describing the VRDisplay.
  63924. */
  63925. readonly capabilities: VRDisplayCapabilities;
  63926. /**
  63927. * z-depth defining the far plane of the eye view frustum
  63928. * enables mapping of values in the render target depth
  63929. * attachment to scene coordinates. Initially set to 10000.0.
  63930. */
  63931. depthFar: number;
  63932. /**
  63933. * z-depth defining the near plane of the eye view frustum
  63934. * enables mapping of values in the render target depth
  63935. * attachment to scene coordinates. Initially set to 0.01.
  63936. */
  63937. depthNear: number;
  63938. /**
  63939. * An identifier for this distinct VRDisplay. Used as an
  63940. * association point in the Gamepad API.
  63941. */
  63942. readonly displayId: number;
  63943. /**
  63944. * A display name, a user-readable name identifying it.
  63945. */
  63946. readonly displayName: string;
  63947. readonly isConnected: boolean;
  63948. readonly isPresenting: boolean;
  63949. /**
  63950. * If this VRDisplay supports room-scale experiences, the optional
  63951. * stage attribute contains details on the room-scale parameters.
  63952. */
  63953. readonly stageParameters: VRStageParameters | null;
  63954. /**
  63955. * Passing the value returned by `requestAnimationFrame` to
  63956. * `cancelAnimationFrame` will unregister the callback.
  63957. * @param handle Define the hanle of the request to cancel
  63958. */
  63959. cancelAnimationFrame(handle: number): void;
  63960. /**
  63961. * Stops presenting to the VRDisplay.
  63962. * @returns a promise to know when it stopped
  63963. */
  63964. exitPresent(): Promise<void>;
  63965. /**
  63966. * Return the current VREyeParameters for the given eye.
  63967. * @param whichEye Define the eye we want the parameter for
  63968. * @returns the eye parameters
  63969. */
  63970. getEyeParameters(whichEye: string): VREyeParameters;
  63971. /**
  63972. * Populates the passed VRFrameData with the information required to render
  63973. * the current frame.
  63974. * @param frameData Define the data structure to populate
  63975. * @returns true if ok otherwise false
  63976. */
  63977. getFrameData(frameData: VRFrameData): boolean;
  63978. /**
  63979. * Get the layers currently being presented.
  63980. * @returns the list of VR layers
  63981. */
  63982. getLayers(): VRLayer[];
  63983. /**
  63984. * Return a VRPose containing the future predicted pose of the VRDisplay
  63985. * when the current frame will be presented. The value returned will not
  63986. * change until JavaScript has returned control to the browser.
  63987. *
  63988. * The VRPose will contain the position, orientation, velocity,
  63989. * and acceleration of each of these properties.
  63990. * @returns the pose object
  63991. */
  63992. getPose(): VRPose;
  63993. /**
  63994. * Return the current instantaneous pose of the VRDisplay, with no
  63995. * prediction applied.
  63996. * @returns the current instantaneous pose
  63997. */
  63998. getImmediatePose(): VRPose;
  63999. /**
  64000. * The callback passed to `requestAnimationFrame` will be called
  64001. * any time a new frame should be rendered. When the VRDisplay is
  64002. * presenting the callback will be called at the native refresh
  64003. * rate of the HMD. When not presenting this function acts
  64004. * identically to how window.requestAnimationFrame acts. Content should
  64005. * make no assumptions of frame rate or vsync behavior as the HMD runs
  64006. * asynchronously from other displays and at differing refresh rates.
  64007. * @param callback Define the eaction to run next frame
  64008. * @returns the request handle it
  64009. */
  64010. requestAnimationFrame(callback: FrameRequestCallback): number;
  64011. /**
  64012. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64013. * Repeat calls while already presenting will update the VRLayers being displayed.
  64014. * @param layers Define the list of layer to present
  64015. * @returns a promise to know when the request has been fulfilled
  64016. */
  64017. requestPresent(layers: VRLayer[]): Promise<void>;
  64018. /**
  64019. * Reset the pose for this display, treating its current position and
  64020. * orientation as the "origin/zero" values. VRPose.position,
  64021. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64022. * updated when calling resetPose(). This should be called in only
  64023. * sitting-space experiences.
  64024. */
  64025. resetPose(): void;
  64026. /**
  64027. * The VRLayer provided to the VRDisplay will be captured and presented
  64028. * in the HMD. Calling this function has the same effect on the source
  64029. * canvas as any other operation that uses its source image, and canvases
  64030. * created without preserveDrawingBuffer set to true will be cleared.
  64031. * @param pose Define the pose to submit
  64032. */
  64033. submitFrame(pose?: VRPose): void;
  64034. }
  64035. declare var VRDisplay: {
  64036. prototype: VRDisplay;
  64037. new(): VRDisplay;
  64038. };
  64039. interface VRLayer {
  64040. leftBounds?: number[] | Float32Array | null;
  64041. rightBounds?: number[] | Float32Array | null;
  64042. source?: HTMLCanvasElement | null;
  64043. }
  64044. interface VRDisplayCapabilities {
  64045. readonly canPresent: boolean;
  64046. readonly hasExternalDisplay: boolean;
  64047. readonly hasOrientation: boolean;
  64048. readonly hasPosition: boolean;
  64049. readonly maxLayers: number;
  64050. }
  64051. interface VREyeParameters {
  64052. /** @deprecated */
  64053. readonly fieldOfView: VRFieldOfView;
  64054. readonly offset: Float32Array;
  64055. readonly renderHeight: number;
  64056. readonly renderWidth: number;
  64057. }
  64058. interface VRFieldOfView {
  64059. readonly downDegrees: number;
  64060. readonly leftDegrees: number;
  64061. readonly rightDegrees: number;
  64062. readonly upDegrees: number;
  64063. }
  64064. interface VRFrameData {
  64065. readonly leftProjectionMatrix: Float32Array;
  64066. readonly leftViewMatrix: Float32Array;
  64067. readonly pose: VRPose;
  64068. readonly rightProjectionMatrix: Float32Array;
  64069. readonly rightViewMatrix: Float32Array;
  64070. readonly timestamp: number;
  64071. }
  64072. interface VRPose {
  64073. readonly angularAcceleration: Float32Array | null;
  64074. readonly angularVelocity: Float32Array | null;
  64075. readonly linearAcceleration: Float32Array | null;
  64076. readonly linearVelocity: Float32Array | null;
  64077. readonly orientation: Float32Array | null;
  64078. readonly position: Float32Array | null;
  64079. readonly timestamp: number;
  64080. }
  64081. interface VRStageParameters {
  64082. sittingToStandingTransform?: Float32Array;
  64083. sizeX?: number;
  64084. sizeY?: number;
  64085. }
  64086. interface Navigator {
  64087. getVRDisplays(): Promise<VRDisplay[]>;
  64088. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  64089. }
  64090. interface Window {
  64091. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  64092. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  64093. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  64094. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64095. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64096. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  64097. }
  64098. interface Gamepad {
  64099. readonly displayId: number;
  64100. }
  64101. type XRSessionMode =
  64102. | "inline"
  64103. | "immersive-vr"
  64104. | "immersive-ar";
  64105. type XRReferenceSpaceType =
  64106. | "viewer"
  64107. | "local"
  64108. | "local-floor"
  64109. | "bounded-floor"
  64110. | "unbounded";
  64111. type XREnvironmentBlendMode =
  64112. | "opaque"
  64113. | "additive"
  64114. | "alpha-blend";
  64115. type XRVisibilityState =
  64116. | "visible"
  64117. | "visible-blurred"
  64118. | "hidden";
  64119. type XRHandedness =
  64120. | "none"
  64121. | "left"
  64122. | "right";
  64123. type XRTargetRayMode =
  64124. | "gaze"
  64125. | "tracked-pointer"
  64126. | "screen";
  64127. type XREye =
  64128. | "none"
  64129. | "left"
  64130. | "right";
  64131. interface XRSpace extends EventTarget {
  64132. }
  64133. interface XRRenderState {
  64134. depthNear?: number;
  64135. depthFar?: number;
  64136. inlineVerticalFieldOfView?: number;
  64137. baseLayer?: XRWebGLLayer;
  64138. }
  64139. interface XRInputSource {
  64140. handedness: XRHandedness;
  64141. targetRayMode: XRTargetRayMode;
  64142. targetRaySpace: XRSpace;
  64143. gripSpace: XRSpace | undefined;
  64144. gamepad: Gamepad | undefined;
  64145. profiles: Array<string>;
  64146. }
  64147. interface XRSession {
  64148. addEventListener: Function;
  64149. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  64150. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  64151. requestAnimationFrame: Function;
  64152. end(): Promise<void>;
  64153. renderState: XRRenderState;
  64154. inputSources: Array<XRInputSource>;
  64155. }
  64156. interface XRReferenceSpace extends XRSpace {
  64157. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  64158. onreset: any;
  64159. }
  64160. interface XRFrame {
  64161. session: XRSession;
  64162. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  64163. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  64164. }
  64165. interface XRViewerPose extends XRPose {
  64166. views: Array<XRView>;
  64167. }
  64168. interface XRPose {
  64169. transform: XRRigidTransform;
  64170. emulatedPosition: boolean;
  64171. }
  64172. declare var XRWebGLLayer: {
  64173. prototype: XRWebGLLayer;
  64174. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  64175. };
  64176. interface XRWebGLLayer {
  64177. framebuffer: WebGLFramebuffer;
  64178. framebufferWidth: number;
  64179. framebufferHeight: number;
  64180. getViewport: Function;
  64181. }
  64182. interface XRRigidTransform {
  64183. position: DOMPointReadOnly;
  64184. orientation: DOMPointReadOnly;
  64185. matrix: Float32Array;
  64186. inverse: XRRigidTransform;
  64187. }
  64188. interface XRView {
  64189. eye: XREye;
  64190. projectionMatrix: Float32Array;
  64191. transform: XRRigidTransform;
  64192. }
  64193. interface XRInputSourceChangeEvent {
  64194. session: XRSession;
  64195. removed: Array<XRInputSource>;
  64196. added: Array<XRInputSource>;
  64197. }
  64198. /**
  64199. * @ignore
  64200. */
  64201. declare module BABYLON.GLTF2.Exporter {
  64202. }
  64203. /**
  64204. * @ignore
  64205. */
  64206. declare module BABYLON.GLTF1 {
  64207. }
  64208. declare module BABYLON.GUI {
  64209. /**
  64210. * Class used to specific a value and its associated unit
  64211. */
  64212. export class ValueAndUnit {
  64213. /** defines the unit to store */
  64214. unit: number;
  64215. /** defines a boolean indicating if the value can be negative */
  64216. negativeValueAllowed: boolean;
  64217. private _value;
  64218. private _originalUnit;
  64219. /**
  64220. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  64221. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64222. */
  64223. ignoreAdaptiveScaling: boolean;
  64224. /**
  64225. * Creates a new ValueAndUnit
  64226. * @param value defines the value to store
  64227. * @param unit defines the unit to store
  64228. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64229. */
  64230. constructor(value: number,
  64231. /** defines the unit to store */
  64232. unit?: number,
  64233. /** defines a boolean indicating if the value can be negative */
  64234. negativeValueAllowed?: boolean);
  64235. /** Gets a boolean indicating if the value is a percentage */
  64236. readonly isPercentage: boolean;
  64237. /** Gets a boolean indicating if the value is store as pixel */
  64238. readonly isPixel: boolean;
  64239. /** Gets direct internal value */
  64240. readonly internalValue: number;
  64241. /**
  64242. * Gets value as pixel
  64243. * @param host defines the root host
  64244. * @param refValue defines the reference value for percentages
  64245. * @returns the value as pixel
  64246. */
  64247. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  64248. /**
  64249. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  64250. * @param value defines the value to store
  64251. * @param unit defines the unit to store
  64252. * @returns the current ValueAndUnit
  64253. */
  64254. updateInPlace(value: number, unit?: number): ValueAndUnit;
  64255. /**
  64256. * Gets the value accordingly to its unit
  64257. * @param host defines the root host
  64258. * @returns the value
  64259. */
  64260. getValue(host: AdvancedDynamicTexture): number;
  64261. /**
  64262. * Gets a string representation of the value
  64263. * @param host defines the root host
  64264. * @param decimals defines an optional number of decimals to display
  64265. * @returns a string
  64266. */
  64267. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  64268. /**
  64269. * Store a value parsed from a string
  64270. * @param source defines the source string
  64271. * @returns true if the value was successfully parsed
  64272. */
  64273. fromString(source: string | number): boolean;
  64274. private static _Regex;
  64275. private static _UNITMODE_PERCENTAGE;
  64276. private static _UNITMODE_PIXEL;
  64277. /** UNITMODE_PERCENTAGE */
  64278. static readonly UNITMODE_PERCENTAGE: number;
  64279. /** UNITMODE_PIXEL */
  64280. static readonly UNITMODE_PIXEL: number;
  64281. }
  64282. }
  64283. declare module BABYLON.GUI {
  64284. /**
  64285. * Define a style used by control to automatically setup properties based on a template.
  64286. * Only support font related properties so far
  64287. */
  64288. export class Style implements BABYLON.IDisposable {
  64289. private _fontFamily;
  64290. private _fontStyle;
  64291. private _fontWeight;
  64292. /** @hidden */
  64293. _host: AdvancedDynamicTexture;
  64294. /** @hidden */
  64295. _fontSize: ValueAndUnit;
  64296. /**
  64297. * BABYLON.Observable raised when the style values are changed
  64298. */
  64299. onChangedObservable: BABYLON.Observable<Style>;
  64300. /**
  64301. * Creates a new style object
  64302. * @param host defines the AdvancedDynamicTexture which hosts this style
  64303. */
  64304. constructor(host: AdvancedDynamicTexture);
  64305. /**
  64306. * Gets or sets the font size
  64307. */
  64308. fontSize: string | number;
  64309. /**
  64310. * Gets or sets the font family
  64311. */
  64312. fontFamily: string;
  64313. /**
  64314. * Gets or sets the font style
  64315. */
  64316. fontStyle: string;
  64317. /** Gets or sets font weight */
  64318. fontWeight: string;
  64319. /** Dispose all associated resources */
  64320. dispose(): void;
  64321. }
  64322. }
  64323. declare module BABYLON.GUI {
  64324. /**
  64325. * Class used to transport BABYLON.Vector2 information for pointer events
  64326. */
  64327. export class Vector2WithInfo extends BABYLON.Vector2 {
  64328. /** defines the current mouse button index */
  64329. buttonIndex: number;
  64330. /**
  64331. * Creates a new Vector2WithInfo
  64332. * @param source defines the vector2 data to transport
  64333. * @param buttonIndex defines the current mouse button index
  64334. */
  64335. constructor(source: BABYLON.Vector2,
  64336. /** defines the current mouse button index */
  64337. buttonIndex?: number);
  64338. }
  64339. /** Class used to provide 2D matrix features */
  64340. export class Matrix2D {
  64341. /** Gets the internal array of 6 floats used to store matrix data */
  64342. m: Float32Array;
  64343. /**
  64344. * Creates a new matrix
  64345. * @param m00 defines value for (0, 0)
  64346. * @param m01 defines value for (0, 1)
  64347. * @param m10 defines value for (1, 0)
  64348. * @param m11 defines value for (1, 1)
  64349. * @param m20 defines value for (2, 0)
  64350. * @param m21 defines value for (2, 1)
  64351. */
  64352. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  64353. /**
  64354. * Fills the matrix from direct values
  64355. * @param m00 defines value for (0, 0)
  64356. * @param m01 defines value for (0, 1)
  64357. * @param m10 defines value for (1, 0)
  64358. * @param m11 defines value for (1, 1)
  64359. * @param m20 defines value for (2, 0)
  64360. * @param m21 defines value for (2, 1)
  64361. * @returns the current modified matrix
  64362. */
  64363. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  64364. /**
  64365. * Gets matrix determinant
  64366. * @returns the determinant
  64367. */
  64368. determinant(): number;
  64369. /**
  64370. * Inverses the matrix and stores it in a target matrix
  64371. * @param result defines the target matrix
  64372. * @returns the current matrix
  64373. */
  64374. invertToRef(result: Matrix2D): Matrix2D;
  64375. /**
  64376. * Multiplies the current matrix with another one
  64377. * @param other defines the second operand
  64378. * @param result defines the target matrix
  64379. * @returns the current matrix
  64380. */
  64381. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  64382. /**
  64383. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  64384. * @param x defines the x coordinate to transform
  64385. * @param y defines the x coordinate to transform
  64386. * @param result defines the target vector2
  64387. * @returns the current matrix
  64388. */
  64389. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  64390. /**
  64391. * Creates an identity matrix
  64392. * @returns a new matrix
  64393. */
  64394. static Identity(): Matrix2D;
  64395. /**
  64396. * Creates a translation matrix and stores it in a target matrix
  64397. * @param x defines the x coordinate of the translation
  64398. * @param y defines the y coordinate of the translation
  64399. * @param result defines the target matrix
  64400. */
  64401. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  64402. /**
  64403. * Creates a scaling matrix and stores it in a target matrix
  64404. * @param x defines the x coordinate of the scaling
  64405. * @param y defines the y coordinate of the scaling
  64406. * @param result defines the target matrix
  64407. */
  64408. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  64409. /**
  64410. * Creates a rotation matrix and stores it in a target matrix
  64411. * @param angle defines the rotation angle
  64412. * @param result defines the target matrix
  64413. */
  64414. static RotationToRef(angle: number, result: Matrix2D): void;
  64415. private static _TempPreTranslationMatrix;
  64416. private static _TempPostTranslationMatrix;
  64417. private static _TempRotationMatrix;
  64418. private static _TempScalingMatrix;
  64419. private static _TempCompose0;
  64420. private static _TempCompose1;
  64421. private static _TempCompose2;
  64422. /**
  64423. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  64424. * @param tx defines the x coordinate of the translation
  64425. * @param ty defines the y coordinate of the translation
  64426. * @param angle defines the rotation angle
  64427. * @param scaleX defines the x coordinate of the scaling
  64428. * @param scaleY defines the y coordinate of the scaling
  64429. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  64430. * @param result defines the target matrix
  64431. */
  64432. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  64433. }
  64434. }
  64435. declare module BABYLON.GUI {
  64436. /**
  64437. * Class used to store 2D control sizes
  64438. */
  64439. export class Measure {
  64440. /** defines left coordinate */
  64441. left: number;
  64442. /** defines top coordinate */
  64443. top: number;
  64444. /** defines width dimension */
  64445. width: number;
  64446. /** defines height dimension */
  64447. height: number;
  64448. /**
  64449. * Creates a new measure
  64450. * @param left defines left coordinate
  64451. * @param top defines top coordinate
  64452. * @param width defines width dimension
  64453. * @param height defines height dimension
  64454. */
  64455. constructor(
  64456. /** defines left coordinate */
  64457. left: number,
  64458. /** defines top coordinate */
  64459. top: number,
  64460. /** defines width dimension */
  64461. width: number,
  64462. /** defines height dimension */
  64463. height: number);
  64464. /**
  64465. * Copy from another measure
  64466. * @param other defines the other measure to copy from
  64467. */
  64468. copyFrom(other: Measure): void;
  64469. /**
  64470. * Copy from a group of 4 floats
  64471. * @param left defines left coordinate
  64472. * @param top defines top coordinate
  64473. * @param width defines width dimension
  64474. * @param height defines height dimension
  64475. */
  64476. copyFromFloats(left: number, top: number, width: number, height: number): void;
  64477. /**
  64478. * Computes the axis aligned bounding box measure for two given measures
  64479. * @param a Input measure
  64480. * @param b Input measure
  64481. * @param result the resulting bounding measure
  64482. */
  64483. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  64484. /**
  64485. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  64486. * @param transform the matrix to transform the measure before computing the AABB
  64487. * @param result the resulting AABB
  64488. */
  64489. transformToRef(transform: Matrix2D, result: Measure): void;
  64490. /**
  64491. * Check equality between this measure and another one
  64492. * @param other defines the other measures
  64493. * @returns true if both measures are equals
  64494. */
  64495. isEqualsTo(other: Measure): boolean;
  64496. /**
  64497. * Creates an empty measure
  64498. * @returns a new measure
  64499. */
  64500. static Empty(): Measure;
  64501. }
  64502. }
  64503. declare module BABYLON.GUI {
  64504. /**
  64505. * Interface used to define a control that can receive focus
  64506. */
  64507. export interface IFocusableControl {
  64508. /**
  64509. * Function called when the control receives the focus
  64510. */
  64511. onFocus(): void;
  64512. /**
  64513. * Function called when the control loses the focus
  64514. */
  64515. onBlur(): void;
  64516. /**
  64517. * Function called to let the control handle keyboard events
  64518. * @param evt defines the current keyboard event
  64519. */
  64520. processKeyboard(evt: KeyboardEvent): void;
  64521. /**
  64522. * Function called to get the list of controls that should not steal the focus from this control
  64523. * @returns an array of controls
  64524. */
  64525. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64526. }
  64527. /**
  64528. * Class used to create texture to support 2D GUI elements
  64529. * @see http://doc.babylonjs.com/how_to/gui
  64530. */
  64531. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  64532. private _isDirty;
  64533. private _renderObserver;
  64534. private _resizeObserver;
  64535. private _preKeyboardObserver;
  64536. private _pointerMoveObserver;
  64537. private _pointerObserver;
  64538. private _canvasPointerOutObserver;
  64539. private _background;
  64540. /** @hidden */
  64541. _rootContainer: Container;
  64542. /** @hidden */
  64543. _lastPickedControl: Control;
  64544. /** @hidden */
  64545. _lastControlOver: {
  64546. [pointerId: number]: Control;
  64547. };
  64548. /** @hidden */
  64549. _lastControlDown: {
  64550. [pointerId: number]: Control;
  64551. };
  64552. /** @hidden */
  64553. _capturingControl: {
  64554. [pointerId: number]: Control;
  64555. };
  64556. /** @hidden */
  64557. _shouldBlockPointer: boolean;
  64558. /** @hidden */
  64559. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64560. /** @hidden */
  64561. _linkedControls: Control[];
  64562. private _isFullscreen;
  64563. private _fullscreenViewport;
  64564. private _idealWidth;
  64565. private _idealHeight;
  64566. private _useSmallestIdeal;
  64567. private _renderAtIdealSize;
  64568. private _focusedControl;
  64569. private _blockNextFocusCheck;
  64570. private _renderScale;
  64571. private _rootCanvas;
  64572. private _cursorChanged;
  64573. /**
  64574. * Define type to string to ensure compatibility across browsers
  64575. * Safari doesn't support DataTransfer constructor
  64576. */
  64577. private _clipboardData;
  64578. /**
  64579. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64580. */
  64581. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64582. /**
  64583. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64584. */
  64585. onControlPickedObservable: BABYLON.Observable<Control>;
  64586. /**
  64587. * BABYLON.Observable event triggered before layout is evaluated
  64588. */
  64589. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64590. /**
  64591. * BABYLON.Observable event triggered after the layout was evaluated
  64592. */
  64593. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64594. /**
  64595. * BABYLON.Observable event triggered before the texture is rendered
  64596. */
  64597. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64598. /**
  64599. * BABYLON.Observable event triggered after the texture was rendered
  64600. */
  64601. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64602. /**
  64603. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64604. */
  64605. premulAlpha: boolean;
  64606. /**
  64607. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64608. * Useful when you want more antialiasing
  64609. */
  64610. renderScale: number;
  64611. /** Gets or sets the background color */
  64612. background: string;
  64613. /**
  64614. * Gets or sets the ideal width used to design controls.
  64615. * The GUI will then rescale everything accordingly
  64616. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64617. */
  64618. idealWidth: number;
  64619. /**
  64620. * Gets or sets the ideal height used to design controls.
  64621. * The GUI will then rescale everything accordingly
  64622. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64623. */
  64624. idealHeight: number;
  64625. /**
  64626. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64627. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64628. */
  64629. useSmallestIdeal: boolean;
  64630. /**
  64631. * Gets or sets a boolean indicating if adaptive scaling must be used
  64632. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64633. */
  64634. renderAtIdealSize: boolean;
  64635. /**
  64636. * Gets the underlying layer used to render the texture when in fullscreen mode
  64637. */
  64638. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64639. /**
  64640. * Gets the root container control
  64641. */
  64642. readonly rootContainer: Container;
  64643. /**
  64644. * Returns an array containing the root container.
  64645. * This is mostly used to let the Inspector introspects the ADT
  64646. * @returns an array containing the rootContainer
  64647. */
  64648. getChildren(): Array<Container>;
  64649. /**
  64650. * Will return all controls that are inside this texture
  64651. * @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
  64652. * @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
  64653. * @return all child controls
  64654. */
  64655. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64656. /**
  64657. * Gets or sets the current focused control
  64658. */
  64659. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64660. /**
  64661. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64662. */
  64663. isForeground: boolean;
  64664. /**
  64665. * Gets or set information about clipboardData
  64666. */
  64667. clipboardData: string;
  64668. /**
  64669. * Creates a new AdvancedDynamicTexture
  64670. * @param name defines the name of the texture
  64671. * @param width defines the width of the texture
  64672. * @param height defines the height of the texture
  64673. * @param scene defines the hosting scene
  64674. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64675. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64676. */
  64677. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64678. /**
  64679. * Get the current class name of the texture useful for serialization or dynamic coding.
  64680. * @returns "AdvancedDynamicTexture"
  64681. */
  64682. getClassName(): string;
  64683. /**
  64684. * Function used to execute a function on all controls
  64685. * @param func defines the function to execute
  64686. * @param container defines the container where controls belong. If null the root container will be used
  64687. */
  64688. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64689. private _useInvalidateRectOptimization;
  64690. /**
  64691. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64692. */
  64693. useInvalidateRectOptimization: boolean;
  64694. private _invalidatedRectangle;
  64695. /**
  64696. * Invalidates a rectangle area on the gui texture
  64697. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64698. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64699. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64700. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64701. */
  64702. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64703. /**
  64704. * Marks the texture as dirty forcing a complete update
  64705. */
  64706. markAsDirty(): void;
  64707. /**
  64708. * Helper function used to create a new style
  64709. * @returns a new style
  64710. * @see http://doc.babylonjs.com/how_to/gui#styles
  64711. */
  64712. createStyle(): Style;
  64713. /**
  64714. * Adds a new control to the root container
  64715. * @param control defines the control to add
  64716. * @returns the current texture
  64717. */
  64718. addControl(control: Control): AdvancedDynamicTexture;
  64719. /**
  64720. * Removes a control from the root container
  64721. * @param control defines the control to remove
  64722. * @returns the current texture
  64723. */
  64724. removeControl(control: Control): AdvancedDynamicTexture;
  64725. /**
  64726. * Release all resources
  64727. */
  64728. dispose(): void;
  64729. private _onResize;
  64730. /** @hidden */
  64731. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64732. /**
  64733. * Get screen coordinates for a vector3
  64734. * @param position defines the position to project
  64735. * @param worldMatrix defines the world matrix to use
  64736. * @returns the projected position
  64737. */
  64738. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64739. private _checkUpdate;
  64740. private _clearMeasure;
  64741. private _render;
  64742. /** @hidden */
  64743. _changeCursor(cursor: string): void;
  64744. /** @hidden */
  64745. _registerLastControlDown(control: Control, pointerId: number): void;
  64746. private _doPicking;
  64747. /** @hidden */
  64748. _cleanControlAfterRemovalFromList(list: {
  64749. [pointerId: number]: Control;
  64750. }, control: Control): void;
  64751. /** @hidden */
  64752. _cleanControlAfterRemoval(control: Control): void;
  64753. /** Attach to all scene events required to support pointer events */
  64754. attach(): void;
  64755. /** @hidden */
  64756. private onClipboardCopy;
  64757. /** @hidden */
  64758. private onClipboardCut;
  64759. /** @hidden */
  64760. private onClipboardPaste;
  64761. /**
  64762. * Register the clipboard Events onto the canvas
  64763. */
  64764. registerClipboardEvents(): void;
  64765. /**
  64766. * Unregister the clipboard Events from the canvas
  64767. */
  64768. unRegisterClipboardEvents(): void;
  64769. /**
  64770. * Connect the texture to a hosting mesh to enable interactions
  64771. * @param mesh defines the mesh to attach to
  64772. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64773. */
  64774. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64775. /**
  64776. * Move the focus to a specific control
  64777. * @param control defines the control which will receive the focus
  64778. */
  64779. moveFocusToControl(control: IFocusableControl): void;
  64780. private _manageFocus;
  64781. private _attachToOnPointerOut;
  64782. /**
  64783. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64784. * @param mesh defines the mesh which will receive the texture
  64785. * @param width defines the texture width (1024 by default)
  64786. * @param height defines the texture height (1024 by default)
  64787. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64788. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64789. * @returns a new AdvancedDynamicTexture
  64790. */
  64791. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64792. /**
  64793. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64794. * In this mode the texture will rely on a layer for its rendering.
  64795. * This allows it to be treated like any other layer.
  64796. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64797. * LayerMask is set through advancedTexture.layer.layerMask
  64798. * @param name defines name for the texture
  64799. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64800. * @param scene defines the hsoting scene
  64801. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64802. * @returns a new AdvancedDynamicTexture
  64803. */
  64804. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64805. }
  64806. }
  64807. declare module BABYLON.GUI {
  64808. /**
  64809. * Root class used for all 2D controls
  64810. * @see http://doc.babylonjs.com/how_to/gui#controls
  64811. */
  64812. export class Control {
  64813. /** defines the name of the control */
  64814. name?: string | undefined;
  64815. /**
  64816. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64817. */
  64818. static AllowAlphaInheritance: boolean;
  64819. private _alpha;
  64820. private _alphaSet;
  64821. private _zIndex;
  64822. /** @hidden */
  64823. _host: AdvancedDynamicTexture;
  64824. /** Gets or sets the control parent */
  64825. parent: BABYLON.Nullable<Container>;
  64826. /** @hidden */
  64827. _currentMeasure: Measure;
  64828. private _fontFamily;
  64829. private _fontStyle;
  64830. private _fontWeight;
  64831. private _fontSize;
  64832. private _font;
  64833. /** @hidden */
  64834. _width: ValueAndUnit;
  64835. /** @hidden */
  64836. _height: ValueAndUnit;
  64837. /** @hidden */
  64838. protected _fontOffset: {
  64839. ascent: number;
  64840. height: number;
  64841. descent: number;
  64842. };
  64843. private _color;
  64844. private _style;
  64845. private _styleObserver;
  64846. /** @hidden */
  64847. protected _horizontalAlignment: number;
  64848. /** @hidden */
  64849. protected _verticalAlignment: number;
  64850. /** @hidden */
  64851. protected _isDirty: boolean;
  64852. /** @hidden */
  64853. protected _wasDirty: boolean;
  64854. /** @hidden */
  64855. _tempParentMeasure: Measure;
  64856. /** @hidden */
  64857. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64858. /** @hidden */
  64859. protected _cachedParentMeasure: Measure;
  64860. private _paddingLeft;
  64861. private _paddingRight;
  64862. private _paddingTop;
  64863. private _paddingBottom;
  64864. /** @hidden */
  64865. _left: ValueAndUnit;
  64866. /** @hidden */
  64867. _top: ValueAndUnit;
  64868. private _scaleX;
  64869. private _scaleY;
  64870. private _rotation;
  64871. private _transformCenterX;
  64872. private _transformCenterY;
  64873. /** @hidden */
  64874. _transformMatrix: Matrix2D;
  64875. /** @hidden */
  64876. protected _invertTransformMatrix: Matrix2D;
  64877. /** @hidden */
  64878. protected _transformedPosition: BABYLON.Vector2;
  64879. private _isMatrixDirty;
  64880. private _cachedOffsetX;
  64881. private _cachedOffsetY;
  64882. private _isVisible;
  64883. private _isHighlighted;
  64884. /** @hidden */
  64885. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64886. private _fontSet;
  64887. private _dummyVector2;
  64888. private _downCount;
  64889. private _enterCount;
  64890. private _doNotRender;
  64891. private _downPointerIds;
  64892. protected _isEnabled: boolean;
  64893. protected _disabledColor: string;
  64894. /** @hidden */
  64895. protected _rebuildLayout: boolean;
  64896. /** @hidden */
  64897. _isClipped: boolean;
  64898. /** @hidden */
  64899. _tag: any;
  64900. /**
  64901. * 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
  64902. */
  64903. uniqueId: number;
  64904. /**
  64905. * Gets or sets an object used to store user defined information for the node
  64906. */
  64907. metadata: any;
  64908. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64909. isHitTestVisible: boolean;
  64910. /** Gets or sets a boolean indicating if the control can block pointer events */
  64911. isPointerBlocker: boolean;
  64912. /** Gets or sets a boolean indicating if the control can be focusable */
  64913. isFocusInvisible: boolean;
  64914. /**
  64915. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64916. * 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
  64917. */
  64918. clipChildren: boolean;
  64919. /**
  64920. * Gets or sets a boolean indicating that control content must be clipped
  64921. * 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
  64922. */
  64923. clipContent: boolean;
  64924. /**
  64925. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64926. */
  64927. useBitmapCache: boolean;
  64928. private _cacheData;
  64929. private _shadowOffsetX;
  64930. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64931. shadowOffsetX: number;
  64932. private _shadowOffsetY;
  64933. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64934. shadowOffsetY: number;
  64935. private _shadowBlur;
  64936. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64937. shadowBlur: number;
  64938. private _shadowColor;
  64939. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64940. shadowColor: string;
  64941. /** Gets or sets the cursor to use when the control is hovered */
  64942. hoverCursor: string;
  64943. /** @hidden */
  64944. protected _linkOffsetX: ValueAndUnit;
  64945. /** @hidden */
  64946. protected _linkOffsetY: ValueAndUnit;
  64947. /** Gets the control type name */
  64948. readonly typeName: string;
  64949. /**
  64950. * Get the current class name of the control.
  64951. * @returns current class name
  64952. */
  64953. getClassName(): string;
  64954. /**
  64955. * An event triggered when the pointer move over the control.
  64956. */
  64957. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64958. /**
  64959. * An event triggered when the pointer move out of the control.
  64960. */
  64961. onPointerOutObservable: BABYLON.Observable<Control>;
  64962. /**
  64963. * An event triggered when the pointer taps the control
  64964. */
  64965. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64966. /**
  64967. * An event triggered when pointer up
  64968. */
  64969. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64970. /**
  64971. * An event triggered when a control is clicked on
  64972. */
  64973. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64974. /**
  64975. * An event triggered when pointer enters the control
  64976. */
  64977. onPointerEnterObservable: BABYLON.Observable<Control>;
  64978. /**
  64979. * An event triggered when the control is marked as dirty
  64980. */
  64981. onDirtyObservable: BABYLON.Observable<Control>;
  64982. /**
  64983. * An event triggered before drawing the control
  64984. */
  64985. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64986. /**
  64987. * An event triggered after the control was drawn
  64988. */
  64989. onAfterDrawObservable: BABYLON.Observable<Control>;
  64990. /**
  64991. * Get the hosting AdvancedDynamicTexture
  64992. */
  64993. readonly host: AdvancedDynamicTexture;
  64994. /** Gets or set information about font offsets (used to render and align text) */
  64995. fontOffset: {
  64996. ascent: number;
  64997. height: number;
  64998. descent: number;
  64999. };
  65000. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  65001. alpha: number;
  65002. /**
  65003. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  65004. */
  65005. isHighlighted: boolean;
  65006. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  65007. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65008. */
  65009. scaleX: number;
  65010. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  65011. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65012. */
  65013. scaleY: number;
  65014. /** Gets or sets the rotation angle (0 by default)
  65015. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65016. */
  65017. rotation: number;
  65018. /** Gets or sets the transformation center on Y axis (0 by default)
  65019. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65020. */
  65021. transformCenterY: number;
  65022. /** Gets or sets the transformation center on X axis (0 by default)
  65023. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65024. */
  65025. transformCenterX: number;
  65026. /**
  65027. * Gets or sets the horizontal alignment
  65028. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65029. */
  65030. horizontalAlignment: number;
  65031. /**
  65032. * Gets or sets the vertical alignment
  65033. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65034. */
  65035. verticalAlignment: number;
  65036. /**
  65037. * Gets or sets control width
  65038. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65039. */
  65040. width: string | number;
  65041. /**
  65042. * Gets or sets the control width in pixel
  65043. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65044. */
  65045. widthInPixels: number;
  65046. /**
  65047. * Gets or sets control height
  65048. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65049. */
  65050. height: string | number;
  65051. /**
  65052. * Gets or sets control height in pixel
  65053. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65054. */
  65055. heightInPixels: number;
  65056. /** Gets or set font family */
  65057. fontFamily: string;
  65058. /** Gets or sets font style */
  65059. fontStyle: string;
  65060. /** Gets or sets font weight */
  65061. fontWeight: string;
  65062. /**
  65063. * Gets or sets style
  65064. * @see http://doc.babylonjs.com/how_to/gui#styles
  65065. */
  65066. style: BABYLON.Nullable<Style>;
  65067. /** @hidden */
  65068. readonly _isFontSizeInPercentage: boolean;
  65069. /** Gets or sets font size in pixels */
  65070. fontSizeInPixels: number;
  65071. /** Gets or sets font size */
  65072. fontSize: string | number;
  65073. /** Gets or sets foreground color */
  65074. color: string;
  65075. /** Gets or sets z index which is used to reorder controls on the z axis */
  65076. zIndex: number;
  65077. /** Gets or sets a boolean indicating if the control can be rendered */
  65078. notRenderable: boolean;
  65079. /** Gets or sets a boolean indicating if the control is visible */
  65080. isVisible: boolean;
  65081. /** Gets a boolean indicating that the control needs to update its rendering */
  65082. readonly isDirty: boolean;
  65083. /**
  65084. * Gets the current linked mesh (or null if none)
  65085. */
  65086. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65087. /**
  65088. * Gets or sets a value indicating the padding to use on the left of the control
  65089. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65090. */
  65091. paddingLeft: string | number;
  65092. /**
  65093. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  65094. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65095. */
  65096. paddingLeftInPixels: number;
  65097. /**
  65098. * Gets or sets a value indicating the padding to use on the right of the control
  65099. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65100. */
  65101. paddingRight: string | number;
  65102. /**
  65103. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  65104. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65105. */
  65106. paddingRightInPixels: number;
  65107. /**
  65108. * Gets or sets a value indicating the padding to use on the top of the control
  65109. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65110. */
  65111. paddingTop: string | number;
  65112. /**
  65113. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  65114. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65115. */
  65116. paddingTopInPixels: number;
  65117. /**
  65118. * Gets or sets a value indicating the padding to use on the bottom of the control
  65119. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65120. */
  65121. paddingBottom: string | number;
  65122. /**
  65123. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  65124. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65125. */
  65126. paddingBottomInPixels: number;
  65127. /**
  65128. * Gets or sets a value indicating the left coordinate of the control
  65129. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65130. */
  65131. left: string | number;
  65132. /**
  65133. * Gets or sets a value indicating the left coordinate in pixels of the control
  65134. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65135. */
  65136. leftInPixels: number;
  65137. /**
  65138. * Gets or sets a value indicating the top coordinate of the control
  65139. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65140. */
  65141. top: string | number;
  65142. /**
  65143. * Gets or sets a value indicating the top coordinate in pixels of the control
  65144. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65145. */
  65146. topInPixels: number;
  65147. /**
  65148. * Gets or sets a value indicating the offset on X axis to the linked mesh
  65149. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65150. */
  65151. linkOffsetX: string | number;
  65152. /**
  65153. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  65154. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65155. */
  65156. linkOffsetXInPixels: number;
  65157. /**
  65158. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  65159. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65160. */
  65161. linkOffsetY: string | number;
  65162. /**
  65163. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  65164. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65165. */
  65166. linkOffsetYInPixels: number;
  65167. /** Gets the center coordinate on X axis */
  65168. readonly centerX: number;
  65169. /** Gets the center coordinate on Y axis */
  65170. readonly centerY: number;
  65171. /** Gets or sets if control is Enabled*/
  65172. isEnabled: boolean;
  65173. /** Gets or sets background color of control if it's disabled*/
  65174. disabledColor: string;
  65175. /**
  65176. * Creates a new control
  65177. * @param name defines the name of the control
  65178. */
  65179. constructor(
  65180. /** defines the name of the control */
  65181. name?: string | undefined);
  65182. /** @hidden */
  65183. protected _getTypeName(): string;
  65184. /**
  65185. * Gets the first ascendant in the hierarchy of the given type
  65186. * @param className defines the required type
  65187. * @returns the ascendant or null if not found
  65188. */
  65189. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  65190. /** @hidden */
  65191. _resetFontCache(): void;
  65192. /**
  65193. * Determines if a container is an ascendant of the current control
  65194. * @param container defines the container to look for
  65195. * @returns true if the container is one of the ascendant of the control
  65196. */
  65197. isAscendant(container: Control): boolean;
  65198. /**
  65199. * Gets coordinates in local control space
  65200. * @param globalCoordinates defines the coordinates to transform
  65201. * @returns the new coordinates in local space
  65202. */
  65203. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65204. /**
  65205. * Gets coordinates in local control space
  65206. * @param globalCoordinates defines the coordinates to transform
  65207. * @param result defines the target vector2 where to store the result
  65208. * @returns the current control
  65209. */
  65210. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  65211. /**
  65212. * Gets coordinates in parent local control space
  65213. * @param globalCoordinates defines the coordinates to transform
  65214. * @returns the new coordinates in parent local space
  65215. */
  65216. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65217. /**
  65218. * Move the current control to a vector3 position projected onto the screen.
  65219. * @param position defines the target position
  65220. * @param scene defines the hosting scene
  65221. */
  65222. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  65223. /** @hidden */
  65224. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65225. /**
  65226. * Will return all controls that have this control as ascendant
  65227. * @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
  65228. * @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
  65229. * @return all child controls
  65230. */
  65231. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65232. /**
  65233. * Link current control with a target mesh
  65234. * @param mesh defines the mesh to link with
  65235. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65236. */
  65237. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  65238. /** @hidden */
  65239. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  65240. /** @hidden */
  65241. _offsetLeft(offset: number): void;
  65242. /** @hidden */
  65243. _offsetTop(offset: number): void;
  65244. /** @hidden */
  65245. _markMatrixAsDirty(): void;
  65246. /** @hidden */
  65247. _flagDescendantsAsMatrixDirty(): void;
  65248. /** @hidden */
  65249. _intersectsRect(rect: Measure): boolean;
  65250. /** @hidden */
  65251. protected invalidateRect(): void;
  65252. /** @hidden */
  65253. _markAsDirty(force?: boolean): void;
  65254. /** @hidden */
  65255. _markAllAsDirty(): void;
  65256. /** @hidden */
  65257. _link(host: AdvancedDynamicTexture): void;
  65258. /** @hidden */
  65259. protected _transform(context?: CanvasRenderingContext2D): void;
  65260. /** @hidden */
  65261. _renderHighlight(context: CanvasRenderingContext2D): void;
  65262. /** @hidden */
  65263. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65264. /** @hidden */
  65265. protected _applyStates(context: CanvasRenderingContext2D): void;
  65266. /** @hidden */
  65267. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65268. /** @hidden */
  65269. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65270. protected _evaluateClippingState(parentMeasure: Measure): void;
  65271. /** @hidden */
  65272. _measure(): void;
  65273. /** @hidden */
  65274. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65275. /** @hidden */
  65276. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65277. /** @hidden */
  65278. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65279. /** @hidden */
  65280. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65281. private static _ClipMeasure;
  65282. private _tmpMeasureA;
  65283. private _clip;
  65284. /** @hidden */
  65285. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  65286. /** @hidden */
  65287. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  65288. /**
  65289. * Tests if a given coordinates belong to the current control
  65290. * @param x defines x coordinate to test
  65291. * @param y defines y coordinate to test
  65292. * @returns true if the coordinates are inside the control
  65293. */
  65294. contains(x: number, y: number): boolean;
  65295. /** @hidden */
  65296. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65297. /** @hidden */
  65298. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65299. /** @hidden */
  65300. _onPointerEnter(target: Control): boolean;
  65301. /** @hidden */
  65302. _onPointerOut(target: Control, force?: boolean): void;
  65303. /** @hidden */
  65304. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65305. /** @hidden */
  65306. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65307. /** @hidden */
  65308. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65309. /** @hidden */
  65310. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  65311. private _prepareFont;
  65312. /** Releases associated resources */
  65313. dispose(): void;
  65314. private static _HORIZONTAL_ALIGNMENT_LEFT;
  65315. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  65316. private static _HORIZONTAL_ALIGNMENT_CENTER;
  65317. private static _VERTICAL_ALIGNMENT_TOP;
  65318. private static _VERTICAL_ALIGNMENT_BOTTOM;
  65319. private static _VERTICAL_ALIGNMENT_CENTER;
  65320. /** HORIZONTAL_ALIGNMENT_LEFT */
  65321. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  65322. /** HORIZONTAL_ALIGNMENT_RIGHT */
  65323. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  65324. /** HORIZONTAL_ALIGNMENT_CENTER */
  65325. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  65326. /** VERTICAL_ALIGNMENT_TOP */
  65327. static readonly VERTICAL_ALIGNMENT_TOP: number;
  65328. /** VERTICAL_ALIGNMENT_BOTTOM */
  65329. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  65330. /** VERTICAL_ALIGNMENT_CENTER */
  65331. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  65332. private static _FontHeightSizes;
  65333. /** @hidden */
  65334. static _GetFontOffset(font: string): {
  65335. ascent: number;
  65336. height: number;
  65337. descent: number;
  65338. };
  65339. /**
  65340. * Creates a stack panel that can be used to render headers
  65341. * @param control defines the control to associate with the header
  65342. * @param text defines the text of the header
  65343. * @param size defines the size of the header
  65344. * @param options defines options used to configure the header
  65345. * @returns a new StackPanel
  65346. * @ignore
  65347. * @hidden
  65348. */
  65349. static AddHeader: (control: Control, text: string, size: string | number, options: {
  65350. isHorizontal: boolean;
  65351. controlFirst: boolean;
  65352. }) => any;
  65353. /** @hidden */
  65354. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  65355. }
  65356. }
  65357. declare module BABYLON.GUI {
  65358. /**
  65359. * Root class for 2D containers
  65360. * @see http://doc.babylonjs.com/how_to/gui#containers
  65361. */
  65362. export class Container extends Control {
  65363. name?: string | undefined;
  65364. /** @hidden */
  65365. protected _children: Control[];
  65366. /** @hidden */
  65367. protected _measureForChildren: Measure;
  65368. /** @hidden */
  65369. protected _background: string;
  65370. /** @hidden */
  65371. protected _adaptWidthToChildren: boolean;
  65372. /** @hidden */
  65373. protected _adaptHeightToChildren: boolean;
  65374. /**
  65375. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  65376. */
  65377. logLayoutCycleErrors: boolean;
  65378. /**
  65379. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  65380. */
  65381. maxLayoutCycle: number;
  65382. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  65383. adaptHeightToChildren: boolean;
  65384. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  65385. adaptWidthToChildren: boolean;
  65386. /** Gets or sets background color */
  65387. background: string;
  65388. /** Gets the list of children */
  65389. readonly children: Control[];
  65390. /**
  65391. * Creates a new Container
  65392. * @param name defines the name of the container
  65393. */
  65394. constructor(name?: string | undefined);
  65395. protected _getTypeName(): string;
  65396. _flagDescendantsAsMatrixDirty(): void;
  65397. /**
  65398. * Gets a child using its name
  65399. * @param name defines the child name to look for
  65400. * @returns the child control if found
  65401. */
  65402. getChildByName(name: string): BABYLON.Nullable<Control>;
  65403. /**
  65404. * Gets a child using its type and its name
  65405. * @param name defines the child name to look for
  65406. * @param type defines the child type to look for
  65407. * @returns the child control if found
  65408. */
  65409. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  65410. /**
  65411. * Search for a specific control in children
  65412. * @param control defines the control to look for
  65413. * @returns true if the control is in child list
  65414. */
  65415. containsControl(control: Control): boolean;
  65416. /**
  65417. * Adds a new control to the current container
  65418. * @param control defines the control to add
  65419. * @returns the current container
  65420. */
  65421. addControl(control: BABYLON.Nullable<Control>): Container;
  65422. /**
  65423. * Removes all controls from the current container
  65424. * @returns the current container
  65425. */
  65426. clearControls(): Container;
  65427. /**
  65428. * Removes a control from the current container
  65429. * @param control defines the control to remove
  65430. * @returns the current container
  65431. */
  65432. removeControl(control: Control): Container;
  65433. /** @hidden */
  65434. _reOrderControl(control: Control): void;
  65435. /** @hidden */
  65436. _offsetLeft(offset: number): void;
  65437. /** @hidden */
  65438. _offsetTop(offset: number): void;
  65439. /** @hidden */
  65440. _markAllAsDirty(): void;
  65441. /** @hidden */
  65442. protected _localDraw(context: CanvasRenderingContext2D): void;
  65443. /** @hidden */
  65444. _link(host: AdvancedDynamicTexture): void;
  65445. /** @hidden */
  65446. protected _beforeLayout(): void;
  65447. /** @hidden */
  65448. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65449. /** @hidden */
  65450. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65451. protected _postMeasure(): void;
  65452. /** @hidden */
  65453. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  65454. /** @hidden */
  65455. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65456. /** @hidden */
  65457. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65458. /** @hidden */
  65459. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65460. /** Releases associated resources */
  65461. dispose(): void;
  65462. }
  65463. }
  65464. declare module BABYLON.GUI {
  65465. /** Class used to create rectangle container */
  65466. export class Rectangle extends Container {
  65467. name?: string | undefined;
  65468. private _thickness;
  65469. private _cornerRadius;
  65470. /** Gets or sets border thickness */
  65471. thickness: number;
  65472. /** Gets or sets the corner radius angle */
  65473. cornerRadius: number;
  65474. /**
  65475. * Creates a new Rectangle
  65476. * @param name defines the control name
  65477. */
  65478. constructor(name?: string | undefined);
  65479. protected _getTypeName(): string;
  65480. protected _localDraw(context: CanvasRenderingContext2D): void;
  65481. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65482. private _drawRoundedRect;
  65483. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65484. }
  65485. }
  65486. declare module BABYLON.GUI {
  65487. /**
  65488. * Enum that determines the text-wrapping mode to use.
  65489. */
  65490. export enum TextWrapping {
  65491. /**
  65492. * Clip the text when it's larger than Control.width; this is the default mode.
  65493. */
  65494. Clip = 0,
  65495. /**
  65496. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  65497. */
  65498. WordWrap = 1,
  65499. /**
  65500. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  65501. */
  65502. Ellipsis = 2
  65503. }
  65504. /**
  65505. * Class used to create text block control
  65506. */
  65507. export class TextBlock extends Control {
  65508. /**
  65509. * Defines the name of the control
  65510. */
  65511. name?: string | undefined;
  65512. private _text;
  65513. private _textWrapping;
  65514. private _textHorizontalAlignment;
  65515. private _textVerticalAlignment;
  65516. private _lines;
  65517. private _resizeToFit;
  65518. private _lineSpacing;
  65519. private _outlineWidth;
  65520. private _outlineColor;
  65521. /**
  65522. * An event triggered after the text is changed
  65523. */
  65524. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  65525. /**
  65526. * An event triggered after the text was broken up into lines
  65527. */
  65528. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  65529. /**
  65530. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  65531. */
  65532. readonly lines: any[];
  65533. /**
  65534. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65535. */
  65536. /**
  65537. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65538. */
  65539. resizeToFit: boolean;
  65540. /**
  65541. * Gets or sets a boolean indicating if text must be wrapped
  65542. */
  65543. /**
  65544. * Gets or sets a boolean indicating if text must be wrapped
  65545. */
  65546. textWrapping: TextWrapping | boolean;
  65547. /**
  65548. * Gets or sets text to display
  65549. */
  65550. /**
  65551. * Gets or sets text to display
  65552. */
  65553. text: string;
  65554. /**
  65555. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65556. */
  65557. /**
  65558. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65559. */
  65560. textHorizontalAlignment: number;
  65561. /**
  65562. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65563. */
  65564. /**
  65565. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65566. */
  65567. textVerticalAlignment: number;
  65568. /**
  65569. * Gets or sets line spacing value
  65570. */
  65571. /**
  65572. * Gets or sets line spacing value
  65573. */
  65574. lineSpacing: string | number;
  65575. /**
  65576. * Gets or sets outlineWidth of the text to display
  65577. */
  65578. /**
  65579. * Gets or sets outlineWidth of the text to display
  65580. */
  65581. outlineWidth: number;
  65582. /**
  65583. * Gets or sets outlineColor of the text to display
  65584. */
  65585. /**
  65586. * Gets or sets outlineColor of the text to display
  65587. */
  65588. outlineColor: string;
  65589. /**
  65590. * Creates a new TextBlock object
  65591. * @param name defines the name of the control
  65592. * @param text defines the text to display (emptry string by default)
  65593. */
  65594. constructor(
  65595. /**
  65596. * Defines the name of the control
  65597. */
  65598. name?: string | undefined, text?: string);
  65599. protected _getTypeName(): string;
  65600. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65601. private _drawText;
  65602. /** @hidden */
  65603. _draw(context: CanvasRenderingContext2D): void;
  65604. protected _applyStates(context: CanvasRenderingContext2D): void;
  65605. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  65606. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  65607. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  65608. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  65609. protected _renderLines(context: CanvasRenderingContext2D): void;
  65610. /**
  65611. * Given a width constraint applied on the text block, find the expected height
  65612. * @returns expected height
  65613. */
  65614. computeExpectedHeight(): number;
  65615. dispose(): void;
  65616. }
  65617. }
  65618. declare module BABYLON.GUI {
  65619. /**
  65620. * Class used to create 2D images
  65621. */
  65622. export class Image extends Control {
  65623. name?: string | undefined;
  65624. private static _WorkingCanvas;
  65625. private _domImage;
  65626. private _imageWidth;
  65627. private _imageHeight;
  65628. private _loaded;
  65629. private _stretch;
  65630. private _source;
  65631. private _autoScale;
  65632. private _sourceLeft;
  65633. private _sourceTop;
  65634. private _sourceWidth;
  65635. private _sourceHeight;
  65636. private _cellWidth;
  65637. private _cellHeight;
  65638. private _cellId;
  65639. private _populateNinePatchSlicesFromImage;
  65640. private _sliceLeft;
  65641. private _sliceRight;
  65642. private _sliceTop;
  65643. private _sliceBottom;
  65644. private _detectPointerOnOpaqueOnly;
  65645. /**
  65646. * BABYLON.Observable notified when the content is loaded
  65647. */
  65648. onImageLoadedObservable: BABYLON.Observable<Image>;
  65649. /**
  65650. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65651. */
  65652. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65653. /**
  65654. * Gets a boolean indicating that the content is loaded
  65655. */
  65656. readonly isLoaded: boolean;
  65657. /**
  65658. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65659. */
  65660. populateNinePatchSlicesFromImage: boolean;
  65661. /**
  65662. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65663. * Beware using this as this will comsume more memory as the image has to be stored twice
  65664. */
  65665. detectPointerOnOpaqueOnly: boolean;
  65666. /**
  65667. * Gets or sets the left value for slicing (9-patch)
  65668. */
  65669. sliceLeft: number;
  65670. /**
  65671. * Gets or sets the right value for slicing (9-patch)
  65672. */
  65673. sliceRight: number;
  65674. /**
  65675. * Gets or sets the top value for slicing (9-patch)
  65676. */
  65677. sliceTop: number;
  65678. /**
  65679. * Gets or sets the bottom value for slicing (9-patch)
  65680. */
  65681. sliceBottom: number;
  65682. /**
  65683. * Gets or sets the left coordinate in the source image
  65684. */
  65685. sourceLeft: number;
  65686. /**
  65687. * Gets or sets the top coordinate in the source image
  65688. */
  65689. sourceTop: number;
  65690. /**
  65691. * Gets or sets the width to capture in the source image
  65692. */
  65693. sourceWidth: number;
  65694. /**
  65695. * Gets or sets the height to capture in the source image
  65696. */
  65697. sourceHeight: number;
  65698. /**
  65699. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65700. * @see http://doc.babylonjs.com/how_to/gui#image
  65701. */
  65702. autoScale: boolean;
  65703. /** Gets or sets the streching mode used by the image */
  65704. stretch: number;
  65705. /**
  65706. * Gets or sets the internal DOM image used to render the control
  65707. */
  65708. domImage: HTMLImageElement;
  65709. private _onImageLoaded;
  65710. private _extractNinePatchSliceDataFromImage;
  65711. /**
  65712. * Gets or sets image source url
  65713. */
  65714. source: BABYLON.Nullable<string>;
  65715. /**
  65716. * Checks for svg document with icon id present
  65717. */
  65718. private _svgCheck;
  65719. /**
  65720. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65721. * given external svg file and icon id
  65722. */
  65723. private _getSVGAttribs;
  65724. /**
  65725. * Gets or sets the cell width to use when animation sheet is enabled
  65726. * @see http://doc.babylonjs.com/how_to/gui#image
  65727. */
  65728. cellWidth: number;
  65729. /**
  65730. * Gets or sets the cell height to use when animation sheet is enabled
  65731. * @see http://doc.babylonjs.com/how_to/gui#image
  65732. */
  65733. cellHeight: number;
  65734. /**
  65735. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65736. * @see http://doc.babylonjs.com/how_to/gui#image
  65737. */
  65738. cellId: number;
  65739. /**
  65740. * Creates a new Image
  65741. * @param name defines the control name
  65742. * @param url defines the image url
  65743. */
  65744. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65745. /**
  65746. * Tests if a given coordinates belong to the current control
  65747. * @param x defines x coordinate to test
  65748. * @param y defines y coordinate to test
  65749. * @returns true if the coordinates are inside the control
  65750. */
  65751. contains(x: number, y: number): boolean;
  65752. protected _getTypeName(): string;
  65753. /** Force the control to synchronize with its content */
  65754. synchronizeSizeWithContent(): void;
  65755. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65756. private _prepareWorkingCanvasForOpaqueDetection;
  65757. private _drawImage;
  65758. _draw(context: CanvasRenderingContext2D): void;
  65759. private _renderCornerPatch;
  65760. private _renderNinePatch;
  65761. dispose(): void;
  65762. /** STRETCH_NONE */
  65763. static readonly STRETCH_NONE: number;
  65764. /** STRETCH_FILL */
  65765. static readonly STRETCH_FILL: number;
  65766. /** STRETCH_UNIFORM */
  65767. static readonly STRETCH_UNIFORM: number;
  65768. /** STRETCH_EXTEND */
  65769. static readonly STRETCH_EXTEND: number;
  65770. /** NINE_PATCH */
  65771. static readonly STRETCH_NINE_PATCH: number;
  65772. }
  65773. }
  65774. declare module BABYLON.GUI {
  65775. /**
  65776. * Class used to create 2D buttons
  65777. */
  65778. export class Button extends Rectangle {
  65779. name?: string | undefined;
  65780. /**
  65781. * Function called to generate a pointer enter animation
  65782. */
  65783. pointerEnterAnimation: () => void;
  65784. /**
  65785. * Function called to generate a pointer out animation
  65786. */
  65787. pointerOutAnimation: () => void;
  65788. /**
  65789. * Function called to generate a pointer down animation
  65790. */
  65791. pointerDownAnimation: () => void;
  65792. /**
  65793. * Function called to generate a pointer up animation
  65794. */
  65795. pointerUpAnimation: () => void;
  65796. /**
  65797. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65798. */
  65799. delegatePickingToChildren: boolean;
  65800. private _image;
  65801. /**
  65802. * Returns the image part of the button (if any)
  65803. */
  65804. readonly image: BABYLON.Nullable<Image>;
  65805. private _textBlock;
  65806. /**
  65807. * Returns the image part of the button (if any)
  65808. */
  65809. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65810. /**
  65811. * Creates a new Button
  65812. * @param name defines the name of the button
  65813. */
  65814. constructor(name?: string | undefined);
  65815. protected _getTypeName(): string;
  65816. /** @hidden */
  65817. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65818. /** @hidden */
  65819. _onPointerEnter(target: Control): boolean;
  65820. /** @hidden */
  65821. _onPointerOut(target: Control, force?: boolean): void;
  65822. /** @hidden */
  65823. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65824. /** @hidden */
  65825. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65826. /**
  65827. * Creates a new button made with an image and a text
  65828. * @param name defines the name of the button
  65829. * @param text defines the text of the button
  65830. * @param imageUrl defines the url of the image
  65831. * @returns a new Button
  65832. */
  65833. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65834. /**
  65835. * Creates a new button made with an image
  65836. * @param name defines the name of the button
  65837. * @param imageUrl defines the url of the image
  65838. * @returns a new Button
  65839. */
  65840. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65841. /**
  65842. * Creates a new button made with a text
  65843. * @param name defines the name of the button
  65844. * @param text defines the text of the button
  65845. * @returns a new Button
  65846. */
  65847. static CreateSimpleButton(name: string, text: string): Button;
  65848. /**
  65849. * Creates a new button made with an image and a centered text
  65850. * @param name defines the name of the button
  65851. * @param text defines the text of the button
  65852. * @param imageUrl defines the url of the image
  65853. * @returns a new Button
  65854. */
  65855. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65856. }
  65857. }
  65858. declare module BABYLON.GUI {
  65859. /**
  65860. * Class used to create a 2D stack panel container
  65861. */
  65862. export class StackPanel extends Container {
  65863. name?: string | undefined;
  65864. private _isVertical;
  65865. private _manualWidth;
  65866. private _manualHeight;
  65867. private _doNotTrackManualChanges;
  65868. /**
  65869. * Gets or sets a boolean indicating that layou warnings should be ignored
  65870. */
  65871. ignoreLayoutWarnings: boolean;
  65872. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65873. isVertical: boolean;
  65874. /**
  65875. * Gets or sets panel width.
  65876. * This value should not be set when in horizontal mode as it will be computed automatically
  65877. */
  65878. width: string | number;
  65879. /**
  65880. * Gets or sets panel height.
  65881. * This value should not be set when in vertical mode as it will be computed automatically
  65882. */
  65883. height: string | number;
  65884. /**
  65885. * Creates a new StackPanel
  65886. * @param name defines control name
  65887. */
  65888. constructor(name?: string | undefined);
  65889. protected _getTypeName(): string;
  65890. /** @hidden */
  65891. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65892. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65893. protected _postMeasure(): void;
  65894. }
  65895. }
  65896. declare module BABYLON.GUI {
  65897. /**
  65898. * Class used to represent a 2D checkbox
  65899. */
  65900. export class Checkbox extends Control {
  65901. name?: string | undefined;
  65902. private _isChecked;
  65903. private _background;
  65904. private _checkSizeRatio;
  65905. private _thickness;
  65906. /** Gets or sets border thickness */
  65907. thickness: number;
  65908. /**
  65909. * BABYLON.Observable raised when isChecked property changes
  65910. */
  65911. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65912. /** Gets or sets a value indicating the ratio between overall size and check size */
  65913. checkSizeRatio: number;
  65914. /** Gets or sets background color */
  65915. background: string;
  65916. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65917. isChecked: boolean;
  65918. /**
  65919. * Creates a new CheckBox
  65920. * @param name defines the control name
  65921. */
  65922. constructor(name?: string | undefined);
  65923. protected _getTypeName(): string;
  65924. /** @hidden */
  65925. _draw(context: CanvasRenderingContext2D): void;
  65926. /** @hidden */
  65927. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65928. /**
  65929. * Utility function to easily create a checkbox with a header
  65930. * @param title defines the label to use for the header
  65931. * @param onValueChanged defines the callback to call when value changes
  65932. * @returns a StackPanel containing the checkbox and a textBlock
  65933. */
  65934. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65935. }
  65936. }
  65937. declare module BABYLON.GUI {
  65938. /**
  65939. * Class used to store key control properties
  65940. */
  65941. export class KeyPropertySet {
  65942. /** Width */
  65943. width?: string;
  65944. /** Height */
  65945. height?: string;
  65946. /** Left padding */
  65947. paddingLeft?: string;
  65948. /** Right padding */
  65949. paddingRight?: string;
  65950. /** Top padding */
  65951. paddingTop?: string;
  65952. /** Bottom padding */
  65953. paddingBottom?: string;
  65954. /** Foreground color */
  65955. color?: string;
  65956. /** Background color */
  65957. background?: string;
  65958. }
  65959. /**
  65960. * Class used to create virtual keyboard
  65961. */
  65962. export class VirtualKeyboard extends StackPanel {
  65963. /** BABYLON.Observable raised when a key is pressed */
  65964. onKeyPressObservable: BABYLON.Observable<string>;
  65965. /** Gets or sets default key button width */
  65966. defaultButtonWidth: string;
  65967. /** Gets or sets default key button height */
  65968. defaultButtonHeight: string;
  65969. /** Gets or sets default key button left padding */
  65970. defaultButtonPaddingLeft: string;
  65971. /** Gets or sets default key button right padding */
  65972. defaultButtonPaddingRight: string;
  65973. /** Gets or sets default key button top padding */
  65974. defaultButtonPaddingTop: string;
  65975. /** Gets or sets default key button bottom padding */
  65976. defaultButtonPaddingBottom: string;
  65977. /** Gets or sets default key button foreground color */
  65978. defaultButtonColor: string;
  65979. /** Gets or sets default key button background color */
  65980. defaultButtonBackground: string;
  65981. /** Gets or sets shift button foreground color */
  65982. shiftButtonColor: string;
  65983. /** Gets or sets shift button thickness*/
  65984. selectedShiftThickness: number;
  65985. /** Gets shift key state */
  65986. shiftState: number;
  65987. protected _getTypeName(): string;
  65988. private _createKey;
  65989. /**
  65990. * Adds a new row of keys
  65991. * @param keys defines the list of keys to add
  65992. * @param propertySets defines the associated property sets
  65993. */
  65994. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65995. /**
  65996. * Set the shift key to a specific state
  65997. * @param shiftState defines the new shift state
  65998. */
  65999. applyShiftState(shiftState: number): void;
  66000. private _currentlyConnectedInputText;
  66001. private _connectedInputTexts;
  66002. private _onKeyPressObserver;
  66003. /** Gets the input text control currently attached to the keyboard */
  66004. readonly connectedInputText: BABYLON.Nullable<InputText>;
  66005. /**
  66006. * Connects the keyboard with an input text control
  66007. *
  66008. * @param input defines the target control
  66009. */
  66010. connect(input: InputText): void;
  66011. /**
  66012. * Disconnects the keyboard from connected InputText controls
  66013. *
  66014. * @param input optionally defines a target control, otherwise all are disconnected
  66015. */
  66016. disconnect(input?: InputText): void;
  66017. private _removeConnectedInputObservables;
  66018. /**
  66019. * Release all resources
  66020. */
  66021. dispose(): void;
  66022. /**
  66023. * Creates a new keyboard using a default layout
  66024. *
  66025. * @param name defines control name
  66026. * @returns a new VirtualKeyboard
  66027. */
  66028. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  66029. }
  66030. }
  66031. declare module BABYLON.GUI {
  66032. /**
  66033. * Class used to create input text control
  66034. */
  66035. export class InputText extends Control implements IFocusableControl {
  66036. name?: string | undefined;
  66037. private _text;
  66038. private _placeholderText;
  66039. private _background;
  66040. private _focusedBackground;
  66041. private _focusedColor;
  66042. private _placeholderColor;
  66043. private _thickness;
  66044. private _margin;
  66045. private _autoStretchWidth;
  66046. private _maxWidth;
  66047. private _isFocused;
  66048. private _blinkTimeout;
  66049. private _blinkIsEven;
  66050. private _cursorOffset;
  66051. private _scrollLeft;
  66052. private _textWidth;
  66053. private _clickedCoordinate;
  66054. private _deadKey;
  66055. private _addKey;
  66056. private _currentKey;
  66057. private _isTextHighlightOn;
  66058. private _textHighlightColor;
  66059. private _highligherOpacity;
  66060. private _highlightedText;
  66061. private _startHighlightIndex;
  66062. private _endHighlightIndex;
  66063. private _cursorIndex;
  66064. private _onFocusSelectAll;
  66065. private _isPointerDown;
  66066. private _onClipboardObserver;
  66067. private _onPointerDblTapObserver;
  66068. /** @hidden */
  66069. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  66070. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  66071. promptMessage: string;
  66072. /** Force disable prompt on mobile device */
  66073. disableMobilePrompt: boolean;
  66074. /** BABYLON.Observable raised when the text changes */
  66075. onTextChangedObservable: BABYLON.Observable<InputText>;
  66076. /** BABYLON.Observable raised just before an entered character is to be added */
  66077. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  66078. /** BABYLON.Observable raised when the control gets the focus */
  66079. onFocusObservable: BABYLON.Observable<InputText>;
  66080. /** BABYLON.Observable raised when the control loses the focus */
  66081. onBlurObservable: BABYLON.Observable<InputText>;
  66082. /**Observable raised when the text is highlighted */
  66083. onTextHighlightObservable: BABYLON.Observable<InputText>;
  66084. /**Observable raised when copy event is triggered */
  66085. onTextCopyObservable: BABYLON.Observable<InputText>;
  66086. /** BABYLON.Observable raised when cut event is triggered */
  66087. onTextCutObservable: BABYLON.Observable<InputText>;
  66088. /** BABYLON.Observable raised when paste event is triggered */
  66089. onTextPasteObservable: BABYLON.Observable<InputText>;
  66090. /** BABYLON.Observable raised when a key event was processed */
  66091. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  66092. /** Gets or sets the maximum width allowed by the control */
  66093. maxWidth: string | number;
  66094. /** Gets the maximum width allowed by the control in pixels */
  66095. readonly maxWidthInPixels: number;
  66096. /** Gets or sets the text highlighter transparency; default: 0.4 */
  66097. highligherOpacity: number;
  66098. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  66099. onFocusSelectAll: boolean;
  66100. /** Gets or sets the text hightlight color */
  66101. textHighlightColor: string;
  66102. /** Gets or sets control margin */
  66103. margin: string;
  66104. /** Gets control margin in pixels */
  66105. readonly marginInPixels: number;
  66106. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  66107. autoStretchWidth: boolean;
  66108. /** Gets or sets border thickness */
  66109. thickness: number;
  66110. /** Gets or sets the background color when focused */
  66111. focusedBackground: string;
  66112. /** Gets or sets the background color when focused */
  66113. focusedColor: string;
  66114. /** Gets or sets the background color */
  66115. background: string;
  66116. /** Gets or sets the placeholder color */
  66117. placeholderColor: string;
  66118. /** Gets or sets the text displayed when the control is empty */
  66119. placeholderText: string;
  66120. /** Gets or sets the dead key flag */
  66121. deadKey: boolean;
  66122. /** Gets or sets the highlight text */
  66123. highlightedText: string;
  66124. /** Gets or sets if the current key should be added */
  66125. addKey: boolean;
  66126. /** Gets or sets the value of the current key being entered */
  66127. currentKey: string;
  66128. /** Gets or sets the text displayed in the control */
  66129. text: string;
  66130. /** Gets or sets control width */
  66131. width: string | number;
  66132. /**
  66133. * Creates a new InputText
  66134. * @param name defines the control name
  66135. * @param text defines the text of the control
  66136. */
  66137. constructor(name?: string | undefined, text?: string);
  66138. /** @hidden */
  66139. onBlur(): void;
  66140. /** @hidden */
  66141. onFocus(): void;
  66142. protected _getTypeName(): string;
  66143. /**
  66144. * Function called to get the list of controls that should not steal the focus from this control
  66145. * @returns an array of controls
  66146. */
  66147. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66148. /** @hidden */
  66149. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  66150. /** @hidden */
  66151. private _updateValueFromCursorIndex;
  66152. /** @hidden */
  66153. private _processDblClick;
  66154. /** @hidden */
  66155. private _selectAllText;
  66156. /**
  66157. * Handles the keyboard event
  66158. * @param evt Defines the KeyboardEvent
  66159. */
  66160. processKeyboard(evt: KeyboardEvent): void;
  66161. /** @hidden */
  66162. private _onCopyText;
  66163. /** @hidden */
  66164. private _onCutText;
  66165. /** @hidden */
  66166. private _onPasteText;
  66167. _draw(context: CanvasRenderingContext2D): void;
  66168. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66169. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66170. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66171. protected _beforeRenderText(text: string): string;
  66172. dispose(): void;
  66173. }
  66174. }
  66175. declare module BABYLON.GUI {
  66176. /**
  66177. * Class used to create a 2D grid container
  66178. */
  66179. export class Grid extends Container {
  66180. name?: string | undefined;
  66181. private _rowDefinitions;
  66182. private _columnDefinitions;
  66183. private _cells;
  66184. private _childControls;
  66185. /**
  66186. * Gets the number of columns
  66187. */
  66188. readonly columnCount: number;
  66189. /**
  66190. * Gets the number of rows
  66191. */
  66192. readonly rowCount: number;
  66193. /** Gets the list of children */
  66194. readonly children: Control[];
  66195. /** Gets the list of cells (e.g. the containers) */
  66196. readonly cells: {
  66197. [key: string]: Container;
  66198. };
  66199. /**
  66200. * Gets the definition of a specific row
  66201. * @param index defines the index of the row
  66202. * @returns the row definition
  66203. */
  66204. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66205. /**
  66206. * Gets the definition of a specific column
  66207. * @param index defines the index of the column
  66208. * @returns the column definition
  66209. */
  66210. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66211. /**
  66212. * Adds a new row to the grid
  66213. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66214. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  66215. * @returns the current grid
  66216. */
  66217. addRowDefinition(height: number, isPixel?: boolean): Grid;
  66218. /**
  66219. * Adds a new column to the grid
  66220. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66221. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66222. * @returns the current grid
  66223. */
  66224. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  66225. /**
  66226. * Update a row definition
  66227. * @param index defines the index of the row to update
  66228. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66229. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  66230. * @returns the current grid
  66231. */
  66232. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  66233. /**
  66234. * Update a column definition
  66235. * @param index defines the index of the column to update
  66236. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66237. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66238. * @returns the current grid
  66239. */
  66240. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  66241. /**
  66242. * Gets the list of children stored in a specific cell
  66243. * @param row defines the row to check
  66244. * @param column defines the column to check
  66245. * @returns the list of controls
  66246. */
  66247. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  66248. /**
  66249. * Gets a string representing the child cell info (row x column)
  66250. * @param child defines the control to get info from
  66251. * @returns a string containing the child cell info (row x column)
  66252. */
  66253. getChildCellInfo(child: Control): string;
  66254. private _removeCell;
  66255. private _offsetCell;
  66256. /**
  66257. * Remove a column definition at specified index
  66258. * @param index defines the index of the column to remove
  66259. * @returns the current grid
  66260. */
  66261. removeColumnDefinition(index: number): Grid;
  66262. /**
  66263. * Remove a row definition at specified index
  66264. * @param index defines the index of the row to remove
  66265. * @returns the current grid
  66266. */
  66267. removeRowDefinition(index: number): Grid;
  66268. /**
  66269. * Adds a new control to the current grid
  66270. * @param control defines the control to add
  66271. * @param row defines the row where to add the control (0 by default)
  66272. * @param column defines the column where to add the control (0 by default)
  66273. * @returns the current grid
  66274. */
  66275. addControl(control: Control, row?: number, column?: number): Grid;
  66276. /**
  66277. * Removes a control from the current container
  66278. * @param control defines the control to remove
  66279. * @returns the current container
  66280. */
  66281. removeControl(control: Control): Container;
  66282. /**
  66283. * Creates a new Grid
  66284. * @param name defines control name
  66285. */
  66286. constructor(name?: string | undefined);
  66287. protected _getTypeName(): string;
  66288. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  66289. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66290. _flagDescendantsAsMatrixDirty(): void;
  66291. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66292. /** Releases associated resources */
  66293. dispose(): void;
  66294. }
  66295. }
  66296. declare module BABYLON.GUI {
  66297. /** Class used to create color pickers */
  66298. export class ColorPicker extends Control {
  66299. name?: string | undefined;
  66300. private static _Epsilon;
  66301. private _colorWheelCanvas;
  66302. private _value;
  66303. private _tmpColor;
  66304. private _pointerStartedOnSquare;
  66305. private _pointerStartedOnWheel;
  66306. private _squareLeft;
  66307. private _squareTop;
  66308. private _squareSize;
  66309. private _h;
  66310. private _s;
  66311. private _v;
  66312. private _lastPointerDownID;
  66313. /**
  66314. * BABYLON.Observable raised when the value changes
  66315. */
  66316. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  66317. /** Gets or sets the color of the color picker */
  66318. value: BABYLON.Color3;
  66319. /**
  66320. * Gets or sets control width
  66321. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66322. */
  66323. width: string | number;
  66324. /**
  66325. * Gets or sets control height
  66326. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66327. */
  66328. /** Gets or sets control height */
  66329. height: string | number;
  66330. /** Gets or sets control size */
  66331. size: string | number;
  66332. /**
  66333. * Creates a new ColorPicker
  66334. * @param name defines the control name
  66335. */
  66336. constructor(name?: string | undefined);
  66337. protected _getTypeName(): string;
  66338. /** @hidden */
  66339. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66340. private _updateSquareProps;
  66341. private _drawGradientSquare;
  66342. private _drawCircle;
  66343. private _createColorWheelCanvas;
  66344. /** @hidden */
  66345. _draw(context: CanvasRenderingContext2D): void;
  66346. private _pointerIsDown;
  66347. private _updateValueFromPointer;
  66348. private _isPointOnSquare;
  66349. private _isPointOnWheel;
  66350. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66351. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66352. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66353. /**
  66354. * This function expands the color picker by creating a color picker dialog with manual
  66355. * color value input and the ability to save colors into an array to be used later in
  66356. * subsequent launches of the dialogue.
  66357. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  66358. * @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.
  66359. * @returns picked color as a hex string and the saved colors array as hex strings.
  66360. */
  66361. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  66362. pickerWidth?: string;
  66363. pickerHeight?: string;
  66364. headerHeight?: string;
  66365. lastColor?: string;
  66366. swatchLimit?: number;
  66367. numSwatchesPerLine?: number;
  66368. savedColors?: Array<string>;
  66369. }): Promise<{
  66370. savedColors?: string[];
  66371. pickedColor: string;
  66372. }>;
  66373. }
  66374. }
  66375. declare module BABYLON.GUI {
  66376. /** Class used to create 2D ellipse containers */
  66377. export class Ellipse extends Container {
  66378. name?: string | undefined;
  66379. private _thickness;
  66380. /** Gets or sets border thickness */
  66381. thickness: number;
  66382. /**
  66383. * Creates a new Ellipse
  66384. * @param name defines the control name
  66385. */
  66386. constructor(name?: string | undefined);
  66387. protected _getTypeName(): string;
  66388. protected _localDraw(context: CanvasRenderingContext2D): void;
  66389. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66390. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66391. }
  66392. }
  66393. declare module BABYLON.GUI {
  66394. /**
  66395. * Class used to create a password control
  66396. */
  66397. export class InputPassword extends InputText {
  66398. protected _beforeRenderText(text: string): string;
  66399. }
  66400. }
  66401. declare module BABYLON.GUI {
  66402. /** Class used to render 2D lines */
  66403. export class Line extends Control {
  66404. name?: string | undefined;
  66405. private _lineWidth;
  66406. private _x1;
  66407. private _y1;
  66408. private _x2;
  66409. private _y2;
  66410. private _dash;
  66411. private _connectedControl;
  66412. private _connectedControlDirtyObserver;
  66413. /** Gets or sets the dash pattern */
  66414. dash: Array<number>;
  66415. /** Gets or sets the control connected with the line end */
  66416. connectedControl: Control;
  66417. /** Gets or sets start coordinates on X axis */
  66418. x1: string | number;
  66419. /** Gets or sets start coordinates on Y axis */
  66420. y1: string | number;
  66421. /** Gets or sets end coordinates on X axis */
  66422. x2: string | number;
  66423. /** Gets or sets end coordinates on Y axis */
  66424. y2: string | number;
  66425. /** Gets or sets line width */
  66426. lineWidth: number;
  66427. /** Gets or sets horizontal alignment */
  66428. horizontalAlignment: number;
  66429. /** Gets or sets vertical alignment */
  66430. verticalAlignment: number;
  66431. private readonly _effectiveX2;
  66432. private readonly _effectiveY2;
  66433. /**
  66434. * Creates a new Line
  66435. * @param name defines the control name
  66436. */
  66437. constructor(name?: string | undefined);
  66438. protected _getTypeName(): string;
  66439. _draw(context: CanvasRenderingContext2D): void;
  66440. _measure(): void;
  66441. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66442. /**
  66443. * Move one end of the line given 3D cartesian coordinates.
  66444. * @param position Targeted world position
  66445. * @param scene BABYLON.Scene
  66446. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66447. */
  66448. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  66449. /**
  66450. * Move one end of the line to a position in screen absolute space.
  66451. * @param projectedPosition Position in screen absolute space (X, Y)
  66452. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66453. */
  66454. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  66455. }
  66456. }
  66457. declare module BABYLON.GUI {
  66458. /**
  66459. * Class used to store a point for a MultiLine object.
  66460. * The point can be pure 2D coordinates, a mesh or a control
  66461. */
  66462. export class MultiLinePoint {
  66463. private _multiLine;
  66464. private _x;
  66465. private _y;
  66466. private _control;
  66467. private _mesh;
  66468. private _controlObserver;
  66469. private _meshObserver;
  66470. /** @hidden */
  66471. _point: BABYLON.Vector2;
  66472. /**
  66473. * Creates a new MultiLinePoint
  66474. * @param multiLine defines the source MultiLine object
  66475. */
  66476. constructor(multiLine: MultiLine);
  66477. /** Gets or sets x coordinate */
  66478. x: string | number;
  66479. /** Gets or sets y coordinate */
  66480. y: string | number;
  66481. /** Gets or sets the control associated with this point */
  66482. control: BABYLON.Nullable<Control>;
  66483. /** Gets or sets the mesh associated with this point */
  66484. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66485. /** Resets links */
  66486. resetLinks(): void;
  66487. /**
  66488. * Gets a translation vector
  66489. * @returns the translation vector
  66490. */
  66491. translate(): BABYLON.Vector2;
  66492. private _translatePoint;
  66493. /** Release associated resources */
  66494. dispose(): void;
  66495. }
  66496. }
  66497. declare module BABYLON.GUI {
  66498. /**
  66499. * Class used to create multi line control
  66500. */
  66501. export class MultiLine extends Control {
  66502. name?: string | undefined;
  66503. private _lineWidth;
  66504. private _dash;
  66505. private _points;
  66506. private _minX;
  66507. private _minY;
  66508. private _maxX;
  66509. private _maxY;
  66510. /**
  66511. * Creates a new MultiLine
  66512. * @param name defines the control name
  66513. */
  66514. constructor(name?: string | undefined);
  66515. /** Gets or sets dash pattern */
  66516. dash: Array<number>;
  66517. /**
  66518. * Gets point stored at specified index
  66519. * @param index defines the index to look for
  66520. * @returns the requested point if found
  66521. */
  66522. getAt(index: number): MultiLinePoint;
  66523. /** Function called when a point is updated */
  66524. onPointUpdate: () => void;
  66525. /**
  66526. * Adds new points to the point collection
  66527. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  66528. * @returns the list of created MultiLinePoint
  66529. */
  66530. add(...items: (AbstractMesh | Control | {
  66531. x: string | number;
  66532. y: string | number;
  66533. })[]): MultiLinePoint[];
  66534. /**
  66535. * Adds a new point to the point collection
  66536. * @param item defines the item (mesh, control or 2d coordiantes) to add
  66537. * @returns the created MultiLinePoint
  66538. */
  66539. push(item?: (AbstractMesh | Control | {
  66540. x: string | number;
  66541. y: string | number;
  66542. })): MultiLinePoint;
  66543. /**
  66544. * Remove a specific value or point from the active point collection
  66545. * @param value defines the value or point to remove
  66546. */
  66547. remove(value: number | MultiLinePoint): void;
  66548. /**
  66549. * Resets this object to initial state (no point)
  66550. */
  66551. reset(): void;
  66552. /**
  66553. * Resets all links
  66554. */
  66555. resetLinks(): void;
  66556. /** Gets or sets line width */
  66557. lineWidth: number;
  66558. horizontalAlignment: number;
  66559. verticalAlignment: number;
  66560. protected _getTypeName(): string;
  66561. _draw(context: CanvasRenderingContext2D): void;
  66562. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66563. _measure(): void;
  66564. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66565. dispose(): void;
  66566. }
  66567. }
  66568. declare module BABYLON.GUI {
  66569. /**
  66570. * Class used to create radio button controls
  66571. */
  66572. export class RadioButton extends Control {
  66573. name?: string | undefined;
  66574. private _isChecked;
  66575. private _background;
  66576. private _checkSizeRatio;
  66577. private _thickness;
  66578. /** Gets or sets border thickness */
  66579. thickness: number;
  66580. /** Gets or sets group name */
  66581. group: string;
  66582. /** BABYLON.Observable raised when isChecked is changed */
  66583. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66584. /** Gets or sets a value indicating the ratio between overall size and check size */
  66585. checkSizeRatio: number;
  66586. /** Gets or sets background color */
  66587. background: string;
  66588. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66589. isChecked: boolean;
  66590. /**
  66591. * Creates a new RadioButton
  66592. * @param name defines the control name
  66593. */
  66594. constructor(name?: string | undefined);
  66595. protected _getTypeName(): string;
  66596. _draw(context: CanvasRenderingContext2D): void;
  66597. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66598. /**
  66599. * Utility function to easily create a radio button with a header
  66600. * @param title defines the label to use for the header
  66601. * @param group defines the group to use for the radio button
  66602. * @param isChecked defines the initial state of the radio button
  66603. * @param onValueChanged defines the callback to call when value changes
  66604. * @returns a StackPanel containing the radio button and a textBlock
  66605. */
  66606. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  66607. }
  66608. }
  66609. declare module BABYLON.GUI {
  66610. /**
  66611. * Class used to create slider controls
  66612. */
  66613. export class BaseSlider extends Control {
  66614. name?: string | undefined;
  66615. protected _thumbWidth: ValueAndUnit;
  66616. private _minimum;
  66617. private _maximum;
  66618. private _value;
  66619. private _isVertical;
  66620. protected _barOffset: ValueAndUnit;
  66621. private _isThumbClamped;
  66622. protected _displayThumb: boolean;
  66623. private _step;
  66624. private _lastPointerDownID;
  66625. protected _effectiveBarOffset: number;
  66626. protected _renderLeft: number;
  66627. protected _renderTop: number;
  66628. protected _renderWidth: number;
  66629. protected _renderHeight: number;
  66630. protected _backgroundBoxLength: number;
  66631. protected _backgroundBoxThickness: number;
  66632. protected _effectiveThumbThickness: number;
  66633. /** BABYLON.Observable raised when the sldier value changes */
  66634. onValueChangedObservable: BABYLON.Observable<number>;
  66635. /** Gets or sets a boolean indicating if the thumb must be rendered */
  66636. displayThumb: boolean;
  66637. /** Gets or sets a step to apply to values (0 by default) */
  66638. step: number;
  66639. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  66640. barOffset: string | number;
  66641. /** Gets main bar offset in pixels*/
  66642. readonly barOffsetInPixels: number;
  66643. /** Gets or sets thumb width */
  66644. thumbWidth: string | number;
  66645. /** Gets thumb width in pixels */
  66646. readonly thumbWidthInPixels: number;
  66647. /** Gets or sets minimum value */
  66648. minimum: number;
  66649. /** Gets or sets maximum value */
  66650. maximum: number;
  66651. /** Gets or sets current value */
  66652. value: number;
  66653. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66654. isVertical: boolean;
  66655. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66656. isThumbClamped: boolean;
  66657. /**
  66658. * Creates a new BaseSlider
  66659. * @param name defines the control name
  66660. */
  66661. constructor(name?: string | undefined);
  66662. protected _getTypeName(): string;
  66663. protected _getThumbPosition(): number;
  66664. protected _getThumbThickness(type: string): number;
  66665. protected _prepareRenderingData(type: string): void;
  66666. private _pointerIsDown;
  66667. /** @hidden */
  66668. protected _updateValueFromPointer(x: number, y: number): void;
  66669. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66670. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66671. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66672. }
  66673. }
  66674. declare module BABYLON.GUI {
  66675. /**
  66676. * Class used to create slider controls
  66677. */
  66678. export class Slider extends BaseSlider {
  66679. name?: string | undefined;
  66680. private _background;
  66681. private _borderColor;
  66682. private _isThumbCircle;
  66683. protected _displayValueBar: boolean;
  66684. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66685. displayValueBar: boolean;
  66686. /** Gets or sets border color */
  66687. borderColor: string;
  66688. /** Gets or sets background color */
  66689. background: string;
  66690. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66691. isThumbCircle: boolean;
  66692. /**
  66693. * Creates a new Slider
  66694. * @param name defines the control name
  66695. */
  66696. constructor(name?: string | undefined);
  66697. protected _getTypeName(): string;
  66698. _draw(context: CanvasRenderingContext2D): void;
  66699. }
  66700. }
  66701. declare module BABYLON.GUI {
  66702. /** Class used to create a RadioGroup
  66703. * which contains groups of radio buttons
  66704. */
  66705. export class SelectorGroup {
  66706. /** name of SelectorGroup */
  66707. name: string;
  66708. private _groupPanel;
  66709. private _selectors;
  66710. private _groupHeader;
  66711. /**
  66712. * Creates a new SelectorGroup
  66713. * @param name of group, used as a group heading
  66714. */
  66715. constructor(
  66716. /** name of SelectorGroup */
  66717. name: string);
  66718. /** Gets the groupPanel of the SelectorGroup */
  66719. readonly groupPanel: StackPanel;
  66720. /** Gets the selectors array */
  66721. readonly selectors: StackPanel[];
  66722. /** Gets and sets the group header */
  66723. header: string;
  66724. /** @hidden */
  66725. private _addGroupHeader;
  66726. /** @hidden*/
  66727. _getSelector(selectorNb: number): StackPanel | undefined;
  66728. /** Removes the selector at the given position
  66729. * @param selectorNb the position of the selector within the group
  66730. */
  66731. removeSelector(selectorNb: number): void;
  66732. }
  66733. /** Class used to create a CheckboxGroup
  66734. * which contains groups of checkbox buttons
  66735. */
  66736. export class CheckboxGroup extends SelectorGroup {
  66737. /** Adds a checkbox as a control
  66738. * @param text is the label for the selector
  66739. * @param func is the function called when the Selector is checked
  66740. * @param checked is true when Selector is checked
  66741. */
  66742. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66743. /** @hidden */
  66744. _setSelectorLabel(selectorNb: number, label: string): void;
  66745. /** @hidden */
  66746. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66747. /** @hidden */
  66748. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66749. /** @hidden */
  66750. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66751. }
  66752. /** Class used to create a RadioGroup
  66753. * which contains groups of radio buttons
  66754. */
  66755. export class RadioGroup extends SelectorGroup {
  66756. private _selectNb;
  66757. /** Adds a radio button as a control
  66758. * @param label is the label for the selector
  66759. * @param func is the function called when the Selector is checked
  66760. * @param checked is true when Selector is checked
  66761. */
  66762. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66763. /** @hidden */
  66764. _setSelectorLabel(selectorNb: number, label: string): void;
  66765. /** @hidden */
  66766. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66767. /** @hidden */
  66768. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66769. /** @hidden */
  66770. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66771. }
  66772. /** Class used to create a SliderGroup
  66773. * which contains groups of slider buttons
  66774. */
  66775. export class SliderGroup extends SelectorGroup {
  66776. /**
  66777. * Adds a slider to the SelectorGroup
  66778. * @param label is the label for the SliderBar
  66779. * @param func is the function called when the Slider moves
  66780. * @param unit is a string describing the units used, eg degrees or metres
  66781. * @param min is the minimum value for the Slider
  66782. * @param max is the maximum value for the Slider
  66783. * @param value is the start value for the Slider between min and max
  66784. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66785. */
  66786. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66787. /** @hidden */
  66788. _setSelectorLabel(selectorNb: number, label: string): void;
  66789. /** @hidden */
  66790. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66791. /** @hidden */
  66792. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66793. /** @hidden */
  66794. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66795. }
  66796. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66797. * @see http://doc.babylonjs.com/how_to/selector
  66798. */
  66799. export class SelectionPanel extends Rectangle {
  66800. /** name of SelectionPanel */
  66801. name: string;
  66802. /** an array of SelectionGroups */
  66803. groups: SelectorGroup[];
  66804. private _panel;
  66805. private _buttonColor;
  66806. private _buttonBackground;
  66807. private _headerColor;
  66808. private _barColor;
  66809. private _barHeight;
  66810. private _spacerHeight;
  66811. private _labelColor;
  66812. private _groups;
  66813. private _bars;
  66814. /**
  66815. * Creates a new SelectionPanel
  66816. * @param name of SelectionPanel
  66817. * @param groups is an array of SelectionGroups
  66818. */
  66819. constructor(
  66820. /** name of SelectionPanel */
  66821. name: string,
  66822. /** an array of SelectionGroups */
  66823. groups?: SelectorGroup[]);
  66824. protected _getTypeName(): string;
  66825. /** Gets or sets the headerColor */
  66826. headerColor: string;
  66827. private _setHeaderColor;
  66828. /** Gets or sets the button color */
  66829. buttonColor: string;
  66830. private _setbuttonColor;
  66831. /** Gets or sets the label color */
  66832. labelColor: string;
  66833. private _setLabelColor;
  66834. /** Gets or sets the button background */
  66835. buttonBackground: string;
  66836. private _setButtonBackground;
  66837. /** Gets or sets the color of separator bar */
  66838. barColor: string;
  66839. private _setBarColor;
  66840. /** Gets or sets the height of separator bar */
  66841. barHeight: string;
  66842. private _setBarHeight;
  66843. /** Gets or sets the height of spacers*/
  66844. spacerHeight: string;
  66845. private _setSpacerHeight;
  66846. /** Adds a bar between groups */
  66847. private _addSpacer;
  66848. /** Add a group to the selection panel
  66849. * @param group is the selector group to add
  66850. */
  66851. addGroup(group: SelectorGroup): void;
  66852. /** Remove the group from the given position
  66853. * @param groupNb is the position of the group in the list
  66854. */
  66855. removeGroup(groupNb: number): void;
  66856. /** Change a group header label
  66857. * @param label is the new group header label
  66858. * @param groupNb is the number of the group to relabel
  66859. * */
  66860. setHeaderName(label: string, groupNb: number): void;
  66861. /** Change selector label to the one given
  66862. * @param label is the new selector label
  66863. * @param groupNb is the number of the groupcontaining the selector
  66864. * @param selectorNb is the number of the selector within a group to relabel
  66865. * */
  66866. relabel(label: string, groupNb: number, selectorNb: number): void;
  66867. /** For a given group position remove the selector at the given position
  66868. * @param groupNb is the number of the group to remove the selector from
  66869. * @param selectorNb is the number of the selector within the group
  66870. */
  66871. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66872. /** For a given group position of correct type add a checkbox button
  66873. * @param groupNb is the number of the group to remove the selector from
  66874. * @param label is the label for the selector
  66875. * @param func is the function called when the Selector is checked
  66876. * @param checked is true when Selector is checked
  66877. */
  66878. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66879. /** For a given group position of correct type add a radio button
  66880. * @param groupNb is the number of the group to remove the selector from
  66881. * @param label is the label for the selector
  66882. * @param func is the function called when the Selector is checked
  66883. * @param checked is true when Selector is checked
  66884. */
  66885. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66886. /**
  66887. * For a given slider group add a slider
  66888. * @param groupNb is the number of the group to add the slider to
  66889. * @param label is the label for the Slider
  66890. * @param func is the function called when the Slider moves
  66891. * @param unit is a string describing the units used, eg degrees or metres
  66892. * @param min is the minimum value for the Slider
  66893. * @param max is the maximum value for the Slider
  66894. * @param value is the start value for the Slider between min and max
  66895. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66896. */
  66897. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66898. }
  66899. }
  66900. declare module BABYLON.GUI {
  66901. /**
  66902. * Class used to hold a the container for ScrollViewer
  66903. * @hidden
  66904. */
  66905. export class _ScrollViewerWindow extends Container {
  66906. parentClientWidth: number;
  66907. parentClientHeight: number;
  66908. /**
  66909. * Creates a new ScrollViewerWindow
  66910. * @param name of ScrollViewerWindow
  66911. */
  66912. constructor(name?: string);
  66913. protected _getTypeName(): string;
  66914. /** @hidden */
  66915. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66916. protected _postMeasure(): void;
  66917. }
  66918. }
  66919. declare module BABYLON.GUI {
  66920. /**
  66921. * Class used to create slider controls
  66922. */
  66923. export class ScrollBar extends BaseSlider {
  66924. name?: string | undefined;
  66925. private _background;
  66926. private _borderColor;
  66927. private _thumbMeasure;
  66928. /** Gets or sets border color */
  66929. borderColor: string;
  66930. /** Gets or sets background color */
  66931. background: string;
  66932. /**
  66933. * Creates a new Slider
  66934. * @param name defines the control name
  66935. */
  66936. constructor(name?: string | undefined);
  66937. protected _getTypeName(): string;
  66938. protected _getThumbThickness(): number;
  66939. _draw(context: CanvasRenderingContext2D): void;
  66940. private _first;
  66941. private _originX;
  66942. private _originY;
  66943. /** @hidden */
  66944. protected _updateValueFromPointer(x: number, y: number): void;
  66945. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66946. }
  66947. }
  66948. declare module BABYLON.GUI {
  66949. /**
  66950. * Class used to hold a viewer window and sliders in a grid
  66951. */
  66952. export class ScrollViewer extends Rectangle {
  66953. private _grid;
  66954. private _horizontalBarSpace;
  66955. private _verticalBarSpace;
  66956. private _dragSpace;
  66957. private _horizontalBar;
  66958. private _verticalBar;
  66959. private _barColor;
  66960. private _barBackground;
  66961. private _barSize;
  66962. private _endLeft;
  66963. private _endTop;
  66964. private _window;
  66965. private _pointerIsOver;
  66966. private _wheelPrecision;
  66967. private _onPointerObserver;
  66968. private _clientWidth;
  66969. private _clientHeight;
  66970. /**
  66971. * Gets the horizontal scrollbar
  66972. */
  66973. readonly horizontalBar: ScrollBar;
  66974. /**
  66975. * Gets the vertical scrollbar
  66976. */
  66977. readonly verticalBar: ScrollBar;
  66978. /**
  66979. * Adds a new control to the current container
  66980. * @param control defines the control to add
  66981. * @returns the current container
  66982. */
  66983. addControl(control: BABYLON.Nullable<Control>): Container;
  66984. /**
  66985. * Removes a control from the current container
  66986. * @param control defines the control to remove
  66987. * @returns the current container
  66988. */
  66989. removeControl(control: Control): Container;
  66990. /** Gets the list of children */
  66991. readonly children: Control[];
  66992. _flagDescendantsAsMatrixDirty(): void;
  66993. /**
  66994. * Creates a new ScrollViewer
  66995. * @param name of ScrollViewer
  66996. */
  66997. constructor(name?: string);
  66998. /** Reset the scroll viewer window to initial size */
  66999. resetWindow(): void;
  67000. protected _getTypeName(): string;
  67001. private _buildClientSizes;
  67002. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67003. protected _postMeasure(): void;
  67004. /**
  67005. * Gets or sets the mouse wheel precision
  67006. * from 0 to 1 with a default value of 0.05
  67007. * */
  67008. wheelPrecision: number;
  67009. /** Gets or sets the bar color */
  67010. barColor: string;
  67011. /** Gets or sets the size of the bar */
  67012. barSize: number;
  67013. /** Gets or sets the bar background */
  67014. barBackground: string;
  67015. /** @hidden */
  67016. private _updateScroller;
  67017. _link(host: AdvancedDynamicTexture): void;
  67018. /** @hidden */
  67019. private _attachWheel;
  67020. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67021. /** Releases associated resources */
  67022. dispose(): void;
  67023. }
  67024. }
  67025. declare module BABYLON.GUI {
  67026. /** Class used to render a grid */
  67027. export class DisplayGrid extends Control {
  67028. name?: string | undefined;
  67029. private _cellWidth;
  67030. private _cellHeight;
  67031. private _minorLineTickness;
  67032. private _minorLineColor;
  67033. private _majorLineTickness;
  67034. private _majorLineColor;
  67035. private _majorLineFrequency;
  67036. private _background;
  67037. private _displayMajorLines;
  67038. private _displayMinorLines;
  67039. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  67040. displayMinorLines: boolean;
  67041. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  67042. displayMajorLines: boolean;
  67043. /** Gets or sets background color (Black by default) */
  67044. background: string;
  67045. /** Gets or sets the width of each cell (20 by default) */
  67046. cellWidth: number;
  67047. /** Gets or sets the height of each cell (20 by default) */
  67048. cellHeight: number;
  67049. /** Gets or sets the tickness of minor lines (1 by default) */
  67050. minorLineTickness: number;
  67051. /** Gets or sets the color of minor lines (DarkGray by default) */
  67052. minorLineColor: string;
  67053. /** Gets or sets the tickness of major lines (2 by default) */
  67054. majorLineTickness: number;
  67055. /** Gets or sets the color of major lines (White by default) */
  67056. majorLineColor: string;
  67057. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  67058. majorLineFrequency: number;
  67059. /**
  67060. * Creates a new GridDisplayRectangle
  67061. * @param name defines the control name
  67062. */
  67063. constructor(name?: string | undefined);
  67064. _draw(context: CanvasRenderingContext2D): void;
  67065. protected _getTypeName(): string;
  67066. }
  67067. }
  67068. declare module BABYLON.GUI {
  67069. /**
  67070. * Class used to create slider controls based on images
  67071. */
  67072. export class ImageBasedSlider extends BaseSlider {
  67073. name?: string | undefined;
  67074. private _backgroundImage;
  67075. private _thumbImage;
  67076. private _valueBarImage;
  67077. private _tempMeasure;
  67078. displayThumb: boolean;
  67079. /**
  67080. * Gets or sets the image used to render the background
  67081. */
  67082. backgroundImage: Image;
  67083. /**
  67084. * Gets or sets the image used to render the value bar
  67085. */
  67086. valueBarImage: Image;
  67087. /**
  67088. * Gets or sets the image used to render the thumb
  67089. */
  67090. thumbImage: Image;
  67091. /**
  67092. * Creates a new ImageBasedSlider
  67093. * @param name defines the control name
  67094. */
  67095. constructor(name?: string | undefined);
  67096. protected _getTypeName(): string;
  67097. _draw(context: CanvasRenderingContext2D): void;
  67098. }
  67099. }
  67100. declare module BABYLON.GUI {
  67101. /**
  67102. * Forcing an export so that this code will execute
  67103. * @hidden
  67104. */
  67105. const name = "Statics";
  67106. }
  67107. declare module BABYLON.GUI {
  67108. /**
  67109. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  67110. */
  67111. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  67112. /**
  67113. * Define the instrumented AdvancedDynamicTexture.
  67114. */
  67115. texture: AdvancedDynamicTexture;
  67116. private _captureRenderTime;
  67117. private _renderTime;
  67118. private _captureLayoutTime;
  67119. private _layoutTime;
  67120. private _onBeginRenderObserver;
  67121. private _onEndRenderObserver;
  67122. private _onBeginLayoutObserver;
  67123. private _onEndLayoutObserver;
  67124. /**
  67125. * Gets the perf counter used to capture render time
  67126. */
  67127. readonly renderTimeCounter: BABYLON.PerfCounter;
  67128. /**
  67129. * Gets the perf counter used to capture layout time
  67130. */
  67131. readonly layoutTimeCounter: BABYLON.PerfCounter;
  67132. /**
  67133. * Enable or disable the render time capture
  67134. */
  67135. captureRenderTime: boolean;
  67136. /**
  67137. * Enable or disable the layout time capture
  67138. */
  67139. captureLayoutTime: boolean;
  67140. /**
  67141. * Instantiates a new advanced dynamic texture instrumentation.
  67142. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  67143. * @param texture Defines the AdvancedDynamicTexture to instrument
  67144. */
  67145. constructor(
  67146. /**
  67147. * Define the instrumented AdvancedDynamicTexture.
  67148. */
  67149. texture: AdvancedDynamicTexture);
  67150. /**
  67151. * Dispose and release associated resources.
  67152. */
  67153. dispose(): void;
  67154. }
  67155. }
  67156. declare module BABYLON.GUI {
  67157. /**
  67158. * Class used to load GUI via XML.
  67159. */
  67160. export class XmlLoader {
  67161. private _nodes;
  67162. private _nodeTypes;
  67163. private _isLoaded;
  67164. private _objectAttributes;
  67165. private _parentClass;
  67166. /**
  67167. * Create a new xml loader
  67168. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  67169. */
  67170. constructor(parentClass?: null);
  67171. private _getChainElement;
  67172. private _getClassAttribute;
  67173. private _createGuiElement;
  67174. private _parseGrid;
  67175. private _parseElement;
  67176. private _prepareSourceElement;
  67177. private _parseElementsFromSource;
  67178. private _parseXml;
  67179. /**
  67180. * Gets if the loading has finished.
  67181. * @returns whether the loading has finished or not
  67182. */
  67183. isLoaded(): boolean;
  67184. /**
  67185. * Gets a loaded node / control by id.
  67186. * @param id the Controls id set in the xml
  67187. * @returns element of type Control
  67188. */
  67189. getNodeById(id: string): any;
  67190. /**
  67191. * Gets all loaded nodes / controls
  67192. * @returns Array of controls
  67193. */
  67194. getNodes(): any;
  67195. /**
  67196. * Initiates the xml layout loading
  67197. * @param xmlFile defines the xml layout to load
  67198. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  67199. * @param callback defines the callback called on layout load.
  67200. */
  67201. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  67202. }
  67203. }
  67204. declare module BABYLON.GUI {
  67205. /**
  67206. * Class used to create containers for controls
  67207. */
  67208. export class Container3D extends Control3D {
  67209. private _blockLayout;
  67210. /**
  67211. * Gets the list of child controls
  67212. */
  67213. protected _children: Control3D[];
  67214. /**
  67215. * Gets the list of child controls
  67216. */
  67217. readonly children: Array<Control3D>;
  67218. /**
  67219. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  67220. * This is helpful to optimize layout operation when adding multiple children in a row
  67221. */
  67222. blockLayout: boolean;
  67223. /**
  67224. * Creates a new container
  67225. * @param name defines the container name
  67226. */
  67227. constructor(name?: string);
  67228. /**
  67229. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  67230. * @returns the current container
  67231. */
  67232. updateLayout(): Container3D;
  67233. /**
  67234. * Gets a boolean indicating if the given control is in the children of this control
  67235. * @param control defines the control to check
  67236. * @returns true if the control is in the child list
  67237. */
  67238. containsControl(control: Control3D): boolean;
  67239. /**
  67240. * Adds a control to the children of this control
  67241. * @param control defines the control to add
  67242. * @returns the current container
  67243. */
  67244. addControl(control: Control3D): Container3D;
  67245. /**
  67246. * This function will be called everytime a new control is added
  67247. */
  67248. protected _arrangeChildren(): void;
  67249. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67250. /**
  67251. * Removes a control from the children of this control
  67252. * @param control defines the control to remove
  67253. * @returns the current container
  67254. */
  67255. removeControl(control: Control3D): Container3D;
  67256. protected _getTypeName(): string;
  67257. /**
  67258. * Releases all associated resources
  67259. */
  67260. dispose(): void;
  67261. /** Control rotation will remain unchanged */
  67262. static readonly UNSET_ORIENTATION: number;
  67263. /** Control will rotate to make it look at sphere central axis */
  67264. static readonly FACEORIGIN_ORIENTATION: number;
  67265. /** Control will rotate to make it look back at sphere central axis */
  67266. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  67267. /** Control will rotate to look at z axis (0, 0, 1) */
  67268. static readonly FACEFORWARD_ORIENTATION: number;
  67269. /** Control will rotate to look at negative z axis (0, 0, -1) */
  67270. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  67271. }
  67272. }
  67273. declare module BABYLON.GUI {
  67274. /**
  67275. * Class used to manage 3D user interface
  67276. * @see http://doc.babylonjs.com/how_to/gui3d
  67277. */
  67278. export class GUI3DManager implements BABYLON.IDisposable {
  67279. private _scene;
  67280. private _sceneDisposeObserver;
  67281. private _utilityLayer;
  67282. private _rootContainer;
  67283. private _pointerObserver;
  67284. private _pointerOutObserver;
  67285. /** @hidden */
  67286. _lastPickedControl: Control3D;
  67287. /** @hidden */
  67288. _lastControlOver: {
  67289. [pointerId: number]: Control3D;
  67290. };
  67291. /** @hidden */
  67292. _lastControlDown: {
  67293. [pointerId: number]: Control3D;
  67294. };
  67295. /**
  67296. * BABYLON.Observable raised when the point picked by the pointer events changed
  67297. */
  67298. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  67299. /** @hidden */
  67300. _sharedMaterials: {
  67301. [key: string]: BABYLON.Material;
  67302. };
  67303. /** Gets the hosting scene */
  67304. readonly scene: BABYLON.Scene;
  67305. /** Gets associated utility layer */
  67306. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  67307. /**
  67308. * Creates a new GUI3DManager
  67309. * @param scene
  67310. */
  67311. constructor(scene?: BABYLON.Scene);
  67312. private _handlePointerOut;
  67313. private _doPicking;
  67314. /**
  67315. * Gets the root container
  67316. */
  67317. readonly rootContainer: Container3D;
  67318. /**
  67319. * Gets a boolean indicating if the given control is in the root child list
  67320. * @param control defines the control to check
  67321. * @returns true if the control is in the root child list
  67322. */
  67323. containsControl(control: Control3D): boolean;
  67324. /**
  67325. * Adds a control to the root child list
  67326. * @param control defines the control to add
  67327. * @returns the current manager
  67328. */
  67329. addControl(control: Control3D): GUI3DManager;
  67330. /**
  67331. * Removes a control from the root child list
  67332. * @param control defines the control to remove
  67333. * @returns the current container
  67334. */
  67335. removeControl(control: Control3D): GUI3DManager;
  67336. /**
  67337. * Releases all associated resources
  67338. */
  67339. dispose(): void;
  67340. }
  67341. }
  67342. declare module BABYLON.GUI {
  67343. /**
  67344. * Class used to transport BABYLON.Vector3 information for pointer events
  67345. */
  67346. export class Vector3WithInfo extends BABYLON.Vector3 {
  67347. /** defines the current mouse button index */
  67348. buttonIndex: number;
  67349. /**
  67350. * Creates a new Vector3WithInfo
  67351. * @param source defines the vector3 data to transport
  67352. * @param buttonIndex defines the current mouse button index
  67353. */
  67354. constructor(source: BABYLON.Vector3,
  67355. /** defines the current mouse button index */
  67356. buttonIndex?: number);
  67357. }
  67358. }
  67359. declare module BABYLON.GUI {
  67360. /**
  67361. * Class used as base class for controls
  67362. */
  67363. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  67364. /** Defines the control name */
  67365. name?: string | undefined;
  67366. /** @hidden */
  67367. _host: GUI3DManager;
  67368. private _node;
  67369. private _downCount;
  67370. private _enterCount;
  67371. private _downPointerIds;
  67372. private _isVisible;
  67373. /** Gets or sets the control position in world space */
  67374. position: BABYLON.Vector3;
  67375. /** Gets or sets the control scaling in world space */
  67376. scaling: BABYLON.Vector3;
  67377. /** Callback used to start pointer enter animation */
  67378. pointerEnterAnimation: () => void;
  67379. /** Callback used to start pointer out animation */
  67380. pointerOutAnimation: () => void;
  67381. /** Callback used to start pointer down animation */
  67382. pointerDownAnimation: () => void;
  67383. /** Callback used to start pointer up animation */
  67384. pointerUpAnimation: () => void;
  67385. /**
  67386. * An event triggered when the pointer move over the control
  67387. */
  67388. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  67389. /**
  67390. * An event triggered when the pointer move out of the control
  67391. */
  67392. onPointerOutObservable: BABYLON.Observable<Control3D>;
  67393. /**
  67394. * An event triggered when the pointer taps the control
  67395. */
  67396. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  67397. /**
  67398. * An event triggered when pointer is up
  67399. */
  67400. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  67401. /**
  67402. * An event triggered when a control is clicked on (with a mouse)
  67403. */
  67404. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  67405. /**
  67406. * An event triggered when pointer enters the control
  67407. */
  67408. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  67409. /**
  67410. * Gets or sets the parent container
  67411. */
  67412. parent: BABYLON.Nullable<Container3D>;
  67413. private _behaviors;
  67414. /**
  67415. * Gets the list of attached behaviors
  67416. * @see http://doc.babylonjs.com/features/behaviour
  67417. */
  67418. readonly behaviors: BABYLON.Behavior<Control3D>[];
  67419. /**
  67420. * Attach a behavior to the control
  67421. * @see http://doc.babylonjs.com/features/behaviour
  67422. * @param behavior defines the behavior to attach
  67423. * @returns the current control
  67424. */
  67425. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67426. /**
  67427. * Remove an attached behavior
  67428. * @see http://doc.babylonjs.com/features/behaviour
  67429. * @param behavior defines the behavior to attach
  67430. * @returns the current control
  67431. */
  67432. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67433. /**
  67434. * Gets an attached behavior by name
  67435. * @param name defines the name of the behavior to look for
  67436. * @see http://doc.babylonjs.com/features/behaviour
  67437. * @returns null if behavior was not found else the requested behavior
  67438. */
  67439. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  67440. /** Gets or sets a boolean indicating if the control is visible */
  67441. isVisible: boolean;
  67442. /**
  67443. * Creates a new control
  67444. * @param name defines the control name
  67445. */
  67446. constructor(
  67447. /** Defines the control name */
  67448. name?: string | undefined);
  67449. /**
  67450. * Gets a string representing the class name
  67451. */
  67452. readonly typeName: string;
  67453. /**
  67454. * Get the current class name of the control.
  67455. * @returns current class name
  67456. */
  67457. getClassName(): string;
  67458. protected _getTypeName(): string;
  67459. /**
  67460. * Gets the transform node used by this control
  67461. */
  67462. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  67463. /**
  67464. * Gets the mesh used to render this control
  67465. */
  67466. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67467. /**
  67468. * Link the control as child of the given node
  67469. * @param node defines the node to link to. Use null to unlink the control
  67470. * @returns the current control
  67471. */
  67472. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  67473. /** @hidden **/
  67474. _prepareNode(scene: BABYLON.Scene): void;
  67475. /**
  67476. * Node creation.
  67477. * Can be overriden by children
  67478. * @param scene defines the scene where the node must be attached
  67479. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  67480. */
  67481. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67482. /**
  67483. * Affect a material to the given mesh
  67484. * @param mesh defines the mesh which will represent the control
  67485. */
  67486. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67487. /** @hidden */
  67488. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  67489. /** @hidden */
  67490. _onPointerEnter(target: Control3D): boolean;
  67491. /** @hidden */
  67492. _onPointerOut(target: Control3D): void;
  67493. /** @hidden */
  67494. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67495. /** @hidden */
  67496. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67497. /** @hidden */
  67498. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67499. /** @hidden */
  67500. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67501. /** @hidden */
  67502. _disposeNode(): void;
  67503. /**
  67504. * Releases all associated resources
  67505. */
  67506. dispose(): void;
  67507. }
  67508. }
  67509. declare module BABYLON.GUI {
  67510. /**
  67511. * Class used as a root to all buttons
  67512. */
  67513. export class AbstractButton3D extends Control3D {
  67514. /**
  67515. * Creates a new button
  67516. * @param name defines the control name
  67517. */
  67518. constructor(name?: string);
  67519. protected _getTypeName(): string;
  67520. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67521. }
  67522. }
  67523. declare module BABYLON.GUI {
  67524. /**
  67525. * Class used to create a button in 3D
  67526. */
  67527. export class Button3D extends AbstractButton3D {
  67528. /** @hidden */
  67529. protected _currentMaterial: BABYLON.Material;
  67530. private _facadeTexture;
  67531. private _content;
  67532. private _contentResolution;
  67533. private _contentScaleRatio;
  67534. /**
  67535. * Gets or sets the texture resolution used to render content (512 by default)
  67536. */
  67537. contentResolution: BABYLON.int;
  67538. /**
  67539. * Gets or sets the texture scale ratio used to render content (2 by default)
  67540. */
  67541. contentScaleRatio: number;
  67542. protected _disposeFacadeTexture(): void;
  67543. protected _resetContent(): void;
  67544. /**
  67545. * Creates a new button
  67546. * @param name defines the control name
  67547. */
  67548. constructor(name?: string);
  67549. /**
  67550. * Gets or sets the GUI 2D content used to display the button's facade
  67551. */
  67552. content: Control;
  67553. /**
  67554. * Apply the facade texture (created from the content property).
  67555. * This function can be overloaded by child classes
  67556. * @param facadeTexture defines the AdvancedDynamicTexture to use
  67557. */
  67558. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67559. protected _getTypeName(): string;
  67560. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67561. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67562. /**
  67563. * Releases all associated resources
  67564. */
  67565. dispose(): void;
  67566. }
  67567. }
  67568. declare module BABYLON.GUI {
  67569. /**
  67570. * Abstract class used to create a container panel deployed on the surface of a volume
  67571. */
  67572. export abstract class VolumeBasedPanel extends Container3D {
  67573. private _columns;
  67574. private _rows;
  67575. private _rowThenColum;
  67576. private _orientation;
  67577. protected _cellWidth: number;
  67578. protected _cellHeight: number;
  67579. /**
  67580. * Gets or sets the distance between elements
  67581. */
  67582. margin: number;
  67583. /**
  67584. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  67585. * | Value | Type | Description |
  67586. * | ----- | ----------------------------------- | ----------- |
  67587. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  67588. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  67589. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  67590. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  67591. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  67592. */
  67593. orientation: number;
  67594. /**
  67595. * Gets or sets the number of columns requested (10 by default).
  67596. * The panel will automatically compute the number of rows based on number of child controls.
  67597. */
  67598. columns: BABYLON.int;
  67599. /**
  67600. * Gets or sets a the number of rows requested.
  67601. * The panel will automatically compute the number of columns based on number of child controls.
  67602. */
  67603. rows: BABYLON.int;
  67604. /**
  67605. * Creates new VolumeBasedPanel
  67606. */
  67607. constructor();
  67608. protected _arrangeChildren(): void;
  67609. /** Child classes must implement this function to provide correct control positioning */
  67610. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67611. /** Child classes can implement this function to provide additional processing */
  67612. protected _finalProcessing(): void;
  67613. }
  67614. }
  67615. declare module BABYLON.GUI {
  67616. /**
  67617. * Class used to create a container panel deployed on the surface of a cylinder
  67618. */
  67619. export class CylinderPanel extends VolumeBasedPanel {
  67620. private _radius;
  67621. /**
  67622. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  67623. */
  67624. radius: BABYLON.float;
  67625. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67626. private _cylindricalMapping;
  67627. }
  67628. }
  67629. declare module BABYLON.GUI {
  67630. /** @hidden */
  67631. export var fluentVertexShader: {
  67632. name: string;
  67633. shader: string;
  67634. };
  67635. }
  67636. declare module BABYLON.GUI {
  67637. /** @hidden */
  67638. export var fluentPixelShader: {
  67639. name: string;
  67640. shader: string;
  67641. };
  67642. }
  67643. declare module BABYLON.GUI {
  67644. /** @hidden */
  67645. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  67646. INNERGLOW: boolean;
  67647. BORDER: boolean;
  67648. HOVERLIGHT: boolean;
  67649. TEXTURE: boolean;
  67650. constructor();
  67651. }
  67652. /**
  67653. * Class used to render controls with fluent desgin
  67654. */
  67655. export class FluentMaterial extends BABYLON.PushMaterial {
  67656. /**
  67657. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  67658. */
  67659. innerGlowColorIntensity: number;
  67660. /**
  67661. * Gets or sets the inner glow color (white by default)
  67662. */
  67663. innerGlowColor: BABYLON.Color3;
  67664. /**
  67665. * Gets or sets alpha value (default is 1.0)
  67666. */
  67667. alpha: number;
  67668. /**
  67669. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  67670. */
  67671. albedoColor: BABYLON.Color3;
  67672. /**
  67673. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  67674. */
  67675. renderBorders: boolean;
  67676. /**
  67677. * Gets or sets border width (default is 0.5)
  67678. */
  67679. borderWidth: number;
  67680. /**
  67681. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  67682. */
  67683. edgeSmoothingValue: number;
  67684. /**
  67685. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67686. */
  67687. borderMinValue: number;
  67688. /**
  67689. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67690. */
  67691. renderHoverLight: boolean;
  67692. /**
  67693. * Gets or sets the radius used to render the hover light (default is 1.0)
  67694. */
  67695. hoverRadius: number;
  67696. /**
  67697. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67698. */
  67699. hoverColor: BABYLON.Color4;
  67700. /**
  67701. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67702. */
  67703. hoverPosition: BABYLON.Vector3;
  67704. private _albedoTexture;
  67705. /** Gets or sets the texture to use for albedo color */
  67706. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67707. /**
  67708. * Creates a new Fluent material
  67709. * @param name defines the name of the material
  67710. * @param scene defines the hosting scene
  67711. */
  67712. constructor(name: string, scene: BABYLON.Scene);
  67713. needAlphaBlending(): boolean;
  67714. needAlphaTesting(): boolean;
  67715. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67716. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67717. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67718. getActiveTextures(): BABYLON.BaseTexture[];
  67719. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67720. dispose(forceDisposeEffect?: boolean): void;
  67721. clone(name: string): FluentMaterial;
  67722. serialize(): any;
  67723. getClassName(): string;
  67724. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67725. }
  67726. }
  67727. declare module BABYLON.GUI {
  67728. /**
  67729. * Class used to create a holographic button in 3D
  67730. */
  67731. export class HolographicButton extends Button3D {
  67732. private _backPlate;
  67733. private _textPlate;
  67734. private _frontPlate;
  67735. private _text;
  67736. private _imageUrl;
  67737. private _shareMaterials;
  67738. private _frontMaterial;
  67739. private _backMaterial;
  67740. private _plateMaterial;
  67741. private _pickedPointObserver;
  67742. private _tooltipFade;
  67743. private _tooltipTextBlock;
  67744. private _tooltipTexture;
  67745. private _tooltipMesh;
  67746. private _tooltipHoverObserver;
  67747. private _tooltipOutObserver;
  67748. private _disposeTooltip;
  67749. /**
  67750. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67751. */
  67752. tooltipText: BABYLON.Nullable<string>;
  67753. /**
  67754. * Gets or sets text for the button
  67755. */
  67756. text: string;
  67757. /**
  67758. * Gets or sets the image url for the button
  67759. */
  67760. imageUrl: string;
  67761. /**
  67762. * Gets the back material used by this button
  67763. */
  67764. readonly backMaterial: FluentMaterial;
  67765. /**
  67766. * Gets the front material used by this button
  67767. */
  67768. readonly frontMaterial: FluentMaterial;
  67769. /**
  67770. * Gets the plate material used by this button
  67771. */
  67772. readonly plateMaterial: BABYLON.StandardMaterial;
  67773. /**
  67774. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67775. */
  67776. readonly shareMaterials: boolean;
  67777. /**
  67778. * Creates a new button
  67779. * @param name defines the control name
  67780. */
  67781. constructor(name?: string, shareMaterials?: boolean);
  67782. protected _getTypeName(): string;
  67783. private _rebuildContent;
  67784. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67785. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67786. private _createBackMaterial;
  67787. private _createFrontMaterial;
  67788. private _createPlateMaterial;
  67789. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67790. /**
  67791. * Releases all associated resources
  67792. */
  67793. dispose(): void;
  67794. }
  67795. }
  67796. declare module BABYLON.GUI {
  67797. /**
  67798. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67799. */
  67800. export class MeshButton3D extends Button3D {
  67801. /** @hidden */
  67802. protected _currentMesh: BABYLON.Mesh;
  67803. /**
  67804. * Creates a new 3D button based on a mesh
  67805. * @param mesh mesh to become a 3D button
  67806. * @param name defines the control name
  67807. */
  67808. constructor(mesh: BABYLON.Mesh, name?: string);
  67809. protected _getTypeName(): string;
  67810. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67811. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67812. }
  67813. }
  67814. declare module BABYLON.GUI {
  67815. /**
  67816. * Class used to create a container panel deployed on the surface of a plane
  67817. */
  67818. export class PlanePanel extends VolumeBasedPanel {
  67819. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67820. }
  67821. }
  67822. declare module BABYLON.GUI {
  67823. /**
  67824. * Class used to create a container panel where items get randomized planar mapping
  67825. */
  67826. export class ScatterPanel extends VolumeBasedPanel {
  67827. private _iteration;
  67828. /**
  67829. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67830. */
  67831. iteration: BABYLON.float;
  67832. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67833. private _scatterMapping;
  67834. protected _finalProcessing(): void;
  67835. }
  67836. }
  67837. declare module BABYLON.GUI {
  67838. /**
  67839. * Class used to create a container panel deployed on the surface of a sphere
  67840. */
  67841. export class SpherePanel extends VolumeBasedPanel {
  67842. private _radius;
  67843. /**
  67844. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67845. */
  67846. radius: BABYLON.float;
  67847. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67848. private _sphericalMapping;
  67849. }
  67850. }
  67851. declare module BABYLON.GUI {
  67852. /**
  67853. * Class used to create a stack panel in 3D on XY plane
  67854. */
  67855. export class StackPanel3D extends Container3D {
  67856. private _isVertical;
  67857. /**
  67858. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67859. */
  67860. isVertical: boolean;
  67861. /**
  67862. * Gets or sets the distance between elements
  67863. */
  67864. margin: number;
  67865. /**
  67866. * Creates new StackPanel
  67867. * @param isVertical
  67868. */
  67869. constructor(isVertical?: boolean);
  67870. protected _arrangeChildren(): void;
  67871. }
  67872. }
  67873. declare module BABYLON {
  67874. /**
  67875. * Mode that determines the coordinate system to use.
  67876. */
  67877. export enum GLTFLoaderCoordinateSystemMode {
  67878. /**
  67879. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67880. */
  67881. AUTO = 0,
  67882. /**
  67883. * Sets the useRightHandedSystem flag on the scene.
  67884. */
  67885. FORCE_RIGHT_HANDED = 1
  67886. }
  67887. /**
  67888. * Mode that determines what animations will start.
  67889. */
  67890. export enum GLTFLoaderAnimationStartMode {
  67891. /**
  67892. * No animation will start.
  67893. */
  67894. NONE = 0,
  67895. /**
  67896. * The first animation will start.
  67897. */
  67898. FIRST = 1,
  67899. /**
  67900. * All animations will start.
  67901. */
  67902. ALL = 2
  67903. }
  67904. /**
  67905. * Interface that contains the data for the glTF asset.
  67906. */
  67907. export interface IGLTFLoaderData {
  67908. /**
  67909. * Object that represents the glTF JSON.
  67910. */
  67911. json: Object;
  67912. /**
  67913. * The BIN chunk of a binary glTF.
  67914. */
  67915. bin: Nullable<ArrayBufferView>;
  67916. }
  67917. /**
  67918. * Interface for extending the loader.
  67919. */
  67920. export interface IGLTFLoaderExtension {
  67921. /**
  67922. * The name of this extension.
  67923. */
  67924. readonly name: string;
  67925. /**
  67926. * Defines whether this extension is enabled.
  67927. */
  67928. enabled: boolean;
  67929. }
  67930. /**
  67931. * Loader state.
  67932. */
  67933. export enum GLTFLoaderState {
  67934. /**
  67935. * The asset is loading.
  67936. */
  67937. LOADING = 0,
  67938. /**
  67939. * The asset is ready for rendering.
  67940. */
  67941. READY = 1,
  67942. /**
  67943. * The asset is completely loaded.
  67944. */
  67945. COMPLETE = 2
  67946. }
  67947. /** @hidden */
  67948. export interface IGLTFLoader extends IDisposable {
  67949. readonly state: Nullable<GLTFLoaderState>;
  67950. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67951. meshes: AbstractMesh[];
  67952. particleSystems: IParticleSystem[];
  67953. skeletons: Skeleton[];
  67954. animationGroups: AnimationGroup[];
  67955. }>;
  67956. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67957. }
  67958. /**
  67959. * File loader for loading glTF files into a scene.
  67960. */
  67961. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67962. /** @hidden */
  67963. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67964. /** @hidden */
  67965. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67966. /**
  67967. * Raised when the asset has been parsed
  67968. */
  67969. onParsedObservable: Observable<IGLTFLoaderData>;
  67970. private _onParsedObserver;
  67971. /**
  67972. * Raised when the asset has been parsed
  67973. */
  67974. onParsed: (loaderData: IGLTFLoaderData) => void;
  67975. /**
  67976. * 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.
  67977. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67978. * Defaults to true.
  67979. * @hidden
  67980. */
  67981. static IncrementalLoading: boolean;
  67982. /**
  67983. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67984. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67985. * @hidden
  67986. */
  67987. static HomogeneousCoordinates: boolean;
  67988. /**
  67989. * The coordinate system mode. Defaults to AUTO.
  67990. */
  67991. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67992. /**
  67993. * The animation start mode. Defaults to FIRST.
  67994. */
  67995. animationStartMode: GLTFLoaderAnimationStartMode;
  67996. /**
  67997. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67998. */
  67999. compileMaterials: boolean;
  68000. /**
  68001. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  68002. */
  68003. useClipPlane: boolean;
  68004. /**
  68005. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  68006. */
  68007. compileShadowGenerators: boolean;
  68008. /**
  68009. * Defines if the Alpha blended materials are only applied as coverage.
  68010. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  68011. * If true, no extra effects are applied to transparent pixels.
  68012. */
  68013. transparencyAsCoverage: boolean;
  68014. /**
  68015. * Function called before loading a url referenced by the asset.
  68016. */
  68017. preprocessUrlAsync: (url: string) => Promise<string>;
  68018. /**
  68019. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68020. */
  68021. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  68022. private _onMeshLoadedObserver;
  68023. /**
  68024. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68025. */
  68026. onMeshLoaded: (mesh: AbstractMesh) => void;
  68027. /**
  68028. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  68029. */
  68030. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  68031. private _onTextureLoadedObserver;
  68032. /**
  68033. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  68034. */
  68035. onTextureLoaded: (texture: BaseTexture) => void;
  68036. /**
  68037. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  68038. */
  68039. readonly onMaterialLoadedObservable: Observable<Material>;
  68040. private _onMaterialLoadedObserver;
  68041. /**
  68042. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  68043. */
  68044. onMaterialLoaded: (material: Material) => void;
  68045. /**
  68046. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  68047. */
  68048. readonly onCameraLoadedObservable: Observable<Camera>;
  68049. private _onCameraLoadedObserver;
  68050. /**
  68051. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  68052. */
  68053. onCameraLoaded: (camera: Camera) => void;
  68054. /**
  68055. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  68056. * For assets with LODs, raised when all of the LODs are complete.
  68057. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68058. */
  68059. readonly onCompleteObservable: Observable<void>;
  68060. private _onCompleteObserver;
  68061. /**
  68062. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  68063. * For assets with LODs, raised when all of the LODs are complete.
  68064. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68065. */
  68066. onComplete: () => void;
  68067. /**
  68068. * Observable raised when an error occurs.
  68069. */
  68070. readonly onErrorObservable: Observable<any>;
  68071. private _onErrorObserver;
  68072. /**
  68073. * Callback raised when an error occurs.
  68074. */
  68075. onError: (reason: any) => void;
  68076. /**
  68077. * Observable raised after the loader is disposed.
  68078. */
  68079. readonly onDisposeObservable: Observable<void>;
  68080. private _onDisposeObserver;
  68081. /**
  68082. * Callback raised after the loader is disposed.
  68083. */
  68084. onDispose: () => void;
  68085. /**
  68086. * Observable raised after a loader extension is created.
  68087. * Set additional options for a loader extension in this event.
  68088. */
  68089. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  68090. private _onExtensionLoadedObserver;
  68091. /**
  68092. * Callback raised after a loader extension is created.
  68093. */
  68094. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  68095. /**
  68096. * Defines if the loader logging is enabled.
  68097. */
  68098. loggingEnabled: boolean;
  68099. /**
  68100. * Defines if the loader should capture performance counters.
  68101. */
  68102. capturePerformanceCounters: boolean;
  68103. /**
  68104. * Defines if the loader should validate the asset.
  68105. */
  68106. validate: boolean;
  68107. /**
  68108. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  68109. */
  68110. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  68111. private _onValidatedObserver;
  68112. /**
  68113. * Callback raised after a loader extension is created.
  68114. */
  68115. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  68116. private _loader;
  68117. /**
  68118. * Name of the loader ("gltf")
  68119. */
  68120. name: string;
  68121. /**
  68122. * Supported file extensions of the loader (.gltf, .glb)
  68123. */
  68124. extensions: ISceneLoaderPluginExtensions;
  68125. /**
  68126. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  68127. */
  68128. dispose(): void;
  68129. /** @hidden */
  68130. _clear(): void;
  68131. /**
  68132. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  68133. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68134. * @param scene the scene the meshes should be added to
  68135. * @param data the glTF data to load
  68136. * @param rootUrl root url to load from
  68137. * @param onProgress event that fires when loading progress has occured
  68138. * @param fileName Defines the name of the file to load
  68139. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68140. */
  68141. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68142. meshes: AbstractMesh[];
  68143. particleSystems: IParticleSystem[];
  68144. skeletons: Skeleton[];
  68145. animationGroups: AnimationGroup[];
  68146. }>;
  68147. /**
  68148. * Imports all objects from the loaded glTF data and adds them to the scene
  68149. * @param scene the scene the objects should be added to
  68150. * @param data the glTF data to load
  68151. * @param rootUrl root url to load from
  68152. * @param onProgress event that fires when loading progress has occured
  68153. * @param fileName Defines the name of the file to load
  68154. * @returns a promise which completes when objects have been loaded to the scene
  68155. */
  68156. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68157. /**
  68158. * Load into an asset container.
  68159. * @param scene The scene to load into
  68160. * @param data The data to import
  68161. * @param rootUrl The root url for scene and resources
  68162. * @param onProgress The callback when the load progresses
  68163. * @param fileName Defines the name of the file to load
  68164. * @returns The loaded asset container
  68165. */
  68166. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68167. /**
  68168. * If the data string can be loaded directly.
  68169. * @param data string contianing the file data
  68170. * @returns if the data can be loaded directly
  68171. */
  68172. canDirectLoad(data: string): boolean;
  68173. /**
  68174. * Rewrites a url by combining a root url and response url.
  68175. */
  68176. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  68177. /**
  68178. * Instantiates a glTF file loader plugin.
  68179. * @returns the created plugin
  68180. */
  68181. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  68182. /**
  68183. * The loader state or null if the loader is not active.
  68184. */
  68185. readonly loaderState: Nullable<GLTFLoaderState>;
  68186. /**
  68187. * Returns a promise that resolves when the asset is completely loaded.
  68188. * @returns a promise that resolves when the asset is completely loaded.
  68189. */
  68190. whenCompleteAsync(): Promise<void>;
  68191. private _parseAsync;
  68192. private _validateAsync;
  68193. private _getLoader;
  68194. private _unpackBinary;
  68195. private _unpackBinaryV1;
  68196. private _unpackBinaryV2;
  68197. private static _parseVersion;
  68198. private static _compareVersion;
  68199. private static _decodeBufferToText;
  68200. private static readonly _logSpaces;
  68201. private _logIndentLevel;
  68202. private _loggingEnabled;
  68203. /** @hidden */
  68204. _log: (message: string) => void;
  68205. /** @hidden */
  68206. _logOpen(message: string): void;
  68207. /** @hidden */
  68208. _logClose(): void;
  68209. private _logEnabled;
  68210. private _logDisabled;
  68211. private _capturePerformanceCounters;
  68212. /** @hidden */
  68213. _startPerformanceCounter: (counterName: string) => void;
  68214. /** @hidden */
  68215. _endPerformanceCounter: (counterName: string) => void;
  68216. private _startPerformanceCounterEnabled;
  68217. private _startPerformanceCounterDisabled;
  68218. private _endPerformanceCounterEnabled;
  68219. private _endPerformanceCounterDisabled;
  68220. }
  68221. }
  68222. declare module BABYLON.GLTF1 {
  68223. /**
  68224. * Enums
  68225. * @hidden
  68226. */
  68227. export enum EComponentType {
  68228. BYTE = 5120,
  68229. UNSIGNED_BYTE = 5121,
  68230. SHORT = 5122,
  68231. UNSIGNED_SHORT = 5123,
  68232. FLOAT = 5126
  68233. }
  68234. /** @hidden */
  68235. export enum EShaderType {
  68236. FRAGMENT = 35632,
  68237. VERTEX = 35633
  68238. }
  68239. /** @hidden */
  68240. export enum EParameterType {
  68241. BYTE = 5120,
  68242. UNSIGNED_BYTE = 5121,
  68243. SHORT = 5122,
  68244. UNSIGNED_SHORT = 5123,
  68245. INT = 5124,
  68246. UNSIGNED_INT = 5125,
  68247. FLOAT = 5126,
  68248. FLOAT_VEC2 = 35664,
  68249. FLOAT_VEC3 = 35665,
  68250. FLOAT_VEC4 = 35666,
  68251. INT_VEC2 = 35667,
  68252. INT_VEC3 = 35668,
  68253. INT_VEC4 = 35669,
  68254. BOOL = 35670,
  68255. BOOL_VEC2 = 35671,
  68256. BOOL_VEC3 = 35672,
  68257. BOOL_VEC4 = 35673,
  68258. FLOAT_MAT2 = 35674,
  68259. FLOAT_MAT3 = 35675,
  68260. FLOAT_MAT4 = 35676,
  68261. SAMPLER_2D = 35678
  68262. }
  68263. /** @hidden */
  68264. export enum ETextureWrapMode {
  68265. CLAMP_TO_EDGE = 33071,
  68266. MIRRORED_REPEAT = 33648,
  68267. REPEAT = 10497
  68268. }
  68269. /** @hidden */
  68270. export enum ETextureFilterType {
  68271. NEAREST = 9728,
  68272. LINEAR = 9728,
  68273. NEAREST_MIPMAP_NEAREST = 9984,
  68274. LINEAR_MIPMAP_NEAREST = 9985,
  68275. NEAREST_MIPMAP_LINEAR = 9986,
  68276. LINEAR_MIPMAP_LINEAR = 9987
  68277. }
  68278. /** @hidden */
  68279. export enum ETextureFormat {
  68280. ALPHA = 6406,
  68281. RGB = 6407,
  68282. RGBA = 6408,
  68283. LUMINANCE = 6409,
  68284. LUMINANCE_ALPHA = 6410
  68285. }
  68286. /** @hidden */
  68287. export enum ECullingType {
  68288. FRONT = 1028,
  68289. BACK = 1029,
  68290. FRONT_AND_BACK = 1032
  68291. }
  68292. /** @hidden */
  68293. export enum EBlendingFunction {
  68294. ZERO = 0,
  68295. ONE = 1,
  68296. SRC_COLOR = 768,
  68297. ONE_MINUS_SRC_COLOR = 769,
  68298. DST_COLOR = 774,
  68299. ONE_MINUS_DST_COLOR = 775,
  68300. SRC_ALPHA = 770,
  68301. ONE_MINUS_SRC_ALPHA = 771,
  68302. DST_ALPHA = 772,
  68303. ONE_MINUS_DST_ALPHA = 773,
  68304. CONSTANT_COLOR = 32769,
  68305. ONE_MINUS_CONSTANT_COLOR = 32770,
  68306. CONSTANT_ALPHA = 32771,
  68307. ONE_MINUS_CONSTANT_ALPHA = 32772,
  68308. SRC_ALPHA_SATURATE = 776
  68309. }
  68310. /** @hidden */
  68311. export interface IGLTFProperty {
  68312. extensions?: {
  68313. [key: string]: any;
  68314. };
  68315. extras?: Object;
  68316. }
  68317. /** @hidden */
  68318. export interface IGLTFChildRootProperty extends IGLTFProperty {
  68319. name?: string;
  68320. }
  68321. /** @hidden */
  68322. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  68323. bufferView: string;
  68324. byteOffset: number;
  68325. byteStride: number;
  68326. count: number;
  68327. type: string;
  68328. componentType: EComponentType;
  68329. max?: number[];
  68330. min?: number[];
  68331. name?: string;
  68332. }
  68333. /** @hidden */
  68334. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  68335. buffer: string;
  68336. byteOffset: number;
  68337. byteLength: number;
  68338. byteStride: number;
  68339. target?: number;
  68340. }
  68341. /** @hidden */
  68342. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  68343. uri: string;
  68344. byteLength?: number;
  68345. type?: string;
  68346. }
  68347. /** @hidden */
  68348. export interface IGLTFShader extends IGLTFChildRootProperty {
  68349. uri: string;
  68350. type: EShaderType;
  68351. }
  68352. /** @hidden */
  68353. export interface IGLTFProgram extends IGLTFChildRootProperty {
  68354. attributes: string[];
  68355. fragmentShader: string;
  68356. vertexShader: string;
  68357. }
  68358. /** @hidden */
  68359. export interface IGLTFTechniqueParameter {
  68360. type: number;
  68361. count?: number;
  68362. semantic?: string;
  68363. node?: string;
  68364. value?: number | boolean | string | Array<any>;
  68365. source?: string;
  68366. babylonValue?: any;
  68367. }
  68368. /** @hidden */
  68369. export interface IGLTFTechniqueCommonProfile {
  68370. lightingModel: string;
  68371. texcoordBindings: Object;
  68372. parameters?: Array<any>;
  68373. }
  68374. /** @hidden */
  68375. export interface IGLTFTechniqueStatesFunctions {
  68376. blendColor?: number[];
  68377. blendEquationSeparate?: number[];
  68378. blendFuncSeparate?: number[];
  68379. colorMask: boolean[];
  68380. cullFace: number[];
  68381. }
  68382. /** @hidden */
  68383. export interface IGLTFTechniqueStates {
  68384. enable: number[];
  68385. functions: IGLTFTechniqueStatesFunctions;
  68386. }
  68387. /** @hidden */
  68388. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  68389. parameters: {
  68390. [key: string]: IGLTFTechniqueParameter;
  68391. };
  68392. program: string;
  68393. attributes: {
  68394. [key: string]: string;
  68395. };
  68396. uniforms: {
  68397. [key: string]: string;
  68398. };
  68399. states: IGLTFTechniqueStates;
  68400. }
  68401. /** @hidden */
  68402. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  68403. technique?: string;
  68404. values: string[];
  68405. }
  68406. /** @hidden */
  68407. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  68408. attributes: {
  68409. [key: string]: string;
  68410. };
  68411. indices: string;
  68412. material: string;
  68413. mode?: number;
  68414. }
  68415. /** @hidden */
  68416. export interface IGLTFMesh extends IGLTFChildRootProperty {
  68417. primitives: IGLTFMeshPrimitive[];
  68418. }
  68419. /** @hidden */
  68420. export interface IGLTFImage extends IGLTFChildRootProperty {
  68421. uri: string;
  68422. }
  68423. /** @hidden */
  68424. export interface IGLTFSampler extends IGLTFChildRootProperty {
  68425. magFilter?: number;
  68426. minFilter?: number;
  68427. wrapS?: number;
  68428. wrapT?: number;
  68429. }
  68430. /** @hidden */
  68431. export interface IGLTFTexture extends IGLTFChildRootProperty {
  68432. sampler: string;
  68433. source: string;
  68434. format?: ETextureFormat;
  68435. internalFormat?: ETextureFormat;
  68436. target?: number;
  68437. type?: number;
  68438. babylonTexture?: Texture;
  68439. }
  68440. /** @hidden */
  68441. export interface IGLTFAmbienLight {
  68442. color?: number[];
  68443. }
  68444. /** @hidden */
  68445. export interface IGLTFDirectionalLight {
  68446. color?: number[];
  68447. }
  68448. /** @hidden */
  68449. export interface IGLTFPointLight {
  68450. color?: number[];
  68451. constantAttenuation?: number;
  68452. linearAttenuation?: number;
  68453. quadraticAttenuation?: number;
  68454. }
  68455. /** @hidden */
  68456. export interface IGLTFSpotLight {
  68457. color?: number[];
  68458. constantAttenuation?: number;
  68459. fallOfAngle?: number;
  68460. fallOffExponent?: number;
  68461. linearAttenuation?: number;
  68462. quadraticAttenuation?: number;
  68463. }
  68464. /** @hidden */
  68465. export interface IGLTFLight extends IGLTFChildRootProperty {
  68466. type: string;
  68467. }
  68468. /** @hidden */
  68469. export interface IGLTFCameraOrthographic {
  68470. xmag: number;
  68471. ymag: number;
  68472. zfar: number;
  68473. znear: number;
  68474. }
  68475. /** @hidden */
  68476. export interface IGLTFCameraPerspective {
  68477. aspectRatio: number;
  68478. yfov: number;
  68479. zfar: number;
  68480. znear: number;
  68481. }
  68482. /** @hidden */
  68483. export interface IGLTFCamera extends IGLTFChildRootProperty {
  68484. type: string;
  68485. }
  68486. /** @hidden */
  68487. export interface IGLTFAnimationChannelTarget {
  68488. id: string;
  68489. path: string;
  68490. }
  68491. /** @hidden */
  68492. export interface IGLTFAnimationChannel {
  68493. sampler: string;
  68494. target: IGLTFAnimationChannelTarget;
  68495. }
  68496. /** @hidden */
  68497. export interface IGLTFAnimationSampler {
  68498. input: string;
  68499. output: string;
  68500. interpolation?: string;
  68501. }
  68502. /** @hidden */
  68503. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  68504. channels?: IGLTFAnimationChannel[];
  68505. parameters?: {
  68506. [key: string]: string;
  68507. };
  68508. samplers?: {
  68509. [key: string]: IGLTFAnimationSampler;
  68510. };
  68511. }
  68512. /** @hidden */
  68513. export interface IGLTFNodeInstanceSkin {
  68514. skeletons: string[];
  68515. skin: string;
  68516. meshes: string[];
  68517. }
  68518. /** @hidden */
  68519. export interface IGLTFSkins extends IGLTFChildRootProperty {
  68520. bindShapeMatrix: number[];
  68521. inverseBindMatrices: string;
  68522. jointNames: string[];
  68523. babylonSkeleton?: Skeleton;
  68524. }
  68525. /** @hidden */
  68526. export interface IGLTFNode extends IGLTFChildRootProperty {
  68527. camera?: string;
  68528. children: string[];
  68529. skin?: string;
  68530. jointName?: string;
  68531. light?: string;
  68532. matrix: number[];
  68533. mesh?: string;
  68534. meshes?: string[];
  68535. rotation?: number[];
  68536. scale?: number[];
  68537. translation?: number[];
  68538. babylonNode?: Node;
  68539. }
  68540. /** @hidden */
  68541. export interface IGLTFScene extends IGLTFChildRootProperty {
  68542. nodes: string[];
  68543. }
  68544. /** @hidden */
  68545. export interface IGLTFRuntime {
  68546. extensions: {
  68547. [key: string]: any;
  68548. };
  68549. accessors: {
  68550. [key: string]: IGLTFAccessor;
  68551. };
  68552. buffers: {
  68553. [key: string]: IGLTFBuffer;
  68554. };
  68555. bufferViews: {
  68556. [key: string]: IGLTFBufferView;
  68557. };
  68558. meshes: {
  68559. [key: string]: IGLTFMesh;
  68560. };
  68561. lights: {
  68562. [key: string]: IGLTFLight;
  68563. };
  68564. cameras: {
  68565. [key: string]: IGLTFCamera;
  68566. };
  68567. nodes: {
  68568. [key: string]: IGLTFNode;
  68569. };
  68570. images: {
  68571. [key: string]: IGLTFImage;
  68572. };
  68573. textures: {
  68574. [key: string]: IGLTFTexture;
  68575. };
  68576. shaders: {
  68577. [key: string]: IGLTFShader;
  68578. };
  68579. programs: {
  68580. [key: string]: IGLTFProgram;
  68581. };
  68582. samplers: {
  68583. [key: string]: IGLTFSampler;
  68584. };
  68585. techniques: {
  68586. [key: string]: IGLTFTechnique;
  68587. };
  68588. materials: {
  68589. [key: string]: IGLTFMaterial;
  68590. };
  68591. animations: {
  68592. [key: string]: IGLTFAnimation;
  68593. };
  68594. skins: {
  68595. [key: string]: IGLTFSkins;
  68596. };
  68597. currentScene?: Object;
  68598. scenes: {
  68599. [key: string]: IGLTFScene;
  68600. };
  68601. extensionsUsed: string[];
  68602. extensionsRequired?: string[];
  68603. buffersCount: number;
  68604. shaderscount: number;
  68605. scene: Scene;
  68606. rootUrl: string;
  68607. loadedBufferCount: number;
  68608. loadedBufferViews: {
  68609. [name: string]: ArrayBufferView;
  68610. };
  68611. loadedShaderCount: number;
  68612. importOnlyMeshes: boolean;
  68613. importMeshesNames?: string[];
  68614. dummyNodes: Node[];
  68615. }
  68616. /** @hidden */
  68617. export interface INodeToRoot {
  68618. bone: Bone;
  68619. node: IGLTFNode;
  68620. id: string;
  68621. }
  68622. /** @hidden */
  68623. export interface IJointNode {
  68624. node: IGLTFNode;
  68625. id: string;
  68626. }
  68627. }
  68628. declare module BABYLON.GLTF1 {
  68629. /**
  68630. * Utils functions for GLTF
  68631. * @hidden
  68632. */
  68633. export class GLTFUtils {
  68634. /**
  68635. * Sets the given "parameter" matrix
  68636. * @param scene: the Scene object
  68637. * @param source: the source node where to pick the matrix
  68638. * @param parameter: the GLTF technique parameter
  68639. * @param uniformName: the name of the shader's uniform
  68640. * @param shaderMaterial: the shader material
  68641. */
  68642. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  68643. /**
  68644. * Sets the given "parameter" matrix
  68645. * @param shaderMaterial: the shader material
  68646. * @param uniform: the name of the shader's uniform
  68647. * @param value: the value of the uniform
  68648. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  68649. */
  68650. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  68651. /**
  68652. * Returns the wrap mode of the texture
  68653. * @param mode: the mode value
  68654. */
  68655. static GetWrapMode(mode: number): number;
  68656. /**
  68657. * Returns the byte stride giving an accessor
  68658. * @param accessor: the GLTF accessor objet
  68659. */
  68660. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  68661. /**
  68662. * Returns the texture filter mode giving a mode value
  68663. * @param mode: the filter mode value
  68664. */
  68665. static GetTextureFilterMode(mode: number): ETextureFilterType;
  68666. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  68667. /**
  68668. * Returns a buffer from its accessor
  68669. * @param gltfRuntime: the GLTF runtime
  68670. * @param accessor: the GLTF accessor
  68671. */
  68672. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  68673. /**
  68674. * Decodes a buffer view into a string
  68675. * @param view: the buffer view
  68676. */
  68677. static DecodeBufferToText(view: ArrayBufferView): string;
  68678. /**
  68679. * Returns the default material of gltf. Related to
  68680. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  68681. * @param scene: the Babylon.js scene
  68682. */
  68683. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  68684. private static _DefaultMaterial;
  68685. }
  68686. }
  68687. declare module BABYLON.GLTF1 {
  68688. /**
  68689. * Implementation of the base glTF spec
  68690. * @hidden
  68691. */
  68692. export class GLTFLoaderBase {
  68693. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  68694. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68695. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  68696. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68697. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  68698. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68699. }
  68700. /**
  68701. * glTF V1 Loader
  68702. * @hidden
  68703. */
  68704. export class GLTFLoader implements IGLTFLoader {
  68705. static Extensions: {
  68706. [name: string]: GLTFLoaderExtension;
  68707. };
  68708. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68709. state: Nullable<GLTFLoaderState>;
  68710. dispose(): void;
  68711. private _importMeshAsync;
  68712. /**
  68713. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68714. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68715. * @param scene the scene the meshes should be added to
  68716. * @param data gltf data containing information of the meshes in a loaded file
  68717. * @param rootUrl root url to load from
  68718. * @param onProgress event that fires when loading progress has occured
  68719. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68720. */
  68721. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68722. meshes: AbstractMesh[];
  68723. particleSystems: IParticleSystem[];
  68724. skeletons: Skeleton[];
  68725. animationGroups: AnimationGroup[];
  68726. }>;
  68727. private _loadAsync;
  68728. /**
  68729. * Imports all objects from a loaded gltf file and adds them to the scene
  68730. * @param scene the scene the objects should be added to
  68731. * @param data gltf data containing information of the meshes in a loaded file
  68732. * @param rootUrl root url to load from
  68733. * @param onProgress event that fires when loading progress has occured
  68734. * @returns a promise which completes when objects have been loaded to the scene
  68735. */
  68736. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  68737. private _loadShadersAsync;
  68738. private _loadBuffersAsync;
  68739. private _createNodes;
  68740. }
  68741. /** @hidden */
  68742. export abstract class GLTFLoaderExtension {
  68743. private _name;
  68744. constructor(name: string);
  68745. readonly name: string;
  68746. /**
  68747. * Defines an override for loading the runtime
  68748. * Return true to stop further extensions from loading the runtime
  68749. */
  68750. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  68751. /**
  68752. * Defines an onverride for creating gltf runtime
  68753. * Return true to stop further extensions from creating the runtime
  68754. */
  68755. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  68756. /**
  68757. * Defines an override for loading buffers
  68758. * Return true to stop further extensions from loading this buffer
  68759. */
  68760. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  68761. /**
  68762. * Defines an override for loading texture buffers
  68763. * Return true to stop further extensions from loading this texture data
  68764. */
  68765. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68766. /**
  68767. * Defines an override for creating textures
  68768. * Return true to stop further extensions from loading this texture
  68769. */
  68770. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  68771. /**
  68772. * Defines an override for loading shader strings
  68773. * Return true to stop further extensions from loading this shader data
  68774. */
  68775. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68776. /**
  68777. * Defines an override for loading materials
  68778. * Return true to stop further extensions from loading this material
  68779. */
  68780. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68781. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  68782. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  68783. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68784. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68785. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  68786. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68787. private static LoadTextureBufferAsync;
  68788. private static CreateTextureAsync;
  68789. private static ApplyExtensions;
  68790. }
  68791. }
  68792. declare module BABYLON.GLTF1 {
  68793. /** @hidden */
  68794. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  68795. private _bin;
  68796. constructor();
  68797. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  68798. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68799. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68800. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68801. }
  68802. }
  68803. declare module BABYLON.GLTF1 {
  68804. /** @hidden */
  68805. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  68806. constructor();
  68807. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  68808. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68809. private _loadTexture;
  68810. }
  68811. }
  68812. declare module BABYLON.GLTF2.Loader {
  68813. /**
  68814. * Loader interface with an index field.
  68815. */
  68816. export interface IArrayItem {
  68817. /**
  68818. * The index of this item in the array.
  68819. */
  68820. index: number;
  68821. }
  68822. /**
  68823. * Loader interface with additional members.
  68824. */
  68825. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68826. /** @hidden */
  68827. _data?: Promise<ArrayBufferView>;
  68828. /** @hidden */
  68829. _babylonVertexBuffer?: Promise<VertexBuffer>;
  68830. }
  68831. /**
  68832. * Loader interface with additional members.
  68833. */
  68834. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68835. }
  68836. /** @hidden */
  68837. export interface _IAnimationSamplerData {
  68838. input: Float32Array;
  68839. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68840. output: Float32Array;
  68841. }
  68842. /**
  68843. * Loader interface with additional members.
  68844. */
  68845. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68846. /** @hidden */
  68847. _data?: Promise<_IAnimationSamplerData>;
  68848. }
  68849. /**
  68850. * Loader interface with additional members.
  68851. */
  68852. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68853. channels: IAnimationChannel[];
  68854. samplers: IAnimationSampler[];
  68855. /** @hidden */
  68856. _babylonAnimationGroup?: AnimationGroup;
  68857. }
  68858. /**
  68859. * Loader interface with additional members.
  68860. */
  68861. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68862. /** @hidden */
  68863. _data?: Promise<ArrayBufferView>;
  68864. }
  68865. /**
  68866. * Loader interface with additional members.
  68867. */
  68868. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68869. /** @hidden */
  68870. _data?: Promise<ArrayBufferView>;
  68871. /** @hidden */
  68872. _babylonBuffer?: Promise<Buffer>;
  68873. }
  68874. /**
  68875. * Loader interface with additional members.
  68876. */
  68877. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68878. }
  68879. /**
  68880. * Loader interface with additional members.
  68881. */
  68882. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68883. /** @hidden */
  68884. _data?: Promise<ArrayBufferView>;
  68885. }
  68886. /**
  68887. * Loader interface with additional members.
  68888. */
  68889. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68890. }
  68891. /**
  68892. * Loader interface with additional members.
  68893. */
  68894. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68895. }
  68896. /**
  68897. * Loader interface with additional members.
  68898. */
  68899. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68900. baseColorTexture?: ITextureInfo;
  68901. metallicRoughnessTexture?: ITextureInfo;
  68902. }
  68903. /**
  68904. * Loader interface with additional members.
  68905. */
  68906. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68907. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68908. normalTexture?: IMaterialNormalTextureInfo;
  68909. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68910. emissiveTexture?: ITextureInfo;
  68911. /** @hidden */
  68912. _data?: {
  68913. [babylonDrawMode: number]: {
  68914. babylonMaterial: Material;
  68915. babylonMeshes: AbstractMesh[];
  68916. promise: Promise<void>;
  68917. };
  68918. };
  68919. }
  68920. /**
  68921. * Loader interface with additional members.
  68922. */
  68923. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68924. primitives: IMeshPrimitive[];
  68925. }
  68926. /**
  68927. * Loader interface with additional members.
  68928. */
  68929. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68930. /** @hidden */
  68931. _instanceData?: {
  68932. babylonSourceMesh: Mesh;
  68933. promise: Promise<any>;
  68934. };
  68935. }
  68936. /**
  68937. * Loader interface with additional members.
  68938. */
  68939. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68940. /**
  68941. * The parent glTF node.
  68942. */
  68943. parent?: INode;
  68944. /** @hidden */
  68945. _babylonTransformNode?: TransformNode;
  68946. /** @hidden */
  68947. _primitiveBabylonMeshes?: AbstractMesh[];
  68948. /** @hidden */
  68949. _babylonBones?: Bone[];
  68950. /** @hidden */
  68951. _numMorphTargets?: number;
  68952. }
  68953. /** @hidden */
  68954. export interface _ISamplerData {
  68955. noMipMaps: boolean;
  68956. samplingMode: number;
  68957. wrapU: number;
  68958. wrapV: number;
  68959. }
  68960. /**
  68961. * Loader interface with additional members.
  68962. */
  68963. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68964. /** @hidden */
  68965. _data?: _ISamplerData;
  68966. }
  68967. /**
  68968. * Loader interface with additional members.
  68969. */
  68970. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68971. }
  68972. /**
  68973. * Loader interface with additional members.
  68974. */
  68975. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68976. /** @hidden */
  68977. _data?: {
  68978. babylonSkeleton: Skeleton;
  68979. promise: Promise<void>;
  68980. };
  68981. }
  68982. /**
  68983. * Loader interface with additional members.
  68984. */
  68985. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68986. }
  68987. /**
  68988. * Loader interface with additional members.
  68989. */
  68990. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68991. }
  68992. /**
  68993. * Loader interface with additional members.
  68994. */
  68995. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68996. accessors?: IAccessor[];
  68997. animations?: IAnimation[];
  68998. buffers?: IBuffer[];
  68999. bufferViews?: IBufferView[];
  69000. cameras?: ICamera[];
  69001. images?: IImage[];
  69002. materials?: IMaterial[];
  69003. meshes?: IMesh[];
  69004. nodes?: INode[];
  69005. samplers?: ISampler[];
  69006. scenes?: IScene[];
  69007. skins?: ISkin[];
  69008. textures?: ITexture[];
  69009. }
  69010. }
  69011. declare module BABYLON.GLTF2 {
  69012. /**
  69013. * Interface for a glTF loader extension.
  69014. */
  69015. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  69016. /**
  69017. * Called after the loader state changes to LOADING.
  69018. */
  69019. onLoading?(): void;
  69020. /**
  69021. * Called after the loader state changes to READY.
  69022. */
  69023. onReady?(): void;
  69024. /**
  69025. * Define this method to modify the default behavior when loading scenes.
  69026. * @param context The context when loading the asset
  69027. * @param scene The glTF scene property
  69028. * @returns A promise that resolves when the load is complete or null if not handled
  69029. */
  69030. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  69031. /**
  69032. * Define this method to modify the default behavior when loading nodes.
  69033. * @param context The context when loading the asset
  69034. * @param node The glTF node property
  69035. * @param assign A function called synchronously after parsing the glTF properties
  69036. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  69037. */
  69038. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69039. /**
  69040. * Define this method to modify the default behavior when loading cameras.
  69041. * @param context The context when loading the asset
  69042. * @param camera The glTF camera property
  69043. * @param assign A function called synchronously after parsing the glTF properties
  69044. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  69045. */
  69046. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69047. /**
  69048. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  69049. * @param context The context when loading the asset
  69050. * @param primitive The glTF mesh primitive property
  69051. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  69052. */
  69053. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69054. /**
  69055. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69056. * @param context The context when loading the asset
  69057. * @param name The mesh name when loading the asset
  69058. * @param node The glTF node when loading the asset
  69059. * @param mesh The glTF mesh when loading the asset
  69060. * @param primitive The glTF mesh primitive property
  69061. * @param assign A function called synchronously after parsing the glTF properties
  69062. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69063. */
  69064. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69065. /**
  69066. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  69067. * @param context The context when loading the asset
  69068. * @param material The glTF material property
  69069. * @param assign A function called synchronously after parsing the glTF properties
  69070. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  69071. */
  69072. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69073. /**
  69074. * Define this method to modify the default behavior when creating materials.
  69075. * @param context The context when loading the asset
  69076. * @param material The glTF material property
  69077. * @param babylonDrawMode The draw mode for the Babylon material
  69078. * @returns The Babylon material or null if not handled
  69079. */
  69080. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69081. /**
  69082. * Define this method to modify the default behavior when loading material properties.
  69083. * @param context The context when loading the asset
  69084. * @param material The glTF material property
  69085. * @param babylonMaterial The Babylon material
  69086. * @returns A promise that resolves when the load is complete or null if not handled
  69087. */
  69088. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69089. /**
  69090. * Define this method to modify the default behavior when loading texture infos.
  69091. * @param context The context when loading the asset
  69092. * @param textureInfo The glTF texture info property
  69093. * @param assign A function called synchronously after parsing the glTF properties
  69094. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  69095. */
  69096. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69097. /**
  69098. * Define this method to modify the default behavior when loading animations.
  69099. * @param context The context when loading the asset
  69100. * @param animation The glTF animation property
  69101. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  69102. */
  69103. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69104. /**
  69105. * @hidden Define this method to modify the default behavior when loading skins.
  69106. * @param context The context when loading the asset
  69107. * @param node The glTF node property
  69108. * @param skin The glTF skin property
  69109. * @returns A promise that resolves when the load is complete or null if not handled
  69110. */
  69111. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  69112. /**
  69113. * @hidden Define this method to modify the default behavior when loading uris.
  69114. * @param context The context when loading the asset
  69115. * @param property The glTF property associated with the uri
  69116. * @param uri The uri to load
  69117. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69118. */
  69119. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69120. /**
  69121. * Define this method to modify the default behavior when loading buffer views.
  69122. * @param context The context when loading the asset
  69123. * @param bufferView The glTF buffer view property
  69124. * @returns A promise that resolves with the loaded buffer view when the load is complete or null if not handled
  69125. */
  69126. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  69127. }
  69128. }
  69129. declare module BABYLON.GLTF2 {
  69130. /**
  69131. * Helper class for working with arrays when loading the glTF asset
  69132. */
  69133. export class ArrayItem {
  69134. /**
  69135. * Gets an item from the given array.
  69136. * @param context The context when loading the asset
  69137. * @param array The array to get the item from
  69138. * @param index The index to the array
  69139. * @returns The array item
  69140. */
  69141. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  69142. /**
  69143. * Assign an `index` field to each item of the given array.
  69144. * @param array The array of items
  69145. */
  69146. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  69147. }
  69148. /**
  69149. * The glTF 2.0 loader
  69150. */
  69151. export class GLTFLoader implements IGLTFLoader {
  69152. /** @hidden */
  69153. _completePromises: Promise<any>[];
  69154. private _disposed;
  69155. private _parent;
  69156. private _state;
  69157. private _extensions;
  69158. private _rootUrl;
  69159. private _fileName;
  69160. private _uniqueRootUrl;
  69161. private _gltf;
  69162. private _babylonScene;
  69163. private _rootBabylonMesh;
  69164. private _defaultBabylonMaterialData;
  69165. private _progressCallback?;
  69166. private _requests;
  69167. private static readonly _DefaultSampler;
  69168. private static _ExtensionNames;
  69169. private static _ExtensionFactories;
  69170. /**
  69171. * Registers a loader extension.
  69172. * @param name The name of the loader extension.
  69173. * @param factory The factory function that creates the loader extension.
  69174. */
  69175. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  69176. /**
  69177. * Unregisters a loader extension.
  69178. * @param name The name of the loader extenion.
  69179. * @returns A boolean indicating whether the extension has been unregistered
  69180. */
  69181. static UnregisterExtension(name: string): boolean;
  69182. /**
  69183. * Gets the loader state.
  69184. */
  69185. readonly state: Nullable<GLTFLoaderState>;
  69186. /**
  69187. * The glTF object parsed from the JSON.
  69188. */
  69189. readonly gltf: IGLTF;
  69190. /**
  69191. * The Babylon scene when loading the asset.
  69192. */
  69193. readonly babylonScene: Scene;
  69194. /**
  69195. * The root Babylon mesh when loading the asset.
  69196. */
  69197. readonly rootBabylonMesh: Mesh;
  69198. /** @hidden */
  69199. constructor(parent: GLTFFileLoader);
  69200. /** @hidden */
  69201. dispose(): void;
  69202. /** @hidden */
  69203. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69204. meshes: AbstractMesh[];
  69205. particleSystems: IParticleSystem[];
  69206. skeletons: Skeleton[];
  69207. animationGroups: AnimationGroup[];
  69208. }>;
  69209. /** @hidden */
  69210. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69211. private _loadAsync;
  69212. private _loadData;
  69213. private _setupData;
  69214. private _loadExtensions;
  69215. private _checkExtensions;
  69216. private _setState;
  69217. private _createRootNode;
  69218. /**
  69219. * Loads a glTF scene.
  69220. * @param context The context when loading the asset
  69221. * @param scene The glTF scene property
  69222. * @returns A promise that resolves when the load is complete
  69223. */
  69224. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  69225. private _forEachPrimitive;
  69226. private _getMeshes;
  69227. private _getSkeletons;
  69228. private _getAnimationGroups;
  69229. private _startAnimations;
  69230. /**
  69231. * Loads a glTF node.
  69232. * @param context The context when loading the asset
  69233. * @param node The glTF node property
  69234. * @param assign A function called synchronously after parsing the glTF properties
  69235. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  69236. */
  69237. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  69238. private _loadMeshAsync;
  69239. /**
  69240. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69241. * @param context The context when loading the asset
  69242. * @param name The mesh name when loading the asset
  69243. * @param node The glTF node when loading the asset
  69244. * @param mesh The glTF mesh when loading the asset
  69245. * @param primitive The glTF mesh primitive property
  69246. * @param assign A function called synchronously after parsing the glTF properties
  69247. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69248. */
  69249. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69250. private _loadVertexDataAsync;
  69251. private _createMorphTargets;
  69252. private _loadMorphTargetsAsync;
  69253. private _loadMorphTargetVertexDataAsync;
  69254. private static _LoadTransform;
  69255. private _loadSkinAsync;
  69256. private _loadBones;
  69257. private _loadBone;
  69258. private _loadSkinInverseBindMatricesDataAsync;
  69259. private _updateBoneMatrices;
  69260. private _getNodeMatrix;
  69261. /**
  69262. * Loads a glTF camera.
  69263. * @param context The context when loading the asset
  69264. * @param camera The glTF camera property
  69265. * @param assign A function called synchronously after parsing the glTF properties
  69266. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  69267. */
  69268. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  69269. private _loadAnimationsAsync;
  69270. /**
  69271. * Loads a glTF animation.
  69272. * @param context The context when loading the asset
  69273. * @param animation The glTF animation property
  69274. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  69275. */
  69276. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  69277. /**
  69278. * @hidden Loads a glTF animation channel.
  69279. * @param context The context when loading the asset
  69280. * @param animationContext The context of the animation when loading the asset
  69281. * @param animation The glTF animation property
  69282. * @param channel The glTF animation channel property
  69283. * @param babylonAnimationGroup The babylon animation group property
  69284. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  69285. * @returns A void promise when the channel load is complete
  69286. */
  69287. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  69288. private _loadAnimationSamplerAsync;
  69289. private _loadBufferAsync;
  69290. /**
  69291. * Loads a glTF buffer view.
  69292. * @param context The context when loading the asset
  69293. * @param bufferView The glTF buffer view property
  69294. * @returns A promise that resolves with the loaded data when the load is complete
  69295. */
  69296. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  69297. private _loadAccessorAsync;
  69298. private _loadFloatAccessorAsync;
  69299. private _loadIndicesAccessorAsync;
  69300. private _loadVertexBufferViewAsync;
  69301. private _loadVertexAccessorAsync;
  69302. private _loadMaterialMetallicRoughnessPropertiesAsync;
  69303. /** @hidden */
  69304. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  69305. private _createDefaultMaterial;
  69306. /**
  69307. * Creates a Babylon material from a glTF material.
  69308. * @param context The context when loading the asset
  69309. * @param material The glTF material property
  69310. * @param babylonDrawMode The draw mode for the Babylon material
  69311. * @returns The Babylon material
  69312. */
  69313. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  69314. /**
  69315. * Loads properties from a glTF material into a Babylon material.
  69316. * @param context The context when loading the asset
  69317. * @param material The glTF material property
  69318. * @param babylonMaterial The Babylon material
  69319. * @returns A promise that resolves when the load is complete
  69320. */
  69321. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69322. /**
  69323. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  69324. * @param context The context when loading the asset
  69325. * @param material The glTF material property
  69326. * @param babylonMaterial The Babylon material
  69327. * @returns A promise that resolves when the load is complete
  69328. */
  69329. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69330. /**
  69331. * Loads the alpha properties from a glTF material into a Babylon material.
  69332. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  69333. * @param context The context when loading the asset
  69334. * @param material The glTF material property
  69335. * @param babylonMaterial The Babylon material
  69336. */
  69337. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  69338. /**
  69339. * Loads a glTF texture info.
  69340. * @param context The context when loading the asset
  69341. * @param textureInfo The glTF texture info property
  69342. * @param assign A function called synchronously after parsing the glTF properties
  69343. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  69344. */
  69345. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  69346. private _loadTextureAsync;
  69347. private _loadSampler;
  69348. /**
  69349. * Loads a glTF image.
  69350. * @param context The context when loading the asset
  69351. * @param image The glTF image property
  69352. * @returns A promise that resolves with the loaded data when the load is complete
  69353. */
  69354. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  69355. /**
  69356. * Loads a glTF uri.
  69357. * @param context The context when loading the asset
  69358. * @param property The glTF property associated with the uri
  69359. * @param uri The base64 or relative uri
  69360. * @returns A promise that resolves with the loaded data when the load is complete
  69361. */
  69362. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  69363. private _onProgress;
  69364. /**
  69365. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  69366. * @param babylonObject the Babylon object with metadata
  69367. * @param pointer the JSON pointer
  69368. */
  69369. static AddPointerMetadata(babylonObject: {
  69370. metadata: any;
  69371. }, pointer: string): void;
  69372. private static _GetTextureWrapMode;
  69373. private static _GetTextureSamplingMode;
  69374. private static _GetTypedArrayConstructor;
  69375. private static _GetTypedArray;
  69376. private static _GetNumComponents;
  69377. private static _ValidateUri;
  69378. private static _GetDrawMode;
  69379. private _compileMaterialsAsync;
  69380. private _compileShadowGeneratorsAsync;
  69381. private _forEachExtensions;
  69382. private _applyExtensions;
  69383. private _extensionsOnLoading;
  69384. private _extensionsOnReady;
  69385. private _extensionsLoadSceneAsync;
  69386. private _extensionsLoadNodeAsync;
  69387. private _extensionsLoadCameraAsync;
  69388. private _extensionsLoadVertexDataAsync;
  69389. private _extensionsLoadMeshPrimitiveAsync;
  69390. private _extensionsLoadMaterialAsync;
  69391. private _extensionsCreateMaterial;
  69392. private _extensionsLoadMaterialPropertiesAsync;
  69393. private _extensionsLoadTextureInfoAsync;
  69394. private _extensionsLoadAnimationAsync;
  69395. private _extensionsLoadSkinAsync;
  69396. private _extensionsLoadUriAsync;
  69397. private _extensionsLoadBufferViewAsync;
  69398. /**
  69399. * Helper method called by a loader extension to load an glTF extension.
  69400. * @param context The context when loading the asset
  69401. * @param property The glTF property to load the extension from
  69402. * @param extensionName The name of the extension to load
  69403. * @param actionAsync The action to run
  69404. * @returns The promise returned by actionAsync or null if the extension does not exist
  69405. */
  69406. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69407. /**
  69408. * Helper method called by a loader extension to load a glTF extra.
  69409. * @param context The context when loading the asset
  69410. * @param property The glTF property to load the extra from
  69411. * @param extensionName The name of the extension to load
  69412. * @param actionAsync The action to run
  69413. * @returns The promise returned by actionAsync or null if the extra does not exist
  69414. */
  69415. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69416. /**
  69417. * Increments the indentation level and logs a message.
  69418. * @param message The message to log
  69419. */
  69420. logOpen(message: string): void;
  69421. /**
  69422. * Decrements the indentation level.
  69423. */
  69424. logClose(): void;
  69425. /**
  69426. * Logs a message
  69427. * @param message The message to log
  69428. */
  69429. log(message: string): void;
  69430. /**
  69431. * Starts a performance counter.
  69432. * @param counterName The name of the performance counter
  69433. */
  69434. startPerformanceCounter(counterName: string): void;
  69435. /**
  69436. * Ends a performance counter.
  69437. * @param counterName The name of the performance counter
  69438. */
  69439. endPerformanceCounter(counterName: string): void;
  69440. }
  69441. }
  69442. declare module BABYLON.GLTF2.Loader.Extensions {
  69443. /**
  69444. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  69445. */
  69446. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  69447. /** The name of this extension. */
  69448. readonly name: string;
  69449. /** Defines whether this extension is enabled. */
  69450. enabled: boolean;
  69451. private _loader;
  69452. private _lights?;
  69453. /** @hidden */
  69454. constructor(loader: GLTFLoader);
  69455. /** @hidden */
  69456. dispose(): void;
  69457. /** @hidden */
  69458. onLoading(): void;
  69459. /** @hidden */
  69460. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69461. private _loadLightAsync;
  69462. }
  69463. }
  69464. declare module BABYLON.GLTF2.Loader.Extensions {
  69465. /**
  69466. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  69467. */
  69468. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  69469. /** The name of this extension. */
  69470. readonly name: string;
  69471. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  69472. dracoCompression?: DracoCompression;
  69473. /** Defines whether this extension is enabled. */
  69474. enabled: boolean;
  69475. private _loader;
  69476. /** @hidden */
  69477. constructor(loader: GLTFLoader);
  69478. /** @hidden */
  69479. dispose(): void;
  69480. /** @hidden */
  69481. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69482. }
  69483. }
  69484. declare module BABYLON.GLTF2.Loader.Extensions {
  69485. /**
  69486. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  69487. */
  69488. export class KHR_lights implements IGLTFLoaderExtension {
  69489. /** The name of this extension. */
  69490. readonly name: string;
  69491. /** Defines whether this extension is enabled. */
  69492. enabled: boolean;
  69493. private _loader;
  69494. private _lights?;
  69495. /** @hidden */
  69496. constructor(loader: GLTFLoader);
  69497. /** @hidden */
  69498. dispose(): void;
  69499. /** @hidden */
  69500. onLoading(): void;
  69501. /** @hidden */
  69502. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69503. }
  69504. }
  69505. declare module BABYLON.GLTF2.Loader.Extensions {
  69506. /**
  69507. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  69508. */
  69509. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  69510. /** The name of this extension. */
  69511. readonly name: string;
  69512. /** Defines whether this extension is enabled. */
  69513. enabled: boolean;
  69514. private _loader;
  69515. /** @hidden */
  69516. constructor(loader: GLTFLoader);
  69517. /** @hidden */
  69518. dispose(): void;
  69519. /** @hidden */
  69520. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69521. private _loadSpecularGlossinessPropertiesAsync;
  69522. }
  69523. }
  69524. declare module BABYLON.GLTF2.Loader.Extensions {
  69525. /**
  69526. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  69527. */
  69528. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  69529. /** The name of this extension. */
  69530. readonly name: string;
  69531. /** Defines whether this extension is enabled. */
  69532. enabled: boolean;
  69533. private _loader;
  69534. /** @hidden */
  69535. constructor(loader: GLTFLoader);
  69536. /** @hidden */
  69537. dispose(): void;
  69538. /** @hidden */
  69539. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69540. private _loadUnlitPropertiesAsync;
  69541. }
  69542. }
  69543. declare module BABYLON.GLTF2.Loader.Extensions {
  69544. /**
  69545. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  69546. */
  69547. export class KHR_texture_transform implements IGLTFLoaderExtension {
  69548. /** The name of this extension. */
  69549. readonly name: string;
  69550. /** Defines whether this extension is enabled. */
  69551. enabled: boolean;
  69552. private _loader;
  69553. /** @hidden */
  69554. constructor(loader: GLTFLoader);
  69555. /** @hidden */
  69556. dispose(): void;
  69557. /** @hidden */
  69558. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69559. }
  69560. }
  69561. declare module BABYLON.GLTF2.Loader.Extensions {
  69562. /**
  69563. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  69564. */
  69565. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  69566. /** The name of this extension. */
  69567. readonly name: string;
  69568. /** Defines whether this extension is enabled. */
  69569. enabled: boolean;
  69570. private _loader;
  69571. private _clips;
  69572. private _emitters;
  69573. /** @hidden */
  69574. constructor(loader: GLTFLoader);
  69575. /** @hidden */
  69576. dispose(): void;
  69577. /** @hidden */
  69578. onLoading(): void;
  69579. /** @hidden */
  69580. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69581. /** @hidden */
  69582. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69583. /** @hidden */
  69584. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69585. private _loadClipAsync;
  69586. private _loadEmitterAsync;
  69587. private _getEventAction;
  69588. private _loadAnimationEventAsync;
  69589. }
  69590. }
  69591. declare module BABYLON.GLTF2.Loader.Extensions {
  69592. /**
  69593. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  69594. */
  69595. export class MSFT_lod implements IGLTFLoaderExtension {
  69596. /** The name of this extension. */
  69597. readonly name: string;
  69598. /** Defines whether this extension is enabled. */
  69599. enabled: boolean;
  69600. /**
  69601. * Maximum number of LODs to load, starting from the lowest LOD.
  69602. */
  69603. maxLODsToLoad: number;
  69604. /**
  69605. * Observable raised when all node LODs of one level are loaded.
  69606. * The event data is the index of the loaded LOD starting from zero.
  69607. * Dispose the loader to cancel the loading of the next level of LODs.
  69608. */
  69609. onNodeLODsLoadedObservable: Observable<number>;
  69610. /**
  69611. * Observable raised when all material LODs of one level are loaded.
  69612. * The event data is the index of the loaded LOD starting from zero.
  69613. * Dispose the loader to cancel the loading of the next level of LODs.
  69614. */
  69615. onMaterialLODsLoadedObservable: Observable<number>;
  69616. private _loader;
  69617. private _nodeIndexLOD;
  69618. private _nodeSignalLODs;
  69619. private _nodePromiseLODs;
  69620. private _materialIndexLOD;
  69621. private _materialSignalLODs;
  69622. private _materialPromiseLODs;
  69623. /** @hidden */
  69624. constructor(loader: GLTFLoader);
  69625. /** @hidden */
  69626. dispose(): void;
  69627. /** @hidden */
  69628. onReady(): void;
  69629. /** @hidden */
  69630. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69631. /** @hidden */
  69632. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69633. /** @hidden */
  69634. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69635. /**
  69636. * Gets an array of LOD properties from lowest to highest.
  69637. */
  69638. private _getLODs;
  69639. private _disposeUnusedMaterials;
  69640. }
  69641. }
  69642. declare module BABYLON.GLTF2.Loader.Extensions {
  69643. /** @hidden */
  69644. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  69645. readonly name: string;
  69646. enabled: boolean;
  69647. private _loader;
  69648. constructor(loader: GLTFLoader);
  69649. dispose(): void;
  69650. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69651. }
  69652. }
  69653. declare module BABYLON.GLTF2.Loader.Extensions {
  69654. /** @hidden */
  69655. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69656. readonly name: string;
  69657. enabled: boolean;
  69658. private _loader;
  69659. constructor(loader: GLTFLoader);
  69660. dispose(): void;
  69661. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69662. }
  69663. }
  69664. declare module BABYLON.GLTF2.Loader.Extensions {
  69665. /**
  69666. * Store glTF extras (if present) in BJS objects' metadata
  69667. */
  69668. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69669. /** The name of this extension. */
  69670. readonly name: string;
  69671. /** Defines whether this extension is enabled. */
  69672. enabled: boolean;
  69673. private _loader;
  69674. private _assignExtras;
  69675. /** @hidden */
  69676. constructor(loader: GLTFLoader);
  69677. /** @hidden */
  69678. dispose(): void;
  69679. /** @hidden */
  69680. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69681. /** @hidden */
  69682. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69683. /** @hidden */
  69684. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69685. }
  69686. }
  69687. declare module BABYLON {
  69688. /**
  69689. * Class reading and parsing the MTL file bundled with the obj file.
  69690. */
  69691. export class MTLFileLoader {
  69692. /**
  69693. * All material loaded from the mtl will be set here
  69694. */
  69695. materials: StandardMaterial[];
  69696. /**
  69697. * This function will read the mtl file and create each material described inside
  69698. * This function could be improve by adding :
  69699. * -some component missing (Ni, Tf...)
  69700. * -including the specific options available
  69701. *
  69702. * @param scene defines the scene the material will be created in
  69703. * @param data defines the mtl data to parse
  69704. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  69705. */
  69706. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  69707. /**
  69708. * Gets the texture for the material.
  69709. *
  69710. * If the material is imported from input file,
  69711. * We sanitize the url to ensure it takes the textre from aside the material.
  69712. *
  69713. * @param rootUrl The root url to load from
  69714. * @param value The value stored in the mtl
  69715. * @return The Texture
  69716. */
  69717. private static _getTexture;
  69718. }
  69719. /**
  69720. * Options for loading OBJ/MTL files
  69721. */
  69722. type MeshLoadOptions = {
  69723. /**
  69724. * Defines if UVs are optimized by default during load.
  69725. */
  69726. OptimizeWithUV: boolean;
  69727. /**
  69728. * Defines custom scaling of UV coordinates of loaded meshes.
  69729. */
  69730. UVScaling: Vector2;
  69731. /**
  69732. * Invert model on y-axis (does a model scaling inversion)
  69733. */
  69734. InvertY: boolean;
  69735. /**
  69736. * Invert Y-Axis of referenced textures on load
  69737. */
  69738. InvertTextureY: boolean;
  69739. /**
  69740. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69741. */
  69742. ImportVertexColors: boolean;
  69743. /**
  69744. * Compute the normals for the model, even if normals are present in the file.
  69745. */
  69746. ComputeNormals: boolean;
  69747. /**
  69748. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69749. */
  69750. SkipMaterials: boolean;
  69751. /**
  69752. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69753. */
  69754. MaterialLoadingFailsSilently: boolean;
  69755. };
  69756. /**
  69757. * OBJ file type loader.
  69758. * This is a babylon scene loader plugin.
  69759. */
  69760. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69761. /**
  69762. * Defines if UVs are optimized by default during load.
  69763. */
  69764. static OPTIMIZE_WITH_UV: boolean;
  69765. /**
  69766. * Invert model on y-axis (does a model scaling inversion)
  69767. */
  69768. static INVERT_Y: boolean;
  69769. /**
  69770. * Invert Y-Axis of referenced textures on load
  69771. */
  69772. static INVERT_TEXTURE_Y: boolean;
  69773. /**
  69774. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69775. */
  69776. static IMPORT_VERTEX_COLORS: boolean;
  69777. /**
  69778. * Compute the normals for the model, even if normals are present in the file.
  69779. */
  69780. static COMPUTE_NORMALS: boolean;
  69781. /**
  69782. * Defines custom scaling of UV coordinates of loaded meshes.
  69783. */
  69784. static UV_SCALING: Vector2;
  69785. /**
  69786. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69787. */
  69788. static SKIP_MATERIALS: boolean;
  69789. /**
  69790. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69791. *
  69792. * Defaults to true for backwards compatibility.
  69793. */
  69794. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  69795. /**
  69796. * Defines the name of the plugin.
  69797. */
  69798. name: string;
  69799. /**
  69800. * Defines the extension the plugin is able to load.
  69801. */
  69802. extensions: string;
  69803. /** @hidden */
  69804. obj: RegExp;
  69805. /** @hidden */
  69806. group: RegExp;
  69807. /** @hidden */
  69808. mtllib: RegExp;
  69809. /** @hidden */
  69810. usemtl: RegExp;
  69811. /** @hidden */
  69812. smooth: RegExp;
  69813. /** @hidden */
  69814. vertexPattern: RegExp;
  69815. /** @hidden */
  69816. normalPattern: RegExp;
  69817. /** @hidden */
  69818. uvPattern: RegExp;
  69819. /** @hidden */
  69820. facePattern1: RegExp;
  69821. /** @hidden */
  69822. facePattern2: RegExp;
  69823. /** @hidden */
  69824. facePattern3: RegExp;
  69825. /** @hidden */
  69826. facePattern4: RegExp;
  69827. /** @hidden */
  69828. facePattern5: RegExp;
  69829. private _meshLoadOptions;
  69830. /**
  69831. * Creates loader for .OBJ files
  69832. *
  69833. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69834. */
  69835. constructor(meshLoadOptions?: MeshLoadOptions);
  69836. private static readonly currentMeshLoadOptions;
  69837. /**
  69838. * Calls synchronously the MTL file attached to this obj.
  69839. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69840. * Without this function materials are not displayed in the first frame (but displayed after).
  69841. * In consequence it is impossible to get material information in your HTML file
  69842. *
  69843. * @param url The URL of the MTL file
  69844. * @param rootUrl
  69845. * @param onSuccess Callback function to be called when the MTL file is loaded
  69846. * @private
  69847. */
  69848. private _loadMTL;
  69849. /**
  69850. * Instantiates a OBJ file loader plugin.
  69851. * @returns the created plugin
  69852. */
  69853. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69854. /**
  69855. * If the data string can be loaded directly.
  69856. *
  69857. * @param data string containing the file data
  69858. * @returns if the data can be loaded directly
  69859. */
  69860. canDirectLoad(data: string): boolean;
  69861. /**
  69862. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69863. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69864. * @param scene the scene the meshes should be added to
  69865. * @param data the OBJ data to load
  69866. * @param rootUrl root url to load from
  69867. * @param onProgress event that fires when loading progress has occured
  69868. * @param fileName Defines the name of the file to load
  69869. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69870. */
  69871. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69872. meshes: AbstractMesh[];
  69873. particleSystems: IParticleSystem[];
  69874. skeletons: Skeleton[];
  69875. animationGroups: AnimationGroup[];
  69876. }>;
  69877. /**
  69878. * Imports all objects from the loaded OBJ data and adds them to the scene
  69879. * @param scene the scene the objects should be added to
  69880. * @param data the OBJ data to load
  69881. * @param rootUrl root url to load from
  69882. * @param onProgress event that fires when loading progress has occured
  69883. * @param fileName Defines the name of the file to load
  69884. * @returns a promise which completes when objects have been loaded to the scene
  69885. */
  69886. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69887. /**
  69888. * Load into an asset container.
  69889. * @param scene The scene to load into
  69890. * @param data The data to import
  69891. * @param rootUrl The root url for scene and resources
  69892. * @param onProgress The callback when the load progresses
  69893. * @param fileName Defines the name of the file to load
  69894. * @returns The loaded asset container
  69895. */
  69896. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69897. /**
  69898. * Read the OBJ file and create an Array of meshes.
  69899. * Each mesh contains all information given by the OBJ and the MTL file.
  69900. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69901. *
  69902. * @param meshesNames
  69903. * @param scene Scene The scene where are displayed the data
  69904. * @param data String The content of the obj file
  69905. * @param rootUrl String The path to the folder
  69906. * @returns Array<AbstractMesh>
  69907. * @private
  69908. */
  69909. private _parseSolid;
  69910. }
  69911. }
  69912. declare module BABYLON {
  69913. /**
  69914. * STL file type loader.
  69915. * This is a babylon scene loader plugin.
  69916. */
  69917. export class STLFileLoader implements ISceneLoaderPlugin {
  69918. /** @hidden */
  69919. solidPattern: RegExp;
  69920. /** @hidden */
  69921. facetsPattern: RegExp;
  69922. /** @hidden */
  69923. normalPattern: RegExp;
  69924. /** @hidden */
  69925. vertexPattern: RegExp;
  69926. /**
  69927. * Defines the name of the plugin.
  69928. */
  69929. name: string;
  69930. /**
  69931. * Defines the extensions the stl loader is able to load.
  69932. * force data to come in as an ArrayBuffer
  69933. * we'll convert to string if it looks like it's an ASCII .stl
  69934. */
  69935. extensions: ISceneLoaderPluginExtensions;
  69936. /**
  69937. * Import meshes into a scene.
  69938. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69939. * @param scene The scene to import into
  69940. * @param data The data to import
  69941. * @param rootUrl The root url for scene and resources
  69942. * @param meshes The meshes array to import into
  69943. * @param particleSystems The particle systems array to import into
  69944. * @param skeletons The skeletons array to import into
  69945. * @param onError The callback when import fails
  69946. * @returns True if successful or false otherwise
  69947. */
  69948. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69949. /**
  69950. * Load into a scene.
  69951. * @param scene The scene to load into
  69952. * @param data The data to import
  69953. * @param rootUrl The root url for scene and resources
  69954. * @param onError The callback when import fails
  69955. * @returns true if successful or false otherwise
  69956. */
  69957. load(scene: Scene, data: any, rootUrl: string): boolean;
  69958. /**
  69959. * Load into an asset container.
  69960. * @param scene The scene to load into
  69961. * @param data The data to import
  69962. * @param rootUrl The root url for scene and resources
  69963. * @param onError The callback when import fails
  69964. * @returns The loaded asset container
  69965. */
  69966. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69967. private _isBinary;
  69968. private _parseBinary;
  69969. private _parseASCII;
  69970. }
  69971. }
  69972. declare module BABYLON {
  69973. /**
  69974. * Class for generating OBJ data from a Babylon scene.
  69975. */
  69976. export class OBJExport {
  69977. /**
  69978. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69979. * @param mesh defines the list of meshes to serialize
  69980. * @param materials defines if materials should be exported
  69981. * @param matlibname defines the name of the associated mtl file
  69982. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69983. * @returns the OBJ content
  69984. */
  69985. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69986. /**
  69987. * Exports the material(s) of a mesh in .MTL file format (text)
  69988. * @param mesh defines the mesh to extract the material from
  69989. * @returns the mtl content
  69990. */
  69991. static MTL(mesh: Mesh): string;
  69992. }
  69993. }
  69994. declare module BABYLON {
  69995. /** @hidden */
  69996. export var __IGLTFExporterExtension: number;
  69997. /**
  69998. * Interface for extending the exporter
  69999. * @hidden
  70000. */
  70001. export interface IGLTFExporterExtension {
  70002. /**
  70003. * The name of this extension
  70004. */
  70005. readonly name: string;
  70006. /**
  70007. * Defines whether this extension is enabled
  70008. */
  70009. enabled: boolean;
  70010. /**
  70011. * Defines whether this extension is required
  70012. */
  70013. required: boolean;
  70014. }
  70015. }
  70016. declare module BABYLON.GLTF2.Exporter {
  70017. /** @hidden */
  70018. export var __IGLTFExporterExtensionV2: number;
  70019. /**
  70020. * Interface for a glTF exporter extension
  70021. * @hidden
  70022. */
  70023. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  70024. /**
  70025. * Define this method to modify the default behavior before exporting a texture
  70026. * @param context The context when loading the asset
  70027. * @param babylonTexture The glTF texture info property
  70028. * @param mimeType The mime-type of the generated image
  70029. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  70030. */
  70031. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70032. /**
  70033. * Define this method to modify the default behavior when exporting texture info
  70034. * @param context The context when loading the asset
  70035. * @param meshPrimitive glTF mesh primitive
  70036. * @param babylonSubMesh Babylon submesh
  70037. * @param binaryWriter glTF serializer binary writer instance
  70038. * @returns nullable IMeshPrimitive promise
  70039. */
  70040. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70041. /**
  70042. * Define this method to modify the default behavior when exporting a node
  70043. * @param context The context when exporting the node
  70044. * @param node glTF node
  70045. * @param babylonNode BabylonJS node
  70046. * @returns nullable INode promise
  70047. */
  70048. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70049. /**
  70050. * Called after the exporter state changes to EXPORTING
  70051. */
  70052. onExporting?(): void;
  70053. }
  70054. }
  70055. declare module BABYLON.GLTF2.Exporter {
  70056. /**
  70057. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  70058. * @hidden
  70059. */
  70060. export class _GLTFMaterialExporter {
  70061. /**
  70062. * Represents the dielectric specular values for R, G and B
  70063. */
  70064. private static readonly _DielectricSpecular;
  70065. /**
  70066. * Allows the maximum specular power to be defined for material calculations
  70067. */
  70068. private static readonly _MaxSpecularPower;
  70069. /**
  70070. * Mapping to store textures
  70071. */
  70072. private _textureMap;
  70073. /**
  70074. * Numeric tolerance value
  70075. */
  70076. private static readonly _Epsilon;
  70077. /**
  70078. * Reference to the glTF Exporter
  70079. */
  70080. private _exporter;
  70081. constructor(exporter: _Exporter);
  70082. /**
  70083. * Specifies if two colors are approximately equal in value
  70084. * @param color1 first color to compare to
  70085. * @param color2 second color to compare to
  70086. * @param epsilon threshold value
  70087. */
  70088. private static FuzzyEquals;
  70089. /**
  70090. * Gets the materials from a Babylon scene and converts them to glTF materials
  70091. * @param scene babylonjs scene
  70092. * @param mimeType texture mime type
  70093. * @param images array of images
  70094. * @param textures array of textures
  70095. * @param materials array of materials
  70096. * @param imageData mapping of texture names to base64 textures
  70097. * @param hasTextureCoords specifies if texture coordinates are present on the material
  70098. */
  70099. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70100. /**
  70101. * Makes a copy of the glTF material without the texture parameters
  70102. * @param originalMaterial original glTF material
  70103. * @returns glTF material without texture parameters
  70104. */
  70105. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  70106. /**
  70107. * Specifies if the material has any texture parameters present
  70108. * @param material glTF Material
  70109. * @returns boolean specifying if texture parameters are present
  70110. */
  70111. _hasTexturesPresent(material: IMaterial): boolean;
  70112. /**
  70113. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  70114. * @param babylonStandardMaterial
  70115. * @returns glTF Metallic Roughness Material representation
  70116. */
  70117. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  70118. /**
  70119. * Computes the metallic factor
  70120. * @param diffuse diffused value
  70121. * @param specular specular value
  70122. * @param oneMinusSpecularStrength one minus the specular strength
  70123. * @returns metallic value
  70124. */
  70125. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  70126. /**
  70127. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  70128. * @param glTFMaterial glTF material
  70129. * @param babylonMaterial Babylon material
  70130. */
  70131. private static _SetAlphaMode;
  70132. /**
  70133. * Converts a Babylon Standard Material to a glTF Material
  70134. * @param babylonStandardMaterial BJS Standard Material
  70135. * @param mimeType mime type to use for the textures
  70136. * @param images array of glTF image interfaces
  70137. * @param textures array of glTF texture interfaces
  70138. * @param materials array of glTF material interfaces
  70139. * @param imageData map of image file name to data
  70140. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70141. */
  70142. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70143. /**
  70144. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70145. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  70146. * @param mimeType mime type to use for the textures
  70147. * @param images array of glTF image interfaces
  70148. * @param textures array of glTF texture interfaces
  70149. * @param materials array of glTF material interfaces
  70150. * @param imageData map of image file name to data
  70151. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70152. */
  70153. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70154. /**
  70155. * Converts an image typed array buffer to a base64 image
  70156. * @param buffer typed array buffer
  70157. * @param width width of the image
  70158. * @param height height of the image
  70159. * @param mimeType mimetype of the image
  70160. * @returns base64 image string
  70161. */
  70162. private _createBase64FromCanvasAsync;
  70163. /**
  70164. * Generates a white texture based on the specified width and height
  70165. * @param width width of the texture in pixels
  70166. * @param height height of the texture in pixels
  70167. * @param scene babylonjs scene
  70168. * @returns white texture
  70169. */
  70170. private _createWhiteTexture;
  70171. /**
  70172. * 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
  70173. * @param texture1 first texture to resize
  70174. * @param texture2 second texture to resize
  70175. * @param scene babylonjs scene
  70176. * @returns resized textures or null
  70177. */
  70178. private _resizeTexturesToSameDimensions;
  70179. /**
  70180. * Converts an array of pixels to a Float32Array
  70181. * Throws an error if the pixel format is not supported
  70182. * @param pixels - array buffer containing pixel values
  70183. * @returns Float32 of pixels
  70184. */
  70185. private _convertPixelArrayToFloat32;
  70186. /**
  70187. * Convert Specular Glossiness Textures to Metallic Roughness
  70188. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  70189. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  70190. * @param diffuseTexture texture used to store diffuse information
  70191. * @param specularGlossinessTexture texture used to store specular and glossiness information
  70192. * @param factors specular glossiness material factors
  70193. * @param mimeType the mime type to use for the texture
  70194. * @returns pbr metallic roughness interface or null
  70195. */
  70196. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  70197. /**
  70198. * Converts specular glossiness material properties to metallic roughness
  70199. * @param specularGlossiness interface with specular glossiness material properties
  70200. * @returns interface with metallic roughness material properties
  70201. */
  70202. private _convertSpecularGlossinessToMetallicRoughness;
  70203. /**
  70204. * Calculates the surface reflectance, independent of lighting conditions
  70205. * @param color Color source to calculate brightness from
  70206. * @returns number representing the perceived brightness, or zero if color is undefined
  70207. */
  70208. private _getPerceivedBrightness;
  70209. /**
  70210. * Returns the maximum color component value
  70211. * @param color
  70212. * @returns maximum color component value, or zero if color is null or undefined
  70213. */
  70214. private _getMaxComponent;
  70215. /**
  70216. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  70217. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70218. * @param mimeType mime type to use for the textures
  70219. * @param images array of glTF image interfaces
  70220. * @param textures array of glTF texture interfaces
  70221. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70222. * @param imageData map of image file name to data
  70223. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70224. * @returns glTF PBR Metallic Roughness factors
  70225. */
  70226. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  70227. private _getGLTFTextureSampler;
  70228. private _getGLTFTextureWrapMode;
  70229. private _getGLTFTextureWrapModesSampler;
  70230. /**
  70231. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  70232. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70233. * @param mimeType mime type to use for the textures
  70234. * @param images array of glTF image interfaces
  70235. * @param textures array of glTF texture interfaces
  70236. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70237. * @param imageData map of image file name to data
  70238. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70239. * @returns glTF PBR Metallic Roughness factors
  70240. */
  70241. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  70242. /**
  70243. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70244. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70245. * @param mimeType mime type to use for the textures
  70246. * @param images array of glTF image interfaces
  70247. * @param textures array of glTF texture interfaces
  70248. * @param materials array of glTF material interfaces
  70249. * @param imageData map of image file name to data
  70250. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70251. */
  70252. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70253. private setMetallicRoughnessPbrMaterial;
  70254. private getPixelsFromTexture;
  70255. /**
  70256. * Extracts a texture from a Babylon texture into file data and glTF data
  70257. * @param babylonTexture Babylon texture to extract
  70258. * @param mimeType Mime Type of the babylonTexture
  70259. * @return glTF texture info, or null if the texture format is not supported
  70260. */
  70261. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70262. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70263. /**
  70264. * Builds a texture from base64 string
  70265. * @param base64Texture base64 texture string
  70266. * @param baseTextureName Name to use for the texture
  70267. * @param mimeType image mime type for the texture
  70268. * @param images array of images
  70269. * @param textures array of textures
  70270. * @param imageData map of image data
  70271. * @returns glTF texture info, or null if the texture format is not supported
  70272. */
  70273. private _getTextureInfoFromBase64;
  70274. }
  70275. }
  70276. declare module BABYLON {
  70277. /**
  70278. * Class for holding and downloading glTF file data
  70279. */
  70280. export class GLTFData {
  70281. /**
  70282. * Object which contains the file name as the key and its data as the value
  70283. */
  70284. glTFFiles: {
  70285. [fileName: string]: string | Blob;
  70286. };
  70287. /**
  70288. * Initializes the glTF file object
  70289. */
  70290. constructor();
  70291. /**
  70292. * Downloads the glTF data as files based on their names and data
  70293. */
  70294. downloadFiles(): void;
  70295. }
  70296. }
  70297. declare module BABYLON {
  70298. /**
  70299. * Holds a collection of exporter options and parameters
  70300. */
  70301. export interface IExportOptions {
  70302. /**
  70303. * Function which indicates whether a babylon node should be exported or not
  70304. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  70305. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  70306. */
  70307. shouldExportNode?(node: Node): boolean;
  70308. /**
  70309. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  70310. * @param metadata source metadata to read from
  70311. * @returns the data to store to glTF node extras
  70312. */
  70313. metadataSelector?(metadata: any): any;
  70314. /**
  70315. * The sample rate to bake animation curves
  70316. */
  70317. animationSampleRate?: number;
  70318. /**
  70319. * Begin serialization without waiting for the scene to be ready
  70320. */
  70321. exportWithoutWaitingForScene?: boolean;
  70322. }
  70323. /**
  70324. * Class for generating glTF data from a Babylon scene.
  70325. */
  70326. export class GLTF2Export {
  70327. /**
  70328. * Exports the geometry of the scene to .gltf file format asynchronously
  70329. * @param scene Babylon scene with scene hierarchy information
  70330. * @param filePrefix File prefix to use when generating the glTF file
  70331. * @param options Exporter options
  70332. * @returns Returns an object with a .gltf file and associates texture names
  70333. * as keys and their data and paths as values
  70334. */
  70335. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70336. private static _PreExportAsync;
  70337. private static _PostExportAsync;
  70338. /**
  70339. * Exports the geometry of the scene to .glb file format asychronously
  70340. * @param scene Babylon scene with scene hierarchy information
  70341. * @param filePrefix File prefix to use when generating glb file
  70342. * @param options Exporter options
  70343. * @returns Returns an object with a .glb filename as key and data as value
  70344. */
  70345. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70346. }
  70347. }
  70348. declare module BABYLON.GLTF2.Exporter {
  70349. /**
  70350. * @hidden
  70351. */
  70352. export class _GLTFUtilities {
  70353. /**
  70354. * Creates a buffer view based on the supplied arguments
  70355. * @param bufferIndex index value of the specified buffer
  70356. * @param byteOffset byte offset value
  70357. * @param byteLength byte length of the bufferView
  70358. * @param byteStride byte distance between conequential elements
  70359. * @param name name of the buffer view
  70360. * @returns bufferView for glTF
  70361. */
  70362. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  70363. /**
  70364. * Creates an accessor based on the supplied arguments
  70365. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  70366. * @param name The name of the accessor
  70367. * @param type The type of the accessor
  70368. * @param componentType The datatype of components in the attribute
  70369. * @param count The number of attributes referenced by this accessor
  70370. * @param byteOffset The offset relative to the start of the bufferView in bytes
  70371. * @param min Minimum value of each component in this attribute
  70372. * @param max Maximum value of each component in this attribute
  70373. * @returns accessor for glTF
  70374. */
  70375. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  70376. /**
  70377. * Calculates the minimum and maximum values of an array of position floats
  70378. * @param positions Positions array of a mesh
  70379. * @param vertexStart Starting vertex offset to calculate min and max values
  70380. * @param vertexCount Number of vertices to check for min and max values
  70381. * @returns min number array and max number array
  70382. */
  70383. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  70384. min: number[];
  70385. max: number[];
  70386. };
  70387. /**
  70388. * Converts a new right-handed Vector3
  70389. * @param vector vector3 array
  70390. * @returns right-handed Vector3
  70391. */
  70392. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  70393. /**
  70394. * Converts a Vector3 to right-handed
  70395. * @param vector Vector3 to convert to right-handed
  70396. */
  70397. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  70398. /**
  70399. * Converts a three element number array to right-handed
  70400. * @param vector number array to convert to right-handed
  70401. */
  70402. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  70403. /**
  70404. * Converts a new right-handed Vector3
  70405. * @param vector vector3 array
  70406. * @returns right-handed Vector3
  70407. */
  70408. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  70409. /**
  70410. * Converts a Vector3 to right-handed
  70411. * @param vector Vector3 to convert to right-handed
  70412. */
  70413. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  70414. /**
  70415. * Converts a three element number array to right-handed
  70416. * @param vector number array to convert to right-handed
  70417. */
  70418. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  70419. /**
  70420. * Converts a Vector4 to right-handed
  70421. * @param vector Vector4 to convert to right-handed
  70422. */
  70423. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  70424. /**
  70425. * Converts a Vector4 to right-handed
  70426. * @param vector Vector4 to convert to right-handed
  70427. */
  70428. static _GetRightHandedArray4FromRef(vector: number[]): void;
  70429. /**
  70430. * Converts a Quaternion to right-handed
  70431. * @param quaternion Source quaternion to convert to right-handed
  70432. */
  70433. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  70434. /**
  70435. * Converts a Quaternion to right-handed
  70436. * @param quaternion Source quaternion to convert to right-handed
  70437. */
  70438. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  70439. static _NormalizeTangentFromRef(tangent: Vector4): void;
  70440. }
  70441. }
  70442. declare module BABYLON.GLTF2.Exporter {
  70443. /**
  70444. * Converts Babylon Scene into glTF 2.0.
  70445. * @hidden
  70446. */
  70447. export class _Exporter {
  70448. /**
  70449. * Stores the glTF to export
  70450. */
  70451. _glTF: IGLTF;
  70452. /**
  70453. * Stores all generated buffer views, which represents views into the main glTF buffer data
  70454. */
  70455. _bufferViews: IBufferView[];
  70456. /**
  70457. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  70458. */
  70459. _accessors: IAccessor[];
  70460. /**
  70461. * Stores all the generated nodes, which contains transform and/or mesh information per node
  70462. */
  70463. private _nodes;
  70464. /**
  70465. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  70466. */
  70467. private _scenes;
  70468. /**
  70469. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  70470. */
  70471. private _meshes;
  70472. /**
  70473. * Stores all the generated material information, which represents the appearance of each primitive
  70474. */
  70475. _materials: IMaterial[];
  70476. _materialMap: {
  70477. [materialID: number]: number;
  70478. };
  70479. /**
  70480. * Stores all the generated texture information, which is referenced by glTF materials
  70481. */
  70482. _textures: ITexture[];
  70483. /**
  70484. * Stores all the generated image information, which is referenced by glTF textures
  70485. */
  70486. _images: IImage[];
  70487. /**
  70488. * Stores all the texture samplers
  70489. */
  70490. _samplers: ISampler[];
  70491. /**
  70492. * Stores all the generated animation samplers, which is referenced by glTF animations
  70493. */
  70494. /**
  70495. * Stores the animations for glTF models
  70496. */
  70497. private _animations;
  70498. /**
  70499. * Stores the total amount of bytes stored in the glTF buffer
  70500. */
  70501. private _totalByteLength;
  70502. /**
  70503. * Stores a reference to the Babylon scene containing the source geometry and material information
  70504. */
  70505. _babylonScene: Scene;
  70506. /**
  70507. * Stores a map of the image data, where the key is the file name and the value
  70508. * is the image data
  70509. */
  70510. _imageData: {
  70511. [fileName: string]: {
  70512. data: Uint8Array;
  70513. mimeType: ImageMimeType;
  70514. };
  70515. };
  70516. /**
  70517. * Stores a map of the unique id of a node to its index in the node array
  70518. */
  70519. private _nodeMap;
  70520. /**
  70521. * Specifies if the Babylon scene should be converted to right-handed on export
  70522. */
  70523. _convertToRightHandedSystem: boolean;
  70524. /**
  70525. * Baked animation sample rate
  70526. */
  70527. private _animationSampleRate;
  70528. private _options;
  70529. private _localEngine;
  70530. _glTFMaterialExporter: _GLTFMaterialExporter;
  70531. private _extensions;
  70532. private static _ExtensionNames;
  70533. private static _ExtensionFactories;
  70534. private _applyExtensions;
  70535. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  70536. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70537. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70538. private _forEachExtensions;
  70539. private _extensionsOnExporting;
  70540. /**
  70541. * Load glTF serializer extensions
  70542. */
  70543. private _loadExtensions;
  70544. /**
  70545. * Creates a glTF Exporter instance, which can accept optional exporter options
  70546. * @param babylonScene Babylon scene object
  70547. * @param options Options to modify the behavior of the exporter
  70548. */
  70549. constructor(babylonScene: Scene, options?: IExportOptions);
  70550. /**
  70551. * Registers a glTF exporter extension
  70552. * @param name Name of the extension to export
  70553. * @param factory The factory function that creates the exporter extension
  70554. */
  70555. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  70556. /**
  70557. * Un-registers an exporter extension
  70558. * @param name The name fo the exporter extension
  70559. * @returns A boolean indicating whether the extension has been un-registered
  70560. */
  70561. static UnregisterExtension(name: string): boolean;
  70562. /**
  70563. * Lazy load a local engine with premultiplied alpha set to false
  70564. */
  70565. _getLocalEngine(): Engine;
  70566. private reorderIndicesBasedOnPrimitiveMode;
  70567. /**
  70568. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  70569. * clock-wise during export to glTF
  70570. * @param submesh BabylonJS submesh
  70571. * @param primitiveMode Primitive mode of the mesh
  70572. * @param sideOrientation the winding order of the submesh
  70573. * @param vertexBufferKind The type of vertex attribute
  70574. * @param meshAttributeArray The vertex attribute data
  70575. * @param byteOffset The offset to the binary data
  70576. * @param binaryWriter The binary data for the glTF file
  70577. */
  70578. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  70579. /**
  70580. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  70581. * clock-wise during export to glTF
  70582. * @param submesh BabylonJS submesh
  70583. * @param primitiveMode Primitive mode of the mesh
  70584. * @param sideOrientation the winding order of the submesh
  70585. * @param vertexBufferKind The type of vertex attribute
  70586. * @param meshAttributeArray The vertex attribute data
  70587. * @param byteOffset The offset to the binary data
  70588. * @param binaryWriter The binary data for the glTF file
  70589. */
  70590. private reorderTriangleFillMode;
  70591. /**
  70592. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  70593. * clock-wise during export to glTF
  70594. * @param submesh BabylonJS submesh
  70595. * @param primitiveMode Primitive mode of the mesh
  70596. * @param sideOrientation the winding order of the submesh
  70597. * @param vertexBufferKind The type of vertex attribute
  70598. * @param meshAttributeArray The vertex attribute data
  70599. * @param byteOffset The offset to the binary data
  70600. * @param binaryWriter The binary data for the glTF file
  70601. */
  70602. private reorderTriangleStripDrawMode;
  70603. /**
  70604. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  70605. * clock-wise during export to glTF
  70606. * @param submesh BabylonJS submesh
  70607. * @param primitiveMode Primitive mode of the mesh
  70608. * @param sideOrientation the winding order of the submesh
  70609. * @param vertexBufferKind The type of vertex attribute
  70610. * @param meshAttributeArray The vertex attribute data
  70611. * @param byteOffset The offset to the binary data
  70612. * @param binaryWriter The binary data for the glTF file
  70613. */
  70614. private reorderTriangleFanMode;
  70615. /**
  70616. * Writes the vertex attribute data to binary
  70617. * @param vertices The vertices to write to the binary writer
  70618. * @param byteOffset The offset into the binary writer to overwrite binary data
  70619. * @param vertexAttributeKind The vertex attribute type
  70620. * @param meshAttributeArray The vertex attribute data
  70621. * @param binaryWriter The writer containing the binary data
  70622. */
  70623. private writeVertexAttributeData;
  70624. /**
  70625. * Writes mesh attribute data to a data buffer
  70626. * Returns the bytelength of the data
  70627. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  70628. * @param meshAttributeArray Array containing the attribute data
  70629. * @param binaryWriter The buffer to write the binary data to
  70630. * @param indices Used to specify the order of the vertex data
  70631. */
  70632. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  70633. /**
  70634. * Generates glTF json data
  70635. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  70636. * @param glTFPrefix Text to use when prefixing a glTF file
  70637. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  70638. * @returns json data as string
  70639. */
  70640. private generateJSON;
  70641. /**
  70642. * Generates data for .gltf and .bin files based on the glTF prefix string
  70643. * @param glTFPrefix Text to use when prefixing a glTF file
  70644. * @returns GLTFData with glTF file data
  70645. */
  70646. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  70647. /**
  70648. * Creates a binary buffer for glTF
  70649. * @returns array buffer for binary data
  70650. */
  70651. private _generateBinaryAsync;
  70652. /**
  70653. * Pads the number to a multiple of 4
  70654. * @param num number to pad
  70655. * @returns padded number
  70656. */
  70657. private _getPadding;
  70658. /**
  70659. * Generates a glb file from the json and binary data
  70660. * Returns an object with the glb file name as the key and data as the value
  70661. * @param glTFPrefix
  70662. * @returns object with glb filename as key and data as value
  70663. */
  70664. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  70665. /**
  70666. * Sets the TRS for each node
  70667. * @param node glTF Node for storing the transformation data
  70668. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  70669. */
  70670. private setNodeTransformation;
  70671. private getVertexBufferFromMesh;
  70672. /**
  70673. * Creates a bufferview based on the vertices type for the Babylon mesh
  70674. * @param kind Indicates the type of vertices data
  70675. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  70676. * @param binaryWriter The buffer to write the bufferview data to
  70677. */
  70678. private createBufferViewKind;
  70679. /**
  70680. * The primitive mode of the Babylon mesh
  70681. * @param babylonMesh The BabylonJS mesh
  70682. */
  70683. private getMeshPrimitiveMode;
  70684. /**
  70685. * Sets the primitive mode of the glTF mesh primitive
  70686. * @param meshPrimitive glTF mesh primitive
  70687. * @param primitiveMode The primitive mode
  70688. */
  70689. private setPrimitiveMode;
  70690. /**
  70691. * Sets the vertex attribute accessor based of the glTF mesh primitive
  70692. * @param meshPrimitive glTF mesh primitive
  70693. * @param attributeKind vertex attribute
  70694. * @returns boolean specifying if uv coordinates are present
  70695. */
  70696. private setAttributeKind;
  70697. /**
  70698. * Sets data for the primitive attributes of each submesh
  70699. * @param mesh glTF Mesh object to store the primitive attribute information
  70700. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70701. * @param binaryWriter Buffer to write the attribute data to
  70702. */
  70703. private setPrimitiveAttributesAsync;
  70704. /**
  70705. * Creates a glTF scene based on the array of meshes
  70706. * Returns the the total byte offset
  70707. * @param babylonScene Babylon scene to get the mesh data from
  70708. * @param binaryWriter Buffer to write binary data to
  70709. */
  70710. private createSceneAsync;
  70711. /**
  70712. * Creates a mapping of Node unique id to node index and handles animations
  70713. * @param babylonScene Babylon Scene
  70714. * @param nodes Babylon transform nodes
  70715. * @param binaryWriter Buffer to write binary data to
  70716. * @returns Node mapping of unique id to index
  70717. */
  70718. private createNodeMapAndAnimationsAsync;
  70719. /**
  70720. * Creates a glTF node from a Babylon mesh
  70721. * @param babylonMesh Source Babylon mesh
  70722. * @param binaryWriter Buffer for storing geometry data
  70723. * @returns glTF node
  70724. */
  70725. private createNodeAsync;
  70726. }
  70727. /**
  70728. * @hidden
  70729. *
  70730. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  70731. */
  70732. export class _BinaryWriter {
  70733. /**
  70734. * Array buffer which stores all binary data
  70735. */
  70736. private _arrayBuffer;
  70737. /**
  70738. * View of the array buffer
  70739. */
  70740. private _dataView;
  70741. /**
  70742. * byte offset of data in array buffer
  70743. */
  70744. private _byteOffset;
  70745. /**
  70746. * Initialize binary writer with an initial byte length
  70747. * @param byteLength Initial byte length of the array buffer
  70748. */
  70749. constructor(byteLength: number);
  70750. /**
  70751. * Resize the array buffer to the specified byte length
  70752. * @param byteLength
  70753. */
  70754. private resizeBuffer;
  70755. /**
  70756. * Get an array buffer with the length of the byte offset
  70757. * @returns ArrayBuffer resized to the byte offset
  70758. */
  70759. getArrayBuffer(): ArrayBuffer;
  70760. /**
  70761. * Get the byte offset of the array buffer
  70762. * @returns byte offset
  70763. */
  70764. getByteOffset(): number;
  70765. /**
  70766. * Stores an UInt8 in the array buffer
  70767. * @param entry
  70768. * @param byteOffset If defined, specifies where to set the value as an offset.
  70769. */
  70770. setUInt8(entry: number, byteOffset?: number): void;
  70771. /**
  70772. * Gets an UInt32 in the array buffer
  70773. * @param entry
  70774. * @param byteOffset If defined, specifies where to set the value as an offset.
  70775. */
  70776. getUInt32(byteOffset: number): number;
  70777. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70778. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70779. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70780. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70781. /**
  70782. * Stores a Float32 in the array buffer
  70783. * @param entry
  70784. */
  70785. setFloat32(entry: number, byteOffset?: number): void;
  70786. /**
  70787. * Stores an UInt32 in the array buffer
  70788. * @param entry
  70789. * @param byteOffset If defined, specifies where to set the value as an offset.
  70790. */
  70791. setUInt32(entry: number, byteOffset?: number): void;
  70792. }
  70793. }
  70794. declare module BABYLON.GLTF2.Exporter {
  70795. /**
  70796. * @hidden
  70797. * Interface to store animation data.
  70798. */
  70799. export interface _IAnimationData {
  70800. /**
  70801. * Keyframe data.
  70802. */
  70803. inputs: number[];
  70804. /**
  70805. * Value data.
  70806. */
  70807. outputs: number[][];
  70808. /**
  70809. * Animation interpolation data.
  70810. */
  70811. samplerInterpolation: AnimationSamplerInterpolation;
  70812. /**
  70813. * Minimum keyframe value.
  70814. */
  70815. inputsMin: number;
  70816. /**
  70817. * Maximum keyframe value.
  70818. */
  70819. inputsMax: number;
  70820. }
  70821. /**
  70822. * @hidden
  70823. */
  70824. export interface _IAnimationInfo {
  70825. /**
  70826. * The target channel for the animation
  70827. */
  70828. animationChannelTargetPath: AnimationChannelTargetPath;
  70829. /**
  70830. * The glTF accessor type for the data.
  70831. */
  70832. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  70833. /**
  70834. * Specifies if quaternions should be used.
  70835. */
  70836. useQuaternion: boolean;
  70837. }
  70838. /**
  70839. * @hidden
  70840. * Utility class for generating glTF animation data from BabylonJS.
  70841. */
  70842. export class _GLTFAnimation {
  70843. /**
  70844. * @ignore
  70845. *
  70846. * Creates glTF channel animation from BabylonJS animation.
  70847. * @param babylonTransformNode - BabylonJS mesh.
  70848. * @param animation - animation.
  70849. * @param animationChannelTargetPath - The target animation channel.
  70850. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70851. * @param useQuaternion - Specifies if quaternions are used.
  70852. * @returns nullable IAnimationData
  70853. */
  70854. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70855. private static _DeduceAnimationInfo;
  70856. /**
  70857. * @ignore
  70858. * Create node animations from the transform node animations
  70859. * @param babylonNode
  70860. * @param runtimeGLTFAnimation
  70861. * @param idleGLTFAnimations
  70862. * @param nodeMap
  70863. * @param nodes
  70864. * @param binaryWriter
  70865. * @param bufferViews
  70866. * @param accessors
  70867. * @param convertToRightHandedSystem
  70868. */
  70869. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70870. [key: number]: number;
  70871. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70872. /**
  70873. * @ignore
  70874. * Create node animations from the animation groups
  70875. * @param babylonScene
  70876. * @param glTFAnimations
  70877. * @param nodeMap
  70878. * @param nodes
  70879. * @param binaryWriter
  70880. * @param bufferViews
  70881. * @param accessors
  70882. * @param convertToRightHandedSystem
  70883. */
  70884. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70885. [key: number]: number;
  70886. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70887. private static AddAnimation;
  70888. /**
  70889. * Create a baked animation
  70890. * @param babylonTransformNode BabylonJS mesh
  70891. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70892. * @param animationChannelTargetPath animation target channel
  70893. * @param minFrame minimum animation frame
  70894. * @param maxFrame maximum animation frame
  70895. * @param fps frames per second of the animation
  70896. * @param inputs input key frames of the animation
  70897. * @param outputs output key frame data of the animation
  70898. * @param convertToRightHandedSystem converts the values to right-handed
  70899. * @param useQuaternion specifies if quaternions should be used
  70900. */
  70901. private static _CreateBakedAnimation;
  70902. private static _ConvertFactorToVector3OrQuaternion;
  70903. private static _SetInterpolatedValue;
  70904. /**
  70905. * Creates linear animation from the animation key frames
  70906. * @param babylonTransformNode BabylonJS mesh
  70907. * @param animation BabylonJS animation
  70908. * @param animationChannelTargetPath The target animation channel
  70909. * @param frameDelta The difference between the last and first frame of the animation
  70910. * @param inputs Array to store the key frame times
  70911. * @param outputs Array to store the key frame data
  70912. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70913. * @param useQuaternion Specifies if quaternions are used in the animation
  70914. */
  70915. private static _CreateLinearOrStepAnimation;
  70916. /**
  70917. * Creates cubic spline animation from the animation key frames
  70918. * @param babylonTransformNode BabylonJS mesh
  70919. * @param animation BabylonJS animation
  70920. * @param animationChannelTargetPath The target animation channel
  70921. * @param frameDelta The difference between the last and first frame of the animation
  70922. * @param inputs Array to store the key frame times
  70923. * @param outputs Array to store the key frame data
  70924. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70925. * @param useQuaternion Specifies if quaternions are used in the animation
  70926. */
  70927. private static _CreateCubicSplineAnimation;
  70928. private static _GetBasePositionRotationOrScale;
  70929. /**
  70930. * Adds a key frame value
  70931. * @param keyFrame
  70932. * @param animation
  70933. * @param outputs
  70934. * @param animationChannelTargetPath
  70935. * @param basePositionRotationOrScale
  70936. * @param convertToRightHandedSystem
  70937. * @param useQuaternion
  70938. */
  70939. private static _AddKeyframeValue;
  70940. /**
  70941. * Determine the interpolation based on the key frames
  70942. * @param keyFrames
  70943. * @param animationChannelTargetPath
  70944. * @param useQuaternion
  70945. */
  70946. private static _DeduceInterpolation;
  70947. /**
  70948. * Adds an input tangent or output tangent to the output data
  70949. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70950. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70951. * @param outputs The animation data by keyframe
  70952. * @param animationChannelTargetPath The target animation channel
  70953. * @param interpolation The interpolation type
  70954. * @param keyFrame The key frame with the animation data
  70955. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70956. * @param useQuaternion Specifies if quaternions are used
  70957. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70958. */
  70959. private static AddSplineTangent;
  70960. /**
  70961. * Get the minimum and maximum key frames' frame values
  70962. * @param keyFrames animation key frames
  70963. * @returns the minimum and maximum key frame value
  70964. */
  70965. private static calculateMinMaxKeyFrames;
  70966. }
  70967. }
  70968. declare module BABYLON.GLTF2.Exporter {
  70969. /** @hidden */
  70970. export var textureTransformPixelShader: {
  70971. name: string;
  70972. shader: string;
  70973. };
  70974. }
  70975. declare module BABYLON.GLTF2.Exporter.Extensions {
  70976. /**
  70977. * @hidden
  70978. */
  70979. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70980. /** Name of this extension */
  70981. readonly name: string;
  70982. /** Defines whether this extension is enabled */
  70983. enabled: boolean;
  70984. /** Defines whether this extension is required */
  70985. required: boolean;
  70986. /** Reference to the glTF exporter */
  70987. private _exporter;
  70988. constructor(exporter: _Exporter);
  70989. dispose(): void;
  70990. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70991. /**
  70992. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70993. * @param babylonTexture
  70994. * @param offset
  70995. * @param rotation
  70996. * @param scale
  70997. * @param scene
  70998. */
  70999. private _textureTransformTextureAsync;
  71000. }
  71001. }
  71002. declare module BABYLON.GLTF2.Exporter.Extensions {
  71003. /**
  71004. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71005. */
  71006. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  71007. /** The name of this extension. */
  71008. readonly name: string;
  71009. /** Defines whether this extension is enabled. */
  71010. enabled: boolean;
  71011. /** Defines whether this extension is required */
  71012. required: boolean;
  71013. /** Reference to the glTF exporter */
  71014. private _exporter;
  71015. private _lights;
  71016. /** @hidden */
  71017. constructor(exporter: _Exporter);
  71018. /** @hidden */
  71019. dispose(): void;
  71020. /** @hidden */
  71021. onExporting(): void;
  71022. /**
  71023. * Define this method to modify the default behavior when exporting a node
  71024. * @param context The context when exporting the node
  71025. * @param node glTF node
  71026. * @param babylonNode BabylonJS node
  71027. * @returns nullable INode promise
  71028. */
  71029. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71030. }
  71031. }
  71032. declare module BABYLON {
  71033. /**
  71034. * Class for generating STL data from a Babylon scene.
  71035. */
  71036. export class STLExport {
  71037. /**
  71038. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  71039. * @param meshes list defines the mesh to serialize
  71040. * @param download triggers the automatic download of the file.
  71041. * @param fileName changes the downloads fileName.
  71042. * @param binary changes the STL to a binary type.
  71043. * @param isLittleEndian toggle for binary type exporter.
  71044. * @returns the STL as UTF8 string
  71045. */
  71046. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  71047. }
  71048. }
  71049. declare module "babylonjs-gltf2interface" {
  71050. export = BABYLON.GLTF2;
  71051. }
  71052. /**
  71053. * Module for glTF 2.0 Interface
  71054. */
  71055. declare module BABYLON.GLTF2 {
  71056. /**
  71057. * The datatype of the components in the attribute
  71058. */
  71059. const enum AccessorComponentType {
  71060. /**
  71061. * Byte
  71062. */
  71063. BYTE = 5120,
  71064. /**
  71065. * Unsigned Byte
  71066. */
  71067. UNSIGNED_BYTE = 5121,
  71068. /**
  71069. * Short
  71070. */
  71071. SHORT = 5122,
  71072. /**
  71073. * Unsigned Short
  71074. */
  71075. UNSIGNED_SHORT = 5123,
  71076. /**
  71077. * Unsigned Int
  71078. */
  71079. UNSIGNED_INT = 5125,
  71080. /**
  71081. * Float
  71082. */
  71083. FLOAT = 5126,
  71084. }
  71085. /**
  71086. * Specifies if the attirbute is a scalar, vector, or matrix
  71087. */
  71088. const enum AccessorType {
  71089. /**
  71090. * Scalar
  71091. */
  71092. SCALAR = "SCALAR",
  71093. /**
  71094. * Vector2
  71095. */
  71096. VEC2 = "VEC2",
  71097. /**
  71098. * Vector3
  71099. */
  71100. VEC3 = "VEC3",
  71101. /**
  71102. * Vector4
  71103. */
  71104. VEC4 = "VEC4",
  71105. /**
  71106. * Matrix2x2
  71107. */
  71108. MAT2 = "MAT2",
  71109. /**
  71110. * Matrix3x3
  71111. */
  71112. MAT3 = "MAT3",
  71113. /**
  71114. * Matrix4x4
  71115. */
  71116. MAT4 = "MAT4",
  71117. }
  71118. /**
  71119. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71120. */
  71121. const enum AnimationChannelTargetPath {
  71122. /**
  71123. * Translation
  71124. */
  71125. TRANSLATION = "translation",
  71126. /**
  71127. * Rotation
  71128. */
  71129. ROTATION = "rotation",
  71130. /**
  71131. * Scale
  71132. */
  71133. SCALE = "scale",
  71134. /**
  71135. * Weights
  71136. */
  71137. WEIGHTS = "weights",
  71138. }
  71139. /**
  71140. * Interpolation algorithm
  71141. */
  71142. const enum AnimationSamplerInterpolation {
  71143. /**
  71144. * The animated values are linearly interpolated between keyframes
  71145. */
  71146. LINEAR = "LINEAR",
  71147. /**
  71148. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  71149. */
  71150. STEP = "STEP",
  71151. /**
  71152. * The animation's interpolation is computed using a cubic spline with specified tangents
  71153. */
  71154. CUBICSPLINE = "CUBICSPLINE",
  71155. }
  71156. /**
  71157. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71158. */
  71159. const enum CameraType {
  71160. /**
  71161. * A perspective camera containing properties to create a perspective projection matrix
  71162. */
  71163. PERSPECTIVE = "perspective",
  71164. /**
  71165. * An orthographic camera containing properties to create an orthographic projection matrix
  71166. */
  71167. ORTHOGRAPHIC = "orthographic",
  71168. }
  71169. /**
  71170. * The mime-type of the image
  71171. */
  71172. const enum ImageMimeType {
  71173. /**
  71174. * JPEG Mime-type
  71175. */
  71176. JPEG = "image/jpeg",
  71177. /**
  71178. * PNG Mime-type
  71179. */
  71180. PNG = "image/png",
  71181. }
  71182. /**
  71183. * The alpha rendering mode of the material
  71184. */
  71185. const enum MaterialAlphaMode {
  71186. /**
  71187. * The alpha value is ignored and the rendered output is fully opaque
  71188. */
  71189. OPAQUE = "OPAQUE",
  71190. /**
  71191. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  71192. */
  71193. MASK = "MASK",
  71194. /**
  71195. * 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)
  71196. */
  71197. BLEND = "BLEND",
  71198. }
  71199. /**
  71200. * The type of the primitives to render
  71201. */
  71202. const enum MeshPrimitiveMode {
  71203. /**
  71204. * Points
  71205. */
  71206. POINTS = 0,
  71207. /**
  71208. * Lines
  71209. */
  71210. LINES = 1,
  71211. /**
  71212. * Line Loop
  71213. */
  71214. LINE_LOOP = 2,
  71215. /**
  71216. * Line Strip
  71217. */
  71218. LINE_STRIP = 3,
  71219. /**
  71220. * Triangles
  71221. */
  71222. TRIANGLES = 4,
  71223. /**
  71224. * Triangle Strip
  71225. */
  71226. TRIANGLE_STRIP = 5,
  71227. /**
  71228. * Triangle Fan
  71229. */
  71230. TRIANGLE_FAN = 6,
  71231. }
  71232. /**
  71233. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71234. */
  71235. const enum TextureMagFilter {
  71236. /**
  71237. * Nearest
  71238. */
  71239. NEAREST = 9728,
  71240. /**
  71241. * Linear
  71242. */
  71243. LINEAR = 9729,
  71244. }
  71245. /**
  71246. * Minification filter. All valid values correspond to WebGL enums
  71247. */
  71248. const enum TextureMinFilter {
  71249. /**
  71250. * Nearest
  71251. */
  71252. NEAREST = 9728,
  71253. /**
  71254. * Linear
  71255. */
  71256. LINEAR = 9729,
  71257. /**
  71258. * Nearest Mip-Map Nearest
  71259. */
  71260. NEAREST_MIPMAP_NEAREST = 9984,
  71261. /**
  71262. * Linear Mipmap Nearest
  71263. */
  71264. LINEAR_MIPMAP_NEAREST = 9985,
  71265. /**
  71266. * Nearest Mipmap Linear
  71267. */
  71268. NEAREST_MIPMAP_LINEAR = 9986,
  71269. /**
  71270. * Linear Mipmap Linear
  71271. */
  71272. LINEAR_MIPMAP_LINEAR = 9987,
  71273. }
  71274. /**
  71275. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71276. */
  71277. const enum TextureWrapMode {
  71278. /**
  71279. * Clamp to Edge
  71280. */
  71281. CLAMP_TO_EDGE = 33071,
  71282. /**
  71283. * Mirrored Repeat
  71284. */
  71285. MIRRORED_REPEAT = 33648,
  71286. /**
  71287. * Repeat
  71288. */
  71289. REPEAT = 10497,
  71290. }
  71291. /**
  71292. * glTF Property
  71293. */
  71294. interface IProperty {
  71295. /**
  71296. * Dictionary object with extension-specific objects
  71297. */
  71298. extensions?: {
  71299. [key: string]: any;
  71300. };
  71301. /**
  71302. * Application-Specific data
  71303. */
  71304. extras?: any;
  71305. }
  71306. /**
  71307. * glTF Child of Root Property
  71308. */
  71309. interface IChildRootProperty extends IProperty {
  71310. /**
  71311. * The user-defined name of this object
  71312. */
  71313. name?: string;
  71314. }
  71315. /**
  71316. * Indices of those attributes that deviate from their initialization value
  71317. */
  71318. interface IAccessorSparseIndices extends IProperty {
  71319. /**
  71320. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71321. */
  71322. bufferView: number;
  71323. /**
  71324. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71325. */
  71326. byteOffset?: number;
  71327. /**
  71328. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  71329. */
  71330. componentType: AccessorComponentType;
  71331. }
  71332. /**
  71333. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  71334. */
  71335. interface IAccessorSparseValues extends IProperty {
  71336. /**
  71337. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71338. */
  71339. bufferView: number;
  71340. /**
  71341. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71342. */
  71343. byteOffset?: number;
  71344. }
  71345. /**
  71346. * Sparse storage of attributes that deviate from their initialization value
  71347. */
  71348. interface IAccessorSparse extends IProperty {
  71349. /**
  71350. * The number of attributes encoded in this sparse accessor
  71351. */
  71352. count: number;
  71353. /**
  71354. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  71355. */
  71356. indices: IAccessorSparseIndices;
  71357. /**
  71358. * 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
  71359. */
  71360. values: IAccessorSparseValues;
  71361. }
  71362. /**
  71363. * 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
  71364. */
  71365. interface IAccessor extends IChildRootProperty {
  71366. /**
  71367. * The index of the bufferview
  71368. */
  71369. bufferView?: number;
  71370. /**
  71371. * The offset relative to the start of the bufferView in bytes
  71372. */
  71373. byteOffset?: number;
  71374. /**
  71375. * The datatype of components in the attribute
  71376. */
  71377. componentType: AccessorComponentType;
  71378. /**
  71379. * Specifies whether integer data values should be normalized
  71380. */
  71381. normalized?: boolean;
  71382. /**
  71383. * The number of attributes referenced by this accessor
  71384. */
  71385. count: number;
  71386. /**
  71387. * Specifies if the attribute is a scalar, vector, or matrix
  71388. */
  71389. type: AccessorType;
  71390. /**
  71391. * Maximum value of each component in this attribute
  71392. */
  71393. max?: number[];
  71394. /**
  71395. * Minimum value of each component in this attribute
  71396. */
  71397. min?: number[];
  71398. /**
  71399. * Sparse storage of attributes that deviate from their initialization value
  71400. */
  71401. sparse?: IAccessorSparse;
  71402. }
  71403. /**
  71404. * Targets an animation's sampler at a node's property
  71405. */
  71406. interface IAnimationChannel extends IProperty {
  71407. /**
  71408. * The index of a sampler in this animation used to compute the value for the target
  71409. */
  71410. sampler: number;
  71411. /**
  71412. * The index of the node and TRS property to target
  71413. */
  71414. target: IAnimationChannelTarget;
  71415. }
  71416. /**
  71417. * The index of the node and TRS property that an animation channel targets
  71418. */
  71419. interface IAnimationChannelTarget extends IProperty {
  71420. /**
  71421. * The index of the node to target
  71422. */
  71423. node: number;
  71424. /**
  71425. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71426. */
  71427. path: AnimationChannelTargetPath;
  71428. }
  71429. /**
  71430. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71431. */
  71432. interface IAnimationSampler extends IProperty {
  71433. /**
  71434. * The index of an accessor containing keyframe input values, e.g., time
  71435. */
  71436. input: number;
  71437. /**
  71438. * Interpolation algorithm
  71439. */
  71440. interpolation?: AnimationSamplerInterpolation;
  71441. /**
  71442. * The index of an accessor, containing keyframe output values
  71443. */
  71444. output: number;
  71445. }
  71446. /**
  71447. * A keyframe animation
  71448. */
  71449. interface IAnimation extends IChildRootProperty {
  71450. /**
  71451. * An array of channels, each of which targets an animation's sampler at a node's property
  71452. */
  71453. channels: IAnimationChannel[];
  71454. /**
  71455. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71456. */
  71457. samplers: IAnimationSampler[];
  71458. }
  71459. /**
  71460. * Metadata about the glTF asset
  71461. */
  71462. interface IAsset extends IChildRootProperty {
  71463. /**
  71464. * A copyright message suitable for display to credit the content creator
  71465. */
  71466. copyright?: string;
  71467. /**
  71468. * Tool that generated this glTF model. Useful for debugging
  71469. */
  71470. generator?: string;
  71471. /**
  71472. * The glTF version that this asset targets
  71473. */
  71474. version: string;
  71475. /**
  71476. * The minimum glTF version that this asset targets
  71477. */
  71478. minVersion?: string;
  71479. }
  71480. /**
  71481. * A buffer points to binary geometry, animation, or skins
  71482. */
  71483. interface IBuffer extends IChildRootProperty {
  71484. /**
  71485. * 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
  71486. */
  71487. uri?: string;
  71488. /**
  71489. * The length of the buffer in bytes
  71490. */
  71491. byteLength: number;
  71492. }
  71493. /**
  71494. * A view into a buffer generally representing a subset of the buffer
  71495. */
  71496. interface IBufferView extends IChildRootProperty {
  71497. /**
  71498. * The index of the buffer
  71499. */
  71500. buffer: number;
  71501. /**
  71502. * The offset into the buffer in bytes
  71503. */
  71504. byteOffset?: number;
  71505. /**
  71506. * The lenth of the bufferView in bytes
  71507. */
  71508. byteLength: number;
  71509. /**
  71510. * The stride, in bytes
  71511. */
  71512. byteStride?: number;
  71513. }
  71514. /**
  71515. * An orthographic camera containing properties to create an orthographic projection matrix
  71516. */
  71517. interface ICameraOrthographic extends IProperty {
  71518. /**
  71519. * The floating-point horizontal magnification of the view. Must not be zero
  71520. */
  71521. xmag: number;
  71522. /**
  71523. * The floating-point vertical magnification of the view. Must not be zero
  71524. */
  71525. ymag: number;
  71526. /**
  71527. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  71528. */
  71529. zfar: number;
  71530. /**
  71531. * The floating-point distance to the near clipping plane
  71532. */
  71533. znear: number;
  71534. }
  71535. /**
  71536. * A perspective camera containing properties to create a perspective projection matrix
  71537. */
  71538. interface ICameraPerspective extends IProperty {
  71539. /**
  71540. * The floating-point aspect ratio of the field of view
  71541. */
  71542. aspectRatio?: number;
  71543. /**
  71544. * The floating-point vertical field of view in radians
  71545. */
  71546. yfov: number;
  71547. /**
  71548. * The floating-point distance to the far clipping plane
  71549. */
  71550. zfar?: number;
  71551. /**
  71552. * The floating-point distance to the near clipping plane
  71553. */
  71554. znear: number;
  71555. }
  71556. /**
  71557. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71558. */
  71559. interface ICamera extends IChildRootProperty {
  71560. /**
  71561. * An orthographic camera containing properties to create an orthographic projection matrix
  71562. */
  71563. orthographic?: ICameraOrthographic;
  71564. /**
  71565. * A perspective camera containing properties to create a perspective projection matrix
  71566. */
  71567. perspective?: ICameraPerspective;
  71568. /**
  71569. * Specifies if the camera uses a perspective or orthographic projection
  71570. */
  71571. type: CameraType;
  71572. }
  71573. /**
  71574. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  71575. */
  71576. interface IImage extends IChildRootProperty {
  71577. /**
  71578. * 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
  71579. */
  71580. uri?: string;
  71581. /**
  71582. * The image's MIME type
  71583. */
  71584. mimeType?: ImageMimeType;
  71585. /**
  71586. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  71587. */
  71588. bufferView?: number;
  71589. }
  71590. /**
  71591. * Material Normal Texture Info
  71592. */
  71593. interface IMaterialNormalTextureInfo extends ITextureInfo {
  71594. /**
  71595. * The scalar multiplier applied to each normal vector of the normal texture
  71596. */
  71597. scale?: number;
  71598. }
  71599. /**
  71600. * Material Occlusion Texture Info
  71601. */
  71602. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  71603. /**
  71604. * A scalar multiplier controlling the amount of occlusion applied
  71605. */
  71606. strength?: number;
  71607. }
  71608. /**
  71609. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  71610. */
  71611. interface IMaterialPbrMetallicRoughness {
  71612. /**
  71613. * The material's base color factor
  71614. */
  71615. baseColorFactor?: number[];
  71616. /**
  71617. * The base color texture
  71618. */
  71619. baseColorTexture?: ITextureInfo;
  71620. /**
  71621. * The metalness of the material
  71622. */
  71623. metallicFactor?: number;
  71624. /**
  71625. * The roughness of the material
  71626. */
  71627. roughnessFactor?: number;
  71628. /**
  71629. * The metallic-roughness texture
  71630. */
  71631. metallicRoughnessTexture?: ITextureInfo;
  71632. }
  71633. /**
  71634. * The material appearance of a primitive
  71635. */
  71636. interface IMaterial extends IChildRootProperty {
  71637. /**
  71638. * 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
  71639. */
  71640. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71641. /**
  71642. * The normal map texture
  71643. */
  71644. normalTexture?: IMaterialNormalTextureInfo;
  71645. /**
  71646. * The occlusion map texture
  71647. */
  71648. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71649. /**
  71650. * The emissive map texture
  71651. */
  71652. emissiveTexture?: ITextureInfo;
  71653. /**
  71654. * 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
  71655. */
  71656. emissiveFactor?: number[];
  71657. /**
  71658. * The alpha rendering mode of the material
  71659. */
  71660. alphaMode?: MaterialAlphaMode;
  71661. /**
  71662. * The alpha cutoff value of the material
  71663. */
  71664. alphaCutoff?: number;
  71665. /**
  71666. * Specifies whether the material is double sided
  71667. */
  71668. doubleSided?: boolean;
  71669. }
  71670. /**
  71671. * Geometry to be rendered with the given material
  71672. */
  71673. interface IMeshPrimitive extends IProperty {
  71674. /**
  71675. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  71676. */
  71677. attributes: {
  71678. [name: string]: number;
  71679. };
  71680. /**
  71681. * The index of the accessor that contains the indices
  71682. */
  71683. indices?: number;
  71684. /**
  71685. * The index of the material to apply to this primitive when rendering
  71686. */
  71687. material?: number;
  71688. /**
  71689. * The type of primitives to render. All valid values correspond to WebGL enums
  71690. */
  71691. mode?: MeshPrimitiveMode;
  71692. /**
  71693. * 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
  71694. */
  71695. targets?: {
  71696. [name: string]: number;
  71697. }[];
  71698. }
  71699. /**
  71700. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71701. */
  71702. interface IMesh extends IChildRootProperty {
  71703. /**
  71704. * An array of primitives, each defining geometry to be rendered with a material
  71705. */
  71706. primitives: IMeshPrimitive[];
  71707. /**
  71708. * Array of weights to be applied to the Morph Targets
  71709. */
  71710. weights?: number[];
  71711. }
  71712. /**
  71713. * A node in the node hierarchy
  71714. */
  71715. interface INode extends IChildRootProperty {
  71716. /**
  71717. * The index of the camera referenced by this node
  71718. */
  71719. camera?: number;
  71720. /**
  71721. * The indices of this node's children
  71722. */
  71723. children?: number[];
  71724. /**
  71725. * The index of the skin referenced by this node
  71726. */
  71727. skin?: number;
  71728. /**
  71729. * A floating-point 4x4 transformation matrix stored in column-major order
  71730. */
  71731. matrix?: number[];
  71732. /**
  71733. * The index of the mesh in this node
  71734. */
  71735. mesh?: number;
  71736. /**
  71737. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  71738. */
  71739. rotation?: number[];
  71740. /**
  71741. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  71742. */
  71743. scale?: number[];
  71744. /**
  71745. * The node's translation along the x, y, and z axes
  71746. */
  71747. translation?: number[];
  71748. /**
  71749. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  71750. */
  71751. weights?: number[];
  71752. }
  71753. /**
  71754. * Texture sampler properties for filtering and wrapping modes
  71755. */
  71756. interface ISampler extends IChildRootProperty {
  71757. /**
  71758. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71759. */
  71760. magFilter?: TextureMagFilter;
  71761. /**
  71762. * Minification filter. All valid values correspond to WebGL enums
  71763. */
  71764. minFilter?: TextureMinFilter;
  71765. /**
  71766. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71767. */
  71768. wrapS?: TextureWrapMode;
  71769. /**
  71770. * T (V) wrapping mode. All valid values correspond to WebGL enums
  71771. */
  71772. wrapT?: TextureWrapMode;
  71773. }
  71774. /**
  71775. * The root nodes of a scene
  71776. */
  71777. interface IScene extends IChildRootProperty {
  71778. /**
  71779. * The indices of each root node
  71780. */
  71781. nodes: number[];
  71782. }
  71783. /**
  71784. * Joints and matrices defining a skin
  71785. */
  71786. interface ISkin extends IChildRootProperty {
  71787. /**
  71788. * 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
  71789. */
  71790. inverseBindMatrices?: number;
  71791. /**
  71792. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  71793. */
  71794. skeleton?: number;
  71795. /**
  71796. * 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)
  71797. */
  71798. joints: number[];
  71799. }
  71800. /**
  71801. * A texture and its sampler
  71802. */
  71803. interface ITexture extends IChildRootProperty {
  71804. /**
  71805. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  71806. */
  71807. sampler?: number;
  71808. /**
  71809. * The index of the image used by this texture
  71810. */
  71811. source: number;
  71812. }
  71813. /**
  71814. * Reference to a texture
  71815. */
  71816. interface ITextureInfo extends IProperty {
  71817. /**
  71818. * The index of the texture
  71819. */
  71820. index: number;
  71821. /**
  71822. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  71823. */
  71824. texCoord?: number;
  71825. }
  71826. /**
  71827. * The root object for a glTF asset
  71828. */
  71829. interface IGLTF extends IProperty {
  71830. /**
  71831. * An array of accessors. An accessor is a typed view into a bufferView
  71832. */
  71833. accessors?: IAccessor[];
  71834. /**
  71835. * An array of keyframe animations
  71836. */
  71837. animations?: IAnimation[];
  71838. /**
  71839. * Metadata about the glTF asset
  71840. */
  71841. asset: IAsset;
  71842. /**
  71843. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71844. */
  71845. buffers?: IBuffer[];
  71846. /**
  71847. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71848. */
  71849. bufferViews?: IBufferView[];
  71850. /**
  71851. * An array of cameras
  71852. */
  71853. cameras?: ICamera[];
  71854. /**
  71855. * Names of glTF extensions used somewhere in this asset
  71856. */
  71857. extensionsUsed?: string[];
  71858. /**
  71859. * Names of glTF extensions required to properly load this asset
  71860. */
  71861. extensionsRequired?: string[];
  71862. /**
  71863. * An array of images. An image defines data used to create a texture
  71864. */
  71865. images?: IImage[];
  71866. /**
  71867. * An array of materials. A material defines the appearance of a primitive
  71868. */
  71869. materials?: IMaterial[];
  71870. /**
  71871. * An array of meshes. A mesh is a set of primitives to be rendered
  71872. */
  71873. meshes?: IMesh[];
  71874. /**
  71875. * An array of nodes
  71876. */
  71877. nodes?: INode[];
  71878. /**
  71879. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71880. */
  71881. samplers?: ISampler[];
  71882. /**
  71883. * The index of the default scene
  71884. */
  71885. scene?: number;
  71886. /**
  71887. * An array of scenes
  71888. */
  71889. scenes?: IScene[];
  71890. /**
  71891. * An array of skins. A skin is defined by joints and matrices
  71892. */
  71893. skins?: ISkin[];
  71894. /**
  71895. * An array of textures
  71896. */
  71897. textures?: ITexture[];
  71898. }
  71899. /**
  71900. * The glTF validation results
  71901. * @ignore
  71902. */
  71903. interface IGLTFValidationResults {
  71904. info: {
  71905. generator: string;
  71906. hasAnimations: boolean;
  71907. hasDefaultScene: boolean;
  71908. hasMaterials: boolean;
  71909. hasMorphTargets: boolean;
  71910. hasSkins: boolean;
  71911. hasTextures: boolean;
  71912. maxAttributesUsed: number;
  71913. primitivesCount: number
  71914. };
  71915. issues: {
  71916. messages: Array<string>;
  71917. numErrors: number;
  71918. numHints: number;
  71919. numInfos: number;
  71920. numWarnings: number;
  71921. truncated: boolean
  71922. };
  71923. mimeType: string;
  71924. uri: string;
  71925. validatedAt: string;
  71926. validatorVersion: string;
  71927. }
  71928. /**
  71929. * The glTF validation options
  71930. */
  71931. interface IGLTFValidationOptions {
  71932. /** Uri to use */
  71933. uri?: string;
  71934. /** Function used to load external resources */
  71935. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71936. /** Boolean indicating that we need to validate accessor data */
  71937. validateAccessorData?: boolean;
  71938. /** max number of issues allowed */
  71939. maxIssues?: number;
  71940. /** Ignored issues */
  71941. ignoredIssues?: Array<string>;
  71942. /** Value to override severy settings */
  71943. severityOverrides?: Object;
  71944. }
  71945. /**
  71946. * The glTF validator object
  71947. * @ignore
  71948. */
  71949. interface IGLTFValidator {
  71950. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71951. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71952. }
  71953. }
  71954. declare module BABYLON {
  71955. /** @hidden */
  71956. export var cellPixelShader: {
  71957. name: string;
  71958. shader: string;
  71959. };
  71960. }
  71961. declare module BABYLON {
  71962. /** @hidden */
  71963. export var cellVertexShader: {
  71964. name: string;
  71965. shader: string;
  71966. };
  71967. }
  71968. declare module BABYLON {
  71969. export class CellMaterial extends BABYLON.PushMaterial {
  71970. private _diffuseTexture;
  71971. diffuseTexture: BABYLON.BaseTexture;
  71972. diffuseColor: BABYLON.Color3;
  71973. _computeHighLevel: boolean;
  71974. computeHighLevel: boolean;
  71975. private _disableLighting;
  71976. disableLighting: boolean;
  71977. private _maxSimultaneousLights;
  71978. maxSimultaneousLights: number;
  71979. private _renderId;
  71980. constructor(name: string, scene: BABYLON.Scene);
  71981. needAlphaBlending(): boolean;
  71982. needAlphaTesting(): boolean;
  71983. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71984. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71985. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71986. getAnimatables(): BABYLON.IAnimatable[];
  71987. getActiveTextures(): BABYLON.BaseTexture[];
  71988. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71989. dispose(forceDisposeEffect?: boolean): void;
  71990. getClassName(): string;
  71991. clone(name: string): CellMaterial;
  71992. serialize(): any;
  71993. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71994. }
  71995. }
  71996. declare module BABYLON {
  71997. export class CustomShaderStructure {
  71998. FragmentStore: string;
  71999. VertexStore: string;
  72000. constructor();
  72001. }
  72002. export class ShaderSpecialParts {
  72003. constructor();
  72004. Fragment_Begin: string;
  72005. Fragment_Definitions: string;
  72006. Fragment_MainBegin: string;
  72007. Fragment_Custom_Diffuse: string;
  72008. Fragment_Before_Lights: string;
  72009. Fragment_Before_Fog: string;
  72010. Fragment_Custom_Alpha: string;
  72011. Fragment_Before_FragColor: string;
  72012. Vertex_Begin: string;
  72013. Vertex_Definitions: string;
  72014. Vertex_MainBegin: string;
  72015. Vertex_Before_PositionUpdated: string;
  72016. Vertex_Before_NormalUpdated: string;
  72017. Vertex_MainEnd: string;
  72018. }
  72019. export class CustomMaterial extends BABYLON.StandardMaterial {
  72020. static ShaderIndexer: number;
  72021. CustomParts: ShaderSpecialParts;
  72022. _isCreatedShader: boolean;
  72023. _createdShaderName: string;
  72024. _customUniform: string[];
  72025. _newUniforms: string[];
  72026. _newUniformInstances: any[];
  72027. _newSamplerInstances: BABYLON.Texture[];
  72028. FragmentShader: string;
  72029. VertexShader: string;
  72030. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72031. ReviewUniform(name: string, arr: string[]): string[];
  72032. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  72033. constructor(name: string, scene: BABYLON.Scene);
  72034. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  72035. Fragment_Begin(shaderPart: string): CustomMaterial;
  72036. Fragment_Definitions(shaderPart: string): CustomMaterial;
  72037. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  72038. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  72039. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  72040. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  72041. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  72042. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  72043. Vertex_Begin(shaderPart: string): CustomMaterial;
  72044. Vertex_Definitions(shaderPart: string): CustomMaterial;
  72045. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  72046. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  72047. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  72048. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  72049. }
  72050. }
  72051. declare module BABYLON {
  72052. export class ShaderAlebdoParts {
  72053. constructor();
  72054. Fragment_Begin: string;
  72055. Fragment_Definitions: string;
  72056. Fragment_MainBegin: string;
  72057. Fragment_Custom_Albedo: string;
  72058. Fragment_Before_Lights: string;
  72059. Fragment_Custom_MetallicRoughness: string;
  72060. Fragment_Custom_MicroSurface: string;
  72061. Fragment_Before_Fog: string;
  72062. Fragment_Custom_Alpha: string;
  72063. Fragment_Before_FragColor: string;
  72064. Vertex_Begin: string;
  72065. Vertex_Definitions: string;
  72066. Vertex_MainBegin: string;
  72067. Vertex_Before_PositionUpdated: string;
  72068. Vertex_Before_NormalUpdated: string;
  72069. Vertex_MainEnd: string;
  72070. }
  72071. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  72072. static ShaderIndexer: number;
  72073. CustomParts: ShaderAlebdoParts;
  72074. _isCreatedShader: boolean;
  72075. _createdShaderName: string;
  72076. _customUniform: string[];
  72077. _newUniforms: string[];
  72078. _newUniformInstances: any[];
  72079. _newSamplerInstances: BABYLON.Texture[];
  72080. FragmentShader: string;
  72081. VertexShader: string;
  72082. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72083. ReviewUniform(name: string, arr: string[]): string[];
  72084. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  72085. constructor(name: string, scene: BABYLON.Scene);
  72086. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  72087. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  72088. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  72089. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  72090. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  72091. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  72092. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  72093. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  72094. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  72095. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  72096. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  72097. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  72098. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  72099. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  72100. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  72101. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  72102. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  72103. }
  72104. }
  72105. declare module BABYLON {
  72106. /** @hidden */
  72107. export var firePixelShader: {
  72108. name: string;
  72109. shader: string;
  72110. };
  72111. }
  72112. declare module BABYLON {
  72113. /** @hidden */
  72114. export var fireVertexShader: {
  72115. name: string;
  72116. shader: string;
  72117. };
  72118. }
  72119. declare module BABYLON {
  72120. export class FireMaterial extends BABYLON.PushMaterial {
  72121. private _diffuseTexture;
  72122. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72123. private _distortionTexture;
  72124. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72125. private _opacityTexture;
  72126. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72127. diffuseColor: BABYLON.Color3;
  72128. speed: number;
  72129. private _scaledDiffuse;
  72130. private _renderId;
  72131. private _lastTime;
  72132. constructor(name: string, scene: BABYLON.Scene);
  72133. needAlphaBlending(): boolean;
  72134. needAlphaTesting(): boolean;
  72135. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72136. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72137. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72138. getAnimatables(): BABYLON.IAnimatable[];
  72139. getActiveTextures(): BABYLON.BaseTexture[];
  72140. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72141. getClassName(): string;
  72142. dispose(forceDisposeEffect?: boolean): void;
  72143. clone(name: string): FireMaterial;
  72144. serialize(): any;
  72145. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  72146. }
  72147. }
  72148. declare module BABYLON {
  72149. /** @hidden */
  72150. export var furPixelShader: {
  72151. name: string;
  72152. shader: string;
  72153. };
  72154. }
  72155. declare module BABYLON {
  72156. /** @hidden */
  72157. export var furVertexShader: {
  72158. name: string;
  72159. shader: string;
  72160. };
  72161. }
  72162. declare module BABYLON {
  72163. export class FurMaterial extends BABYLON.PushMaterial {
  72164. private _diffuseTexture;
  72165. diffuseTexture: BABYLON.BaseTexture;
  72166. private _heightTexture;
  72167. heightTexture: BABYLON.BaseTexture;
  72168. diffuseColor: BABYLON.Color3;
  72169. furLength: number;
  72170. furAngle: number;
  72171. furColor: BABYLON.Color3;
  72172. furOffset: number;
  72173. furSpacing: number;
  72174. furGravity: BABYLON.Vector3;
  72175. furSpeed: number;
  72176. furDensity: number;
  72177. furOcclusion: number;
  72178. furTexture: BABYLON.DynamicTexture;
  72179. private _disableLighting;
  72180. disableLighting: boolean;
  72181. private _maxSimultaneousLights;
  72182. maxSimultaneousLights: number;
  72183. highLevelFur: boolean;
  72184. _meshes: BABYLON.AbstractMesh[];
  72185. private _renderId;
  72186. private _furTime;
  72187. constructor(name: string, scene: BABYLON.Scene);
  72188. furTime: number;
  72189. needAlphaBlending(): boolean;
  72190. needAlphaTesting(): boolean;
  72191. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72192. updateFur(): void;
  72193. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72194. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72195. getAnimatables(): BABYLON.IAnimatable[];
  72196. getActiveTextures(): BABYLON.BaseTexture[];
  72197. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72198. dispose(forceDisposeEffect?: boolean): void;
  72199. clone(name: string): FurMaterial;
  72200. serialize(): any;
  72201. getClassName(): string;
  72202. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  72203. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  72204. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  72205. }
  72206. }
  72207. declare module BABYLON {
  72208. /** @hidden */
  72209. export var gradientPixelShader: {
  72210. name: string;
  72211. shader: string;
  72212. };
  72213. }
  72214. declare module BABYLON {
  72215. /** @hidden */
  72216. export var gradientVertexShader: {
  72217. name: string;
  72218. shader: string;
  72219. };
  72220. }
  72221. declare module BABYLON {
  72222. export class GradientMaterial extends BABYLON.PushMaterial {
  72223. private _maxSimultaneousLights;
  72224. maxSimultaneousLights: number;
  72225. topColor: BABYLON.Color3;
  72226. topColorAlpha: number;
  72227. bottomColor: BABYLON.Color3;
  72228. bottomColorAlpha: number;
  72229. offset: number;
  72230. scale: number;
  72231. smoothness: number;
  72232. private _disableLighting;
  72233. disableLighting: boolean;
  72234. private _renderId;
  72235. constructor(name: string, scene: BABYLON.Scene);
  72236. needAlphaBlending(): boolean;
  72237. needAlphaTesting(): boolean;
  72238. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72239. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72240. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72241. getAnimatables(): BABYLON.IAnimatable[];
  72242. dispose(forceDisposeEffect?: boolean): void;
  72243. clone(name: string): GradientMaterial;
  72244. serialize(): any;
  72245. getClassName(): string;
  72246. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  72247. }
  72248. }
  72249. declare module BABYLON {
  72250. /** @hidden */
  72251. export var gridPixelShader: {
  72252. name: string;
  72253. shader: string;
  72254. };
  72255. }
  72256. declare module BABYLON {
  72257. /** @hidden */
  72258. export var gridVertexShader: {
  72259. name: string;
  72260. shader: string;
  72261. };
  72262. }
  72263. declare module BABYLON {
  72264. /**
  72265. * The grid materials allows you to wrap any shape with a grid.
  72266. * Colors are customizable.
  72267. */
  72268. export class GridMaterial extends BABYLON.PushMaterial {
  72269. /**
  72270. * Main color of the grid (e.g. between lines)
  72271. */
  72272. mainColor: BABYLON.Color3;
  72273. /**
  72274. * Color of the grid lines.
  72275. */
  72276. lineColor: BABYLON.Color3;
  72277. /**
  72278. * The scale of the grid compared to unit.
  72279. */
  72280. gridRatio: number;
  72281. /**
  72282. * Allows setting an offset for the grid lines.
  72283. */
  72284. gridOffset: BABYLON.Vector3;
  72285. /**
  72286. * The frequency of thicker lines.
  72287. */
  72288. majorUnitFrequency: number;
  72289. /**
  72290. * The visibility of minor units in the grid.
  72291. */
  72292. minorUnitVisibility: number;
  72293. /**
  72294. * The grid opacity outside of the lines.
  72295. */
  72296. opacity: number;
  72297. /**
  72298. * Determine RBG output is premultiplied by alpha value.
  72299. */
  72300. preMultiplyAlpha: boolean;
  72301. private _opacityTexture;
  72302. opacityTexture: BABYLON.BaseTexture;
  72303. private _gridControl;
  72304. private _renderId;
  72305. /**
  72306. * constructor
  72307. * @param name The name given to the material in order to identify it afterwards.
  72308. * @param scene The scene the material is used in.
  72309. */
  72310. constructor(name: string, scene: BABYLON.Scene);
  72311. /**
  72312. * Returns wehter or not the grid requires alpha blending.
  72313. */
  72314. needAlphaBlending(): boolean;
  72315. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72316. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72317. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72318. /**
  72319. * Dispose the material and its associated resources.
  72320. * @param forceDisposeEffect will also dispose the used effect when true
  72321. */
  72322. dispose(forceDisposeEffect?: boolean): void;
  72323. clone(name: string): GridMaterial;
  72324. serialize(): any;
  72325. getClassName(): string;
  72326. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  72327. }
  72328. }
  72329. declare module BABYLON {
  72330. /** @hidden */
  72331. export var lavaPixelShader: {
  72332. name: string;
  72333. shader: string;
  72334. };
  72335. }
  72336. declare module BABYLON {
  72337. /** @hidden */
  72338. export var lavaVertexShader: {
  72339. name: string;
  72340. shader: string;
  72341. };
  72342. }
  72343. declare module BABYLON {
  72344. export class LavaMaterial extends BABYLON.PushMaterial {
  72345. private _diffuseTexture;
  72346. diffuseTexture: BABYLON.BaseTexture;
  72347. noiseTexture: BABYLON.BaseTexture;
  72348. fogColor: BABYLON.Color3;
  72349. speed: number;
  72350. movingSpeed: number;
  72351. lowFrequencySpeed: number;
  72352. fogDensity: number;
  72353. private _lastTime;
  72354. diffuseColor: BABYLON.Color3;
  72355. private _disableLighting;
  72356. disableLighting: boolean;
  72357. private _unlit;
  72358. unlit: boolean;
  72359. private _maxSimultaneousLights;
  72360. maxSimultaneousLights: number;
  72361. private _scaledDiffuse;
  72362. private _renderId;
  72363. constructor(name: string, scene: BABYLON.Scene);
  72364. needAlphaBlending(): boolean;
  72365. needAlphaTesting(): boolean;
  72366. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72367. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72368. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72369. getAnimatables(): BABYLON.IAnimatable[];
  72370. getActiveTextures(): BABYLON.BaseTexture[];
  72371. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72372. dispose(forceDisposeEffect?: boolean): void;
  72373. clone(name: string): LavaMaterial;
  72374. serialize(): any;
  72375. getClassName(): string;
  72376. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  72377. }
  72378. }
  72379. declare module BABYLON {
  72380. /** @hidden */
  72381. export var mixPixelShader: {
  72382. name: string;
  72383. shader: string;
  72384. };
  72385. }
  72386. declare module BABYLON {
  72387. /** @hidden */
  72388. export var mixVertexShader: {
  72389. name: string;
  72390. shader: string;
  72391. };
  72392. }
  72393. declare module BABYLON {
  72394. export class MixMaterial extends BABYLON.PushMaterial {
  72395. /**
  72396. * Mix textures
  72397. */
  72398. private _mixTexture1;
  72399. mixTexture1: BABYLON.BaseTexture;
  72400. private _mixTexture2;
  72401. mixTexture2: BABYLON.BaseTexture;
  72402. /**
  72403. * Diffuse textures
  72404. */
  72405. private _diffuseTexture1;
  72406. diffuseTexture1: BABYLON.Texture;
  72407. private _diffuseTexture2;
  72408. diffuseTexture2: BABYLON.Texture;
  72409. private _diffuseTexture3;
  72410. diffuseTexture3: BABYLON.Texture;
  72411. private _diffuseTexture4;
  72412. diffuseTexture4: BABYLON.Texture;
  72413. private _diffuseTexture5;
  72414. diffuseTexture5: BABYLON.Texture;
  72415. private _diffuseTexture6;
  72416. diffuseTexture6: BABYLON.Texture;
  72417. private _diffuseTexture7;
  72418. diffuseTexture7: BABYLON.Texture;
  72419. private _diffuseTexture8;
  72420. diffuseTexture8: BABYLON.Texture;
  72421. /**
  72422. * Uniforms
  72423. */
  72424. diffuseColor: BABYLON.Color3;
  72425. specularColor: BABYLON.Color3;
  72426. specularPower: number;
  72427. private _disableLighting;
  72428. disableLighting: boolean;
  72429. private _maxSimultaneousLights;
  72430. maxSimultaneousLights: number;
  72431. private _renderId;
  72432. constructor(name: string, scene: BABYLON.Scene);
  72433. needAlphaBlending(): boolean;
  72434. needAlphaTesting(): boolean;
  72435. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72436. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72437. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72438. getAnimatables(): BABYLON.IAnimatable[];
  72439. getActiveTextures(): BABYLON.BaseTexture[];
  72440. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72441. dispose(forceDisposeEffect?: boolean): void;
  72442. clone(name: string): MixMaterial;
  72443. serialize(): any;
  72444. getClassName(): string;
  72445. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  72446. }
  72447. }
  72448. declare module BABYLON {
  72449. /** @hidden */
  72450. export var normalPixelShader: {
  72451. name: string;
  72452. shader: string;
  72453. };
  72454. }
  72455. declare module BABYLON {
  72456. /** @hidden */
  72457. export var normalVertexShader: {
  72458. name: string;
  72459. shader: string;
  72460. };
  72461. }
  72462. declare module BABYLON {
  72463. export class NormalMaterial extends BABYLON.PushMaterial {
  72464. private _diffuseTexture;
  72465. diffuseTexture: BABYLON.BaseTexture;
  72466. diffuseColor: BABYLON.Color3;
  72467. private _disableLighting;
  72468. disableLighting: boolean;
  72469. private _maxSimultaneousLights;
  72470. maxSimultaneousLights: number;
  72471. private _renderId;
  72472. constructor(name: string, scene: BABYLON.Scene);
  72473. needAlphaBlending(): boolean;
  72474. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72475. needAlphaTesting(): boolean;
  72476. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72477. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72478. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72479. getAnimatables(): BABYLON.IAnimatable[];
  72480. getActiveTextures(): BABYLON.BaseTexture[];
  72481. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72482. dispose(forceDisposeEffect?: boolean): void;
  72483. clone(name: string): NormalMaterial;
  72484. serialize(): any;
  72485. getClassName(): string;
  72486. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  72487. }
  72488. }
  72489. declare module BABYLON {
  72490. /** @hidden */
  72491. export var shadowOnlyPixelShader: {
  72492. name: string;
  72493. shader: string;
  72494. };
  72495. }
  72496. declare module BABYLON {
  72497. /** @hidden */
  72498. export var shadowOnlyVertexShader: {
  72499. name: string;
  72500. shader: string;
  72501. };
  72502. }
  72503. declare module BABYLON {
  72504. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  72505. private _renderId;
  72506. private _activeLight;
  72507. constructor(name: string, scene: BABYLON.Scene);
  72508. shadowColor: BABYLON.Color3;
  72509. needAlphaBlending(): boolean;
  72510. needAlphaTesting(): boolean;
  72511. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72512. activeLight: BABYLON.IShadowLight;
  72513. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72514. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72515. clone(name: string): ShadowOnlyMaterial;
  72516. serialize(): any;
  72517. getClassName(): string;
  72518. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  72519. }
  72520. }
  72521. declare module BABYLON {
  72522. /** @hidden */
  72523. export var simplePixelShader: {
  72524. name: string;
  72525. shader: string;
  72526. };
  72527. }
  72528. declare module BABYLON {
  72529. /** @hidden */
  72530. export var simpleVertexShader: {
  72531. name: string;
  72532. shader: string;
  72533. };
  72534. }
  72535. declare module BABYLON {
  72536. export class SimpleMaterial extends BABYLON.PushMaterial {
  72537. private _diffuseTexture;
  72538. diffuseTexture: BABYLON.BaseTexture;
  72539. diffuseColor: BABYLON.Color3;
  72540. private _disableLighting;
  72541. disableLighting: boolean;
  72542. private _maxSimultaneousLights;
  72543. maxSimultaneousLights: number;
  72544. private _renderId;
  72545. constructor(name: string, scene: BABYLON.Scene);
  72546. needAlphaBlending(): boolean;
  72547. needAlphaTesting(): boolean;
  72548. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72549. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72550. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72551. getAnimatables(): BABYLON.IAnimatable[];
  72552. getActiveTextures(): BABYLON.BaseTexture[];
  72553. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72554. dispose(forceDisposeEffect?: boolean): void;
  72555. clone(name: string): SimpleMaterial;
  72556. serialize(): any;
  72557. getClassName(): string;
  72558. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  72559. }
  72560. }
  72561. declare module BABYLON {
  72562. /** @hidden */
  72563. export var skyPixelShader: {
  72564. name: string;
  72565. shader: string;
  72566. };
  72567. }
  72568. declare module BABYLON {
  72569. /** @hidden */
  72570. export var skyVertexShader: {
  72571. name: string;
  72572. shader: string;
  72573. };
  72574. }
  72575. declare module BABYLON {
  72576. /**
  72577. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  72578. * @see https://doc.babylonjs.com/extensions/sky
  72579. */
  72580. export class SkyMaterial extends BABYLON.PushMaterial {
  72581. /**
  72582. * Defines the overall luminance of sky in interval ]0, 1[.
  72583. */
  72584. luminance: number;
  72585. /**
  72586. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  72587. */
  72588. turbidity: number;
  72589. /**
  72590. * Defines the sky appearance (light intensity).
  72591. */
  72592. rayleigh: number;
  72593. /**
  72594. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  72595. */
  72596. mieCoefficient: number;
  72597. /**
  72598. * Defines the amount of haze particles following the Mie scattering theory.
  72599. */
  72600. mieDirectionalG: number;
  72601. /**
  72602. * Defines the distance of the sun according to the active scene camera.
  72603. */
  72604. distance: number;
  72605. /**
  72606. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  72607. * "inclined".
  72608. */
  72609. inclination: number;
  72610. /**
  72611. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  72612. * an object direction and a reference direction.
  72613. */
  72614. azimuth: number;
  72615. /**
  72616. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  72617. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  72618. */
  72619. sunPosition: BABYLON.Vector3;
  72620. /**
  72621. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  72622. * .sunPosition property.
  72623. */
  72624. useSunPosition: boolean;
  72625. /**
  72626. * Defines an offset vector used to get a horizon offset.
  72627. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  72628. */
  72629. cameraOffset: BABYLON.Vector3;
  72630. private _cameraPosition;
  72631. private _renderId;
  72632. /**
  72633. * Instantiates a new sky material.
  72634. * This material allows to create dynamic and texture free
  72635. * effects for skyboxes by taking care of the atmosphere state.
  72636. * @see https://doc.babylonjs.com/extensions/sky
  72637. * @param name Define the name of the material in the scene
  72638. * @param scene Define the scene the material belong to
  72639. */
  72640. constructor(name: string, scene: BABYLON.Scene);
  72641. /**
  72642. * Specifies if the material will require alpha blending
  72643. * @returns a boolean specifying if alpha blending is needed
  72644. */
  72645. needAlphaBlending(): boolean;
  72646. /**
  72647. * Specifies if this material should be rendered in alpha test mode
  72648. * @returns false as the sky material doesn't need alpha testing.
  72649. */
  72650. needAlphaTesting(): boolean;
  72651. /**
  72652. * Get the texture used for alpha test purpose.
  72653. * @returns null as the sky material has no texture.
  72654. */
  72655. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72656. /**
  72657. * Get if the submesh is ready to be used and all its information available.
  72658. * Child classes can use it to update shaders
  72659. * @param mesh defines the mesh to check
  72660. * @param subMesh defines which submesh to check
  72661. * @param useInstances specifies that instances should be used
  72662. * @returns a boolean indicating that the submesh is ready or not
  72663. */
  72664. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72665. /**
  72666. * Binds the submesh to this material by preparing the effect and shader to draw
  72667. * @param world defines the world transformation matrix
  72668. * @param mesh defines the mesh containing the submesh
  72669. * @param subMesh defines the submesh to bind the material to
  72670. */
  72671. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72672. /**
  72673. * Get the list of animatables in the material.
  72674. * @returns the list of animatables object used in the material
  72675. */
  72676. getAnimatables(): BABYLON.IAnimatable[];
  72677. /**
  72678. * Disposes the material
  72679. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72680. */
  72681. dispose(forceDisposeEffect?: boolean): void;
  72682. /**
  72683. * Makes a duplicate of the material, and gives it a new name
  72684. * @param name defines the new name for the duplicated material
  72685. * @returns the cloned material
  72686. */
  72687. clone(name: string): SkyMaterial;
  72688. /**
  72689. * Serializes this material in a JSON representation
  72690. * @returns the serialized material object
  72691. */
  72692. serialize(): any;
  72693. /**
  72694. * Gets the current class name of the material e.g. "SkyMaterial"
  72695. * Mainly use in serialization.
  72696. * @returns the class name
  72697. */
  72698. getClassName(): string;
  72699. /**
  72700. * Creates a sky material from parsed material data
  72701. * @param source defines the JSON representation of the material
  72702. * @param scene defines the hosting scene
  72703. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72704. * @returns a new sky material
  72705. */
  72706. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  72707. }
  72708. }
  72709. declare module BABYLON {
  72710. /** @hidden */
  72711. export var terrainPixelShader: {
  72712. name: string;
  72713. shader: string;
  72714. };
  72715. }
  72716. declare module BABYLON {
  72717. /** @hidden */
  72718. export var terrainVertexShader: {
  72719. name: string;
  72720. shader: string;
  72721. };
  72722. }
  72723. declare module BABYLON {
  72724. export class TerrainMaterial extends BABYLON.PushMaterial {
  72725. private _mixTexture;
  72726. mixTexture: BABYLON.BaseTexture;
  72727. private _diffuseTexture1;
  72728. diffuseTexture1: BABYLON.Texture;
  72729. private _diffuseTexture2;
  72730. diffuseTexture2: BABYLON.Texture;
  72731. private _diffuseTexture3;
  72732. diffuseTexture3: BABYLON.Texture;
  72733. private _bumpTexture1;
  72734. bumpTexture1: BABYLON.Texture;
  72735. private _bumpTexture2;
  72736. bumpTexture2: BABYLON.Texture;
  72737. private _bumpTexture3;
  72738. bumpTexture3: BABYLON.Texture;
  72739. diffuseColor: BABYLON.Color3;
  72740. specularColor: BABYLON.Color3;
  72741. specularPower: number;
  72742. private _disableLighting;
  72743. disableLighting: boolean;
  72744. private _maxSimultaneousLights;
  72745. maxSimultaneousLights: number;
  72746. private _renderId;
  72747. constructor(name: string, scene: BABYLON.Scene);
  72748. needAlphaBlending(): boolean;
  72749. needAlphaTesting(): boolean;
  72750. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72751. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72752. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72753. getAnimatables(): BABYLON.IAnimatable[];
  72754. getActiveTextures(): BABYLON.BaseTexture[];
  72755. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72756. dispose(forceDisposeEffect?: boolean): void;
  72757. clone(name: string): TerrainMaterial;
  72758. serialize(): any;
  72759. getClassName(): string;
  72760. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  72761. }
  72762. }
  72763. declare module BABYLON {
  72764. /** @hidden */
  72765. export var triplanarPixelShader: {
  72766. name: string;
  72767. shader: string;
  72768. };
  72769. }
  72770. declare module BABYLON {
  72771. /** @hidden */
  72772. export var triplanarVertexShader: {
  72773. name: string;
  72774. shader: string;
  72775. };
  72776. }
  72777. declare module BABYLON {
  72778. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  72779. mixTexture: BABYLON.BaseTexture;
  72780. private _diffuseTextureX;
  72781. diffuseTextureX: BABYLON.BaseTexture;
  72782. private _diffuseTextureY;
  72783. diffuseTextureY: BABYLON.BaseTexture;
  72784. private _diffuseTextureZ;
  72785. diffuseTextureZ: BABYLON.BaseTexture;
  72786. private _normalTextureX;
  72787. normalTextureX: BABYLON.BaseTexture;
  72788. private _normalTextureY;
  72789. normalTextureY: BABYLON.BaseTexture;
  72790. private _normalTextureZ;
  72791. normalTextureZ: BABYLON.BaseTexture;
  72792. tileSize: number;
  72793. diffuseColor: BABYLON.Color3;
  72794. specularColor: BABYLON.Color3;
  72795. specularPower: number;
  72796. private _disableLighting;
  72797. disableLighting: boolean;
  72798. private _maxSimultaneousLights;
  72799. maxSimultaneousLights: number;
  72800. private _renderId;
  72801. constructor(name: string, scene: BABYLON.Scene);
  72802. needAlphaBlending(): boolean;
  72803. needAlphaTesting(): boolean;
  72804. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72805. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72806. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72807. getAnimatables(): BABYLON.IAnimatable[];
  72808. getActiveTextures(): BABYLON.BaseTexture[];
  72809. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72810. dispose(forceDisposeEffect?: boolean): void;
  72811. clone(name: string): TriPlanarMaterial;
  72812. serialize(): any;
  72813. getClassName(): string;
  72814. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  72815. }
  72816. }
  72817. declare module BABYLON {
  72818. /** @hidden */
  72819. export var waterPixelShader: {
  72820. name: string;
  72821. shader: string;
  72822. };
  72823. }
  72824. declare module BABYLON {
  72825. /** @hidden */
  72826. export var waterVertexShader: {
  72827. name: string;
  72828. shader: string;
  72829. };
  72830. }
  72831. declare module BABYLON {
  72832. export class WaterMaterial extends BABYLON.PushMaterial {
  72833. renderTargetSize: BABYLON.Vector2;
  72834. private _bumpTexture;
  72835. bumpTexture: BABYLON.BaseTexture;
  72836. diffuseColor: BABYLON.Color3;
  72837. specularColor: BABYLON.Color3;
  72838. specularPower: number;
  72839. private _disableLighting;
  72840. disableLighting: boolean;
  72841. private _maxSimultaneousLights;
  72842. maxSimultaneousLights: number;
  72843. /**
  72844. * @param {number}: Represents the wind force
  72845. */
  72846. windForce: number;
  72847. /**
  72848. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72849. */
  72850. windDirection: BABYLON.Vector2;
  72851. /**
  72852. * @param {number}: Wave height, represents the height of the waves
  72853. */
  72854. waveHeight: number;
  72855. /**
  72856. * @param {number}: Bump height, represents the bump height related to the bump map
  72857. */
  72858. bumpHeight: number;
  72859. /**
  72860. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72861. */
  72862. private _bumpSuperimpose;
  72863. bumpSuperimpose: boolean;
  72864. /**
  72865. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72866. */
  72867. private _fresnelSeparate;
  72868. fresnelSeparate: boolean;
  72869. /**
  72870. * @param {boolean}: bump Waves modify the reflection.
  72871. */
  72872. private _bumpAffectsReflection;
  72873. bumpAffectsReflection: boolean;
  72874. /**
  72875. * @param {number}: The water color blended with the refraction (near)
  72876. */
  72877. waterColor: BABYLON.Color3;
  72878. /**
  72879. * @param {number}: The blend factor related to the water color
  72880. */
  72881. colorBlendFactor: number;
  72882. /**
  72883. * @param {number}: The water color blended with the reflection (far)
  72884. */
  72885. waterColor2: BABYLON.Color3;
  72886. /**
  72887. * @param {number}: The blend factor related to the water color (reflection, far)
  72888. */
  72889. colorBlendFactor2: number;
  72890. /**
  72891. * @param {number}: Represents the maximum length of a wave
  72892. */
  72893. waveLength: number;
  72894. /**
  72895. * @param {number}: Defines the waves speed
  72896. */
  72897. waveSpeed: number;
  72898. /**
  72899. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72900. * will avoid calculating useless pixels in the pixel shader of the water material.
  72901. */
  72902. disableClipPlane: boolean;
  72903. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72904. private _mesh;
  72905. private _refractionRTT;
  72906. private _reflectionRTT;
  72907. private _reflectionTransform;
  72908. private _lastTime;
  72909. private _lastDeltaTime;
  72910. private _renderId;
  72911. private _useLogarithmicDepth;
  72912. private _waitingRenderList;
  72913. private _imageProcessingConfiguration;
  72914. private _imageProcessingObserver;
  72915. /**
  72916. * Gets a boolean indicating that current material needs to register RTT
  72917. */
  72918. readonly hasRenderTargetTextures: boolean;
  72919. /**
  72920. * Constructor
  72921. */
  72922. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72923. useLogarithmicDepth: boolean;
  72924. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72925. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72926. addToRenderList(node: any): void;
  72927. enableRenderTargets(enable: boolean): void;
  72928. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72929. readonly renderTargetsEnabled: boolean;
  72930. needAlphaBlending(): boolean;
  72931. needAlphaTesting(): boolean;
  72932. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72933. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72934. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72935. private _createRenderTargets;
  72936. getAnimatables(): BABYLON.IAnimatable[];
  72937. getActiveTextures(): BABYLON.BaseTexture[];
  72938. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72939. dispose(forceDisposeEffect?: boolean): void;
  72940. clone(name: string): WaterMaterial;
  72941. serialize(): any;
  72942. getClassName(): string;
  72943. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72944. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72945. }
  72946. }
  72947. declare module BABYLON {
  72948. /** @hidden */
  72949. export var asciiartPixelShader: {
  72950. name: string;
  72951. shader: string;
  72952. };
  72953. }
  72954. declare module BABYLON {
  72955. /**
  72956. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72957. *
  72958. * It basically takes care rendering the font front the given font size to a texture.
  72959. * This is used later on in the postprocess.
  72960. */
  72961. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72962. private _font;
  72963. private _text;
  72964. private _charSize;
  72965. /**
  72966. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72967. */
  72968. readonly charSize: number;
  72969. /**
  72970. * Create a new instance of the Ascii Art FontTexture class
  72971. * @param name the name of the texture
  72972. * @param font the font to use, use the W3C CSS notation
  72973. * @param text the caracter set to use in the rendering.
  72974. * @param scene the scene that owns the texture
  72975. */
  72976. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72977. /**
  72978. * Gets the max char width of a font.
  72979. * @param font the font to use, use the W3C CSS notation
  72980. * @return the max char width
  72981. */
  72982. private getFontWidth;
  72983. /**
  72984. * Gets the max char height of a font.
  72985. * @param font the font to use, use the W3C CSS notation
  72986. * @return the max char height
  72987. */
  72988. private getFontHeight;
  72989. /**
  72990. * Clones the current AsciiArtTexture.
  72991. * @return the clone of the texture.
  72992. */
  72993. clone(): AsciiArtFontTexture;
  72994. /**
  72995. * Parses a json object representing the texture and returns an instance of it.
  72996. * @param source the source JSON representation
  72997. * @param scene the scene to create the texture for
  72998. * @return the parsed texture
  72999. */
  73000. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  73001. }
  73002. /**
  73003. * Option available in the Ascii Art Post Process.
  73004. */
  73005. export interface IAsciiArtPostProcessOptions {
  73006. /**
  73007. * The font to use following the w3c font definition.
  73008. */
  73009. font?: string;
  73010. /**
  73011. * The character set to use in the postprocess.
  73012. */
  73013. characterSet?: string;
  73014. /**
  73015. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73016. * This number is defined between 0 and 1;
  73017. */
  73018. mixToTile?: number;
  73019. /**
  73020. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73021. * This number is defined between 0 and 1;
  73022. */
  73023. mixToNormal?: number;
  73024. }
  73025. /**
  73026. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  73027. *
  73028. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73029. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  73030. */
  73031. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  73032. /**
  73033. * The font texture used to render the char in the post process.
  73034. */
  73035. private _asciiArtFontTexture;
  73036. /**
  73037. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73038. * This number is defined between 0 and 1;
  73039. */
  73040. mixToTile: number;
  73041. /**
  73042. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73043. * This number is defined between 0 and 1;
  73044. */
  73045. mixToNormal: number;
  73046. /**
  73047. * Instantiates a new Ascii Art Post Process.
  73048. * @param name the name to give to the postprocess
  73049. * @camera the camera to apply the post process to.
  73050. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  73051. */
  73052. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  73053. }
  73054. }
  73055. declare module BABYLON {
  73056. /** @hidden */
  73057. export var digitalrainPixelShader: {
  73058. name: string;
  73059. shader: string;
  73060. };
  73061. }
  73062. declare module BABYLON {
  73063. /**
  73064. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  73065. *
  73066. * It basically takes care rendering the font front the given font size to a texture.
  73067. * This is used later on in the postprocess.
  73068. */
  73069. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  73070. private _font;
  73071. private _text;
  73072. private _charSize;
  73073. /**
  73074. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73075. */
  73076. readonly charSize: number;
  73077. /**
  73078. * Create a new instance of the Digital Rain FontTexture class
  73079. * @param name the name of the texture
  73080. * @param font the font to use, use the W3C CSS notation
  73081. * @param text the caracter set to use in the rendering.
  73082. * @param scene the scene that owns the texture
  73083. */
  73084. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73085. /**
  73086. * Gets the max char width of a font.
  73087. * @param font the font to use, use the W3C CSS notation
  73088. * @return the max char width
  73089. */
  73090. private getFontWidth;
  73091. /**
  73092. * Gets the max char height of a font.
  73093. * @param font the font to use, use the W3C CSS notation
  73094. * @return the max char height
  73095. */
  73096. private getFontHeight;
  73097. /**
  73098. * Clones the current DigitalRainFontTexture.
  73099. * @return the clone of the texture.
  73100. */
  73101. clone(): DigitalRainFontTexture;
  73102. /**
  73103. * Parses a json object representing the texture and returns an instance of it.
  73104. * @param source the source JSON representation
  73105. * @param scene the scene to create the texture for
  73106. * @return the parsed texture
  73107. */
  73108. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  73109. }
  73110. /**
  73111. * Option available in the Digital Rain Post Process.
  73112. */
  73113. export interface IDigitalRainPostProcessOptions {
  73114. /**
  73115. * The font to use following the w3c font definition.
  73116. */
  73117. font?: string;
  73118. /**
  73119. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73120. * This number is defined between 0 and 1;
  73121. */
  73122. mixToTile?: number;
  73123. /**
  73124. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73125. * This number is defined between 0 and 1;
  73126. */
  73127. mixToNormal?: number;
  73128. }
  73129. /**
  73130. * DigitalRainPostProcess helps rendering everithing in digital rain.
  73131. *
  73132. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73133. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  73134. */
  73135. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  73136. /**
  73137. * The font texture used to render the char in the post process.
  73138. */
  73139. private _digitalRainFontTexture;
  73140. /**
  73141. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73142. * This number is defined between 0 and 1;
  73143. */
  73144. mixToTile: number;
  73145. /**
  73146. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73147. * This number is defined between 0 and 1;
  73148. */
  73149. mixToNormal: number;
  73150. /**
  73151. * Instantiates a new Digital Rain Post Process.
  73152. * @param name the name to give to the postprocess
  73153. * @camera the camera to apply the post process to.
  73154. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  73155. */
  73156. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  73157. }
  73158. }
  73159. declare module BABYLON {
  73160. /** @hidden */
  73161. export var oceanPostProcessPixelShader: {
  73162. name: string;
  73163. shader: string;
  73164. };
  73165. }
  73166. declare module BABYLON {
  73167. /**
  73168. * Option available in the Ocean Post Process.
  73169. */
  73170. export interface IOceanPostProcessOptions {
  73171. /**
  73172. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73173. */
  73174. reflectionSize?: number | {
  73175. width: number;
  73176. height: number;
  73177. } | {
  73178. ratio: number;
  73179. };
  73180. /**
  73181. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73182. */
  73183. refractionSize?: number | {
  73184. width: number;
  73185. height: number;
  73186. } | {
  73187. ratio: number;
  73188. };
  73189. }
  73190. /**
  73191. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  73192. *
  73193. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73194. * Example usage:
  73195. * var pp = new OceanPostProcess("myOcean", camera);
  73196. * pp.reflectionEnabled = true;
  73197. * pp.refractionEnabled = true;
  73198. */
  73199. export class OceanPostProcess extends BABYLON.PostProcess {
  73200. /**
  73201. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  73202. */
  73203. /**
  73204. * Sets weither or not the real-time reflection is enabled on the ocean.
  73205. * Is set to true, the reflection mirror texture will be used as reflection texture.
  73206. */
  73207. reflectionEnabled: boolean;
  73208. /**
  73209. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  73210. */
  73211. /**
  73212. * Sets weither or not the real-time refraction is enabled on the ocean.
  73213. * Is set to true, the refraction render target texture will be used as refraction texture.
  73214. */
  73215. refractionEnabled: boolean;
  73216. /**
  73217. * Gets wether or not the post-processes is supported by the running hardware.
  73218. * This requires draw buffer supports.
  73219. */
  73220. readonly isSupported: boolean;
  73221. /**
  73222. * This is the reflection mirror texture used to display reflections on the ocean.
  73223. * By default, render list is empty.
  73224. */
  73225. reflectionTexture: BABYLON.MirrorTexture;
  73226. /**
  73227. * This is the refraction render target texture used to display refraction on the ocean.
  73228. * By default, render list is empty.
  73229. */
  73230. refractionTexture: BABYLON.RenderTargetTexture;
  73231. private _time;
  73232. private _cameraRotation;
  73233. private _cameraViewMatrix;
  73234. private _reflectionEnabled;
  73235. private _refractionEnabled;
  73236. private _geometryRenderer;
  73237. /**
  73238. * Instantiates a new Ocean Post Process.
  73239. * @param name the name to give to the postprocess.
  73240. * @camera the camera to apply the post process to.
  73241. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  73242. */
  73243. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  73244. /**
  73245. * Returns the appropriate defines according to the current configuration.
  73246. */
  73247. private _getDefines;
  73248. /**
  73249. * Computes the current camera rotation as the shader requires a camera rotation.
  73250. */
  73251. private _computeCameraRotation;
  73252. }
  73253. }
  73254. declare module BABYLON {
  73255. /** @hidden */
  73256. export var brickProceduralTexturePixelShader: {
  73257. name: string;
  73258. shader: string;
  73259. };
  73260. }
  73261. declare module BABYLON {
  73262. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  73263. private _numberOfBricksHeight;
  73264. private _numberOfBricksWidth;
  73265. private _jointColor;
  73266. private _brickColor;
  73267. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73268. updateShaderUniforms(): void;
  73269. numberOfBricksHeight: number;
  73270. numberOfBricksWidth: number;
  73271. jointColor: BABYLON.Color3;
  73272. brickColor: BABYLON.Color3;
  73273. /**
  73274. * Serializes this brick procedural texture
  73275. * @returns a serialized brick procedural texture object
  73276. */
  73277. serialize(): any;
  73278. /**
  73279. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  73280. * @param parsedTexture defines parsed texture data
  73281. * @param scene defines the current scene
  73282. * @param rootUrl defines the root URL containing brick procedural texture information
  73283. * @returns a parsed Brick Procedural BABYLON.Texture
  73284. */
  73285. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  73286. }
  73287. }
  73288. declare module BABYLON {
  73289. /** @hidden */
  73290. export var cloudProceduralTexturePixelShader: {
  73291. name: string;
  73292. shader: string;
  73293. };
  73294. }
  73295. declare module BABYLON {
  73296. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  73297. private _skyColor;
  73298. private _cloudColor;
  73299. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73300. updateShaderUniforms(): void;
  73301. skyColor: BABYLON.Color4;
  73302. cloudColor: BABYLON.Color4;
  73303. /**
  73304. * Serializes this cloud procedural texture
  73305. * @returns a serialized cloud procedural texture object
  73306. */
  73307. serialize(): any;
  73308. /**
  73309. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  73310. * @param parsedTexture defines parsed texture data
  73311. * @param scene defines the current scene
  73312. * @param rootUrl defines the root URL containing cloud procedural texture information
  73313. * @returns a parsed Cloud Procedural BABYLON.Texture
  73314. */
  73315. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  73316. }
  73317. }
  73318. declare module BABYLON {
  73319. /** @hidden */
  73320. export var fireProceduralTexturePixelShader: {
  73321. name: string;
  73322. shader: string;
  73323. };
  73324. }
  73325. declare module BABYLON {
  73326. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  73327. private _time;
  73328. private _speed;
  73329. private _autoGenerateTime;
  73330. private _fireColors;
  73331. private _alphaThreshold;
  73332. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73333. updateShaderUniforms(): void;
  73334. render(useCameraPostProcess?: boolean): void;
  73335. static readonly PurpleFireColors: BABYLON.Color3[];
  73336. static readonly GreenFireColors: BABYLON.Color3[];
  73337. static readonly RedFireColors: BABYLON.Color3[];
  73338. static readonly BlueFireColors: BABYLON.Color3[];
  73339. autoGenerateTime: boolean;
  73340. fireColors: BABYLON.Color3[];
  73341. time: number;
  73342. speed: BABYLON.Vector2;
  73343. alphaThreshold: number;
  73344. /**
  73345. * Serializes this fire procedural texture
  73346. * @returns a serialized fire procedural texture object
  73347. */
  73348. serialize(): any;
  73349. /**
  73350. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  73351. * @param parsedTexture defines parsed texture data
  73352. * @param scene defines the current scene
  73353. * @param rootUrl defines the root URL containing fire procedural texture information
  73354. * @returns a parsed Fire Procedural BABYLON.Texture
  73355. */
  73356. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  73357. }
  73358. }
  73359. declare module BABYLON {
  73360. /** @hidden */
  73361. export var grassProceduralTexturePixelShader: {
  73362. name: string;
  73363. shader: string;
  73364. };
  73365. }
  73366. declare module BABYLON {
  73367. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  73368. private _grassColors;
  73369. private _groundColor;
  73370. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73371. updateShaderUniforms(): void;
  73372. grassColors: BABYLON.Color3[];
  73373. groundColor: BABYLON.Color3;
  73374. /**
  73375. * Serializes this grass procedural texture
  73376. * @returns a serialized grass procedural texture object
  73377. */
  73378. serialize(): any;
  73379. /**
  73380. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  73381. * @param parsedTexture defines parsed texture data
  73382. * @param scene defines the current scene
  73383. * @param rootUrl defines the root URL containing grass procedural texture information
  73384. * @returns a parsed Grass Procedural BABYLON.Texture
  73385. */
  73386. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  73387. }
  73388. }
  73389. declare module BABYLON {
  73390. /** @hidden */
  73391. export var marbleProceduralTexturePixelShader: {
  73392. name: string;
  73393. shader: string;
  73394. };
  73395. }
  73396. declare module BABYLON {
  73397. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  73398. private _numberOfTilesHeight;
  73399. private _numberOfTilesWidth;
  73400. private _amplitude;
  73401. private _jointColor;
  73402. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73403. updateShaderUniforms(): void;
  73404. numberOfTilesHeight: number;
  73405. amplitude: number;
  73406. numberOfTilesWidth: number;
  73407. jointColor: BABYLON.Color3;
  73408. /**
  73409. * Serializes this marble procedural texture
  73410. * @returns a serialized marble procedural texture object
  73411. */
  73412. serialize(): any;
  73413. /**
  73414. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  73415. * @param parsedTexture defines parsed texture data
  73416. * @param scene defines the current scene
  73417. * @param rootUrl defines the root URL containing marble procedural texture information
  73418. * @returns a parsed Marble Procedural BABYLON.Texture
  73419. */
  73420. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  73421. }
  73422. }
  73423. declare module BABYLON {
  73424. /** @hidden */
  73425. export var normalMapProceduralTexturePixelShader: {
  73426. name: string;
  73427. shader: string;
  73428. };
  73429. }
  73430. declare module BABYLON {
  73431. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  73432. private _baseTexture;
  73433. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73434. updateShaderUniforms(): void;
  73435. render(useCameraPostProcess?: boolean): void;
  73436. resize(size: any, generateMipMaps: any): void;
  73437. baseTexture: BABYLON.Texture;
  73438. /**
  73439. * Serializes this normal map procedural texture
  73440. * @returns a serialized normal map procedural texture object
  73441. */
  73442. serialize(): any;
  73443. /**
  73444. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  73445. * @param parsedTexture defines parsed texture data
  73446. * @param scene defines the current scene
  73447. * @param rootUrl defines the root URL containing normal map procedural texture information
  73448. * @returns a parsed Normal Map Procedural BABYLON.Texture
  73449. */
  73450. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  73451. }
  73452. }
  73453. declare module BABYLON {
  73454. /** @hidden */
  73455. export var perlinNoiseProceduralTexturePixelShader: {
  73456. name: string;
  73457. shader: string;
  73458. };
  73459. }
  73460. declare module BABYLON {
  73461. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  73462. time: number;
  73463. timeScale: number;
  73464. translationSpeed: number;
  73465. private _currentTranslation;
  73466. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73467. updateShaderUniforms(): void;
  73468. render(useCameraPostProcess?: boolean): void;
  73469. resize(size: any, generateMipMaps: any): void;
  73470. /**
  73471. * Serializes this perlin noise procedural texture
  73472. * @returns a serialized perlin noise procedural texture object
  73473. */
  73474. serialize(): any;
  73475. /**
  73476. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  73477. * @param parsedTexture defines parsed texture data
  73478. * @param scene defines the current scene
  73479. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  73480. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  73481. */
  73482. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  73483. }
  73484. }
  73485. declare module BABYLON {
  73486. /** @hidden */
  73487. export var roadProceduralTexturePixelShader: {
  73488. name: string;
  73489. shader: string;
  73490. };
  73491. }
  73492. declare module BABYLON {
  73493. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  73494. private _roadColor;
  73495. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73496. updateShaderUniforms(): void;
  73497. roadColor: BABYLON.Color3;
  73498. /**
  73499. * Serializes this road procedural texture
  73500. * @returns a serialized road procedural texture object
  73501. */
  73502. serialize(): any;
  73503. /**
  73504. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  73505. * @param parsedTexture defines parsed texture data
  73506. * @param scene defines the current scene
  73507. * @param rootUrl defines the root URL containing road procedural texture information
  73508. * @returns a parsed Road Procedural BABYLON.Texture
  73509. */
  73510. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  73511. }
  73512. }
  73513. declare module BABYLON {
  73514. /** @hidden */
  73515. export var starfieldProceduralTexturePixelShader: {
  73516. name: string;
  73517. shader: string;
  73518. };
  73519. }
  73520. declare module BABYLON {
  73521. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  73522. private _time;
  73523. private _alpha;
  73524. private _beta;
  73525. private _zoom;
  73526. private _formuparam;
  73527. private _stepsize;
  73528. private _tile;
  73529. private _brightness;
  73530. private _darkmatter;
  73531. private _distfading;
  73532. private _saturation;
  73533. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73534. updateShaderUniforms(): void;
  73535. time: number;
  73536. alpha: number;
  73537. beta: number;
  73538. formuparam: number;
  73539. stepsize: number;
  73540. zoom: number;
  73541. tile: number;
  73542. brightness: number;
  73543. darkmatter: number;
  73544. distfading: number;
  73545. saturation: number;
  73546. /**
  73547. * Serializes this starfield procedural texture
  73548. * @returns a serialized starfield procedural texture object
  73549. */
  73550. serialize(): any;
  73551. /**
  73552. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  73553. * @param parsedTexture defines parsed texture data
  73554. * @param scene defines the current scene
  73555. * @param rootUrl defines the root URL containing startfield procedural texture information
  73556. * @returns a parsed Starfield Procedural BABYLON.Texture
  73557. */
  73558. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  73559. }
  73560. }
  73561. declare module BABYLON {
  73562. /** @hidden */
  73563. export var woodProceduralTexturePixelShader: {
  73564. name: string;
  73565. shader: string;
  73566. };
  73567. }
  73568. declare module BABYLON {
  73569. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  73570. private _ampScale;
  73571. private _woodColor;
  73572. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73573. updateShaderUniforms(): void;
  73574. ampScale: number;
  73575. woodColor: BABYLON.Color3;
  73576. /**
  73577. * Serializes this wood procedural texture
  73578. * @returns a serialized wood procedural texture object
  73579. */
  73580. serialize(): any;
  73581. /**
  73582. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  73583. * @param parsedTexture defines parsed texture data
  73584. * @param scene defines the current scene
  73585. * @param rootUrl defines the root URL containing wood procedural texture information
  73586. * @returns a parsed Wood Procedural BABYLON.Texture
  73587. */
  73588. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  73589. }
  73590. }